ProviewR Programmer's Reference Manual  V7.0.0
co_cdh.c
Go to the documentation of this file.
1 
38 /* co_cdh.c -- class definition handler
39  This module contains the API-routines to the
40  Class Definition Handler, CDH. */
41 
42 #include <ctype.h>
43 #include <errno.h>
44 #include <math.h>
45 #include <stddef.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48 
49 #include "co_cdh_msg.h"
50 #include "co_cdh.h"
51 #include "co_string.h"
52 #include "co_time.h"
53 #include "co_utf8.h"
54 
60 
62 
68 int cdh_ObjidCompare(pwr_tObjid Objid_1, pwr_tObjid Objid_2)
69 {
70  if (Objid_1.vid == Objid_2.vid) {
71  if (Objid_1.oix == Objid_2.oix)
72  return 0;
73  else if (Objid_1.oix < Objid_2.oix)
74  return -1;
75  else
76  return 1;
77  } else if (Objid_1.vid < Objid_2.vid)
78  return -1;
79  else
80  return 1;
81 }
82 
84 
89 int cdh_ObjidIsEqual(pwr_tObjid Objid_1, pwr_tObjid Objid_2)
90 {
91  return (Objid_1.vid == Objid_2.vid) && (Objid_1.oix == Objid_2.oix);
92 }
93 
95 
101 {
102  return (Objid_1.vid != Objid_2.vid) || (Objid_1.oix != Objid_2.oix);
103 }
104 
106 
112 {
113  return (Objid.vid == pwr_cNObjid.vid) && (Objid.oix == pwr_cNObjid.oix);
114 }
115 
117 
123 {
124  return (Objid.vid != pwr_cNObjid.vid) || (Objid.oix != pwr_cNObjid.oix);
125 }
126 
127 int cdh_RefIdCompare(pwr_tRefId Reference_1, pwr_tRefId Reference_2)
128 {
129  return cdh_ObjidCompare(
130  *(pwr_tObjid*)&Reference_1, *(pwr_tObjid*)&Reference_2);
131 }
132 
133 int cdh_RefIdIsEqual(pwr_tRefId Reference_1, pwr_tRefId Reference_2)
134 {
135  return cdh_ObjidIsEqual(
136  *(pwr_tObjid*)&Reference_1, *(pwr_tObjid*)&Reference_2);
137 }
138 
139 int cdh_RefIdIsNotEqual(pwr_tRefId Reference_1, pwr_tRefId Reference_2)
140 {
141  return cdh_ObjidIsNotEqual(
142  *(pwr_tObjid*)&Reference_1, *(pwr_tObjid*)&Reference_2);
143 }
144 
145 int cdh_RefIdIsNull(pwr_tRefId Reference)
146 {
147  return cdh_ObjidIsNull(*(pwr_tObjid*)&Reference);
148 }
149 
150 int cdh_RefIdIsNotNull(pwr_tRefId Reference)
151 {
152  return cdh_ObjidIsNotNull(*(pwr_tObjid*)&Reference);
153 }
154 
155 int cdh_SubidCompare(pwr_tSubid Subscription_1, pwr_tSubid Subscription_2)
156 {
157  return cdh_ObjidCompare(
158  *(pwr_tObjid*)&Subscription_1, *(pwr_tObjid*)&Subscription_2);
159 }
160 
161 int cdh_SubidIsEqual(pwr_tSubid Subscription_1, pwr_tSubid Subscription_2)
162 {
163  return cdh_ObjidIsEqual(
164  *(pwr_tObjid*)&Subscription_1, *(pwr_tObjid*)&Subscription_2);
165 }
166 
167 int cdh_SubidIsNotEqual(pwr_tSubid Subscription_1, pwr_tSubid Subscription_2)
168 {
169  return cdh_ObjidIsNotEqual(
170  *(pwr_tObjid*)&Subscription_1, *(pwr_tObjid*)&Subscription_2);
171 }
172 
173 int cdh_SubidIsNull(pwr_tSubid Subscription)
174 {
175  return cdh_ObjidIsNull(*(pwr_tObjid*)&Subscription);
176 }
177 
178 int cdh_SubidIsNotNull(pwr_tSubid Subscription)
179 {
180  return cdh_ObjidIsNotNull(*(pwr_tObjid*)&Subscription);
181 }
182 
183 int cdh_DlidCompare(pwr_tDlid DirectLink_1, pwr_tDlid DirectLink_2)
184 {
185  return cdh_ObjidCompare(
186  *(pwr_tObjid*)&DirectLink_1, *(pwr_tObjid*)&DirectLink_2);
187 }
188 
189 int cdh_DlidIsEqual(pwr_tDlid DirectLink_1, pwr_tDlid DirectLink_2)
190 {
191  return cdh_ObjidIsEqual(
192  *(pwr_tObjid*)&DirectLink_1, *(pwr_tObjid*)&DirectLink_2);
193 }
194 
195 int cdh_DlidIsNotEqual(pwr_tDlid DirectLink_1, pwr_tDlid DirectLink_2)
196 {
197  return cdh_ObjidIsNotEqual(
198  *(pwr_tObjid*)&DirectLink_1, *(pwr_tObjid*)&DirectLink_2);
199 }
200 
201 int cdh_DlidIsNull(pwr_tDlid DirectLink)
202 {
203  return cdh_ObjidIsNull(*(pwr_tObjid*)&DirectLink);
204 }
205 
206 int cdh_DlidIsNotNull(pwr_tDlid DirectLink)
207 {
208  return cdh_ObjidIsNotNull(*(pwr_tObjid*)&DirectLink);
209 }
210 
211 int cdh_ArefIsEqual(pwr_sAttrRef* arp1, pwr_sAttrRef* arp2)
212 {
213  if (arp1->Flags.b.Object && arp2->Flags.b.Object)
214  return (arp1->Objid.vid == arp2->Objid.vid
215  && arp1->Objid.oix == arp2->Objid.oix);
216  else
217  return (arp1->Objid.vid == arp2->Objid.vid
218  && arp1->Objid.oix == arp2->Objid.oix && arp1->Offset == arp2->Offset
219  && (arp1->Size == 0 || arp2->Size == 0 || arp1->Size == arp2->Size));
220 }
221 
223 
229 {
230  cdh_uTypeId cid;
231  cdh_uObjid oid;
232 
233  oid.pwr = Objid;
234 
235  cid.c.bix = 0;
236  cid.c.cix = oid.c.cix;
237  cid.c.must_be_zero = 0;
238  cid.c.vid_0 = oid.c.vid_0;
239  cid.c.vid_1 = oid.c.vid_1;
240 
241  return (pwr_tClassId)cid.pwr;
242 }
243 
245 
251 {
252  cdh_uObjid oid;
253  cdh_uTypeId cid;
254 
255  cid.pwr = Class;
256 
257  oid.c.aix = 0;
258  oid.c.reserved = 0;
259  oid.c.bix = 0;
260  oid.c.cix = cid.c.cix;
261  oid.c.must_be_two = 2;
262  oid.c.vid_0 = cid.c.vid_0;
263  oid.c.vid_1 = cid.c.vid_1;
264  oid.c.vid_2 = 0;
265  oid.c.vid_3 = 0;
266 
267  return oid.pwr;
268 }
269 
271 
277 {
278  cdh_uObjid oid;
279  cdh_uTypeId tid;
280 
281  oid.pwr = Objid;
282 
283  if (oid.t.must_be_three == 2) {
284  /* We have a class body. */
285  tid.c.bix = oid.c.bix;
286  tid.c.cix = oid.c.cix;
287  tid.c.must_be_zero = 0;
288  tid.c.vid_0 = oid.c.vid_0;
289  tid.c.vid_1 = oid.c.vid_1;
290  } else if (oid.t.must_be_three == 3) {
291  /* We have a type. */
292  tid.t.tix = oid.t.tix;
293  tid.t.tyg = oid.t.tyg;
294  tid.t.must_be_one = 1;
295  tid.t.vid_0 = oid.t.vid_0;
296  tid.t.vid_1 = oid.t.vid_1;
297  } else {
298  // TODO: We have an error.
299  tid.t.tix = oid.t.tix;
300  tid.t.tyg = oid.t.tyg;
301  tid.t.must_be_one = 1;
302  tid.t.vid_0 = oid.t.vid_0;
303  tid.t.vid_1 = oid.t.vid_1;
304  }
305 
306  return tid.pwr;
307 }
308 
310 
312 {
313  cdh_uTypeId tid;
314 
315  tid.pwr = Type;
316 
317  return tid.t.tix;
318 }
319 
321 
323 {
324  cdh_uObjid oid;
325  cdh_uTypeId tid;
326 
327  tid.pwr = Type;
328 
329  if (tid.t.must_be_one == 1) {
330  oid.t.aix = 0;
331  oid.t.reserved = 0;
332  oid.t.tix = tid.t.tix;
333  oid.t.tyg = tid.t.tyg;
334  oid.t.must_be_three = 3;
335  oid.t.vid_0 = tid.t.vid_0;
336  oid.t.vid_1 = tid.t.vid_1;
337  oid.t.vid_2 = 0;
338  oid.t.vid_3 = 0;
339  } else {
340  oid.c.aix = 0;
341  oid.c.reserved = 0;
342  oid.c.bix = tid.c.bix;
343  oid.c.cix = tid.c.cix;
344  oid.c.must_be_two = 2;
345  oid.c.vid_0 = tid.c.vid_0;
346  oid.c.vid_1 = tid.c.vid_1;
347  oid.c.vid_2 = 0;
348  oid.c.vid_3 = 0;
349  }
350 
351  return oid.pwr;
352 }
353 
356 {
357  pwr_sAttrRef a = pwr_cNAttrRef;
358  a.Objid = Objid;
359  a.Flags.b.Object = 1;
360 
361  return a;
362 }
363 
365 
367  pwr_eType Type, void* Value, char* String, int MaxSize)
368 {
369  pwr_tStatus sts = CDH__SUCCESS;
370  char timbuf[24];
371 
372  switch (Type) {
373  case pwr_eType_Boolean:
374  if (*(pwr_tBoolean*)Value)
375  strcpy(String, "1");
376  else
377  strcpy(String, "0");
378  break;
379  case pwr_eType_Float32: {
380  pwr_tFloat32 f;
381  memcpy(&f, Value, sizeof(f));
382  snprintf(String, MaxSize, "%.7g", f);
383  break;
384  }
385  case pwr_eType_Float64: {
386  pwr_tFloat64 f;
387  memcpy(&f, Value, sizeof(f));
388  snprintf(String, MaxSize, "%.17g", f);
389  break;
390  }
391  case pwr_eType_Char:
392  if (*(pwr_tChar*)Value == 0)
393  *String = '\0';
394  else
395  sprintf(String, "%c", *(pwr_tChar*)Value);
396  break;
397  case pwr_eType_Int8:
398  snprintf(String, MaxSize, "%d", *(pwr_tInt8*)Value);
399  break;
400  case pwr_eType_Int16:
401  snprintf(String, MaxSize, "%hd", *(pwr_tInt16*)Value);
402  break;
403  case pwr_eType_Int32:
404  case pwr_eType_Status:
405  case pwr_eType_NetStatus:
406  case pwr_eType_Enum:
407  snprintf(String, MaxSize, "%d", *(pwr_tInt32*)Value);
408  break;
409  case pwr_eType_Int64:
410  snprintf(String, MaxSize, pwr_dFormatInt64, *(pwr_tInt64*)Value);
411  break;
412  case pwr_eType_UInt8:
413  snprintf(String, MaxSize, "%u", *(pwr_tUInt8*)Value);
414  break;
415  case pwr_eType_UInt16:
416  snprintf(String, MaxSize, "%hu", *(pwr_tUInt16*)Value);
417  break;
418  case pwr_eType_UInt32:
419  case pwr_eType_Mask:
420  snprintf(String, MaxSize, "%u", *(pwr_tUInt32*)Value);
421  break;
422  case pwr_eType_UInt64:
423  snprintf(String, MaxSize, pwr_dFormatUInt64, *(pwr_tUInt64*)Value);
424  break;
425  case pwr_eType_Time:
426  if (ODD(time_AtoAscii(
427  Value, time_eFormat_DateAndTime, timbuf, sizeof(timbuf)))) {
428  strncpy(String, timbuf, MaxSize);
429  } else {
430  strncpy(String, "*** Bad time value ***", MaxSize);
431  sts = CDH__INVTIME;
432  }
433  break;
434  case pwr_eType_DeltaTime:
435  if (ODD(time_DtoAscii(Value, 1, timbuf, sizeof(timbuf)))) {
436  strncpy(String, timbuf, MaxSize);
437  } else {
438  strncpy(String, "*** Bad delta time value ***", MaxSize);
439  sts = CDH__INVDELTATIME;
440  }
441  break;
442  case pwr_eType_String:
443  case pwr_eType_Text:
444  snprintf(String, MaxSize, "%s", (char*)Value);
445  break;
446  case pwr_eType_ProString: {
447  int len = MIN(strlen((char*)Value), MaxSize-1);
448  int i;
449  strcpy(String, "");
450  for (i = 0; i < len; i++)
451  strcat(String, "*");
452  break;
453  }
454  default:
455  sts = CDH__INVTYPE;
456  break;
457  }
458 
459  str_Cut(String, MaxSize);
460  return sts;
461 }
462 
465 
467  pwr_eType Type, const char* String, void* Value)
468 {
469  pwr_tStatus sts = CDH__SUCCESS;
470  pwr_tBoolean bval = 0;
471  pwr_tInt8 i8val = 0;
472  pwr_tInt16 i16val = 0;
473  pwr_tInt32 i32val = 0;
474  pwr_tInt64 i64val = 0;
475  pwr_tUInt8 ui8val = 0;
476  pwr_tUInt16 ui16val = 0;
477  pwr_tUInt32 ui32val = 0;
478  pwr_tUInt64 ui64val = 0;
479  pwr_tFloat32 f32val = 0.0;
480  pwr_tFloat64 f64val = 0.0;
481  pwr_tClassId cidval = pwr_cNClassId;
482  pwr_tTypeId tidval = pwr_cNTypeId;
483  pwr_tObjectIx oixval = pwr_cNObjectIx;
484  pwr_tVolumeId vidval = pwr_cNVolumeId;
485  pwr_tTime timeval;
486  pwr_tDeltaTime dtimeval;
487  char timbuf[24];
488  unsigned int timlen;
489  char* endp;
490 
491  errno = 0;
492 
493  pwr_Assert(String != NULL);
494  pwr_Assert(Value != NULL);
495 
496  switch (Type) {
497  case pwr_eType_Boolean:
498  if (*String != '\0') {
499  i32val = strtoul(String, &endp, 0);
500  if (errno == ERANGE || *endp != '\0' || (i32val != 0 && i32val != 1)) {
501  sts = CDH__INVBOOL;
502  break;
503  }
504  }
505  bval = i32val;
506  memcpy(Value, &bval, sizeof(bval));
507  break;
508 
509  case pwr_eType_Float32:
510  if (*String != '\0') {
511  f64val = strtod(String, &endp);
512  if (errno == ERANGE || *endp != '\0' || fabs(f64val) > FLT_MAX) {
513  sts = CDH__INVFLOAT32;
514  break;
515  }
516  }
517  f32val = f64val;
518  memcpy(Value, &f32val, sizeof(f32val));
519  break;
520 
521  case pwr_eType_Float64:
522  if (*String != '\0') {
523  f64val = strtod(String, &endp);
524  if (errno == ERANGE || *endp != '\0' || fabs(f64val) > DBL_MAX) {
525  sts = CDH__INVFLOAT64;
526  break;
527  }
528  }
529  memcpy(Value, &f64val, sizeof(f64val));
530  break;
531 
532  case pwr_eType_Char:
533  *((char*)Value) = *String;
534  break;
535 
536  case pwr_eType_Int8:
537  if (*String != '\0') {
538  i32val = strtol(String, &endp, 0);
539  if (errno == ERANGE || *endp != '\0' || i32val > SCHAR_MAX
540  || i32val < SCHAR_MIN) {
541  sts = CDH__INVINT8;
542  break;
543  }
544  }
545  i8val = i32val;
546  memcpy(Value, &i8val, sizeof(i8val));
547  break;
548 
549  case pwr_eType_Int16:
550  if (*String != '\0') {
551  i32val = strtol(String, &endp, 0);
552  if (errno == ERANGE || *endp != '\0' || i32val > SHRT_MAX
553  || i32val < SHRT_MIN) {
554  sts = CDH__INVINT16;
555  break;
556  }
557  }
558  i16val = i32val;
559  memcpy(Value, &i16val, sizeof(i16val));
560  break;
561 
562  case pwr_eType_Int32:
563  case pwr_eType_Status:
564  case pwr_eType_NetStatus:
565  case pwr_eType_Enum:
566  if (*String != '\0') {
567  i32val = strtol(String, &endp, 0);
568  if (errno == ERANGE || *endp != '\0' || i32val > INT_MAX
569  || i32val < INT_MIN) {
570  sts = CDH__INVINT32;
571  break;
572  }
573  }
574  memcpy(Value, &i32val, sizeof(i32val));
575  break;
576 
577  case pwr_eType_Int64:
578  if (*String != '\0') {
579  if (sscanf(String, pwr_dFormatInt64, &i64val) != 1) {
580  sts = CDH__INVINT32;
581  break;
582  }
583  }
584  memcpy(Value, &i64val, sizeof(i64val));
585  break;
586 
587  case pwr_eType_UInt8:
588  while (*String && isspace(*String))
589  String++;
590  if (*String != '\0') {
591  ui32val = strtoul(String, &endp, 0);
592  if (errno == ERANGE || *endp != '\0' || ui32val > UCHAR_MAX
593  || *String == '-') {
594  sts = CDH__INVUINT8;
595  break;
596  }
597  }
598  ui8val = ui32val;
599  memcpy(Value, &ui8val, sizeof(ui8val));
600  break;
601 
602  case pwr_eType_UInt16:
603  while (*String && isspace(*String))
604  String++;
605  if (*String != '\0') {
606  ui32val = strtoul(String, &endp, 0);
607  if (errno == ERANGE || *endp != '\0' || ui32val > USHRT_MAX
608  || *String == '-') {
609  sts = CDH__INVUINT16;
610  break;
611  }
612  }
613  ui16val = ui32val;
614  memcpy(Value, &ui16val, sizeof(ui16val));
615  break;
616 
617  case pwr_eType_UInt32:
618  case pwr_eType_Mask:
619  while (*String && isspace(*String))
620  String++;
621  if (*String != '\0') {
622  ui32val = strtoul(String, &endp, 0);
623  if (errno == ERANGE || *endp != '\0' || ui32val > UINT_MAX
624  || *String == '-') {
625  sts = CDH__INVUINT32;
626  break;
627  }
628  }
629  memcpy(Value, &ui32val, sizeof(ui32val));
630  break;
631 
632  case pwr_eType_UInt64:
633  if (*String != '\0') {
634  if (sscanf(String, pwr_dFormatUInt64, &ui64val) != 1) {
635  sts = CDH__INVUINT32;
636  break;
637  }
638  }
639  memcpy(Value, &ui64val, sizeof(ui64val));
640  break;
641 
642  case pwr_eType_String:
643  case pwr_eType_Text:
644  case pwr_eType_ProString:
645  strcpy(Value, String);
646  break;
647 
648  case pwr_eType_Time:
649  timlen = strlen(String);
650  if (timlen > 23) {
651  sts = CDH__INVTIME;
652  break;
653  }
654  memcpy(timbuf, String, MIN(sizeof(timbuf), timlen));
655  timbuf[MIN(sizeof(timbuf), timlen)] = '\0';
656  sts = time_AsciiToA(timbuf, &timeval);
657  if (EVEN(sts)) {
658  sts = CDH__INVTIME;
659  break;
660  }
661  memcpy(Value, &timeval, sizeof(timeval));
662  break;
663 
664  case pwr_eType_DeltaTime:
665  timlen = strlen(String);
666  if (timlen > 23) {
667  sts = CDH__INVDELTATIME;
668  break;
669  }
670  memcpy(timbuf, String, MIN(sizeof(timbuf), timlen));
671  timbuf[MIN(sizeof(timbuf), timlen)] = '\0';
672  sts = time_AsciiToD(timbuf, &dtimeval);
673  if (EVEN(sts)) {
674  sts = CDH__INVDELTATIME;
675  break;
676  }
677  memcpy(Value, &dtimeval, sizeof(dtimeval));
678  break;
679 
680  case pwr_eType_ClassId:
681  while (*String && isspace(*String))
682  String++;
683  if (*String != '\0') {
684  sts = cdh_StringToClassId(String, &cidval);
685  if (EVEN(sts))
686  break;
687  }
688  memcpy(Value, &cidval, sizeof(cidval));
689  break;
690 
691  case pwr_eType_VolumeId:
692  while (*String && isspace(*String))
693  String++;
694  if (*String != '\0') {
695  sts = cdh_StringToVolumeId(String, &vidval);
696  if (EVEN(sts))
697  break;
698  }
699  memcpy(Value, &vidval, sizeof(vidval));
700  break;
701 
702  case pwr_eType_TypeId:
703  while (*String && isspace(*String))
704  String++;
705  if (*String != '\0') {
706  sts = cdh_StringToTypeId(String, &tidval);
707  if (EVEN(sts))
708  break;
709  }
710  memcpy(Value, &tidval, sizeof(tidval));
711  break;
712 
713  case pwr_eType_ObjectIx:
714  while (*String && isspace(*String))
715  String++;
716  if (*String != '\0') {
717  sts = cdh_StringToObjectIx(String, &oixval);
718  if (EVEN(sts))
719  break;
720  }
721  memcpy(Value, &oixval, sizeof(oixval));
722  break;
723 
724  default:
725  sts = CDH__INVTYPE;
726  break;
727  }
728 
729  return sts;
730 }
731 
734 
735 void cdh_MaskToBinaryString(unsigned int mask, int noofbits, char* str)
736 {
737  unsigned int m;
738  int i;
739 
740  m = 1 << (noofbits - 1);
741  strcpy(str, "");
742  for (i = 0; i < noofbits; i++) {
743  if (m & mask)
744  strcat(str, "1");
745  else
746  strcat(str, "0");
747  m >>= 1;
748  }
749 }
750 
752 
761 {
762  unsigned int vid_0;
763  unsigned int vid_1;
764  unsigned int cix;
765  cdh_uTypeId lcid;
766 
767  pwr_Assert(cid != NULL);
768 
769  lcid.pwr = pwr_cNClassId;
770 
771  if (*s == '_')
772  s++;
773  if (*s == 'C' || *s == 'c')
774  s++;
775 
776  if (sscanf(s, "%d.%d:%d%*s", &vid_1, &vid_0, &cix) != 3)
777  return CDH__INVCID;
778 
779  if (vid_1 > cdh_cMaxVidGroup || vid_0 > cdh_cMaxVidGroup || cix > cdh_cMaxCix)
780  return CDH__INVCID;
781 
782  lcid.c.vid_1 = vid_1;
783  lcid.c.vid_0 = vid_0;
784  lcid.c.cix = cix;
785 
786  *cid = lcid.pwr;
787 
788  return CDH__SUCCESS;
789 }
790 
792 
802 {
803  unsigned int vid_0;
804  unsigned int vid_1;
805  unsigned int vid_2;
806  unsigned int vid_3;
807  unsigned int oix;
808  cdh_uObjid loid;
809 
810  pwr_Assert(oid != NULL);
811 
812  loid.pwr = pwr_cNObjid;
813 
814  if (*s == '_')
815  s++;
816  if (*s == 'O' || *s == 'o')
817  s++;
818  if (*s == 'A' || *s == 'a')
819  s++;
820 
821  if (sscanf(s, "%d.%d.%d.%d:%u%*s", &vid_3, &vid_2, &vid_1, &vid_0, &oix) != 5)
822  return CDH__INVOID;
823 
824  if (vid_3 > cdh_cMaxVidGroup || vid_2 > cdh_cMaxVidGroup
825  || vid_1 > cdh_cMaxVidGroup || vid_0 > cdh_cMaxVidGroup) {
826  return CDH__INVOID;
827  }
828 
829  loid.o.vid_3 = vid_3;
830  loid.o.vid_2 = vid_2;
831  loid.o.vid_1 = vid_1;
832  loid.o.vid_0 = vid_0;
833  loid.o.oix = oix;
834 
835  *oid = loid.pwr;
836 
837  return CDH__SUCCESS;
838 }
839 
841 
852 {
853  char oid_str[40];
854  char body_str[40];
855  char offset_str[40];
856  char size_str[40];
857  pwr_tAttrRef a;
858  pwr_tStatus sts;
859  unsigned int idx;
860  unsigned int state;
861  const char* t;
862 
863  pwr_Assert(aref != NULL);
864 
865  idx = 0;
866  state = 0;
867  for (t = s; *t; t++) {
868  if (state == 0 && *t == '(') {
869  oid_str[idx] = 0;
870  idx = 0;
871  state++;
872  } else if (state == 1 && *t == ')') {
873  body_str[idx] = 0;
874  idx = 0;
875  state++;
876  t++;
877  if (*t != '[')
878  return CDH__INVCID;
879  } else if (state == 2 && *t == '.') {
880  offset_str[idx] = 0;
881  idx = 0;
882  state++;
883  } else if (state == 3 && *t == ']') {
884  size_str[idx] = 0;
885  state++;
886  } else {
887  if (state == 0)
888  oid_str[idx++] = *t;
889  else if (state == 1)
890  body_str[idx++] = *t;
891  else if (state == 2)
892  offset_str[idx++] = *t;
893  else if (state == 3)
894  size_str[idx++] = *t;
895  else
896  return CDH__INVCID;
897  }
898  }
899 
900  memset(&a, 0, sizeof(a));
901 
902  sts = cdh_StringToObjid(oid_str, &a.Objid);
903  if (EVEN(sts))
904  return sts;
905 
906  if (state < 1)
907  a.Flags.b.Object = 1;
908  else {
909  sts = cdh_StringToTypeId(body_str, &a.Body);
910  if (EVEN(sts))
911  return sts;
912 
913  if (state < 2)
914  a.Flags.b.Object = 1;
915  else {
916  if (sscanf(offset_str, "%u", &a.Offset) != 1)
917  return CDH__INVCID;
918  if (sscanf(size_str, "%u", &a.Size) != 1)
919  return CDH__INVCID;
920 
921  a.Flags.m = 0;
922  }
923  }
924 
925  *aref = a;
926 
927  return CDH__SUCCESS;
928 }
929 
931 
939 {
940  unsigned int vid_0;
941  unsigned int vid_1;
942  unsigned int bit;
943  unsigned int tyg;
944  unsigned int tix;
945  cdh_uTypeId ltid;
946 
947  pwr_Assert(tid != NULL);
948 
949  ltid.pwr = pwr_cNTypeId;
950 
951  if (*s == '_')
952  s++;
953  if (*s == 'T' || *s == 't')
954  s++;
955 
956  if (sscanf(s, "%d.%d:%d.%d.%d%*s", &vid_1, &vid_0, &bit, &tyg, &tix) != 5)
957  return CDH__INVTID;
958 
959  if (vid_0 > cdh_cMaxVidGroup || vid_1 > cdh_cMaxVidGroup || bit > 1)
960  return CDH__INVTID;
961 
962  if (bit == 0) { /* Class Type. */
963  if (tyg > cdh_cMaxCix || tix > cdh_cMaxBix)
964  return CDH__INVTID;
965 
966  ltid.c.vid_1 = vid_1;
967  ltid.c.vid_0 = vid_0;
968  ltid.c.must_be_zero = 0;
969  ltid.c.cix = tyg;
970  ltid.c.bix = tix;
971 
972  } else { /* Type. */
973  if (tyg > cdh_cMaxTyg || tix > cdh_cMaxTix)
974  return CDH__INVTID;
975 
976  ltid.t.vid_1 = vid_1;
977  ltid.t.vid_0 = vid_0;
978  ltid.t.must_be_one = 1;
979  ltid.t.tyg = tyg;
980  ltid.t.tix = tix;
981  }
982 
983  *tid = ltid.pwr;
984  return CDH__SUCCESS;
985 }
986 
988 
997 {
998  unsigned int vid_0;
999  unsigned int vid_1;
1000  unsigned int vid_2;
1001  unsigned int vid_3;
1002  cdh_uVolumeId lvid;
1003 
1004  pwr_Assert(vid != NULL);
1005 
1006  lvid.pwr = pwr_cNVolumeId;
1007 
1008  if (*s == '_')
1009  s++;
1010  if (*s == 'V' || *s == 'v')
1011  s++;
1012  if (*s == 'O' || *s == 'o')
1013  s++;
1014  if (*s == 'A' || *s == 'a')
1015  s++;
1016 
1017  if (sscanf(s, "%d.%d.%d.%d%*s", &vid_3, &vid_2, &vid_1, &vid_0) != 4)
1018  return CDH__INVVID;
1019 
1020  if (vid_3 > cdh_cMaxVidGroup || vid_2 > cdh_cMaxVidGroup
1021  || vid_1 > cdh_cMaxVidGroup || vid_0 > cdh_cMaxVidGroup)
1022  return CDH__INVVID;
1023 
1024  lvid.v.vid_3 = vid_3;
1025  lvid.v.vid_2 = vid_2;
1026  lvid.v.vid_1 = vid_1;
1027  lvid.v.vid_0 = vid_0;
1028 
1029  *vid = lvid.pwr;
1030 
1031  return CDH__SUCCESS;
1032 }
1033 
1035 
1044 {
1045  pwr_tObjectIx loix = pwr_cNObjectIx;
1046 
1047  pwr_Assert(oix != NULL);
1048  errno = 0;
1049 
1050  if (*s == '_')
1051  s++;
1052  if (*s == 'X' || *s == 'x')
1053  s++;
1054 
1055  loix = strtoul(s, NULL, 0);
1056  if (errno == ERANGE || loix > cdh_cMaxOix)
1057  return CDH__INVOIX;
1058 
1059  *oix = loix;
1060 
1061  return CDH__SUCCESS;
1062 }
1063 
1064 pwr_tStatus cdh_StringToSubid(const char* s, pwr_tSubid* sid)
1065 {
1066  unsigned int vid_0;
1067  unsigned int vid_1;
1068  unsigned int vid_2;
1069  unsigned int vid_3;
1070  unsigned int six;
1071  cdh_uRefId lrid;
1072 
1073  pwr_Assert(sid != NULL);
1074 
1075  lrid.pwr = pwr_cNSubid;
1076 
1077  if (*s == '_')
1078  s++;
1079  if (*s == 'S' || *s == 's')
1080  s++;
1081 
1082  if (sscanf(s, "%d.%d.%d.%d:%u%*s", &vid_3, &vid_2, &vid_1, &vid_0, &six) != 5)
1083  return CDH__INVSID;
1084 
1085  if (vid_3 != cdh_eVid3_subid || vid_2 > cdh_cMaxVidGroup
1086  || vid_1 > cdh_cMaxVidGroup || vid_0 > cdh_cMaxVidGroup) {
1087  return CDH__INVSID;
1088  }
1089 
1090  lrid.r.vid_3 = vid_3;
1091  lrid.r.vid_2 = vid_2;
1092  lrid.r.vid_1 = vid_1;
1093  lrid.r.vid_0 = vid_0;
1094  lrid.r.rix = six;
1095 
1096  *sid = lrid.pwr;
1097 
1098  return CDH__SUCCESS;
1099 }
1100 
1101 pwr_tStatus cdh_StringToDlid(const char* s, pwr_tDlid* did)
1102 {
1103  unsigned int vid_0;
1104  unsigned int vid_1;
1105  unsigned int vid_2;
1106  unsigned int vid_3;
1107  unsigned int dix;
1108  cdh_uRefId lrid;
1109 
1110  pwr_Assert(did != NULL);
1111 
1112  lrid.pwr = pwr_cNDlid;
1113 
1114  if (*s == '_')
1115  s++;
1116  if (*s == 'D' || *s == 'd')
1117  s++;
1118 
1119  if (sscanf(s, "%d.%d.%d.%d:%u%*s", &vid_3, &vid_2, &vid_1, &vid_0, &dix) != 5)
1120  return CDH__INVDID;
1121 
1122  if (vid_3 != cdh_eVid3_dlid || vid_2 > cdh_cMaxVidGroup
1123  || vid_1 > cdh_cMaxVidGroup || vid_0 > cdh_cMaxVidGroup) {
1124  return CDH__INVDID;
1125  }
1126 
1127  lrid.r.vid_3 = vid_3;
1128  lrid.r.vid_2 = vid_2;
1129  lrid.r.vid_1 = vid_1;
1130  lrid.r.vid_0 = vid_0;
1131  lrid.r.rix = dix;
1132 
1133  *did = lrid.pwr;
1134 
1135  return CDH__SUCCESS;
1136 }
1137 
1139 
1152 void cdh_ClassIdToString(char* s, int size, pwr_tClassId cid, int prefix)
1153 {
1154  cdh_uTypeId lcid;
1155 
1156  lcid.pwr = cid;
1157 
1158  if (/* Check validity of class identifier. */
1159  lcid.c.bix != 0 || lcid.c.must_be_zero != 0) {
1160  snprintf(s, size, "%s%u.%u:?%u?", (prefix ? "_C" : ""), lcid.c.vid_1,
1161  lcid.c.vid_0, lcid.c.cix);
1162  } else {
1163  snprintf(s, size, "%s%u.%u:%u", (prefix ? "_C" : ""), lcid.c.vid_1,
1164  lcid.c.vid_0, lcid.c.cix);
1165  }
1166 }
1167 
1169 
1189 void cdh_TypeIdToString(char* s, int size, pwr_tTypeId tid, int prefix)
1190 {
1191  cdh_uTypeId ltid;
1192 
1193  ltid.pwr = tid;
1194 
1195  if (ltid.t.must_be_one == 0) { /* This is a class TypeId. */
1196  snprintf(s, size, "%s%u.%u:0.%u.%u", (prefix ? "_T" : ""), ltid.c.vid_1,
1197  ltid.c.vid_0, ltid.c.cix, ltid.c.bix);
1198  } else { /* This i s a type TypeId. */
1199  snprintf(s, size, "%s%u.%u:1.%u.%u", (prefix ? "_T" : ""), ltid.t.vid_1,
1200  ltid.t.vid_0, ltid.t.tyg, ltid.t.tix);
1201  }
1202 }
1203 
1205 
1217 void cdh_ObjectIxToString(char* s, int size, pwr_tObjectIx oix, int prefix)
1218 {
1219  snprintf(s, size, "%s%u", (prefix ? "_X" : ""), oix);
1220 }
1221 
1223 
1232 void cdh_ArefToString(char* s, int size, pwr_sAttrRef* aref, int prefix)
1233 {
1234  char ls[200];
1235  char tmp[40];
1236 
1237  cdh_OidToString(ls, sizeof(ls), aref->Objid, 0);
1238 
1239  if (aref->Body != pwr_cNTypeId) {
1240  strcat(ls, "(");
1241  cdh_TypeIdToString(&ls[strlen(ls)], sizeof(ls), aref->Body, 1);
1242  strcat(ls, ")");
1243  if (aref->Offset > 0 || aref->Size > 0) {
1244  sprintf(tmp, "[%d.%d]", aref->Offset, aref->Size);
1245  strcat(ls, tmp);
1246  }
1247  }
1248 
1249  sprintf(s, "%s", (prefix ? "_A" : ""));
1250  strncat(s, ls, size - strlen(s));
1251 }
1252 
1254 
1267 char* cdh_AttrRefToString(pwr_sAttrRef* aref, int prefix)
1268 {
1269  static char ls[200];
1270 
1271  cdh_ArefToString(ls, sizeof(ls), aref, prefix);
1272  return ls;
1273 }
1274 
1276 
1291 char* cdh_NodeIdToString(char* s, pwr_tNodeId nid, int prefix, int suffix)
1292 {
1293  cdh_uVolumeId lvid;
1294  static char ls[sizeof("_N255.255.255.255:")];
1295 
1296  lvid.pwr = (pwr_tVolumeId)nid;
1297 
1298  sprintf(ls, "%s%u.%u.%u.%u%s", (prefix ? "_N" : ""), lvid.v.vid_3,
1299  lvid.v.vid_2, lvid.v.vid_1, lvid.v.vid_0, (suffix ? ":" : ""));
1300 
1301  if (s != NULL)
1302  return strcat(s, ls);
1303  else
1304  return ls;
1305 }
1306 
1308 
1317 void cdh_OidToString(char* s, int size, pwr_tObjid oid, int prefix)
1318 {
1319  cdh_uObjid loid;
1320 
1321  loid.pwr = oid;
1322 
1323  snprintf(s, size, "%s%u.%u.%u.%u:%u", (prefix ? "_O" : ""), loid.o.vid_3,
1324  loid.o.vid_2, loid.o.vid_1, loid.o.vid_0, loid.o.oix);
1325 }
1326 
1328 
1341 char* cdh_ObjidToString(pwr_tObjid oid, int prefix)
1342 {
1343  cdh_uObjid loid;
1344  static char ls[sizeof("_O255.255.255.255:4294967295")];
1345 
1346  loid.pwr = oid;
1347 
1348  sprintf(ls, "%s%u.%u.%u.%u:%u", (prefix ? "_O" : ""), loid.o.vid_3,
1349  loid.o.vid_2, loid.o.vid_1, loid.o.vid_0, loid.o.oix);
1350  return ls;
1351 }
1352 
1354 
1368 char* cdh_ObjidToFnString(char* s, pwr_tOid oid)
1369 {
1370  cdh_uObjid loid;
1371  static char str[40];
1372 
1373  loid.pwr = oid;
1374 
1375  sprintf(str, "%3.3u_%3.3u_%3.3u_%3.3u_%8.8x", loid.o.vid_3, loid.o.vid_2,
1376  loid.o.vid_1, loid.o.vid_0, loid.o.oix);
1377 
1378  if (s != NULL)
1379  return strcat(s, str);
1380  else
1381  return str;
1382 }
1383 
1385 
1403  char* s, int size, pwr_tVolumeId vid, int prefix, int suffix)
1404 {
1405  cdh_uVolumeId lvid;
1406  static char ls[sizeof("_V255.255.255.255:")];
1407 
1408  lvid.pwr = vid;
1409 
1410  if (s) {
1411  snprintf(s, size, "%s%u.%u.%u.%u%s", (prefix ? "_V" : ""), lvid.v.vid_3,
1412  lvid.v.vid_2, lvid.v.vid_1, lvid.v.vid_0, (suffix ? ":" : ""));
1413  return s;
1414  } else
1415  sprintf(ls, "%s%u.%u.%u.%u%s", (prefix ? "_V" : ""), lvid.v.vid_3,
1416  lvid.v.vid_2, lvid.v.vid_1, lvid.v.vid_0, (suffix ? ":" : ""));
1417  return ls;
1418 }
1419 
1421 
1429 char* cdh_VolumeIdToFnString(char* s, int size, pwr_tVolumeId vid)
1430 {
1431  cdh_uVolumeId lvid;
1432 
1433  lvid.pwr = vid;
1434 
1435  snprintf(s, size, "%3.3u_%3.3u_%3.3u_%3.3u", lvid.v.vid_3, lvid.v.vid_2,
1436  lvid.v.vid_1, lvid.v.vid_0);
1437 
1438  return s;
1439 }
1440 
1442 
1451 void cdh_SubidToString(char* s, int size, pwr_tSubid sid, int prefix)
1452 {
1453  cdh_uRefId lrid;
1454 
1455  lrid.pwr = sid;
1456 
1457  snprintf(s, size, "%s%u.%u.%u.%u:%u", (prefix ? "_S" : ""), lrid.r.vid_3,
1458  lrid.r.vid_2, lrid.r.vid_1, lrid.r.vid_0, lrid.r.rix);
1459 }
1460 
1462 
1471 void cdh_DlidToString(char* s, int size, pwr_tDlid did, int prefix)
1472 {
1473  cdh_uRefId lrid;
1474 
1475  lrid.pwr = did;
1476 
1477  snprintf(s, size, "%s%u.%u.%u.%u:%u", (prefix ? "_D" : ""), lrid.r.vid_3,
1478  lrid.r.vid_2, lrid.r.vid_1, lrid.r.vid_0, lrid.r.rix);
1479 }
1480 
1481 cdh_sFamily* cdh_Family(cdh_sFamily* f, const char* name, pwr_tObjid poid)
1482 {
1483  cdh_ObjName(&f->name, name);
1484  f->poid = poid;
1485 
1486  return f;
1487 }
1488 
1489 cdh_sObjName* cdh_ObjName(cdh_sObjName* on, const char* name)
1490 {
1491  char *s, *t;
1492  int utf_len;
1493 
1494  strncpy(on->orig, name, sizeof(pwr_tObjName));
1495  str_Cut(on->orig, sizeof(pwr_tObjName));
1496  for (s = on->orig, t = on->norm; *s;) {
1497  utf_len = str_Utf8Len((unsigned char*)s);
1498  if (t - on->norm + utf_len > sizeof(pwr_tObjName) - 1) {
1499  *t = 0;
1500  break;
1501  }
1502  str_ToNormUtf8((unsigned char*)t, (unsigned char*)s);
1503  s += utf_len;
1504  t += utf_len;
1505  }
1506  *t = 0;
1507  on->pack.key = cdh_PackName(on->norm);
1508 
1509  return on;
1510 }
1511 
1512 #define IDX_UTF8 256
1513 
1514 cdh_sParseName* cdh_ParseName(pwr_tStatus* sts, cdh_sParseName* pn,
1515  pwr_tObjid poid, const char* name, pwr_tUInt32 flags)
1516 {
1517  pwr_tStatus lsts = 1;
1518  const char* inp;
1519  char* outp;
1520  char* outcp;
1521  pwr_tUInt32 len;
1522  pwr_tUInt32 seglen = 0;
1523  pwr_tUInt32 number = 0;
1524  unsigned char c;
1525  unsigned char cc;
1526  char* segp;
1527  char* segcp;
1528  pwr_tInt32 state;
1529  cdh_sParseName ParseName;
1530  char origName[256];
1531  char normName[256];
1532  char utf_len;
1533 
1534  /* Conversion table.
1535  ! : illegal character
1536  * : terminates state
1537  ^ : lowercase, subtract 32 if cdh_mParseName_UpperCase
1538  + : eat
1539  - : new segment
1540  . : new segment
1541  ~ : end of string
1542  */
1543 
1544  static const char* cvttab[] = { /* 0: init */
1545  "\
1546 ~+++++++++++++++++++++++++++++++\
1547 +*******************************\
1548 ********************************\
1549 ********************************\
1550 ++++++++++++++++++++++++++++++++\
1551 ********************************\
1552 ********************************\
1553 ********************************\
1554 *",
1555  /* 1: id() before '(' */
1556  "\
1557 ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1558 !!!!!!!!*!!!!-.!0123456789:!!!!!\
1559 !A!CD!!!!!!!!!!O!!!ST!V!X!!!!!!_\
1560 !^!^^!!!!!!!!!!^!!!^^!^!^!!!!!!!\
1561 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1562 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1563 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1564 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1565 !",
1566  /* 2: id(bname)attribute[index], (bvol:Class-b-b-b) before ':' */
1567  "\
1568 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1569 !!!!$!!!!!!!!!!!0123456789*!!!!!\
1570 !ABCDEFGHIJKLMNOPQRSTUVWXYZ!!!!_\
1571 !^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
1572 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1573 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1574 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1575 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1576 !",
1577  /* 3: id(bname)attribute[index], (bvol:Class-b-b-b) before ')' */
1578  "\
1579 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1580 !!!!$!!!!*!!!-!!0123456789!!!!!!\
1581 !ABCDEFGHIJKLMNOPQRSTUVWXYZ!!!!_\
1582 !^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
1583 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1584 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1585 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1586 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1587 !",
1588  /* 4: id(bname)attribute[index], attribute before '[' */
1589  "\
1590 ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1591 !!!!$!!!!!!!!!!!0123456789!!!!!!\
1592 !ABCDEFGHIJKLMNOPQRSTUVWXYZ*!!!_\
1593 !^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
1594 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1595 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1596 ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ!ÑÒÓÔÕÖרÙÚÛÜÝ!!\
1597 ^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^!!\
1598 C",
1599  /* 5: id(bname)attribute[index], index before ']' */
1600  "\
1601 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1602 !!!!!!!!!!!!!!!!0123456789!!!!!!\
1603 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!*!!\
1604 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1605 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1606 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1607 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1608 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1609 !",
1610  /* 6: id(bname)attribute[index], after ']' */
1611  "\
1612 ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1613 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1614 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1615 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1616 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1617 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1618 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1619 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1620 ",
1621  /* 7: id(bid)[offset.size], bid before ')' */
1622  "\
1623 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1624 !!!!!!!!!*!!!!.!0123456789:!!!!!\
1625 !!!!!!!!!!!!!!!!!!!!T!!!!!!!!!!_\
1626 !!!!!!!!!!!!!!!!!!!!^!!!!!!!!!!!\
1627 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1628 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1629 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1630 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1631 !",
1632  /* 8: id(bid)[offset.size], offset before '.' */
1633  "\
1634 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1635 !!!!!!!!!!!!!!*!0123456789!!!!!!\
1636 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1637 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1638 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1639 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1640 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1641 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1642 !",
1643  /* 9: id(bid)[offset.size], size before ']' */
1644  "\
1645 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1646 !!!!!!!!!!!!!!!!0123456789!!!!!!\
1647 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!*!!\
1648 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1649 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1650 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1651 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1652 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1653 !",
1654  /* 10: id(bid)[offset.size], after ']' */
1655  "\
1656 ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1657 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1658 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1659 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1660 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1661 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1662 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1663 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1664 !",
1665  /* 11: name.attribute[index], name before ':' */
1666  "\
1667 ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1668 !!!!$!!!!!!!!**!0123456789*!!!!!\
1669 !ABCDEFGHIJKLMNOPQRSTUVWXYZ!!!!_\
1670 !^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
1671 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1672 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1673 ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ!ÑÒÓÔÕÖרÙÚÛÜÝ!!\
1674 ^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^!!\
1675 C",
1676  /* 12: name.attribute[index], name before '.' */
1677  "\
1678 ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1679 !!!!$!!!!!!!!-*!0123456789!!!!!!\
1680 !ABCDEFGHIJKLMNOPQRSTUVWXYZ!!!!_\
1681 !^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
1682 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1683 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1684 ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ!ÑÒÓÔÕÖרÙÚÛÜÝ!!\
1685 ^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^!!\
1686 C",
1687  /* 13: name.attribute[index], attribute before '[' or '.' */
1688  "\
1689 ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1690 !!!!$!!!!!!!!!.!0123456789!!!!!!\
1691 !ABCDEFGHIJKLMNOPQRSTUVWXYZ*!!!_\
1692 !^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
1693 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1694 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1695 ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ!ÑÒÓÔÕÖרÙÚÛÜÝ!!\
1696 ^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^!!\
1697 C",
1698  /* 14: name.attribute[index], index before ']' */
1699  "\
1700 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1701 !!!!!!!!!!!!!!!!0123456789!!!!!!\
1702 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!*!!\
1703 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1704 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1705 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1706 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1707 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1708 !",
1709  /* 15: name.attribute[index], after ']' */
1710  "\
1711 ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1712 !!!!!!!!!!!!!!*!!!!!!!!!!!!!!!!!\
1713 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1714 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1715 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1716 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1717 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1718 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1719 !",
1720  "\
1721 ~!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1722 !!!!$!!!!!!!!-.!0123456789:!!!!!\
1723 !ABCDEFGHIJKLMNOPQRSTUVWXYZ[!]!_\
1724 !^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
1725 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1726 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1727 ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ!ÑÒÓÔÕÖרÙÚÛÜÝ!!\
1728 ^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^!!\
1729 !"
1730  };
1731 
1732  /* Conversion table.
1733  ! : do not convert
1734  any other copy as is. */
1735 
1736  static const char ascii7tab[] = { "\
1737 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1738 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1739 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1740 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1741 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1742 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
1743 AAAAAAACEEEEIIII!NOOOOOOOUUUUY!!\
1744 aaaaaaaceeeeiiii!nooooooouuuuy!!\
1745 !" };
1746 
1747  len = strlen(name);
1748  if (len >= sizeof(origName)) {
1749  *sts = CDH__NAMELEN;
1750  return NULL;
1751  }
1752 
1753  if (pn == NULL)
1754  pn = &ParseName;
1755 
1756  memset(pn, 0, sizeof(*pn));
1757 
1758  if (cdh_ObjidIsNotNull(poid)) {
1759  pn->poid = poid;
1760  pn->flags.b.parent = 1;
1761  }
1762  pn->parseFlags.m = flags;
1763 
1764  inp = name;
1765  outp = normName;
1766  outcp = origName;
1767  *outp = '\0';
1768  *outcp = '\0';
1769  segp = outp;
1770  segcp = outcp;
1771  seglen = 0;
1772 
1773  state = 0;
1774 
1775  while (inp <= name + len) {
1776  cc = c = *inp;
1777  utf_len = str_Utf8Len((unsigned char*)inp);
1778  if (utf_len > 1) {
1779  if (cvttab[state][IDX_UTF8] == '!') {
1780  printf("State: %d, %c\n", state, c);
1781  lsts = CDH__INVCHAR;
1782  goto error;
1783  }
1784  c = cvttab[state][IDX_UTF8];
1785  } else {
1786  if (cvttab[state][c] == '!') {
1787  printf("State: %d, %c\n", state, c);
1788  lsts = CDH__INVCHAR;
1789  goto error;
1790  } else if (cvttab[state][c] == '^')
1791  c -= 32;
1792  else
1793  c = cvttab[state][c];
1794 
1795  if (pn->parseFlags.b.ascii_7 && ascii7tab[c] != '!') {
1796  c = ascii7tab[c];
1797  cc = ascii7tab[cc];
1798  }
1799  }
1800 
1801  switch (state) {
1802  case 0: /* 0: init */
1803  if (c == '*') {
1804  if (*inp == '_') {
1805  state++;
1806  } else if (*inp == '.') {
1807  ++inp;
1808  state = 13;
1809  } else if (pn->flags.b.parent) {
1810  state = 12;
1811  } else {
1812  state = 11;
1813  }
1814  } else if (c == '~') {
1815  lsts = CDH__NONAME;
1816  goto error;
1817  } else if (c == '+') {
1818  ++inp;
1819  }
1820  break;
1821  case 1: /* 1: id before '(' */
1822  if (c == '~') {
1823  if (outp == segp) {
1824  lsts = CDH__INVID;
1825  goto error;
1826  }
1827  *outp++ = '\0';
1828  *outcp++ = '\0';
1829  pn->flags.b.idString = 1;
1830  switch (segp[1]) {
1831  case 'O':
1832  lsts = cdh_StringToObjid(segp, &pn->uId.oid);
1833  pn->eId = cdh_eId_objid;
1834  break;
1835  case 'C':
1836  lsts = cdh_StringToClassId(segp, &pn->uId.cid);
1837  pn->eId = cdh_eId_classId;
1838  break;
1839  case 'V':
1840  lsts = cdh_StringToVolumeId(segp, &pn->uId.vid);
1841  pn->eId = cdh_eId_volumeId;
1842  break;
1843  case 'T':
1844  lsts = cdh_StringToTypeId(segp, &pn->uId.tid);
1845  pn->eId = cdh_eId_typeId;
1846  break;
1847  case 'A':
1848  lsts = cdh_StringToObjid(segp, &pn->uId.aref.Objid);
1849  pn->eId = cdh_eId_aref;
1850  break;
1851  case 'S':
1852  lsts = cdh_StringToSubid(segp, &pn->uId.sid);
1853  pn->eId = cdh_eId_subid;
1854  break;
1855  case 'D':
1856  lsts = cdh_StringToDlid(segp, &pn->uId.did);
1857  pn->eId = cdh_eId_dlid;
1858  break;
1859  case 'X':
1860  lsts = cdh_StringToObjectIx(segp, &pn->uId.oix);
1861  pn->eId = cdh_eId_objectIx;
1862  break;
1863  default:
1864  lsts = CDH__INVIDCHAR;
1865  goto error;
1866  }
1867  if (EVEN(lsts))
1868  goto error;
1869  segp = outp;
1870  segcp = outcp;
1871  seglen = 0;
1872  } else if (c == '*') {
1873  if (outp == segp) {
1874  lsts = CDH__INVSYNTAX;
1875  goto error;
1876  }
1877  *outp++ = '\0';
1878  *outcp++ = '\0';
1879  pn->flags.b.idString = 1;
1880  switch (segp[1]) {
1881  case 'A':
1882  lsts = cdh_StringToObjid(segp, &pn->uId.aref.Objid);
1883  pn->eId = cdh_eId_aref;
1884  if (*(inp + 1) == '_')
1885  state = 7;
1886  else
1887  state = 2;
1888  break;
1889  default:
1890  lsts = CDH__INVIDCHAR;
1891  goto error;
1892  }
1893  if (EVEN(lsts)) {
1894  goto error;
1895  }
1896  segp = outp;
1897  segcp = outcp;
1898  seglen = 0;
1899  } else if (c == '-') {
1900  if (outp == segp) {
1901  lsts = CDH__INVSYNTAX;
1902  goto error;
1903  }
1904  *outp++ = '\0';
1905  *outcp++ = '\0';
1906  pn->flags.b.parent = 1;
1907  switch (segp[1]) {
1908  case 'A':
1909  case 'O':
1910  lsts = cdh_StringToObjid(segp, &pn->poid);
1911  state = 12;
1912  break;
1913  default:
1914  lsts = CDH__INVIDCHAR;
1915  goto error;
1916  }
1917  if (EVEN(lsts))
1918  goto error;
1919  segp = outp;
1920  segcp = outcp;
1921  seglen = 0;
1922  } else {
1923  *outp++ = c;
1924  *outcp++ = cc;
1925  seglen++;
1926  }
1927  inp++;
1928  break;
1929  case 2: /* 2: id(bname)attribute[index], (bvol:Class-b-b-b) before ':' */
1930  if (c == '*') {
1931  if (outp == segp) {
1932  lsts = CDH__INVTYPENAME;
1933  goto error;
1934  }
1935  *outp++ = '\0';
1936  *outcp++ = '\0';
1937  if (seglen >= sizeof(pwr_tObjName)) {
1938  lsts = CDH__SEGLEN;
1939  goto error;
1940  }
1941  strcpy(pn->body[pn->nBody].name.orig, segcp);
1942  strcpy(pn->body[pn->nBody].name.norm, segp);
1943  pn->body[pn->nBody].name.pack.key = cdh_PackName(segp);
1944  pn->nBody++;
1945  segp = outp;
1946  segcp = outcp;
1947  seglen = 0;
1948  state++;
1949  } else {
1950  *outp++ = c;
1951  *outcp++ = cc;
1952  seglen++;
1953  }
1954  inp++;
1955  break;
1956  case 3: /* 3: id(bname)attribute[index], (bvol:Class-b-b-b) before ')' */
1957  if (c == '*') {
1958  if (outp == segp) {
1959  lsts = CDH__INVTYPENAME;
1960  goto error;
1961  }
1962  *outp++ = '\0';
1963  *outcp++ = '\0';
1964  pn->flags.b.bodyName = 1;
1965  if (seglen >= sizeof(pwr_tObjName)) {
1966  lsts = CDH__SEGLEN;
1967  goto error;
1968  }
1969  strcpy(pn->body[pn->nBody].name.orig, segcp);
1970  strcpy(pn->body[pn->nBody].name.norm, segp);
1971  pn->body[pn->nBody].name.pack.key = cdh_PackName(segp);
1972  pn->nBody++;
1973  segp = outp;
1974  segcp = outcp;
1975  seglen = 0;
1976  state++;
1977  } else if (c == '-') {
1978  if (outp == segp) {
1979  lsts = CDH__INVTYPENAME;
1980  goto error;
1981  }
1982  *outp++ = '\0';
1983  *outcp++ = '\0';
1984  if (seglen >= sizeof(pwr_tObjName)) {
1985  lsts = CDH__SEGLEN;
1986  goto error;
1987  }
1988  strcpy(pn->body[pn->nBody].name.orig, segcp);
1989  strcpy(pn->body[pn->nBody].name.norm, segp);
1990  pn->body[pn->nBody].name.pack.key = cdh_PackName(segp);
1991  pn->nBody++;
1992  segp = outp;
1993  segcp = outcp;
1994  seglen = 0;
1995  } else {
1996  *outp++ = c;
1997  *outcp++ = cc;
1998  seglen++;
1999  }
2000  inp++;
2001  break;
2002  case 4: /* 4: id(bname)attribute[index], attribute before '[' */
2003  if (c == '~') {
2004  if (outp != segp) {
2005  *outp++ = '\0';
2006  *outcp++ = '\0';
2007  pn->flags.b.attribute = 1;
2008  if (seglen >= sizeof(pwr_tObjName)) {
2009  lsts = CDH__SEGLEN;
2010  goto error;
2011  }
2012  strcpy(pn->attribute[0].name.orig, segcp);
2013  strcpy(pn->attribute[0].name.norm, segp);
2014  pn->attribute[0].name.pack.key = cdh_PackName(segp);
2015  segp = outp;
2016  segcp = outcp;
2017  seglen = 0;
2018  }
2019  } else if (c == '*') {
2020  if (outp == segp) {
2021  lsts = CDH__INVATTRNAME;
2022  goto error;
2023  }
2024  *outp++ = '\0';
2025  *outcp++ = '\0';
2026  pn->flags.b.attribute = 1;
2027  if (seglen >= sizeof(pwr_tObjName)) {
2028  lsts = CDH__SEGLEN;
2029  goto error;
2030  }
2031  strcpy(pn->attribute[0].name.orig, segcp);
2032  strcpy(pn->attribute[0].name.norm, segp);
2033  pn->attribute[0].name.pack.key = cdh_PackName(segp);
2034  segp = outp;
2035  segcp = outcp;
2036  seglen = 0;
2037  state++;
2038  } else {
2039  *outp++ = c;
2040  *outcp++ = cc;
2041  seglen++;
2042  }
2043  inp++;
2044  break;
2045  case 7: /* 7: id(bid)[offset.size], bid before ')' */
2046  if (c == '*') {
2047  if (outp == segp) {
2048  lsts = CDH__INVBID;
2049  goto error;
2050  }
2051  *outp++ = '\0';
2052  *outcp++ = '\0';
2053  lsts = cdh_StringToTypeId(segp, &pn->bid);
2054  if (EVEN(lsts))
2055  goto error;
2056  pn->uId.aref.Body = pn->bid;
2057  pn->flags.b.bodyId = 1;
2058  segp = outp;
2059  segcp = outcp;
2060  seglen = 0;
2061  if (*(inp + 1) == '[') {
2062  inp++;
2063  state = 8;
2064  } else {
2065  state = 10;
2066  }
2067  } else {
2068  *outp++ = c;
2069  *outcp++ = cc;
2070  seglen++;
2071  }
2072  inp++;
2073  break;
2074  case 11: /* 11: name.attribute[index], name before ':' */
2075  if (c == '~') {
2076  if (outp == segp) {
2077  lsts = CDH__INVCHAR;
2078  goto error;
2079  }
2080  *outp++ = '\0';
2081  *outcp++ = '\0';
2082  pn->flags.b.object = 1;
2083  if (seglen >= sizeof(pwr_tObjName)) {
2084  lsts = CDH__SEGLEN;
2085  goto error;
2086  }
2087  strcpy(pn->object[pn->nObject].name.orig, segcp);
2088  strcpy(pn->object[pn->nObject].name.norm, segp);
2089  pn->object[pn->nObject].name.pack.key = cdh_PackName(segp);
2090  pn->nObject++;
2091  segp = outp;
2092  segcp = outcp;
2093  seglen = 0;
2094  } else if (c == '*') {
2095  if (outp == segp) {
2096  lsts = CDH__INVCHAR;
2097  goto error;
2098  }
2099  *outp++ = '\0';
2100  *outcp++ = '\0';
2101  if (*inp == ':') {
2102  if (seglen >= sizeof(pwr_tObjName)) {
2103  lsts = CDH__SEGLEN;
2104  goto error;
2105  }
2106  strcpy(pn->volume.name.orig, segcp);
2107  strcpy(pn->volume.name.norm, segp);
2108  pn->volume.name.pack.key = cdh_PackName(segp);
2109  pn->flags.b.volume = 1;
2110  state = 12;
2111  } else if (*inp == '-') {
2112  pn->flags.b.object = 1;
2113  if (seglen >= sizeof(pwr_tObjName)) {
2114  lsts = CDH__SEGLEN;
2115  goto error;
2116  }
2117  strcpy(pn->object[pn->nObject].name.orig, segcp);
2118  strcpy(pn->object[pn->nObject].name.norm, segp);
2119  pn->object[pn->nObject].name.pack.key = cdh_PackName(segp);
2120  pn->nObject++;
2121  state = 12;
2122  } else if (*inp == '.') {
2123  pn->flags.b.object = 1;
2124  if (seglen >= sizeof(pwr_tObjName)) {
2125  lsts = CDH__SEGLEN;
2126  goto error;
2127  }
2128  strcpy(pn->object[pn->nObject].name.orig, segcp);
2129  strcpy(pn->object[pn->nObject].name.norm, segp);
2130  pn->object[pn->nObject].name.pack.key = cdh_PackName(segp);
2131  pn->nObject++;
2132  state = 13;
2133  }
2134  segp = outp;
2135  segcp = outcp;
2136  seglen = 0;
2137  } else {
2138  if (utf_len > 1) {
2139  str_CpyUtf8((unsigned char*)outcp, (unsigned char*)inp);
2140  str_ToNormUtf8((unsigned char*)outp, (unsigned char*)inp);
2141  inp += utf_len - 1;
2142  outp += utf_len;
2143  outcp += utf_len;
2144  seglen += utf_len;
2145  } else {
2146  *outp++ = c;
2147  *outcp++ = cc;
2148  seglen++;
2149  }
2150  }
2151  inp++;
2152  break;
2153  case 12: /* 12: name.attribute[index], name before '.' */
2154  if (c == '~') {
2155  if (outp != segp) {
2156  *outp++ = '\0';
2157  *outcp++ = '\0';
2158  pn->flags.b.object = 1;
2159  if (seglen >= sizeof(pwr_tObjName)) {
2160  lsts = CDH__SEGLEN;
2161  goto error;
2162  }
2163  strcpy(pn->object[pn->nObject].name.orig, segcp);
2164  strcpy(pn->object[pn->nObject].name.norm, segp);
2165  pn->object[pn->nObject].name.pack.key = cdh_PackName(segp);
2166  pn->nObject++;
2167  segp = outp;
2168  segcp = outcp;
2169  seglen = 0;
2170  }
2171  } else if (c == '*') {
2172  if (outp == segp) {
2173  lsts = CDH__INVCHAR;
2174  goto error;
2175  }
2176  *outp++ = '\0';
2177  *outcp++ = '\0';
2178  pn->flags.b.object = 1;
2179  if (seglen >= sizeof(pwr_tObjName)) {
2180  lsts = CDH__SEGLEN;
2181  goto error;
2182  }
2183  strcpy(pn->object[pn->nObject].name.orig, segcp);
2184  strcpy(pn->object[pn->nObject].name.norm, segp);
2185  pn->object[pn->nObject].name.pack.key = cdh_PackName(segp);
2186  pn->nObject++;
2187  segp = outp;
2188  segcp = outcp;
2189  seglen = 0;
2190  state = 13;
2191  } else if (c == '-') {
2192  if (outp == segp) {
2193  lsts = CDH__INVCHAR;
2194  goto error;
2195  }
2196  *outp++ = '\0';
2197  *outcp++ = '\0';
2198  pn->flags.b.object = 1;
2199  if (seglen >= sizeof(pwr_tObjName)) {
2200  lsts = CDH__SEGLEN;
2201  goto error;
2202  }
2203  strcpy(pn->object[pn->nObject].name.orig, segcp);
2204  strcpy(pn->object[pn->nObject].name.norm, segp);
2205  pn->object[pn->nObject].name.pack.key = cdh_PackName(segp);
2206  pn->nObject++;
2207  segp = outp;
2208  segcp = outcp;
2209  seglen = 0;
2210  } else {
2211  if (utf_len > 1) {
2212  str_CpyUtf8((unsigned char*)outcp, (unsigned char*)inp);
2213  str_ToNormUtf8((unsigned char*)outp, (unsigned char*)inp);
2214  inp += utf_len - 1;
2215  outp += utf_len;
2216  outcp += utf_len;
2217  seglen += utf_len;
2218  } else {
2219  *outp++ = c;
2220  *outcp++ = cc;
2221  seglen++;
2222  }
2223  }
2224  inp++;
2225  break;
2226  case 13: /* 13: name.attribute[index], attribute before '[' */
2227  if (c == '~') {
2228  if (outp == segp) {
2229  lsts = CDH__INVATTRNAME;
2230  goto error;
2231  }
2232  *outp++ = '\0';
2233  *outcp++ = '\0';
2234  pn->flags.b.attribute = 1;
2235  if (seglen >= sizeof(pwr_tObjName)) {
2236  lsts = CDH__SEGLEN;
2237  goto error;
2238  }
2239  strcpy(pn->attribute[pn->nAttribute].name.orig, segcp);
2240  strcpy(pn->attribute[pn->nAttribute].name.norm, segp);
2241  pn->attribute[pn->nAttribute].name.pack.key = cdh_PackName(segp);
2242  pn->nAttribute++;
2243  segp = outp;
2244  segcp = outcp;
2245  seglen = 0;
2246  } else if (c == '*') {
2247  if (outp == segp) {
2248  lsts = CDH__INVATTRNAME;
2249  goto error;
2250  }
2251  *outp++ = '\0';
2252  *outcp++ = '\0';
2253  pn->flags.b.attribute = 1;
2254  if (seglen >= sizeof(pwr_tObjName)) {
2255  lsts = CDH__SEGLEN;
2256  goto error;
2257  }
2258  strcpy(pn->attribute[pn->nAttribute].name.orig, segcp);
2259  strcpy(pn->attribute[pn->nAttribute].name.norm, segp);
2260  pn->attribute[pn->nAttribute].name.pack.key = cdh_PackName(segp);
2261  pn->nAttribute++;
2262  segp = outp;
2263  segcp = outcp;
2264  seglen = 0;
2265  state++;
2266  } else if (c == '.') {
2267  if (outp == segp) {
2268  lsts = CDH__INVATTRNAME;
2269  goto error;
2270  }
2271  *outp++ = '\0';
2272  *outcp++ = '\0';
2273  pn->flags.b.attribute = 1;
2274  if (seglen >= sizeof(pwr_tObjName)) {
2275  lsts = CDH__SEGLEN;
2276  goto error;
2277  }
2278  strcpy(pn->attribute[pn->nAttribute].name.orig, segcp);
2279  strcpy(pn->attribute[pn->nAttribute].name.norm, segp);
2280  pn->attribute[pn->nAttribute].name.pack.key = cdh_PackName(segp);
2281  pn->nAttribute++;
2282  segp = outp;
2283  segcp = outcp;
2284  seglen = 0;
2285  } else {
2286  if (utf_len > 1) {
2287  str_CpyUtf8((unsigned char*)outcp, (unsigned char*)inp);
2288  str_ToNormUtf8((unsigned char*)outp, (unsigned char*)inp);
2289  inp += utf_len - 1;
2290  outp += utf_len;
2291  outcp += utf_len;
2292  seglen += utf_len;
2293  } else {
2294  *outp++ = c;
2295  *outcp++ = cc;
2296  seglen++;
2297  }
2298  }
2299  inp++;
2300  break;
2301  case 5: /* 5: id(bname)attribute[index], index before ']' */
2302  case 8: /* 8: id(bid)[offset.size], offset before '.' */
2303  case 9: /* 9: id(bid)[offset.size], size before ']' */
2304  case 14: /* 14: name.attribute[index], index before ']' */
2305  if (c == '*') {
2306  switch (state) {
2307  case 5:
2308  case 14:
2309  pn->index[pn->nAttribute - 1] = number;
2310  pn->hasIndex[pn->nAttribute - 1] = 1;
2311  pn->flags.b.index = 1;
2312  break;
2313  case 8:
2314  pn->offset = number;
2315  pn->uId.aref.Offset = pn->offset;
2316  break;
2317  case 9:
2318  pn->size = number;
2319  pn->uId.aref.Size = pn->size;
2320  pn->flags.b.index = 1;
2321  break;
2322  }
2323  number = 0;
2324  state++;
2325  } else {
2326  number = number * 10 + (c - '0');
2327  if (number > 65535) {
2328  lsts = CDH__INVATTRINDEX;
2329  goto error;
2330  }
2331  }
2332  inp++;
2333  break;
2334  case 6: /* 6: id(bname)attribute[index], after ']' */
2335  case 10: /* 10: id(bid)[offset.size], after ']' */
2336  case 15: /* 15: name.attribute[index], after ']' */
2337  if (c == '*') {
2338  state = 13;
2339  } else {
2340  state = -1;
2341  }
2342  inp++;
2343  break;
2344  }
2345  }
2346 
2347  if (pn->nObject > 1)
2348  pn->flags.b.path = 1;
2349  *sts = lsts;
2350  return pn;
2351 
2352 error:
2353  *sts = lsts;
2354  return NULL;
2355 }
2356 
2357 pwr_tUInt32 cdh_PackName(const char* name)
2358 {
2359  cdh_uPackName pack;
2360  unsigned int len = strlen(name);
2361  const char* s = name;
2362  unsigned char hash = 0;
2363 
2364  while (*s)
2365  hash = (hash * 3) ^ *s++;
2366 
2367  pack.c.len = len;
2368  pack.c.hash = hash;
2369  pack.c.first = name[0];
2370  pack.c.last = name[len - 1];
2371 
2372  return pack.key;
2373 }
2374 
2376 
2381 char* cdh_Low(const char* s)
2382 {
2383  static char buf[500];
2384 
2385  return str_ToLower(buf, (char*)s);
2386 }
2387 
2389 
2396 char* cdh_OpSysToStr(pwr_mOpSys opsys)
2397 {
2398  static char str[32];
2399 
2400  switch (opsys) {
2401  case pwr_mOpSys_PPC_LINUX:
2402  strcpy(str, "ppc_linux");
2403  break;
2404  case pwr_mOpSys_X86_LINUX:
2405  strcpy(str, "x86_linux");
2406  break;
2407  case pwr_mOpSys_X86_64_LINUX:
2408  strcpy(str, "x86_64_linux");
2409  break;
2410  case pwr_mOpSys_X86_64_MACOS:
2411  strcpy(str, "x86_64_macos");
2412  break;
2413  case pwr_mOpSys_ARM_LINUX:
2414  strcpy(str, "arm_linux");
2415  break;
2416  case pwr_mOpSys_ARM64_LINUX:
2417  strcpy(str, "arm64_linux");
2418  break;
2419  case pwr_mOpSys_X86_64_FREEBSD:
2420  strcpy(str, "x86_64_freebsd");
2421  break;
2422  case pwr_mOpSys_X86_64_OPENBSD:
2423  strcpy(str, "x86_64_openbsd");
2424  break;
2425  case pwr_mOpSys_X86_CYGWIN:
2426  strcpy(str, "x86_cygwin");
2427  break;
2428  default:
2429  strcpy(str, "");
2430  }
2431  return str;
2432 }
2433 
2435 
2442 char* cdh_OpSysToDirStr(pwr_mOpSys opsys)
2443 {
2444  static char str[80];
2445 
2446  switch (opsys) {
2447  case pwr_mOpSys_PPC_LINUX:
2448  strcpy(str, "os_linux/hw_ppc");
2449  break;
2450  case pwr_mOpSys_X86_LINUX:
2451  strcpy(str, "os_linux/hw_x86");
2452  break;
2453  case pwr_mOpSys_X86_64_LINUX:
2454  strcpy(str, "os_linux/hw_x86_64");
2455  break;
2456  case pwr_mOpSys_X86_64_MACOS:
2457  strcpy(str, "os_macos/hw_x86_64");
2458  break;
2459  case pwr_mOpSys_ARM_LINUX:
2460  strcpy(str, "os_linux/hw_arm");
2461  break;
2462  case pwr_mOpSys_ARM64_LINUX:
2463  strcpy(str, "os_linux/hw_arm64");
2464  break;
2465  case pwr_mOpSys_X86_64_FREEBSD:
2466  strcpy(str, "os_freebsd/hw_x86_64");
2467  break;
2468  case pwr_mOpSys_X86_64_OPENBSD:
2469  strcpy(str, "os_openbsd/hw_x86_64");
2470  break;
2471  case pwr_mOpSys_X86_CYGWIN:
2472  strcpy(str, "os_cygwin/hw_x86");
2473  break;
2474  default:
2475  strcpy(str, "");
2476  }
2477  return str;
2478 }
2479 
2480 int cdh_IsClassVolume(pwr_tVid vid)
2481 {
2482  return ((cdh_cSystemClassVolMin <= vid && vid <= cdh_cSystemClassVolMax)
2484  || (cdh_cUserClassVolMin <= vid && vid <= cdh_cUserClassVolMax));
2485 }
2486 
2487 pwr_sAttrRef cdh_ArefToCastAref(pwr_sAttrRef* arp)
2488 {
2489  pwr_sAttrRef cast_aref;
2490 
2491  cast_aref = *arp;
2492  if (arp->Flags.b.DisableAttr)
2493  cast_aref.Offset -= pwr_cAlignLW;
2494  cast_aref.Offset -= pwr_cAlignLW;
2495  cast_aref.Size = sizeof(pwr_tCastId);
2496  cast_aref.Flags.b.ObjectAttr = 0;
2497  cast_aref.Flags.b.CastAttr = 0;
2498  cast_aref.Flags.b.DisableAttr = 0;
2499  cast_aref.Flags.b.Indirect = 0;
2500  return cast_aref;
2501 }
2502 
2503 pwr_sAttrRef cdh_ArefToDisableAref(pwr_sAttrRef* arp)
2504 {
2505  pwr_sAttrRef dis_aref;
2506 
2507  dis_aref = *arp;
2508  dis_aref.Offset -= pwr_cAlignLW;
2509  dis_aref.Size = sizeof(pwr_tDisableAttr);
2510  dis_aref.Flags.b.ObjectAttr = 0;
2511  dis_aref.Flags.b.CastAttr = 0;
2512  dis_aref.Flags.b.DisableAttr = 0;
2513  return dis_aref;
2514 }
2515 
2516 pwr_sAttrRef cdh_ArefAdd(pwr_sAttrRef* arp1, pwr_sAttrRef* arp2)
2517 {
2518  pwr_sAttrRef aref = *arp1;
2519  aref.Offset += arp2->Offset;
2520  aref.Size = arp2->Size;
2521  aref.Flags = arp2->Flags;
2522  return aref;
2523 }
2524 
2525 void cdh_SuppressSuper(char* out, char* in)
2526 {
2527  char* s = in;
2528  while (str_StartsWith(s, "Super."))
2529  s += 6;
2530  strcpy(out, s);
2531 }
2532 
2533 void cdh_SuppressSuperAll(char* out, char* in)
2534 {
2535  char *s, *t;
2536 
2537  for (s = in, t = out; *s;) {
2538  if (str_StartsWith(s, "Super."))
2539  s += 6;
2540  else {
2541  *t = *s;
2542  s++;
2543  t++;
2544  }
2545  }
2546  *t = 0;
2547 }
2548 
2549 int cdh_TypeToMaxStrSize(pwr_eType type, int attr_size, int attr_elements)
2550 {
2551  int size;
2552 
2553  switch (type) {
2554  case pwr_eType_Boolean:
2555  size = 1;
2556  break;
2557  case pwr_eType_Int64:
2558  size = 20;
2559  break;
2560  case pwr_eType_UInt64:
2561  size = 20;
2562  break;
2563  case pwr_eType_Enum:
2564  case pwr_eType_Mask:
2565  case pwr_eType_Status:
2566  case pwr_eType_NetStatus:
2567  case pwr_eType_Int32:
2568  size = 11;
2569  break;
2570  case pwr_eType_UInt32:
2571  size = 10;
2572  break;
2573  case pwr_eType_Int16:
2574  size = 6;
2575  break;
2576  case pwr_eType_UInt16:
2577  size = 5;
2578  break;
2579  case pwr_eType_Int8:
2580  size = 4;
2581  break;
2582  case pwr_eType_UInt8:
2583  size = 3;
2584  break;
2585  case pwr_eType_Char:
2586  size = 1;
2587  break;
2588  case pwr_eType_Float32:
2589  size = 40;
2590  break;
2591  case pwr_eType_Float64:
2592  size = 40;
2593  break;
2594  case pwr_eType_Time:
2595  size = 23;
2596  break;
2597  case pwr_eType_DeltaTime:
2598  size = 40;
2599  break;
2600  case pwr_eType_AttrRef:
2601  size = sizeof(pwr_tAName) - 1;
2602  break;
2603  case pwr_eType_TypeId:
2604  case pwr_eType_ClassId:
2605  case pwr_eType_Objid:
2606  size = sizeof(pwr_tOName) - 1;
2607  break;
2608  case pwr_eType_VolumeId:
2609  size = sizeof(pwr_tObjName) - 1;
2610  break;
2611  case pwr_eType_String:
2612  case pwr_eType_Text:
2613  size = attr_size / attr_elements - 1;
2614  break;
2615  default:
2616  size = 80;
2617  }
2618  return size;
2619 }
2620 
2621 int cdh_TypeToSize(pwr_eType type)
2622 {
2623  int size;
2624 
2625  switch (type) {
2626  case pwr_eType_Boolean:
2627  size = sizeof(pwr_tBoolean);
2628  break;
2629  case pwr_eType_Enum:
2630  size = sizeof(pwr_tEnum);
2631  break;
2632  case pwr_eType_Mask:
2633  size = sizeof(pwr_tMask);
2634  break;
2635  case pwr_eType_Status:
2636  case pwr_eType_NetStatus:
2637  size = sizeof(pwr_tStatus);
2638  break;
2639  case pwr_eType_Int64:
2640  case pwr_eType_UInt64:
2641  size = sizeof(pwr_tInt64);
2642  break;
2643  case pwr_eType_Int32:
2644  case pwr_eType_UInt32:
2645  size = sizeof(pwr_tInt32);
2646  break;
2647  case pwr_eType_Int16:
2648  case pwr_eType_UInt16:
2649  size = sizeof(pwr_tInt16);
2650  break;
2651  case pwr_eType_Int8:
2652  case pwr_eType_UInt8:
2653  size = sizeof(pwr_tInt8);
2654  break;
2655  case pwr_eType_Char:
2656  size = sizeof(pwr_tChar);
2657  break;
2658  case pwr_eType_Float32:
2659  size = sizeof(pwr_tFloat32);
2660  break;
2661  case pwr_eType_Float64:
2662  size = sizeof(pwr_tFloat64);
2663  break;
2664  case pwr_eType_Time:
2665  size = sizeof(pwr_tTime);
2666  break;
2667  case pwr_eType_DeltaTime:
2668  size = sizeof(pwr_tDeltaTime);
2669  break;
2670  case pwr_eType_AttrRef:
2671  size = sizeof(pwr_tAttrRef);
2672  break;
2673  case pwr_eType_TypeId:
2674  size = sizeof(pwr_tTypeId);
2675  break;
2676  case pwr_eType_ClassId:
2677  size = sizeof(pwr_tClassId);
2678  break;
2679  case pwr_eType_ObjectIx:
2680  size = sizeof(pwr_tObjectIx);
2681  break;
2682  case pwr_eType_RefId:
2683  size = sizeof(pwr_tRefId);
2684  break;
2685  case pwr_eType_CastId:
2686  size = sizeof(pwr_tCastId);
2687  break;
2688  case pwr_eType_DisableAttr:
2689  size = sizeof(pwr_tDisableAttr);
2690  break;
2691  case pwr_eType_Objid:
2692  size = sizeof(pwr_tObjid);
2693  break;
2694  case pwr_eType_VolumeId:
2695  size = sizeof(pwr_tVolumeId);
2696  break;
2697  default:
2698  size = 0;
2699  }
2700  return size;
2701 }
2702 
2704 
2713 char* cdh_StringToObjectName(char* t, const char* s)
2714 {
2715  static const char valtab[] = "\
2716 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
2717 !!!!$!!!!!!!!!!!0123456789!!!!!!\
2718 !ABCDEFGHIJKLMNOPQRSTUVWXYZ!!!!_\
2719 !^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
2720 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
2721 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
2722 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
2723 ^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^!!";
2724  char* rs = t;
2725  const char* s1 = s;
2726  int len;
2727 
2728  if (t == NULL)
2729  return NULL;
2730  if (s == NULL)
2731  s = t;
2732 
2733  while (*s1) {
2734  len = str_Utf8Len((unsigned char*)s1);
2735  if(len > 1) {
2736  strncpy(t, s1, len);
2737  s1 += len;
2738  t += len;
2739  } else {
2740  if (valtab[(unsigned char)*s1] == '!') {
2741  if (s1 == s)
2742  *t++ = 'O';
2743  else
2744  *t++ = '_';
2745  s1++;
2746  } else
2747  *t++ = *s1++;
2748  }
2749  }
2750  *t = *s1; /* Copy the null byte. */
2751 
2752  return rs;
2753 }
2754 
2756 
2765 pwr_tStatus cdh_NextObjectName(char* t, const char* s)
2766 {
2767  int i;
2768  int num;
2769  int len = strlen(s);
2770  char name[80];
2771 
2772  for (i = len - 1; i >= 0; i--) {
2773  if (isdigit(s[i]) == 0)
2774  break;
2775  }
2776  if (i == len - 1)
2777  return CDH__NONAME;
2778 
2779  strncpy(name, s, i + 1);
2780  sscanf(&s[i + 1], "%d", &num);
2781  num++;
2782  if (s[i + 1] == '0')
2783  sprintf(&name[i + 1], "%0*d", len - i - 1, num);
2784  else
2785  sprintf(&name[i + 1], "%d", num);
2786 
2787  if (strlen(name) > sizeof(pwr_tObjName) - 1)
2788  return CDH__NAMELEN;
2789 
2790  strcpy(t, name);
2791  return CDH__SUCCESS;
2792 }
2793 
2795 
2803 void cdh_CutNameSegments(char* outname, char* name, int segments)
2804 {
2805  char* s[20];
2806  int i, j, last_i = 0;
2807 
2808  if (segments == 0) {
2809  strcpy(outname, "");
2810  return;
2811  }
2812 
2813  for (i = 0; i < segments; i++) {
2814  s[i] = strrchr(name, '-');
2815  if (s[i] == 0) {
2816  last_i = i;
2817  break;
2818  }
2819  *s[i] = '+';
2820  last_i = i;
2821  }
2822  for (j = 0; j <= last_i; j++) {
2823  if (s[j] != 0)
2824  *s[j] = '-';
2825  }
2826  if (s[last_i] == 0)
2827  strcpy(outname, name);
2828  else
2829  strcpy(outname, s[last_i] + 1);
2830 }
2831 
2833 
2836 pwr_tUInt32 cdh_AttrSize(pwr_sParInfo* info)
2837 {
2838  if (info->Flags & PWR_MASK_POINTER && !(info->Flags & PWR_MASK_PRIVATE))
2839  /* Return pointer size, info size contains size of pointed entity */
2840  return sizeof(pwr_tUInt64) * info->Elements;
2841 
2842  return info->Size;
2843 }
2844 
2846 
2849 pwr_tUInt32 cdh_AttrElemSize(pwr_sParInfo* info)
2850 {
2851  return cdh_AttrSize(info) / info->Elements;
2852 }
2853 
Include file for Cdh Class definition handler.
Include file for Time management.
#define cdh_cManufactClassVolMax
Largest value of volume identity for manufacturer classvolumes.
Definition: co_cdh.h:127
#define cdh_cManufactClassVolMin
Smallest value of volume identity for manufacturer classvolumes.
Definition: co_cdh.h:124
#define cdh_cSystemClassVolMin
Smallest value of volume identity for system classvolumes.
Definition: co_cdh.h:136
#define cdh_cUserClassVolMin
Smallest value of volume identity for user classvolumes.
Definition: co_cdh.h:130
#define cdh_cSystemClassVolMax
Largest value of volume identity for system classvolumes.
Definition: co_cdh.h:139
#define cdh_cUserClassVolMax
Largest value of volume identity for user classvolumes.
Definition: co_cdh.h:133
@ cdh_eId_objid
Object identity.
Definition: co_cdh.h:381
@ cdh_eId_objectIx
Object index.
Definition: co_cdh.h:380
@ cdh_eId_typeId
Type identity.
Definition: co_cdh.h:384
@ cdh_eId_volumeId
Volume identity.
Definition: co_cdh.h:383
@ cdh_eId_classId
Class identity.
Definition: co_cdh.h:382
@ cdh_eId_dlid
Direct link identity.
Definition: co_cdh.h:386
@ cdh_eId_aref
Attribute reference.
Definition: co_cdh.h:387
@ cdh_eId_subid
Subscription identity.
Definition: co_cdh.h:385
char * cdh_VolumeIdToString(char *s, int size, pwr_tVolumeId vid, int prefix, int suffix)
Converts a volume identifier, 'vid' to a string.
Definition: co_cdh.c:1402
void cdh_DlidToString(char *s, int size, pwr_tDlid did, int prefix)
Converts a direct link identifier, 'did' to a string.
Definition: co_cdh.c:1471
int cdh_ObjidIsNull(pwr_tObjid Objid)
Test if object identity is null.
Definition: co_cdh.c:111
char * cdh_ObjidToFnString(char *s, pwr_tOid oid)
Converts a object identifier, 'oid' to a filename string.
Definition: co_cdh.c:1368
pwr_tStatus cdh_StringToAref(const char *s, pwr_tAttrRef *aref)
Convert AttrRef string to id.
Definition: co_cdh.c:851
void cdh_ObjectIxToString(char *s, int size, pwr_tObjectIx oix, int prefix)
Converts a object index, 'oix' to a string.
Definition: co_cdh.c:1217
char * cdh_AttrRefToString(pwr_sAttrRef *aref, int prefix)
Converts an attribute reference , 'aref' to a string.
Definition: co_cdh.c:1267
int cdh_ObjidIsNotNull(pwr_tObjid Objid)
Test if object identity is not null.
Definition: co_cdh.c:122
char * cdh_VolumeIdToFnString(char *s, int size, pwr_tVolumeId vid)
Converts a volume identifier, 'vid' to a filename string.
Definition: co_cdh.c:1429
pwr_tStatus cdh_StringToObjid(const char *s, pwr_tObjid *oid)
Convert Objid string to id.
Definition: co_cdh.c:801
char * cdh_OpSysToDirStr(pwr_mOpSys opsys)
Convert operating system to directory string.
Definition: co_cdh.c:2442
pwr_tStatus cdh_AttrValueToString(pwr_eType Type, void *Value, char *String, int MaxSize)
Converts an attribute given in internal binary format to a text string.
Definition: co_cdh.c:366
pwr_tStatus cdh_StringToClassId(const char *s, pwr_tClassId *cid)
Convert ClassId string to id.
Definition: co_cdh.c:760
void cdh_CutNameSegments(char *outname, char *name, int segments)
Cut the leading segments of an object name.
Definition: co_cdh.c:2803
char * cdh_Low(const char *s)
Convert string to lower case.
Definition: co_cdh.c:2381
char * cdh_StringToObjectName(char *t, const char *s)
Convert string to valid object name.
Definition: co_cdh.c:2713
pwr_tStatus cdh_StringToVolumeId(const char *s, pwr_tVolumeId *vid)
Convert VolumeId string to id.
Definition: co_cdh.c:996
void cdh_SubidToString(char *s, int size, pwr_tSubid sid, int prefix)
Converts a subscription identifier, 'sid' to a string.
Definition: co_cdh.c:1451
pwr_tUInt32 cdh_AttrElemSize(pwr_sParInfo *info)
Get attribute array element size.
Definition: co_cdh.c:2849
void cdh_MaskToBinaryString(unsigned int mask, int noofbits, char *str)
Definition: co_cdh.c:735
pwr_tStatus cdh_StringToObjectIx(const char *s, pwr_tObjectIx *oix)
Converts ObjectIx string to index.
Definition: co_cdh.c:1043
void cdh_TypeIdToString(char *s, int size, pwr_tTypeId tid, int prefix)
Converts a type identifier, 'tid' to a string.
Definition: co_cdh.c:1189
void cdh_OidToString(char *s, int size, pwr_tObjid oid, int prefix)
Converts a object identifier, 'oid' to a string.
Definition: co_cdh.c:1317
void cdh_ClassIdToString(char *s, int size, pwr_tClassId cid, int prefix)
Converts a class identifier, 'cid' to a string.
Definition: co_cdh.c:1152
pwr_tClassId cdh_ClassObjidToId(pwr_tObjid Objid)
Convert Objid to ClassId.
Definition: co_cdh.c:228
pwr_tStatus cdh_NextObjectName(char *t, const char *s)
Create an similar objectname from another object name.
Definition: co_cdh.c:2765
pwr_tObjid cdh_ClassIdToObjid(pwr_tClassId Class)
Convert ClassId to Objid.
Definition: co_cdh.c:250
pwr_tTypeId cdh_TypeObjidToId(pwr_tObjid Objid)
Convert Objid to TypeId.
Definition: co_cdh.c:276
int cdh_ObjidCompare(pwr_tObjid Objid_1, pwr_tObjid Objid_2)
Compare two object identities.
Definition: co_cdh.c:68
pwr_tStatus cdh_StringToAttrValue(pwr_eType Type, const char *String, void *Value)
Definition: co_cdh.c:466
int cdh_ObjidIsEqual(pwr_tObjid Objid_1, pwr_tObjid Objid_2)
Test if two object identities are equal.
Definition: co_cdh.c:89
void cdh_ArefToString(char *s, int size, pwr_sAttrRef *aref, int prefix)
Converts an attribute reference , 'aref' to a string.
Definition: co_cdh.c:1232
int cdh_ObjidIsNotEqual(pwr_tObjid Objid_1, pwr_tObjid Objid_2)
Test if two object identities are different.
Definition: co_cdh.c:100
char * cdh_OpSysToStr(pwr_mOpSys opsys)
Convert operating system to string.
Definition: co_cdh.c:2396
pwr_sAttrRef cdh_ObjidToAref(pwr_tObjid Objid)
Converts an objid to an attrref.
Definition: co_cdh.c:355
pwr_tObjid cdh_TypeIdToObjid(pwr_tTypeId Type)
Convert TypeId to Objid.
Definition: co_cdh.c:322
pwr_tStatus cdh_StringToTypeId(const char *s, pwr_tTypeId *tid)
Convert TypeId string to id.
Definition: co_cdh.c:938
int cdh_TypeIdToIndex(pwr_tTypeId Type)
Convert TypeId to index.
Definition: co_cdh.c:311
char * cdh_NodeIdToString(char *s, pwr_tNodeId nid, int prefix, int suffix)
Converts a volume identifier, 'vid' to a string.
Definition: co_cdh.c:1291
char * cdh_ObjidToString(pwr_tObjid oid, int prefix)
Converts a object identifier, 'oid' to a string.
Definition: co_cdh.c:1341
pwr_tUInt32 cdh_AttrSize(pwr_sParInfo *info)
Get attribute size.
Definition: co_cdh.c:2836
@ time_eFormat_DateAndTime
Display date and time, 01-JAN-1970 01:00:00.00.
Definition: co_time.h:73
pwr_tStatus time_AsciiToA(const char *, pwr_tTime *)
Convert ascii time to timespec.
Definition: co_time.c:999
pwr_tStatus time_AsciiToD(const char *, pwr_tDeltaTime *)
Convert ascii to timespec.
Definition: co_time.c:928
pwr_tStatus time_DtoAscii(pwr_tDeltaTime *, int, char *, int)
Convert a delta time to ascii string.
Definition: co_time.c:819
pwr_tStatus time_AtoAscii(pwr_tTime *, time_eFormat, char *, int)
Convert timespec to ascii.
Definition: co_time.c:878
#define EVEN(a)
Check if value is even.
Definition: pwr.h:627
unsigned int pwr_tUInt32
32-bit unsigned integer type.
Definition: pwr.h:233
char pwr_tAName[399+1]
Full Aref Name type.
Definition: pwr.h:397
double pwr_tFloat64
64-bit float.
Definition: pwr.h:135
char pwr_tChar
Character type.
Definition: pwr.h:139
pwr_tNid pwr_tNodeId
Node identity type.
Definition: pwr.h:298
unsigned int pwr_tVid
Volume identity type.
Definition: pwr.h:237
pwr_tOix pwr_tObjectIx
Object index type.
Definition: pwr.h:244
pwr_tTypeId pwr_tCastId
CastId type.
Definition: pwr.h:464
#define pwr_cNDlid
Zero direct link identity constant.
Definition: pwr.h:590
pwr_tTid pwr_tTypeId
Type identity type.
Definition: pwr.h:279
unsigned int pwr_tBoolean
Boolean type.
Definition: pwr.h:127
pwr_tCid pwr_tClassId
Class identity type.
Definition: pwr.h:274
char pwr_tInt8
8-bit integer type.
Definition: pwr.h:151
pwr_tRid pwr_tSubid
Subscription identity type.
Definition: pwr.h:312
pwr_tOid pwr_tObjid
Object identity type.
Definition: pwr.h:268
short pwr_tInt16
16-bit integer type.
Definition: pwr.h:155
int pwr_tInt32
32-bit integer type.
Definition: pwr.h:159
#define pwr_cNSubid
Zero subscription identity constant.
Definition: pwr.h:589
unsigned char pwr_tUInt8
8-bit unsigned integer type.
Definition: pwr.h:225
int pwr_tStatus
Status type.
Definition: pwr.h:284
pwr_tInt32 pwr_tEnum
Enumeration type.
Definition: pwr.h:252
pwr_tVid pwr_tVolumeId
Volume identity type.
Definition: pwr.h:238
pwr_tRid pwr_tDlid
Direct link identity type.
Definition: pwr.h:311
char pwr_tOName[199+1]
Full Object Name type.
Definition: pwr.h:396
#define ODD(a)
Check if value is odd.
Definition: pwr.h:622
pwr_tRid pwr_tRefId
Reference identity type.
Definition: pwr.h:310
unsigned int pwr_tDisableAttr
DisableAttr type.
Definition: pwr.h:468
unsigned short pwr_tUInt16
16-bit unsigned integer type.
Definition: pwr.h:229
char pwr_tObjName[31+1]
Object name type.
Definition: pwr.h:377
pwr_tUInt32 pwr_tMask
Mask type.
Definition: pwr.h:248
float pwr_tFloat32
32-bit float.
Definition: pwr.h:131
unsigned int vid_3
Object index.
Definition: co_cdh.h:151
Family struct.
Definition: co_cdh.h:434
Object name struct.
Definition: co_cdh.h:427
Parse name struct.
Definition: co_cdh.h:684
Attribute reference.
Definition: pwr.h:561
pwr_tUInt32 Size
Attribute size.
Definition: pwr.h:565
pwr_tCid Body
Typeid of attribute, body or class.
Definition: pwr.h:563
pwr_tOid Objid
Object identity.
Definition: pwr.h:562
pwr_mAttrRef Flags
Attribute flags.
Definition: pwr.h:566
pwr_tUInt32 Offset
Offset in body.
Definition: pwr.h:564
Delta time type.
Definition: pwr.h:369
Object identity type.
Definition: pwr.h:263
struct cdh_mName::@4 b
Bit mask representation.
struct cdh_mParseName::@3 b
Bitmask representation.
Type for representions of object identity.
Definition: co_cdh.h:340
cdh_mClassObjid c
ClassDef object representation.
Definition: co_cdh.h:343
cdh_mObjid o
Common object representation.
Definition: co_cdh.h:342
pwr_tOid pwr
Extern representation.
Definition: co_cdh.h:341
cdh_mTypeObjid t
TypeDef object representation.
Definition: co_cdh.h:344
Pack name.
Definition: co_cdh.h:404
struct cdh_uPackName::@2 c
Name structure.
Type for representations of reference identity.
Definition: co_cdh.h:349
cdh_mRid r
Intern representation.
Definition: co_cdh.h:351
pwr_tRid pwr
Extern representation.
Definition: co_cdh.h:350
Type for representation of type identity.
Definition: co_cdh.h:356
cdh_mCid c
Class identity representation.
Definition: co_cdh.h:358
cdh_mTid t
Type identity representation.
Definition: co_cdh.h:359
pwr_tCid pwr
Extern representation.
Definition: co_cdh.h:357
Type for representation of volume identity.
Definition: co_cdh.h:364
cdh_mVid v
Intern representation.
Definition: co_cdh.h:366
pwr_tVid pwr
Extern representation.
Definition: co_cdh.h:365
struct pwr_mAttrRef::@1 b
Bitmask representation.