b89e66e453ab651487adb31b0bb3fcb9aee925cd
[profile/ivi/murphy.git] / src / resource / resource-owner.c
1 /*
2  * Copyright (c) 2012, Intel Corporation
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *  * Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *  * Neither the name of Intel Corporation nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include <stdio.h>
31 #include <string.h>
32 #include <ctype.h>
33 #include <errno.h>
34
35 #include <murphy/common/mm.h>
36 #include <murphy/common/hashtbl.h>
37 #include <murphy/common/utils.h>
38 #include <murphy/common/log.h>
39
40 #include <murphy-db/mqi.h>
41
42 #include <murphy/resource/client-api.h>
43 #include <murphy/resource/config-api.h>
44
45 #include "resource-owner.h"
46 #include "application-class.h"
47 #include "resource-set.h"
48 #include "resource.h"
49 #include "zone.h"
50 #include "resource-lua.h"
51
52 #define NAME_LENGTH          24
53
54 #define ZONE_ID_IDX          0
55 #define ZONE_NAME_IDX        1
56 #define CLASS_NAME_IDX       2
57 #define FIRST_ATTRIBUTE_IDX  3
58
59 typedef struct {
60     uint32_t          zone_id;
61     const char       *zone_name;
62     const char       *class_name;
63     mrp_attr_value_t  attrs[MQI_COLUMN_MAX];
64 } owner_row_t;
65
66 static mrp_resource_owner_t  resource_owners[MRP_ZONE_MAX * MRP_RESOURCE_MAX];
67 static mqi_handle_t          owner_tables[MRP_RESOURCE_MAX];
68
69 static mrp_resource_owner_t *get_owner(uint32_t, uint32_t);
70 static void reset_owners(uint32_t, mrp_resource_owner_t *);
71 static bool grant_ownership(mrp_resource_owner_t *, mrp_zone_t *,
72                             mrp_application_class_t *, mrp_resource_set_t *,
73                             mrp_resource_t *);
74 static bool advice_ownership(mrp_resource_owner_t *, mrp_zone_t *,
75                              mrp_application_class_t *, mrp_resource_set_t *,
76                              mrp_resource_t *);
77
78 static void manager_start_transaction(mrp_zone_t *);
79 static void manager_end_transaction(mrp_zone_t *);
80
81 static void delete_resource_owner(mrp_zone_t *, mrp_resource_t *);
82 static void insert_resource_owner(mrp_zone_t *, mrp_application_class_t *,
83                                   mrp_resource_t *);
84 static void update_resource_owner(mrp_zone_t *, mrp_application_class_t *,
85                                   mrp_resource_t *);
86 static void set_attr_descriptors(mqi_column_desc_t *, mrp_resource_t *);
87
88
89 int mrp_resource_owner_create_database_table(mrp_resource_def_t *rdef)
90 {
91     MQI_COLUMN_DEFINITION_LIST(base_coldefs,
92         MQI_COLUMN_DEFINITION( "zone_id"          , MQI_UNSIGNED             ),
93         MQI_COLUMN_DEFINITION( "zone_name"        , MQI_VARCHAR(NAME_LENGTH) ),
94         MQI_COLUMN_DEFINITION( "application_class", MQI_VARCHAR(NAME_LENGTH) )
95     );
96
97     MQI_INDEX_DEFINITION(indexdef,
98         MQI_INDEX_COLUMN( "zone_id" )
99     );
100
101     static bool initialized = false;
102
103     char name[256];
104     mqi_column_def_t  coldefs[MQI_COLUMN_MAX + 1];
105     mqi_column_def_t *col;
106     mrp_attr_def_t *atd;
107     mqi_handle_t table;
108     char c, *p;
109     size_t i,j;
110
111     if (!initialized) {
112         mqi_open();
113         for (i = 0;  i < MRP_RESOURCE_MAX;  i++)
114             owner_tables[i] = MQI_HANDLE_INVALID;
115         initialized = true;
116     }
117
118     MRP_ASSERT(sizeof(base_coldefs) < sizeof(coldefs),"too many base columns");
119     MRP_ASSERT(rdef, "invalid argument");
120     MRP_ASSERT(rdef->id < MRP_RESOURCE_MAX, "confused with data structures");
121     MRP_ASSERT(owner_tables[rdef->id] == MQI_HANDLE_INVALID,
122                "owner table already exist");
123
124     snprintf(name, sizeof(name), "%s_owner", rdef->name);
125     for (p = name; (c = *p);  p++) {
126         if (!isascii(c) || (!isalnum(c) && c != '_'))
127             *p = '_';
128     }
129
130     j = MQI_DIMENSION(base_coldefs) - 1;
131     memcpy(coldefs, base_coldefs, j * sizeof(mqi_column_def_t));
132
133     for (i = 0;  i < rdef->nattr && j < MQI_COLUMN_MAX;  i++, j++) {
134         col = coldefs + j;
135         atd = rdef->attrdefs + i;
136
137         col->name   = atd->name;
138         col->type   = atd->type;
139         col->length = (col->type == mqi_string) ? NAME_LENGTH : 0;
140         col->flags  = 0;
141     }
142
143     memset(coldefs + j, 0, sizeof(mqi_column_def_t));
144
145     table = MQI_CREATE_TABLE(name, MQI_TEMPORARY, coldefs, indexdef);
146
147     if (table == MQI_HANDLE_INVALID) {
148         mrp_log_error("Can't create table '%s': %s", name, strerror(errno));
149         return -1;
150     }
151
152     owner_tables[rdef->id] = table;
153
154     return 0;
155 }
156
157
158 void mrp_resource_owner_update_zone(uint32_t zoneid,
159                                     mrp_resource_set_t *reqset,
160                                     uint32_t reqid)
161 {
162     typedef struct {
163         uint32_t replyid;
164         mrp_resource_set_t *rset;
165         bool move;
166     } event_t;
167
168     mrp_resource_owner_t oldowners[MRP_RESOURCE_MAX];
169     mrp_resource_owner_t backup[MRP_RESOURCE_MAX];
170     mrp_zone_t *zone;
171     mrp_application_class_t *class;
172     mrp_resource_set_t *rset;
173     mrp_resource_t *res;
174     mrp_resource_def_t *rdef;
175     mrp_resource_mgr_ftbl_t *ftbl;
176     mrp_resource_owner_t *owner, *old, *owners;
177     mrp_resource_mask_t mask;
178     mrp_resource_mask_t mandatory;
179     mrp_resource_mask_t grant;
180     mrp_resource_mask_t advice;
181     void *clc, *rsc, *rc;
182     uint32_t rid;
183     uint32_t rcnt;
184     bool force_release;
185     bool changed;
186     bool move;
187     mrp_resource_event_t notify;
188     uint32_t replyid;
189     uint32_t nevent, maxev;
190     event_t *events, *ev, *lastev;
191
192     MRP_ASSERT(zoneid < MRP_ZONE_MAX, "invalid argument");
193
194     zone = mrp_zone_find_by_id(zoneid);
195
196     MRP_ASSERT(zone, "zone is not defined");
197
198     maxev  = mrp_get_resource_set_count();
199     nevent = 0;
200     events = mrp_alloc(sizeof(event_t) * maxev);
201
202     MRP_ASSERT(events, "Memory alloc failure. Can't update zone");
203
204     reset_owners(zoneid, oldowners);
205     manager_start_transaction(zone);
206
207     rcnt = mrp_resource_definition_count();
208     clc  = NULL;
209
210     while ((class = mrp_application_class_iterate_classes(&clc))) {
211         rsc = NULL;
212
213         while ((rset=mrp_application_class_iterate_rsets(class,zoneid,&rsc))) {
214             force_release = false;
215             mandatory = rset->resource.mask.mandatory;
216             grant = 0;
217             advice = 0;
218             rc = NULL;
219
220             switch (rset->state) {
221
222             case mrp_resource_acquire:
223                 while ((res = mrp_resource_set_iterate_resources(rset, &rc))) {
224                     rdef  = res->def;
225                     rid   = rdef->id;
226                     owner = get_owner(zoneid, rid);
227
228                     backup[rid] = *owner;
229
230                     if (grant_ownership(owner, zone, class, rset, res))
231                         grant |= ((mrp_resource_mask_t)1 << rid);
232                     else {
233                         if (owner->rset != rset)
234                             force_release |= owner->modal;
235                     }
236                 }
237                 owners = get_owner(zoneid, 0);
238                 if ((grant & mandatory) == mandatory &&
239                     mrp_resource_lua_veto(zone, rset, owners, grant))
240                 {
241                     advice = grant;
242                 }
243                 else {
244                     /* rollback, ie. restore the backed up state */
245                     rc = NULL;
246                     while ((res=mrp_resource_set_iterate_resources(rset,&rc))){
247                          rdef  = res->def;
248                          rid   = rdef->id;
249                          mask  = (mrp_resource_mask_t)1 << rid;
250                          owner = get_owner(zoneid, rid);
251                         *owner = backup[rid];
252
253                         if ((grant & mask)) {
254                             if ((ftbl = rdef->manager.ftbl) && ftbl->free)
255                                 ftbl->free(zone, res, rdef->manager.userdata);
256                         }
257
258                         if (advice_ownership(owner, zone, class, rset, res))
259                             advice |= mask;
260                     }
261
262                     grant = 0;
263
264                     if ((advice & mandatory) != mandatory)
265                         advice = 0;
266
267                     mrp_resource_lua_set_owners(zone, owners);
268                 }
269                 break;
270
271             case mrp_resource_release:
272                 while ((res = mrp_resource_set_iterate_resources(rset, &rc))) {
273                     rdef  = res->def;
274                     rid   = rdef->id;
275                     owner = get_owner(zoneid, rid);
276
277                     if (advice_ownership(owner, zone, class, rset, res))
278                         advice |= ((mrp_resource_mask_t)1 << rid);
279                 }
280                 if ((advice & mandatory) != mandatory)
281                     advice = 0;
282                 break;
283
284             default:
285                 break;
286             }
287
288             changed = false;
289             move    = false;
290             notify  = 0;
291             replyid = (reqset == rset && reqid == rset->request.id) ? reqid:0;
292
293
294             if (force_release) {
295                 move = (rset->state != mrp_resource_release);
296                 notify = move ? MRP_RESOURCE_EVENT_RELEASE : 0;
297                 changed = move || rset->resource.mask.grant;
298                 rset->state = mrp_resource_release;
299                 rset->resource.mask.grant = 0;
300             }
301             else {
302                 if (grant == rset->resource.mask.grant) {
303                     if (rset->state == mrp_resource_acquire &&
304                         !grant && rset->dont_wait)
305                     {
306                         notify = MRP_RESOURCE_EVENT_RELEASE;
307                         rset->state = mrp_resource_release;
308                         move = true;
309                     }
310                 }
311                 else {
312                     rset->resource.mask.grant = grant;
313                     changed = true;
314
315                     if (!grant && rset->auto_release) {
316                         if (rset->state != mrp_resource_release)
317                             notify = MRP_RESOURCE_EVENT_RELEASE;
318                         rset->state = mrp_resource_release;
319                         move = true;
320                     }
321                 }
322             }
323
324             if (notify) {
325                 mrp_resource_set_notify(rset, notify);
326             }
327
328             if (advice != rset->resource.mask.advice) {
329                 rset->resource.mask.advice = advice;
330                 changed = true;
331             }
332
333             if (replyid || changed) {
334                 ev = events + nevent++;
335
336                 ev->replyid = replyid;
337                 ev->rset    = rset;
338                 ev->move    = move;
339             }
340         } /* while rset */
341     } /* while class */
342
343     manager_end_transaction(zone);
344
345     for (lastev = (ev = events) + nevent;     ev < lastev;     ev++) {
346         rset = ev->rset;
347
348         if (ev->move)
349             mrp_application_class_move_resource_set(rset);
350
351         mrp_resource_set_updated(rset);
352
353         if (rset->event)
354             rset->event(ev->replyid, rset, rset->user_data);
355     }
356
357     mrp_free(events);
358
359     for (rid = 0;  rid < rcnt;  rid++) {
360         owner = get_owner(zoneid, rid);
361         old   = oldowners + rid;
362
363         if (owner->class != old->class ||
364             owner->rset  != old->rset  ||
365             owner->res   != old->res     )
366         {
367             if (!owner->res)
368                 delete_resource_owner(zone, old->res);
369             else if (!old->res)
370                 insert_resource_owner(zone, owner->class, owner->res);
371             else
372                 update_resource_owner(zone, owner->class, owner->res);
373         }
374     }
375 }
376
377 int mrp_resource_owner_print(char *buf, int len)
378 {
379 #define PRINT(fmt, args...)  if (p<e) { p += snprintf(p, e-p, fmt , ##args); }
380
381     mrp_zone_t *zone;
382     mrp_resource_owner_t *owner;
383     mrp_application_class_t *class;
384     mrp_resource_set_t *rset;
385     mrp_resource_t *res;
386     mrp_resource_def_t *rdef;
387     uint32_t rcnt, rid;
388     uint32_t zcnt, zid;
389     char *p, *e;
390
391     MRP_ASSERT(buf && len > 0, "invalid argument");
392
393     rcnt = mrp_resource_definition_count();
394     zcnt = mrp_zone_count();
395
396     e = (p = buf) + len;
397
398     PRINT("Resource owners:\n");
399
400     for (zid = 0;  zid < zcnt;  zid++) {
401         zone = mrp_zone_find_by_id(zid);
402
403         if (!zone) {
404             PRINT("   Zone %u:\n", zid);
405         }
406         else {
407             PRINT("   Zone %s:", zone->name);
408             p += mrp_zone_attribute_print(zone, p, e-p);
409             PRINT("\n");
410         }
411
412         for (rid = 0;   rid < rcnt;   rid++) {
413             if (!(rdef = mrp_resource_definition_find_by_id(rid)))
414                 continue;
415
416             PRINT("      %-15s: ", rdef->name);
417
418             owner = get_owner(zid, rid);
419
420             if (!(class = owner->class) ||
421                 !(rset  = owner->rset ) ||
422                 !(res   = owner->res  )    )
423             {
424                 PRINT("<nobody>");
425             }
426             else {
427                 MRP_ASSERT(rdef == res->def, "confused with data structures");
428
429                 PRINT("%-15s", class->name);
430
431                 p += mrp_resource_attribute_print(res, p, e-p);
432             }
433
434             PRINT("\n");
435         }
436     }
437
438     return p - buf;
439
440 #undef PRINT
441 }
442
443
444 static mrp_resource_owner_t *get_owner(uint32_t zone, uint32_t resid)
445 {
446     MRP_ASSERT(zone < MRP_ZONE_MAX && resid < MRP_RESOURCE_MAX,
447                "invalid argument");
448
449     return resource_owners + (zone * MRP_RESOURCE_MAX + resid);
450 }
451
452 static void reset_owners(uint32_t zone, mrp_resource_owner_t *oldowners)
453 {
454     mrp_resource_owner_t *owners = get_owner(zone, 0);
455     size_t size = sizeof(mrp_resource_owner_t) * MRP_RESOURCE_MAX;
456     size_t i;
457
458     if (oldowners)
459         memcpy(oldowners, owners, size);
460
461     memset(owners, 0, size);
462
463     for (i = 0;   i < MRP_RESOURCE_MAX;   i++)
464         owners[i].share = true;
465 }
466
467 static bool grant_ownership(mrp_resource_owner_t    *owner,
468                             mrp_zone_t              *zone,
469                             mrp_application_class_t *class,
470                             mrp_resource_set_t      *rset,
471                             mrp_resource_t          *res)
472 {
473     mrp_resource_def_t      *rdef = res->def;
474     mrp_resource_mgr_ftbl_t *ftbl = rdef->manager.ftbl;
475     bool                     set_owner = false;
476
477     /*
478       if (forbid_grant())
479         return false;
480      */
481
482     if (owner->modal)
483         return false;
484
485     do { /* not a loop */
486         if (!owner->class && !owner->rset) {
487             /* nobody owns this, so grab it */
488             set_owner = true;
489             break;
490         }
491
492         if (owner->class == class && owner->rset == rset) {
493             /* we happen to already own it */
494             break;
495         }
496
497         if (rdef->shareable && owner->share) {
498             /* OK, someone else owns it but
499                the owner is ready to share it with us */
500             break;
501         }
502
503         return false;
504
505     } while(0);
506
507     if (ftbl && ftbl->allocate) {
508         if (!ftbl->allocate(zone, res, rdef->manager.userdata))
509             return false;
510     }
511
512     if (set_owner) {
513         owner->class = class;
514         owner->rset  = rset;
515         owner->res   = res;
516         owner->modal = class->modal;
517     }
518
519     owner->share = class->share && res->shared;
520
521     return true;
522 }
523
524 static bool advice_ownership(mrp_resource_owner_t    *owner,
525                              mrp_zone_t              *zone,
526                              mrp_application_class_t *class,
527                              mrp_resource_set_t      *rset,
528                              mrp_resource_t          *res)
529 {
530     mrp_resource_def_t      *rdef = res->def;
531     mrp_resource_mgr_ftbl_t *ftbl = rdef->manager.ftbl;
532
533     (void)zone;
534
535     /*
536       if (forbid_grant())
537         return false;
538      */
539
540     if (owner->modal)
541         return false;
542
543     do { /* not a loop */
544         if (!owner->class && !owner->rset)
545             /* nobody owns this */
546             break;
547
548         if (owner->share)
549             /* someone else owns it but it can be shared */
550             break;
551
552
553         if (owner->class == class) {
554             if (owner->rset->class.priority == rset->class.priority)
555                 break;
556         }
557
558         return false;
559
560     } while(0);
561
562     if (ftbl && ftbl->advice) {
563         if (!ftbl->advice(zone, res, rdef->manager.userdata))
564             return false;
565     }
566
567     return true;
568 }
569
570 static void manager_start_transaction(mrp_zone_t *zone)
571 {
572     mrp_resource_def_t *rdef;
573     mrp_resource_mgr_ftbl_t *ftbl;
574     void *cursor = NULL;
575
576     while ((rdef = mrp_resource_definition_iterate_manager(&cursor))) {
577         ftbl = rdef->manager.ftbl;
578
579         MRP_ASSERT(ftbl, "confused with data structures");
580
581         if (ftbl->init)
582             ftbl->init(zone, rdef->manager.userdata);
583     }
584 }
585
586 static void manager_end_transaction(mrp_zone_t *zone)
587 {
588     mrp_resource_def_t *rdef;
589     mrp_resource_mgr_ftbl_t *ftbl;
590     void *cursor = NULL;
591
592     while ((rdef = mrp_resource_definition_iterate_manager(&cursor))) {
593         ftbl = rdef->manager.ftbl;
594
595         MRP_ASSERT(ftbl, "confused with data structures");
596
597         if (ftbl->commit)
598             ftbl->commit(zone, rdef->manager.userdata);
599     }
600 }
601
602
603 static void delete_resource_owner(mrp_zone_t *zone, mrp_resource_t *res)
604 {
605     static uint32_t zone_id;
606
607     MQI_WHERE_CLAUSE(where,
608         MQI_EQUAL( MQI_COLUMN(0), MQI_UNSIGNED_VAR(zone_id) )
609     );
610
611     mrp_resource_def_t *rdef;
612     int n;
613
614     MRP_ASSERT(res, "invalid argument");
615
616     rdef = res->def;
617     zone_id = zone->id;
618
619     if ((n = MQI_DELETE(owner_tables[rdef->id], where)) != 1)
620         mrp_log_error("Could not delete resource owner");
621 }
622
623 static void insert_resource_owner(mrp_zone_t *zone,
624                                   mrp_application_class_t *class,
625                                   mrp_resource_t *res)
626 {
627     mrp_resource_def_t *rdef = res->def;
628     uint32_t i;
629     int n;
630     owner_row_t row;
631     owner_row_t *rows[2];
632     mqi_column_desc_t cdsc[FIRST_ATTRIBUTE_IDX + MQI_COLUMN_MAX + 1];
633
634     MRP_ASSERT(FIRST_ATTRIBUTE_IDX + rdef->nattr <= MQI_COLUMN_MAX,
635                "too many attributes for a table");
636
637     row.zone_id    = zone->id;
638     row.zone_name  = zone->name;
639     row.class_name = class->name;
640     memcpy(row.attrs, res->attrs, rdef->nattr * sizeof(mrp_attr_value_t));
641
642     i = 0;
643     cdsc[i].cindex = ZONE_ID_IDX;
644     cdsc[i].offset = MQI_OFFSET(owner_row_t, zone_id);
645
646     i++;
647     cdsc[i].cindex = ZONE_NAME_IDX;
648     cdsc[i].offset = MQI_OFFSET(owner_row_t, zone_name);
649
650     i++;
651     cdsc[i].cindex = CLASS_NAME_IDX;
652     cdsc[i].offset = MQI_OFFSET(owner_row_t, class_name);
653
654     set_attr_descriptors(cdsc + (i+1), res);
655
656     rows[0] = &row;
657     rows[1] = NULL;
658
659     if ((n = MQI_INSERT_INTO(owner_tables[rdef->id], cdsc, rows)) != 1)
660         mrp_log_error("can't insert row into owner table");
661 }
662
663 static void update_resource_owner(mrp_zone_t *zone,
664                                   mrp_application_class_t *class,
665                                   mrp_resource_t *res)
666 {
667     static uint32_t zone_id;
668
669     MQI_WHERE_CLAUSE(where,
670         MQI_EQUAL( MQI_COLUMN(0), MQI_UNSIGNED_VAR(zone_id) )
671     );
672
673     mrp_resource_def_t *rdef = res->def;
674     uint32_t i;
675     int n;
676     owner_row_t row;
677     mqi_column_desc_t cdsc[FIRST_ATTRIBUTE_IDX + MQI_COLUMN_MAX + 1];
678
679     zone_id = zone->id;
680
681     MRP_ASSERT(1 + rdef->nattr <= MQI_COLUMN_MAX,
682                "too many attributes for a table");
683
684     row.class_name = class->name;
685     memcpy(row.attrs, res->attrs, rdef->nattr * sizeof(mrp_attr_value_t));
686
687     i = 0;
688     cdsc[i].cindex = CLASS_NAME_IDX;
689     cdsc[i].offset = MQI_OFFSET(owner_row_t, class_name);
690
691     set_attr_descriptors(cdsc + (i+1), res);
692
693
694     if ((n = MQI_UPDATE(owner_tables[rdef->id], cdsc, &row, where)) != 1)
695         mrp_log_error("can't update row in owner table");
696 }
697
698
699 static void set_attr_descriptors(mqi_column_desc_t *cdsc, mrp_resource_t *res)
700 {
701     mrp_resource_def_t *rdef = res->def;
702     uint32_t i,j;
703     int o;
704
705     for (i = j = 0;  j < rdef->nattr;  j++) {
706         switch (rdef->attrdefs[j].type) {
707         case mqi_string:   o = MQI_OFFSET(owner_row_t,attrs[j].string);  break;
708         case mqi_integer:  o = MQI_OFFSET(owner_row_t,attrs[j].integer); break;
709         case mqi_unsignd:  o = MQI_OFFSET(owner_row_t,attrs[j].unsignd); break;
710         case mqi_floating: o = MQI_OFFSET(owner_row_t,attrs[j].floating);break;
711         default:           /* skip this */                            continue;
712         }
713
714         cdsc[i].cindex = FIRST_ATTRIBUTE_IDX + j;
715         cdsc[i].offset = o;
716         i++;
717     }
718
719     cdsc[i].cindex = -1;
720     cdsc[i].offset =  1;
721 }
722
723
724 /*
725  * Local Variables:
726  * c-basic-offset: 4
727  * indent-tabs-mode: nil
728  * End:
729  *
730  */