ProviewR Programmer's Reference Manual  V6.1.4
rt_gdh.c
Go to the documentation of this file.
1 /*
2  * ProviewR Open Source Process Control.
3  * Copyright (C) 2005-2025 SSAB EMEA AB.
4  *
5  * This file is part of ProviewR.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation, either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with ProviewR. If not, see <http://www.gnu.org/licenses/>
19  *
20  * Linking ProviewR statically or dynamically with other modules is
21  * making a combined work based on ProviewR. Thus, the terms and
22  * conditions of the GNU General Public License cover the whole
23  * combination.
24  *
25  * In addition, as a special exception, the copyright holders of
26  * ProviewR give you permission to, from the build function in the
27  * ProviewR Configurator, combine ProviewR with modules generated by the
28  * ProviewR PLC Editor to a PLC program, regardless of the license
29  * terms of these modules. You may copy and distribute the resulting
30  * combined work under the terms of your choice, provided that every
31  * copy of the combined work is accompanied by a complete copy of
32  * the source code of ProviewR (the version used to produce the
33  * combined work), being distributed under the terms of the GNU
34  * General Public License plus this exception.
35  */
36 
37 /* rt_gdh.c
38  This module contains the access routines to the Global Data
39  Handler. Those routines are callable from application level. */
40 
45 #include <stdlib.h>
46 
47 #include "co_array.h"
48 #include "co_dcli.h"
49 #include "co_string.h"
50 #include "co_time.h"
51 
52 #include "rt_gdh_msg.h"
53 #include "rt_hash_msg.h"
54 #include "rt_pwr_msg.h"
55 #include "rt_gdh.h"
56 #include "rt_dvol.h"
57 #include "rt_cmvolc.h"
58 #include "rt_cvolc.h"
59 #include "rt_ndc.h"
60 #include "rt_subc.h"
61 #include "rt_sanc.h"
62 #include "rt_dl.h"
63 #include "rt_lck.h"
64 #include "pwr_baseclasses.h"
65 
66 #if defined(OS_LINUX) || defined OS_MACOS
67 #define gdh_Lock \
68  pthread_mutex_lock(&gdbroot->thread_lock); \
69  gdb_Lock
70 #define gdh_Unlock \
71  gdb_Unlock; \
72  pthread_mutex_unlock(&gdbroot->thread_lock)
73 
74 #else
75 #define gdh_Lock gdb_Lock
76 #define gdh_Unlock gdb_Unlock
77 #endif
78 
79 #define gdh_ScopeLock \
80  gdh_Lock; \
81  do
82 #define gdh_ScopeUnlock \
83  while (0) \
84  ; \
85  gdh_Unlock
86 
87 #define touchObject(op) \
88  if (op != NULL && op->l.flags.b.isCached) \
89  cvolc_TouchObject(op)
90 
91 #define STS_M_SEVERITY 0x7
92 //#define STS_K_WARNING 0 /**< WARNING */
93 //#define STS_K_SUCCESS 1 /**< SUCCESSFUL COMPLETION */
94 #define STS_K_ERROR 2
95 #define STS_K_INFO 3
97 static void (*gdh_log_cb)(char*, void*, unsigned int) = 0;
98 
106 static void getAlarmVisibility(pwr_tStatus* status,
107  gdb_sObject* op,
108  pwr_tUInt32* avis
109  )
110 {
111  gdb_sObject* pop;
112  pwr_dStatus(sts, status, GDH__SUCCESS);
113 
114  *avis = op->l.al.b;
115  pop = op;
116  while (pop->l.por != pool_cNRef) {
117  pop = pool_Address(sts, gdbroot->pool, pop->l.por);
118  if (EVEN(*sts))
119  return;
120 
121  *avis = MAX(*avis, pop->l.al.b);
122  }
123 }
129  pwr_sAttrRef* arp,
130  char* name,
131  unsigned int size,
132  pwr_tBitMask nametype
133  )
134 {
135  pwr_tStatus sts = GDH__SUCCESS;
136  mvol_sAttribute Attribute;
137  mvol_sAttribute* ap;
138  unsigned int lsize;
139  char string[512];
140  char* s = NULL;
141  cdh_mName lnametype;
142 
143  if (arp == NULL)
144  return GDH__BADARG;
145  if (name == NULL)
146  return GDH__BADARG;
147 
148  if (arp->Flags.b.Object)
149  return gdh_ObjidToName(arp->Objid, name, size, nametype);
150 
151  memset(&Attribute, 0, sizeof(Attribute));
152 
153  if (nametype == cdh_mNName)
154  lnametype.m = cdh_mName_pathStrict;
155  else
156  lnametype.m = nametype;
157 
158  gdh_ScopeLock
159  {
160  ap = vol_ArefToAttribute(
161  &sts, &Attribute, arp, gdb_mLo_global, vol_mTrans_all);
162  if (ap == NULL)
163  break;
164 
165  touchObject(ap->op);
166  s = vol_AttributeToName(&sts, ap, lnametype.m, string);
167  }
168  gdh_ScopeUnlock;
169 
170  if (ap == NULL && lnametype.b.fallback != cdh_mName_eFallback_strict) {
171  sts = GDH__SUCCESS;
172  cdh_ArefToString(string, sizeof(string), arp, 1);
173  s = string;
174  }
175 
176  if (s != NULL) {
177  lsize = strlen(s);
178  if (lsize >= size)
179  sts = GDH__NAMEBUF;
180  strncpy(name, s, lsize + 1);
181  }
182 
183  return sts;
184 }
185 
193  pwr_sAttrRef* arp,
194  const char* aname,
195  pwr_sAttrRef* oarp
196  )
197 {
198  pwr_tStatus sts = GDH__SUCCESS;
199  mvol_sAttribute Attribute;
200  mvol_sAttribute* ap;
201  char string[512];
202  char* s = NULL;
203  cdh_sParseName parseName;
204  cdh_sParseName* pn = NULL;
205  gdb_sObject* op;
206 
207  gdh_ScopeLock
208  {
209  memset(&Attribute, 0, sizeof(Attribute));
210 
211  if (arp->Flags.b.Object) {
212  op = vol_OidToObject(
213  &sts, arp->Objid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_none);
214  if (op == NULL)
215  break;
216 
217  touchObject(op);
218  s = vol_ObjectToName(&sts, op, cdh_mName_volumeStrict, string);
219  } else {
220  ap = vol_ArefToAttribute(
221  &sts, &Attribute, arp, gdb_mLo_global, vol_mTrans_all);
222  if (ap == NULL)
223  break;
224 
225  touchObject(ap->op);
226  s = vol_AttributeToName(&sts, ap, cdh_mName_volumeStrict, string);
227  }
228  strcat(string, ".");
229  strcat(string, aname);
230 
231  pn = cdh_ParseName(&sts, &parseName, pwr_cNOid, string, 0);
232  if (pn == NULL)
233  break;
234 
235  memset(&Attribute, 0, sizeof(Attribute));
236 
237  ap = vol_NameToAttribute(
238  &sts, &Attribute, pn, gdb_mLo_global, vol_mTrans_all);
239  if (ap == NULL)
240  break;
241 
242  mvol_AttributeToAref(&sts, ap, oarp);
243  }
244  gdh_ScopeUnlock;
245 
246  return sts;
247 }
248 
258  pwr_sAttrRef* arp,
259  pwr_sAttrRef* oarp
261  )
262 {
263  pwr_tStatus sts = GDH__SUCCESS;
264  mvol_sAttribute Attribute;
265  mvol_sAttribute* ap;
266  char string[512];
267  char* s = NULL;
268  char* t;
269  cdh_sParseName parseName;
270  cdh_sParseName* pn = NULL;
271 
272  if (arp->Flags.b.Object)
273  return GDH__NOATTR;
274 
275  gdh_ScopeLock
276  {
277  memset(&Attribute, 0, sizeof(Attribute));
278 
279  ap = vol_ArefToAttribute(
280  &sts, &Attribute, arp, gdb_mLo_global, vol_mTrans_all);
281  if (ap == NULL)
282  break;
283 
284  touchObject(ap->op);
285  s = vol_AttributeToName(&sts, ap, cdh_mName_volumeStrict, string);
286 
287  t = strrchr(string, '.');
288  if (!t) {
289  sts = GDH__NOATTR;
290  break;
291  }
292  *t = 0;
293 
294  pn = cdh_ParseName(&sts, &parseName, pwr_cNOid, string, 0);
295  if (pn == NULL)
296  break;
297 
298  memset(&Attribute, 0, sizeof(Attribute));
299 
300  ap = vol_NameToAttribute(
301  &sts, &Attribute, pn, gdb_mLo_global, vol_mTrans_all);
302  if (ap == NULL)
303  break;
304 
305  mvol_AttributeToAref(&sts, ap, oarp);
306  }
307  gdh_ScopeUnlock;
308 
309  return sts;
310 }
311 
321  cid,
322  const char* name,
323  pwr_sAttrRef* arp
324  )
325 {
326  pwr_tStatus sts = GDH__SUCCESS;
327  mvol_sAttribute Attribute;
328  mvol_sAttribute* ap;
329  cdh_sParseName ParseName;
330  cdh_sParseName* pn = NULL;
331  char buff[512] = ".";
332 
333  if (arp == NULL)
334  return GDH__BADARG;
335 
336  /* If no attribute name is given, Assume whole body. */
337 
338  if (name != NULL && *name != '\0') {
339  pn = cdh_ParseName(&sts, &ParseName, pwr_cNObjid, name, 0);
340  if (pn == NULL || pn->nAttribute == 0) {
341  strcat(buff, name);
342  pn = cdh_ParseName(&sts, &ParseName, pwr_cNObjid, buff, 0);
343  }
344  if (pn == NULL)
345  return GDH__BADNAME;
346  }
347 
348  memset(&Attribute, 0, sizeof(Attribute));
349 
350  gdh_ScopeLock
351  {
352  ap = mvol_AnameToAttribute(&sts, &Attribute, cid, pn, NULL);
353  if (ap == NULL)
354  break;
355  mvol_AttributeToAref(&sts, ap, arp);
356  }
357  gdh_ScopeUnlock;
358 
359  return sts;
360 }
361 
371  cid,
372  pwr_sAttrRef* arp,
373  char* name,
374  int size
375  )
376 {
377  pwr_tStatus sts = GDH__SUCCESS;
378  mvol_sAttribute Attribute;
379  mvol_sAttribute* ap;
380 
381  if (arp == NULL)
382  return GDH__BADARG;
383  if (name == NULL)
384  return GDH__BADARG;
385 
386  memset(&Attribute, 0, sizeof(Attribute));
387 
388  gdh_ScopeLock
389  {
390  ap = mvol_ArefToAttribute(&sts, &Attribute, arp, cid);
391  }
392  gdh_ScopeUnlock;
393 
394  if (ap != NULL) {
395  if (ap->adef && ap->adef->Info.Elements > 1
396  && ap->size < ap->adef->Info.Size) {
397  char aname[256];
398 
399  sprintf(aname, "%s[%d]", ap->name, ap->idx);
400  strncpy(name, aname, size);
401  } else
402  strncpy(name, ap->name, size);
403  }
404 
405  return sts;
406 }
407 
413 pwr_tStatus gdh_ClassNameToId(const char* name,
414  pwr_tClassId* cid
415  )
416 {
417  pwr_tStatus sts = GDH__SUCCESS;
418  gdb_sClass* cp;
419 
420  if (name == NULL)
421  return GDH__BADARG;
422 
423  gdh_ScopeLock
424  {
425  cp = mvol_NameToClass(&sts, name);
426  if (cp != NULL && cid != NULL)
427  *cid = cp->cid;
428  }
429  gdh_ScopeUnlock;
430 
431  return sts;
432 }
433 
456  char* name,
457  pwr_tClassId cid,
458  unsigned int size,
460  pwr_tObjid* oid,
461  pwr_tObjid req_oid,
463  pwr_tBitMask flags,
464  pwr_tObjid
465  soid
466  )
467 {
468  pwr_tStatus sts = GDH__SUCCESS;
469  gdb_sObject* op;
470  cdh_sParseName ParseName;
471  cdh_sParseName* pn;
472 
473  if (name == NULL)
474  return GDH__BADARG;
475  if (oid == NULL)
476  return GDH__BADARG;
477 
478  pn = cdh_ParseName(&sts, &ParseName, pwr_cNObjid, name, 0);
479  if (pn == NULL)
480  return sts;
481  if (pn->flags.b.idString)
482  return GDH__NOSUCHOBJ;
483 
484  gdh_ScopeLock
485  {
486  op = dvol_CreateObject(&sts, pn, cid, size, req_oid);
487  }
488  gdh_ScopeUnlock;
489 
490  if (op != NULL)
491  *oid = op->g.oid;
492 
493  return sts;
494 }
495 
514  pwr_tObjid oid
515  )
516 {
517  pwr_tStatus sts = GDH__SUCCESS;
518 
519  if (cdh_ObjidIsNull(oid))
520  return GDH__NOSUCHOBJ;
521 
522  gdh_ScopeLock
523  {
524  dvol_DeleteObject(&sts, oid);
525  }
526  gdh_ScopeUnlock;
527 
528  return sts;
529 }
530 
549  pwr_tObjid oid
550  )
551 {
552  pwr_tStatus sts = GDH__SUCCESS;
553 
554  if (cdh_ObjidIsNull(oid))
555  return GDH__NOSUCHOBJ;
556 
557  gdh_ScopeLock
558  {
559  dvol_DeleteObjectTree(&sts, oid);
560  }
561  gdh_ScopeUnlock;
562 
563  return sts;
564 }
565 
579  pwr_sAttrRef* arp,
581  void** infop,
582  pwr_tDlid* dlid
583  )
584 {
585  pwr_tStatus sts = GDH__SUCCESS;
586  dl_sLink* dp;
587  mvol_sAttribute Attribute;
588  mvol_sAttribute* ap;
589  void* p;
590 
591  if (arp == NULL)
592  return GDH__BADARG;
593 
594  memset(&Attribute, 0, sizeof(Attribute));
595 
596  gdh_ScopeLock
597  {
598  ap = vol_ArefToAttribute(
599  &sts, &Attribute, arp, gdb_mLo_native, vol_mTrans_all);
600  if (ap == NULL)
601  break;
602 
603  if (ap->op->u.n.lflags.b.readOnly) {
604  sts = GDH__READONLY;
605  break;
606  }
607 
608  p = vol_AttributeToAddress(&sts, ap);
609  if (p == NULL)
610  break;
611 
612  dp = dl_Create(&sts, ap, arp);
613  if (dp == NULL)
614  break;
615 
616  if (infop != NULL)
617  *infop = p;
618  if (dlid != NULL)
619  *dlid = dp->dlid;
620  }
621  gdh_ScopeUnlock;
622 
623  return sts;
624 }
625 
638  pwr_tDlid dlid
639  )
640 {
641  pwr_tStatus sts = GDH__SUCCESS;
642 
643  gdh_ScopeLock
644  {
645  dl_Cancel(&sts, dlid);
646  }
647  gdh_ScopeUnlock;
648 
649  return sts;
650 }
651 
657 {
658  gdh_ScopeLock
659  {
660  dl_CancelUser(gdbroot->my_pid);
661  }
662  gdh_ScopeUnlock;
663 }
664 
671  pwr_tUInt32* a,
672  pwr_tUInt32*
673  maxa,
675  pwr_tUInt32*
676  b,
677  pwr_tUInt32*
678  maxb,
680  pwr_tUInt32* alarmvisibility
681  )
682 {
683  pwr_tStatus sts = GDH__SUCCESS;
684  gdb_sObject* op;
685 
686  gdh_ScopeLock
687  {
688  op = vol_OidToObject(
689  &sts, oid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_none);
690  if (op == NULL)
691  break;
692 
693  touchObject(op);
694 
695  if (!op->l.flags.b.isNative)
696  sanc_Subscribe(NULL, op);
697 
698  if (a != NULL)
699  *a = op->l.al.a;
700 
701  if (maxa != NULL) {
702  *maxa = op->l.al.maxa;
703  if (op->l.flags.b.isNative)
704  *maxa = MAX(*maxa, op->u.n.ral.maxa);
705  }
706 
707  if (b != NULL)
708  *b = op->l.al.b;
709 
710  if (maxb != NULL) {
711  *maxb = op->l.al.maxb;
712  if (op->l.flags.b.isNative)
713  *maxb = MAX(*maxb, op->u.n.ral.maxb);
714  }
715 
716  if (alarmvisibility != NULL) {
717  getAlarmVisibility(&sts, op, alarmvisibility);
718  }
719  }
720  gdh_ScopeUnlock;
721 
722  return sts;
723 }
724 
730  pwr_tNodeId* nid
731  )
732 {
733  if (nid == NULL)
734  return GDH__BADARG;
735 
736  gdh_ScopeLock
737  {
738  *nid = gdbroot->my_node->nid;
739  }
740  gdh_ScopeUnlock;
741 
742  return GDH__SUCCESS;
743 }
744 
751  pwr_tNodeId* nid
752  )
753 {
754  pwr_tStatus sts = GDH__SUCCESS;
755  gdb_sObject* op;
756  gdb_sVolume* vp;
757 
758  if (nid == NULL)
759  return GDH__BADARG;
760 
761  gdh_ScopeLock
762  {
763  op = vol_OidToObject(
764  &sts, oid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_none);
765  if (op == NULL)
766  break;
767 
768  touchObject(op);
769 
770  vp = pool_Address(NULL, gdbroot->pool, op->l.vr);
771  *nid = vp->g.nid;
772  }
773  gdh_ScopeUnlock;
774 
775  return sts;
776  ;
777 }
778 
790  const char* name,
791  pwr_tAddress bufp,
793  pwr_tUInt32 bufsize
794  )
795 {
796  pwr_tStatus sts = GDH__SUCCESS;
797  cdh_sParseName parseName;
798  cdh_sParseName* pn;
799  gdb_sVolume* vp;
800  gdb_sNode* np = NULL;
801  mvol_sAttribute attribute;
802  mvol_sAttribute* ap;
803  void* p;
804  pwr_sAttrRef aref;
805  pwr_sAttrRef* arp = NULL;
806  pwr_sAttrRef raref;
807  pwr_sAttrRef* rarp = NULL;
808  gdb_sCclass* ccp = NULL;
809  gdb_sCclass* ccpLocked = NULL;
810  pwr_tBoolean equal = 0;
811  pwr_tBoolean fetched;
812  pwr_tUInt32 ridx = UINT_MAX;
813 
814  if (name == NULL)
815  return GDH__BADARG;
816 
817  pn = cdh_ParseName(&sts, &parseName, pwr_cNObjid, name, 0);
818  if (pn == NULL)
819  return sts;
820 
821  memset(&attribute, 0, sizeof(attribute));
822 
823  gdh_Lock;
824 
825  do {
826  ap = vol_NameToAttribute(
827  &sts, &attribute, pn, gdb_mLo_global, vol_mTrans_all);
828  if (ap == NULL)
829  break;
830  if (ap->op == NULL)
831  break;
832 
833  touchObject(ap->op);
834 
835  p = vol_AttributeToAddress(&sts, ap);
836  if (p != NULL) {
837  memcpy(bufp, p, MIN(ap->size, bufsize));
838  break;
839  } else if (ap->op->l.flags.m & gdb_mLo_native) {
840  break;
841  }
842 
843  /* Try remote. */
844 
845  arp = mvol_AttributeToAref(&sts, ap, &aref);
846  if (arp == NULL)
847  break;
848 
849  vp = pool_Address(NULL, gdbroot->pool, ap->op->l.vr);
850  np = hash_Search(&sts, gdbroot->nid_ht, &vp->g.nid);
851  if (np == NULL)
852  break;
853 
854  ccp = NULL;
855  /* Get cached class if needed */
856  if (!ap->op->u.c.flags.b.classChecked || !ap->op->u.c.flags.b.classEqual) {
857  ccp = cmvolc_GetCachedClass(&sts, np, vp, ap, &equal, &fetched, NULL);
858  if (EVEN(sts)) {
859  np = NULL;
860  break;
861  }
862  if (equal)
863  ccp = NULL;
864 
865  if (ccpLocked == NULL && ccp != NULL && !equal) {
866  cmvolc_LockClass(NULL, ccp);
867  ccpLocked = ccp;
868  }
869 
870  /* If gdb has been unlocked, refresh pointers */
872  if (fetched) {
873  memset(&attribute, 0, sizeof(attribute));
874  np = NULL;
875  continue;
876  }
877 
878  if (equal)
879  break;
880 
881  rarp = ndc_NarefToRaref(
882  &sts, ap, arp, ccp, &ridx, &raref, &equal, pn, ccpLocked, vp, np);
883  }
884  break;
885  } while (1);
886 
887  gdh_Unlock;
888 
889  if (np != NULL && ODD(sts)) {
890  if (equal)
891  cvolc_GetObjectInfo(
892  &sts, np, arp, NULL, NULL, UINT_MAX, ap, bufp, bufsize);
893  else
894  cvolc_GetObjectInfo(&sts, np, arp, ccp, rarp, ridx, ap, bufp, bufsize);
895  }
896 
897  if (ccpLocked) {
898  gdb_Lock;
899  cmvolc_UnlockClass(NULL, ccpLocked);
900  gdb_Unlock;
901  }
902 
903  return sts;
904 }
905 
917  pwr_sAttrRef* arp,
919  void* bufp,
920  unsigned int bufsize
921  )
922 {
923  pwr_tStatus sts = GDH__SUCCESS;
924  gdb_sVolume* vp;
925  gdb_sNode* np = NULL;
926  mvol_sAttribute attribute;
927  mvol_sAttribute* ap;
928  void* p;
929  gdb_sCclass* ccp = NULL;
930  gdb_sCclass* ccpLocked = NULL;
931  pwr_sAttrRef raref;
932  pwr_sAttrRef* rarp = NULL;
933  pwr_tBoolean equal = 0;
934  pwr_tBoolean fetched;
935  pwr_tUInt32 ridx = UINT_MAX;
936 
937  memset(&attribute, 0, sizeof(attribute));
938 
939  gdh_Lock;
940 
941  do {
942  ap = vol_ArefToAttribute(
943  &sts, &attribute, arp, gdb_mLo_global, vol_mTrans_all);
944  if (ap == NULL || ap->op == NULL)
945  break;
946 
947  touchObject(ap->op);
948 
949  p = vol_AttributeToAddress(&sts, ap);
950  if (p != NULL) {
951  memcpy(bufp, p, MIN(ap->size, bufsize));
952  break;
953  } else if ((ap->op->l.flags.m & gdb_mLo_native) != 0) {
954  break;
955  }
956 
957  /* Try remote. */
958 
959  vp = pool_Address(NULL, gdbroot->pool, ap->op->l.vr);
960  np = hash_Search(&sts, gdbroot->nid_ht, &vp->g.nid);
961 
962  if (np == NULL)
963  break;
964 
965  ccp = NULL;
966  /* Get cached class if needed */
967  if (!ap->op->u.c.flags.b.classChecked || !ap->op->u.c.flags.b.classEqual) {
968  ccp = cmvolc_GetCachedClass(&sts, np, vp, ap, &equal, &fetched, NULL);
969  if (EVEN(sts)) {
970  np = NULL;
971  break;
972  }
973  if (equal)
974  ccp = NULL;
975 
976  if (ccpLocked == NULL && ccp != NULL && !equal) {
977  cmvolc_LockClass(NULL, ccp);
978  ccpLocked = ccp;
979  }
980 
981  /* If gdb has been unlocked, refresh pointers */
982  if (fetched) {
983  memset(&attribute, 0, sizeof(attribute));
984  np = NULL;
985  continue;
986  }
987 
988  if (equal)
989  break;
990 
991  rarp = ndc_NarefToRaref(
992  &sts, ap, arp, ccp, &ridx, &raref, &equal, NULL, ccpLocked, vp, np);
993  }
994 
995  break;
996  } while (1);
997 
998  gdh_Unlock;
999 
1000  if (np != NULL && ODD(sts)) {
1001  if (equal)
1002  cvolc_GetObjectInfo(
1003  &sts, np, arp, NULL, NULL, UINT_MAX, ap, bufp, bufsize);
1004  else
1005  cvolc_GetObjectInfo(&sts, np, arp, ccp, rarp, ridx, ap, bufp, bufsize);
1006  }
1007 
1008  if (ccpLocked) {
1009  gdb_Lock;
1010  cmvolc_UnlockClass(NULL, ccpLocked);
1011  gdb_Unlock;
1012  }
1013 
1014  return sts;
1015 }
1016 
1026  pwr_tUInt32* size
1027  )
1028 {
1029  pwr_tStatus sts = GDH__SUCCESS;
1030  gdb_sObject* op;
1031 
1032  if (size == NULL)
1033  return GDH__BADARG;
1034 
1035  gdh_ScopeLock
1036  {
1037  op = vol_OidToObject(
1038  &sts, oid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_none);
1039  if (op != NULL) {
1040  touchObject(op);
1041  *size = op->g.size;
1042  }
1043  }
1044  gdh_ScopeUnlock;
1045 
1046  return sts;
1047 }
1048 
1056  char* name,
1057  pwr_tUInt32* size
1058  )
1059 {
1060  pwr_tStatus sts = GDH__SUCCESS;
1061  gdb_sObject* op;
1062  mvol_sAttribute Attribute;
1063  mvol_sAttribute* ap;
1064  cdh_sParseName ParseName;
1065  cdh_sParseName* pn = NULL;
1066 
1067  if (size == NULL)
1068  return GDH__BADARG;
1069 
1070  if (name != NULL && *name != '\0') {
1071  pn = cdh_ParseName(&sts, &ParseName, pwr_cNObjid, name, 0);
1072  if (pn == NULL)
1073  return GDH__BADNAME;
1074  } else
1075  return GDH__BADNAME;
1076 
1077  memset(&Attribute, 0, sizeof(Attribute));
1078 
1079  gdh_ScopeLock
1080  {
1081  op = vol_OidToObject(
1082  &sts, oid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_none);
1083  if (op != NULL) {
1084  touchObject(op);
1085  *size = op->g.size;
1086  }
1087 
1088  ap = mvol_AnameToAttribute(&sts, &Attribute, op->g.cid, pn, NULL);
1089  if (ap == NULL)
1090  break;
1091  }
1092  gdh_ScopeUnlock;
1093  if (ap == 0)
1094  sts = GDH__ATTRIBUTE;
1095 
1096  *size -= ap->offs;
1097  return sts;
1098 }
1099 
1108  pwr_tObjid oid,
1109  pwr_tClassId* cid
1110  )
1111 {
1112  pwr_tStatus sts = GDH__SUCCESS;
1113  gdb_sObject* op;
1114  gdb_sClass* cp;
1115  pwr_tStatus lsts;
1116 
1117  if (cid == NULL)
1118  return GDH__BADARG;
1119 
1120  gdh_ScopeLock
1121  {
1122  op = vol_OidToObject(
1123  &sts, oid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_none);
1124  if (op != NULL) {
1125  touchObject(op);
1126  *cid = op->g.cid;
1127 
1128  if (op->l.flags.b.isCached) {
1129  cp = hash_Search(&lsts, gdbroot->cid_ht, cid);
1130  if (cp == NULL) {
1131  cmvolc_GetNonExistingClass(&lsts, op, *cid);
1132  }
1133  }
1134  }
1135  }
1136  gdh_ScopeUnlock;
1137 
1138  return sts;
1139 }
1140 
1146  pwr_sAttrRef* arp,
1147  pwr_tTid* tid
1148  )
1149 {
1150  pwr_tStatus sts = GDH__SUCCESS;
1151  mvol_sAttribute* ap;
1152  mvol_sAttribute attribute;
1153  gdb_sClass* cp;
1154 
1155  if (arp->Flags.b.Object && arp->Body) {
1156  *tid = arp->Body & ~7;
1157  return GDH__SUCCESS;
1158  }
1159  if ((arp->Body == 0 && arp->Offset == 0)
1160  || (arp->Offset == 0 && arp->Size == 0))
1161  return gdh_GetObjectClass(arp->Objid, tid);
1162 
1163  gdh_ScopeLock
1164  {
1165  memset(&attribute, 0, sizeof(attribute));
1166 
1167  ap = vol_ArefToAttribute(
1168  &sts, &attribute, arp, gdb_mLo_global, vol_mTrans_all);
1169  if (ap != NULL)
1170  touchObject(ap->op);
1171  }
1172  gdh_ScopeUnlock;
1173 
1174  if (ap != 0 && ap->adef != 0) {
1175  if (ap->adef->Info.Flags & PWR_MASK_CASTATTR) {
1176  pwr_tCastId castid;
1177  pwr_sAttrRef cast_aref = cdh_ArefToCastAref(arp);
1178 
1179  sts = gdh_GetObjectInfoAttrref(&cast_aref, &castid, sizeof(castid));
1180  if (ODD(sts) && castid != pwr_cNCastId) {
1181  *tid = castid;
1182  } else {
1183  *tid = ap->adef->TypeRef;
1184  }
1185  } else {
1186  *tid = ap->adef->TypeRef;
1187  }
1188 
1189  if (cdh_tidIsCid(*tid) && !(ap->op->l.flags.m & gdb_mLo_native)) {
1190  gdh_ScopeLock
1191  {
1192  cp = hash_Search(&sts, gdbroot->cid_ht, tid);
1193  if (cp == NULL) {
1194  cmvolc_GetNonExistingClass(&sts, ap->op, *tid);
1195  cp = hash_Search(&sts, gdbroot->cid_ht, tid);
1196  if (cp == NULL) {
1197  sts = GDH__NOSUCHCLASS;
1198  }
1199  }
1200  }
1201  gdh_ScopeUnlock;
1202  }
1203  } else if (ap != 0 && ap->adef == 0 && ODD(sts)) {
1204  *tid = ap->cp->cid;
1205  }
1206  return sts;
1207 }
1208 
1220  pwr_tObjid oid,
1221  pwr_tBoolean* location
1223  )
1224 {
1225  pwr_tStatus sts = GDH__SUCCESS;
1226  gdb_sObject* op;
1227 
1228  if (location == NULL)
1229  return GDH__BADARG;
1230 
1231  gdh_ScopeLock
1232  {
1233  op = vol_OidToObject(
1234  &sts, oid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_none);
1235  if (op != NULL) {
1236  touchObject(op);
1237  *location = (op->l.flags.m & gdb_mLo_native) != 0;
1238  }
1239  }
1240  gdh_ScopeUnlock;
1241 
1242  return sts;
1243 }
1244 
1252  pwr_tUInt32* count
1254  )
1255 {
1256  pwr_tStatus sts = GDH__SUCCESS;
1257  gdb_sObject* op;
1258 
1259  if (count == NULL)
1260  return GDH__BADARG;
1261 
1262  gdh_ScopeLock
1263  {
1264  op = vol_OidToObject(
1265  &sts, oid, gdb_mLo_native, vol_mTrans_all, cvol_eHint_none);
1266  if (op != NULL) {
1267  *count = op->u.n.dlcount;
1268  }
1269  }
1270  gdh_ScopeUnlock;
1271 
1272  return sts;
1273 }
1274 
1282  pwr_tObjid* new_oid
1283  )
1284 {
1285  pwr_tStatus sts = GDH__SUCCESS;
1286  gdb_sObject* op;
1287 
1288  if (new_oid == NULL)
1289  return GDH__BADARG;
1290 
1291  gdh_ScopeLock
1292  {
1293  op = vol_OidToObject(
1294  &sts, oid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_none);
1295  if (op != NULL) {
1296  touchObject(op);
1297  if (op->g.f.poid.oix == pwr_cNObjectIx) {
1298  *new_oid = pwr_cNObjid;
1299  sts = GDH__NO_PARENT;
1300  } else {
1301  *new_oid = op->g.f.poid;
1302  }
1303  }
1304  }
1305  gdh_ScopeUnlock;
1306 
1307  return sts;
1308 }
1309 
1321  pwr_tObjid oid,
1322  pwr_tObjid* new_oid
1323  )
1324 {
1325  pwr_tStatus sts = GDH__SUCCESS;
1326  gdb_sObject* op;
1327 
1328  if (new_oid == NULL)
1329  return GDH__BADARG;
1330 
1331  gdh_ScopeLock
1332  {
1333  op = vol_OidToObject(
1334  &sts, oid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_none);
1335  if (op != NULL) {
1336  touchObject(op);
1337  if (op->g.f.poid.oix == pwr_cNObjectIx) {
1338  *new_oid = pwr_cNObjid;
1339  sts = GDH__NO_PARENT;
1340  } else {
1341  *new_oid = op->g.f.poid;
1342  }
1343  }
1344  }
1345  gdh_ScopeUnlock;
1346 
1347  return sts;
1348 }
1349 
1359  pwr_tSubid sid,
1360  pwr_tBoolean* old,
1362  pwr_tTime* lastupdate,
1365  pwr_tStatus* status
1366  )
1367 {
1368  pwr_tStatus sts = GDH__SUCCESS;
1369  sub_sClient* cp;
1370  cdh_uRefId rid;
1371  void* p;
1372 
1373  rid.pwr = sid;
1374 
1375  gdh_ScopeLock
1376  {
1377  p = hash_Search(&sts, gdbroot->subc_ht, &sid);
1378  if (p == NULL)
1379  break;
1380 
1381  if (rid.r.vid_3 == cdh_eVid3_subid) {
1382  cp = (sub_sClient*)p;
1383 
1384  if (old != NULL)
1385  *old = cp->old;
1386  if (lastupdate != NULL)
1387  memcpy(lastupdate, &cp->lastupdate, sizeof(cp->lastupdate));
1388  if (status != NULL)
1389  *status = cp->sts;
1390  } else if (rid.r.vid_3 == cdh_eVid3_dlid) {
1391  if (old != NULL)
1392  *old = FALSE;
1393  if (lastupdate != NULL)
1394  time_GetTime(lastupdate);
1395  if (status != NULL)
1396  *status = GDH__SUCCESS;
1397  } else {
1398  sts = GDH__WEIRD;
1399  }
1400  }
1401  gdh_ScopeUnlock;
1402 
1403  return sts;
1404 }
1405 
1431  pwr_tObjid* new_oid
1432  )
1433 {
1434  pwr_tStatus sts = GDH__SUCCESS;
1435  gdb_sObject* op;
1436 
1437  if (new_oid == NULL)
1438  return GDH__BADARG;
1439 
1440  gdh_ScopeLock
1441  {
1442  op = vol_OidToObject(
1443  &sts, oid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_child);
1444  if (op != NULL) {
1445  touchObject(op);
1446  if (op->g.flags.b.isParent) {
1447  *new_oid = op->g.soid;
1448  } else {
1449  sts = GDH__NO_CHILD;
1450  }
1451  }
1452  }
1453  gdh_ScopeUnlock;
1454 
1455  return sts;
1456 }
1457 
1466  pwr_tObjid* new_oid
1467  )
1468 {
1469  pwr_tStatus sts = GDH__SUCCESS;
1470  gdb_sObject* op;
1471  gdb_sObject* pop = NULL;
1472  pwr_tObjid noid;
1473 
1474  if (new_oid == NULL)
1475  return GDH__BADARG;
1476 
1477  gdh_ScopeLock
1478  {
1479  op = vol_OidToObject(
1480  &sts, oid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_next);
1481  if (op != NULL) {
1482  touchObject(op);
1483  noid.vid = op->g.oid.vid;
1484  noid.oix = op->g.sib.flink;
1485  pop = pool_Address(NULL, gdbroot->pool, op->l.por);
1486  }
1487  }
1488  gdh_ScopeUnlock;
1489 
1490  if (op == NULL)
1491  return sts;
1492 
1493  if (pop == NULL || noid.oix == pop->g.soid.oix) {
1494  sts = GDH__NO_SIBLING;
1495  } else {
1496  *new_oid = noid;
1497  }
1498 
1499  return sts;
1500 }
1501 
1510  pwr_tObjid*
1511  new_oid
1512  )
1513 {
1514  pwr_tStatus sts = GDH__SUCCESS;
1515  gdb_sObject* op;
1516  gdb_sObject* pop = NULL;
1517  pwr_tObjid noid = {0, 0};
1518 
1519  if (new_oid == NULL)
1520  return GDH__BADARG;
1521 
1522  gdh_ScopeLock
1523  {
1524  op = vol_OidToObject(
1525  &sts, oid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_prev);
1526  if (op != NULL) {
1527  touchObject(op);
1528  noid.vid = op->g.oid.vid;
1529  noid.oix = op->g.sib.blink;
1530  pop = pool_Address(NULL, gdbroot->pool, op->l.por);
1531  }
1532  }
1533  gdh_ScopeUnlock;
1534 
1535  if (op == NULL)
1536  return sts;
1537 
1538  if (pop == NULL || oid.oix == pop->g.soid.oix) {
1539  sts = GDH__NO_SIBLING;
1540  } else {
1541  *new_oid = noid;
1542  }
1543 
1544  return sts;
1545 }
1546 
1572  oid
1573  )
1574 {
1575  pwr_tStatus sts = GDH__SUCCESS;
1576  gdb_sObject* op;
1577 
1578  /* Check arguments. */
1579  if (oid == NULL)
1580  return GDH__BADARG;
1581 
1582  gdh_ScopeLock
1583  {
1584  /* Get the first child of the rootvolume. */
1585 
1586  op = hash_Search(&sts, gdbroot->oid_ht, &gdbroot->my_volume->g.oid);
1587  if (op != NULL) {
1588  if (op->g.flags.b.isParent) {
1589  *oid = op->g.soid;
1590  } else {
1591  sts = GDH__NOSUCHOBJ;
1592  }
1593  }
1594  }
1595  gdh_ScopeUnlock;
1596 
1597  return sts;
1598 }
1599 
1628  pwr_tObjid* oid
1629  )
1630 {
1631  pwr_tStatus sts = GDH__SUCCESS;
1632  gdb_sObject* op = NULL;
1633 
1634  gdh_ScopeLock
1635  {
1636  op = mvol_ClassList(&sts, cid, pwr_cNObjid, mvol_eList_first);
1637  if (op != NULL) {
1638  *oid = op->g.oid;
1639  }
1640  }
1641  gdh_ScopeUnlock;
1642 
1643  return sts;
1644 }
1645 
1660  pwr_tObjid* new_oid
1661  )
1662 {
1663  pwr_tStatus sts = GDH__SUCCESS;
1664  gdb_sObject* op;
1665 
1666  /* Check arguments. */
1667  if (new_oid == NULL)
1668  return GDH__BADARG;
1669 
1670  gdh_ScopeLock
1671  {
1672  op = mvol_ClassList(&sts, pwr_cNClassId, oid, mvol_eList_next);
1673  if (op != NULL) {
1674  *new_oid = op->g.oid;
1675  }
1676  }
1677  gdh_ScopeUnlock;
1678 
1679  return sts;
1680 }
1681 
1713  pwr_tClassId cid,
1714  pwr_sAttrRef* arp
1715  )
1716 {
1717  pwr_tStatus sts = GDH__SUCCESS;
1718 
1719  gdh_ScopeLock
1720  {
1721  mvol_ClassListAttrRef(&sts, cid, NULL, arp, mvol_eList_first);
1722  }
1723  gdh_ScopeUnlock;
1724 
1725  return sts;
1726 }
1727 
1743  pwr_sAttrRef* arp,
1744  pwr_sAttrRef* new_arp
1745  )
1746 {
1747  pwr_tStatus sts = GDH__SUCCESS;
1748 
1749  /* Check arguments. */
1750  if (new_arp == NULL)
1751  return GDH__BADARG;
1752 
1753  gdh_ScopeLock
1754  {
1755  mvol_ClassListAttrRef(&sts, cid, arp, new_arp, mvol_eList_next);
1756  }
1757  gdh_ScopeUnlock;
1758 
1759  return sts;
1760 }
1761 
1769  pwr_tOid oid,
1770  pwr_sAttrRef* arp
1771  )
1772 {
1773  pwr_tStatus sts = GDH__SUCCESS;
1774  pwr_sAttrRef ar;
1775 
1776  gdh_ScopeLock
1777  {
1778  ar.Objid = oid;
1779  mvol_ClassListAttrRef(&sts, cid, &ar, arp, mvol_eList_objectfirst);
1780  }
1781  gdh_ScopeUnlock;
1782 
1783  return sts;
1784 }
1785 
1793  pwr_tClassId cid,
1794  pwr_sAttrRef* arp,
1795  pwr_sAttrRef* new_arp
1796  )
1797 {
1798  pwr_tStatus sts = GDH__SUCCESS;
1799 
1800  /* Check arguments. */
1801  if (new_arp == NULL)
1802  return GDH__BADARG;
1803 
1804  gdh_ScopeLock
1805  {
1806  mvol_ClassListAttrRef(&sts, cid, arp, new_arp, mvol_eList_objectnext);
1807  }
1808  gdh_ScopeUnlock;
1809 
1810  return sts;
1811 }
1812 
1823  pwr_tObjid* oid
1824  )
1825 {
1826  pwr_tStatus sts = GDH__SUCCESS;
1827  gdb_sNode* np;
1828 
1829  if (oid == NULL)
1830  return GDH__BADARG;
1831 
1832  gdh_ScopeLock
1833  {
1834  if (nid == pwr_cNNodeId) {
1835  *oid = gdbroot->db->nod_oid;
1836  } else {
1837  np = hash_Search(&sts, gdbroot->nid_ht, &nid);
1838  if (np != NULL) {
1839  *oid = np->nod_oid;
1840  }
1841  }
1842  }
1843  gdh_ScopeUnlock;
1844 
1845  return sts;
1846 }
1847 
1855  gdh_sNodeInfo* ip
1856  )
1857 {
1858  pwr_tStatus sts = GDH__SUCCESS;
1859  gdb_sNode* np;
1860 
1861  if (ip == NULL)
1862  return GDH__BADARG;
1863 
1864  gdh_ScopeLock
1865  {
1866  np = hash_Search(&sts, gdbroot->nid_ht, &nid);
1867  if (np != NULL) {
1868  ip->nodidx = np->nid;
1869  ip->nix = np->vol_oid.vid;
1870  strcpy(ip->nodename, np->name);
1871  ip->objid = np->nod_oid;
1872  ip->linkstate = 0;
1873  ip->upcnt = np->upcnt;
1874  ip->timeup = np->timeup;
1875  ip->timedown = np->timedown;
1876  }
1877  }
1878  gdh_ScopeUnlock;
1879 
1880  return sts;
1881 }
1882 
1893  char* name,
1896  pwr_tTypeId* tid,
1898  pwr_tUInt32* size,
1900  pwr_tUInt32* offs,
1902  pwr_tUInt32* elem
1904  )
1905 {
1906  pwr_tStatus sts = GDH__SUCCESS;
1907  cdh_sParseName parseName;
1908  cdh_sParseName* pn;
1909  mvol_sAttribute attribute;
1910  mvol_sAttribute* ap;
1911 
1912  pn = cdh_ParseName(&sts, &parseName, pwr_cNObjid, name, 0);
1913  if (pn == NULL)
1914  return sts;
1915 
1916  memset(&attribute, 0, sizeof(attribute));
1917 
1918  gdh_ScopeLock
1919  {
1920  ap = vol_NameToAttribute(
1921  &sts, &attribute, pn, gdb_mLo_global, vol_mTrans_all);
1922  if (ap != NULL)
1923  touchObject(ap->op);
1924  }
1925  gdh_ScopeUnlock;
1926 
1927  if (ap != NULL) {
1928  if (size != NULL)
1929  *size = ap->size;
1930  if (offs != NULL)
1931  *offs = ap->offs;
1932  if (tid != NULL)
1933  *tid = ap->tid;
1934  if (elem != NULL)
1935  *elem = ap->elem;
1936  }
1937 
1938  return sts;
1939 }
1940 
1950  pwr_sAttrRef*
1951  arp,
1952  pwr_tTypeId* tid,
1953  unsigned int* size,
1954  unsigned int* offs,
1956  unsigned int* elem
1957  )
1958 {
1959  pwr_tStatus sts = GDH__SUCCESS;
1960  mvol_sAttribute attribute;
1961  mvol_sAttribute* ap;
1962 
1963  memset(&attribute, 0, sizeof(attribute));
1964 
1965  gdh_ScopeLock
1966  {
1967  ap = vol_ArefToAttribute(
1968  &sts, &attribute, arp, gdb_mLo_global, vol_mTrans_all);
1969  if (ap != NULL)
1970  touchObject(ap->op);
1971  }
1972  gdh_ScopeUnlock;
1973 
1974  if (ap != NULL) {
1975  if (size != NULL)
1976  *size = ap->size;
1977  if (offs != NULL)
1978  *offs = ap->offs;
1979  if (tid != NULL)
1980  *tid = ap->tid;
1981  if (elem != NULL)
1982  *elem = ap->elem;
1983  }
1984 
1985  return sts;
1986 }
1987 
1995  pwr_sAttrRef* arp,
1996  unsigned int* flags
1997  )
1998 {
1999  pwr_tStatus sts = GDH__SUCCESS;
2000  mvol_sAttribute attribute;
2001  mvol_sAttribute* ap;
2002 
2003  memset(&attribute, 0, sizeof(attribute));
2004 
2005  gdh_ScopeLock
2006  {
2007  ap = vol_ArefToAttribute(
2008  &sts, &attribute, arp, gdb_mLo_global, vol_mTrans_all);
2009  if (ap != NULL)
2010  touchObject(ap->op);
2011  }
2012  gdh_ScopeUnlock;
2013 
2014  if (ap != NULL)
2015  *flags = ap->adef->Info.Flags;
2016 
2017  return sts;
2018 }
2019 
2032  pwr_tObjid* new_oid
2033  )
2034 {
2035  pwr_tStatus sts = GDH__SUCCESS;
2036  gdb_sObject* op;
2037 
2038  if (new_oid == NULL)
2039  return GDH__BADARG;
2040 
2041  gdh_ScopeLock
2042  {
2043  op = mvol_ClassList(&sts, pwr_cNClassId, oid, mvol_eList_prev);
2044  if (op != NULL) {
2045  *new_oid = op->g.oid;
2046  }
2047  }
2048  gdh_ScopeUnlock;
2049 
2050  return sts;
2051 }
2052 
2065 pwr_tStatus gdh_Init(const char* name
2066  )
2067 {
2068  pwr_tStatus sts = GDH__SUCCESS;
2069 
2070  /* Map the database. */
2071 
2072  gdbroot = gdb_MapDb(&sts, NULL, name);
2073 
2074  return sts;
2075 }
2076 
2077 /*
2078  * Fetch the meta data of an attribute, given its attrref or its name.
2079  *
2080  * If meta data is wanted for a class use the class parameter.
2081  * The output arguments can be NULL if they are not wanted.
2082  */
2083 pwr_tStatus gdh_MDAttribute(
2084  pwr_tClassId cid, /* Class. Use pwr_cNClassId if meta
2085  data for an object and not for
2086  a class is wanted. */
2087  pwr_sAttrRef* arp, /* Use NULL if attrname should be used
2088  instead of the attribute reference. */
2089  char* aname, /* String containing
2090  object.attribute or
2091  object.attribute[index]
2092  If class data then name of attribute
2093  must start with a dot. */
2094  pwr_tTypeId* tid, /* Address of an type id where the
2095  attribute type will be stored
2096  or NULL if not wanted */
2097  unsigned int* size, /* Address of an integer where the
2098  attribute size will be stored
2099  or NULL if not wanted. */
2100  unsigned int* offs, /* Address of an integer where the
2101  attribute offset will be stored
2102  or NULL if not wanted. */
2103  unsigned int* elem /* Address of an integer where the
2104  number of elements will be stored
2105  or NULL if not wanted. */
2106  )
2107 {
2108  pwr_tStatus sts = GDH__SUCCESS;
2109  cdh_sParseName parseName;
2110  cdh_sParseName* pn = NULL;
2111  mvol_sAttribute attribute;
2112  mvol_sAttribute* ap = NULL;
2113 
2114  if (arp == NULL) {
2115  pn = cdh_ParseName(&sts, &parseName, pwr_cNObjid, aname, 0);
2116  if (pn == NULL)
2117  return sts;
2118  }
2119 
2120  memset(&attribute, 0, sizeof(attribute));
2121 
2122  gdh_ScopeLock
2123  {
2124  if (arp != NULL) {
2125  ap = vol_ArefToAttribute(
2126  &sts, &attribute, arp, gdb_mLo_global, vol_mTrans_all);
2127  } else if (cid != pwr_cNClassId) {
2128  ap = mvol_AnameToAttribute(&sts, ap, cid, pn, NULL);
2129  } else {
2130  ap = vol_NameToAttribute(&sts, ap, pn, gdb_mLo_global, vol_mTrans_all);
2131  }
2132 
2133  if (ap != NULL)
2134  touchObject(ap->op);
2135  }
2136  gdh_ScopeUnlock;
2137 
2138  if (ap != NULL) {
2139  if (size != NULL)
2140  *size = ap->size;
2141  if (offs != NULL)
2142  *offs = ap->offs;
2143  if (tid != NULL)
2144  *tid = ap->tid;
2145  if (elem != NULL)
2146  *elem = ap->elem;
2147  }
2148 
2149  return sts;
2150 }
2151 
2163  pwr_tObjid oid,
2164  pwr_tObjid poid
2165  )
2166 {
2167  pwr_tStatus sts = GDH__SUCCESS;
2168 
2169  if (cdh_ObjidIsNull(oid))
2170  return GDH__NOSUCHOBJ;
2171  if (oid.oix == pwr_cNObjectIx)
2172  return GDH__NOTMOVABLE;
2173  if (poid.vid == pwr_cNVolumeId)
2174  poid.vid = oid.vid;
2175  if (oid.vid != poid.vid)
2176  return GDH__SAMEVOLUME;
2177  if (oid.oix == poid.oix)
2178  return GDH__CHILDSELF;
2179 
2180  gdh_ScopeLock
2181  {
2182  dvol_MoveObject(&sts, oid, poid);
2183  }
2184  gdh_ScopeUnlock;
2185 
2186  return sts;
2187 }
2188 
2202 pwr_tStatus gdh_NameToObjid(const char* name,
2203  pwr_tObjid* oid
2204  )
2205 {
2206  pwr_tStatus sts = GDH__SUCCESS;
2207  cdh_sParseName parseName;
2208  cdh_sParseName* pn;
2209  gdb_sObject* op = NULL;
2210 
2211  if (name == NULL)
2212  return GDH__BADARG;
2213  if (oid == NULL)
2214  return GDH__BADARG;
2215 
2216  pn = cdh_ParseName(&sts, &parseName, pwr_cNObjid, name, 0);
2217  if (pn == NULL)
2218  return sts;
2219 
2220  gdh_ScopeLock
2221  {
2222  op = vol_NameToObject(&sts, pn, gdb_mLo_global, vol_mTrans_all);
2223  if (op != NULL) {
2224  touchObject(op);
2225  *oid = op->g.oid;
2226  }
2227  }
2228  gdh_ScopeUnlock;
2229 
2230  return sts;
2231 }
2232 
2240 pwr_tStatus gdh_NameToPointer(const char* name,
2241  void** p
2242  )
2243 {
2244  pwr_tStatus sts = GDH__SUCCESS;
2245  cdh_sParseName parseName;
2246  cdh_sParseName* pn;
2247  gdb_sObject* op = NULL;
2248 
2249  if (name == NULL)
2250  return GDH__BADARG;
2251  if (p == NULL)
2252  return GDH__BADARG;
2253 
2254  pn = cdh_ParseName(&sts, &parseName, pwr_cNObjid, name, 0);
2255  if (pn == NULL)
2256  return sts;
2257 
2258  gdh_ScopeLock
2259  {
2260  op = vol_NameToObject(&sts, pn, gdb_mLo_global, vol_mTrans_all);
2261  if (op != NULL)
2262  *p = vol_ObjectToAddress(&sts, op);
2263  }
2264  gdh_ScopeUnlock;
2265 
2266  return sts;
2267 }
2268 
2285 {
2286  pwr_tStatus sts = GDH__SUCCESS;
2287 
2288  gdh_ScopeLock
2289  {
2290  if (gdbroot->db->nethandler.qix != 0)
2291  sts = GDH__SUCCESS;
2292  else
2293  sts = GDH__NONETHANDLER;
2294  }
2295  gdh_ScopeUnlock;
2296 
2297  return sts;
2298 }
2299 
2315  pwr_tObjid
2316  poid,
2319  const char*
2320  name,
2324  pwr_sAttrRef* arp
2325  )
2326 {
2327  pwr_tStatus sts = GDH__SUCCESS;
2328  cdh_sParseName parseName;
2329  cdh_sParseName* pn;
2330  mvol_sAttribute attribute;
2331  mvol_sAttribute* ap;
2332 
2333  if (arp == NULL)
2334  return GDH__BADARG;
2335 
2336  pn = cdh_ParseName(&sts, &parseName, poid, name, 0);
2337  if (pn == NULL)
2338  return sts;
2339 
2340  memset(&attribute, 0, sizeof(attribute));
2341 
2342  gdh_ScopeLock
2343  {
2344  ap = vol_NameToAttribute(
2345  &sts, &attribute, pn, gdb_mLo_global, vol_mTrans_all);
2346  if (ap == NULL)
2347  break;
2348 
2349  touchObject(ap->op);
2350  mvol_AttributeToAref(&sts, ap, arp);
2351  }
2352  gdh_ScopeUnlock;
2353 
2354  return sts;
2355 }
2356 
2372  char* namebuf,
2373  pwr_tUInt32 size,
2374  pwr_tBitMask nametype
2375  )
2376 {
2377  pwr_tStatus sts = GDH__SUCCESS;
2378  char name[512];
2379  char* s = NULL;
2380  pwr_tInt32 len;
2381  cdh_mName lnametype;
2382  gdb_sObject* op;
2383 
2384  if (namebuf == NULL)
2385  return GDH__BADARG;
2386 
2387  if (nametype == cdh_mNName)
2388  lnametype.m = cdh_mName_pathStrict;
2389  else
2390  lnametype.m = nametype;
2391 
2392  if (cdh_ObjidIsNull(oid))
2393  return GDH__NOSUCHOBJ;
2394 
2395  gdh_ScopeLock
2396  {
2397  op = vol_OidToObject(
2398  &sts, oid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_none);
2399  if (op == NULL)
2400  break;
2401 
2402  touchObject(op);
2403  s = vol_ObjectToName(&sts, op, lnametype.m, name);
2404  }
2405  gdh_ScopeUnlock;
2406 
2407  if (op == NULL && lnametype.b.fallback != cdh_mName_eFallback_strict) {
2408  sts = GDH__SUCCESS;
2409  cdh_OidToString(name, sizeof(name), oid, 1);
2410  s = name;
2411  }
2412 
2413  if (s != NULL) {
2414  len = strlen(s);
2415  if (len >= size)
2416  sts = GDH__NAMEBUF;
2417  strncpy(namebuf, s, len + 1);
2418  }
2419 
2420  return sts;
2421 }
2422 
2432  void** p
2433  )
2434 {
2435  pwr_tStatus sts = GDH__SUCCESS;
2436  gdb_sObject* op;
2437 
2438  if (p == NULL)
2439  return GDH__BADARG;
2440 
2441  gdh_ScopeLock
2442  {
2443  op = vol_OidToObject(
2444  &sts, oid, gdb_mLo_native, vol_mTrans_all, cvol_eHint_none);
2445  if (op == NULL)
2446  break;
2447 
2448  if (op->u.n.lflags.b.readOnly) {
2449  sts = GDH__READONLY;
2450  break;
2451  }
2452 
2453  *p = vol_ObjectToAddress(&sts, op);
2454  }
2455  gdh_ScopeUnlock;
2456 
2457  return sts;
2458 }
2459 
2465  void** p
2466  )
2467 {
2468  pwr_tStatus sts = GDH__SUCCESS;
2469  gdb_sObject* op;
2470 
2471  if (p == NULL)
2472  return GDH__BADARG;
2473 
2474  gdh_ScopeLock
2475  {
2476  op = vol_OidToObject(
2477  &sts, oid, gdb_mLo_native, vol_mTrans_none, cvol_eHint_none);
2478  if (op != NULL)
2479  *p = vol_ObjectToAddress(&sts, op);
2480  }
2481  gdh_ScopeUnlock;
2482 
2483  return sts;
2484 }
2485 
2494  void** p
2495  )
2496 {
2497  pwr_tStatus sts = GDH__SUCCESS;
2498  gdb_sObject* op;
2499 
2500  if (p == NULL)
2501  return GDH__BADARG;
2502 
2503  gdh_ScopeLock
2504  {
2505  op = vol_OidToObject(
2506  &sts, arp->Objid, gdb_mLo_native, vol_mTrans_all, cvol_eHint_none);
2507  if (op == NULL)
2508  break;
2509 
2510  if (op->u.n.lflags.b.readOnly) {
2511  sts = GDH__READONLY;
2512  break;
2513  }
2514 
2515  *p = vol_ObjectToAddress(&sts, op);
2516  *p = (char*)*p + arp->Offset;
2517  }
2518  gdh_ScopeUnlock;
2519 
2520  return sts;
2521 }
2522 
2535  pwr_tObjid oid,
2536  char* name
2537  )
2538 {
2539  pwr_tStatus sts = GDH__SUCCESS;
2540  cdh_sParseName parseName;
2541  cdh_sParseName* pn;
2542 
2543  if (name == NULL)
2544  return GDH__BADARG;
2545 
2546  pn = cdh_ParseName(&sts, &parseName, pwr_cNObjid, name, 0);
2547  if (pn == NULL || pn->nObject != 1 || pn->flags.b.idString)
2548  return GDH__BADNAME;
2549 
2550  gdh_ScopeLock
2551  {
2552  dvol_RenameObject(&sts, oid, pn);
2553  }
2554  gdh_ScopeUnlock;
2555 
2556  return sts;
2557 }
2558 
2580  const char* name,
2581  void* bufp,
2582  unsigned int bufsize
2583  )
2584 {
2585  pwr_tStatus sts = GDH__SUCCESS;
2586  cdh_sParseName parseName;
2587  cdh_sParseName* pn;
2588  mvol_sAttribute attribute;
2589  mvol_sAttribute* ap;
2590  gdb_sVolume* vp;
2591  gdb_sNode* np = NULL;
2592  pwr_sAttrRef aref;
2593  pwr_sAttrRef* arp = NULL;
2594  void* p;
2595  pwr_sAttrRef raref;
2596  pwr_sAttrRef* rarp = NULL;
2597  gdb_sCclass* ccp = NULL;
2598  gdb_sCclass* ccpLocked = NULL;
2599  pwr_tBoolean equal = 0;
2600  pwr_tBoolean fetched;
2601  pwr_tUInt32 ridx = UINT_MAX;
2602 
2603  if (name == NULL)
2604  return GDH__BADARG;
2605  if (bufp == NULL)
2606  return GDH__BADARG;
2607 
2608  pn = cdh_ParseName(&sts, &parseName, pwr_cNObjid, name, 0);
2609  if (pn == NULL)
2610  return sts;
2611 
2612  memset(&attribute, 0, sizeof(attribute));
2613 
2614  gdh_Lock;
2615 
2616  do {
2617  ap = vol_NameToAttribute(
2618  &sts, &attribute, pn, gdb_mLo_global, vol_mTrans_all);
2619  if (ap == NULL || ap->op == NULL)
2620  break;
2621 
2622  if (ap->op->u.n.lflags.b.readOnly
2623  || (ap->adef && ap->adef->Info.Flags & PWR_MASK_CONST)) {
2624  sts = GDH__READONLY;
2625  break;
2626  }
2627 
2628  touchObject(ap->op);
2629  p = vol_AttributeToAddress(&sts, ap);
2630  if (p != NULL) {
2631  memcpy(p, bufp, MIN(ap->size, bufsize));
2632  break;
2633  } else if ((ap->op->l.flags.m & gdb_mLo_native) != 0) {
2634  break;
2635  }
2636 
2637  /* Try remote. */
2638 
2639  memset(&aref, 0, sizeof(aref));
2640  arp = mvol_AttributeToAref(&sts, ap, &aref);
2641  if (arp == NULL)
2642  break;
2643 
2644  vp = pool_Address(NULL, gdbroot->pool, ap->op->l.vr);
2645  np = pool_Address(NULL, gdbroot->pool, vp->l.nr);
2646  if (np == NULL)
2647  break;
2648 
2649  ccp = NULL;
2650  /* Get cached class if needed */
2651  if (!ap->op->u.c.flags.b.classChecked || !ap->op->u.c.flags.b.classEqual) {
2652  ccp = cmvolc_GetCachedClass(&sts, np, vp, ap, &equal, &fetched, NULL);
2653  if (EVEN(sts)) {
2654  np = NULL;
2655  break;
2656  }
2657  if (equal)
2658  ccp = NULL;
2659 
2660  if (ccpLocked == NULL && ccp != NULL && !equal) {
2661  cmvolc_LockClass(NULL, ccp);
2662  ccpLocked = ccp;
2663  }
2664 
2665  /* If gdb has been unlocked, refresh pointers */
2667  if (fetched) {
2668  memset(&attribute, 0, sizeof(attribute));
2669  np = NULL;
2670  continue;
2671  }
2672 
2673  if (equal)
2674  break;
2675 
2676  rarp = ndc_NarefToRaref(
2677  &sts, ap, arp, ccp, &ridx, &raref, &equal, pn, ccpLocked, vp, np);
2678  }
2679  break;
2680  } while (1);
2681 
2682  gdh_Unlock;
2683 
2684  if (np != NULL && ODD(sts)) {
2685  if (equal)
2686  cvolc_SetObjectInfo(
2687  &sts, np, arp, NULL, NULL, UINT_MAX, ap, bufp, bufsize);
2688  else
2689  cvolc_SetObjectInfo(&sts, np, arp, ccp, rarp, ridx, ap, bufp, bufsize);
2690  }
2691 
2692  if (gdh_log_cb && ODD(sts))
2693  gdh_log_cb((char *)name, bufp, bufsize);
2694 
2695  if (ccpLocked) {
2696  gdb_Lock;
2697  cmvolc_UnlockClass(NULL, ccpLocked);
2698  gdb_Unlock;
2699  }
2700 
2701  return sts;
2702 }
2703 
2723  pwr_sAttrRef*
2724  arp,
2726  void* bufp,
2727  unsigned int bufsize
2728  )
2729 {
2730  pwr_tStatus sts = GDH__SUCCESS;
2731  mvol_sAttribute attribute;
2732  mvol_sAttribute* ap;
2733  gdb_sVolume* vp;
2734  gdb_sNode* np = NULL;
2735  void* p;
2736  gdb_sCclass* ccp = NULL;
2737  gdb_sCclass* ccpLocked = NULL;
2738  pwr_sAttrRef raref;
2739  pwr_sAttrRef* rarp = NULL;
2740  pwr_tBoolean equal = 0;
2741  pwr_tBoolean fetched;
2742  pwr_tUInt32 ridx = UINT_MAX;
2743 
2744  if (arp == NULL)
2745  return GDH__BADARG;
2746  if (bufp == NULL)
2747  return GDH__BADARG;
2748 
2749  memset(&attribute, 0, sizeof(attribute));
2750 
2751  gdh_Lock;
2752  do {
2753  ap = vol_ArefToAttribute(
2754  &sts, &attribute, arp, gdb_mLo_global, vol_mTrans_all);
2755  if (ap == NULL || ap->op == NULL)
2756  break;
2757 
2758  if (ap->op->u.n.lflags.b.readOnly
2759  || (ap->adef && ap->adef->Info.Flags & PWR_MASK_CONST)) {
2760  sts = GDH__READONLY;
2761  break;
2762  }
2763 
2764  touchObject(ap->op);
2765  p = vol_AttributeToAddress(&sts, ap);
2766  if (p != NULL) {
2767  memcpy(p, bufp, MIN(ap->size, bufsize));
2768  break;
2769  } else if ((ap->op->l.flags.m & gdb_mLo_native) != 0) {
2770  break;
2771  }
2772 
2773  /* Try remote. */
2774  sts = GDH__SUCCESS;
2775 
2776  vp = pool_Address(NULL, gdbroot->pool, ap->op->l.vr);
2777  np = pool_Address(NULL, gdbroot->pool, vp->l.nr);
2778 
2779  if (np == NULL)
2780  break;
2781 
2782  ccp = NULL;
2783  /* Get cached class if needed */
2784  if (!ap->op->u.c.flags.b.classChecked || !ap->op->u.c.flags.b.classEqual) {
2785  ccp = cmvolc_GetCachedClass(&sts, np, vp, ap, &equal, &fetched, NULL);
2786  if (EVEN(sts)) {
2787  np = NULL;
2788  break;
2789  }
2790  if (equal)
2791  ccp = NULL;
2792 
2793  if (ccpLocked == NULL && ccp != NULL && !equal) {
2794  cmvolc_LockClass(NULL, ccp);
2795  ccpLocked = ccp;
2796  }
2797 
2798  /* If gdb has been unlocked, refresh pointers */
2799  if (fetched) {
2800  memset(&attribute, 0, sizeof(attribute));
2801  np = NULL;
2802  continue;
2803  }
2804 
2805  if (equal)
2806  break;
2807 
2808  rarp = ndc_NarefToRaref(
2809  &sts, ap, arp, ccp, &ridx, &raref, &equal, NULL, ccpLocked, vp, np);
2810  } else
2811  equal = ap->op->u.c.flags.b.classEqual;
2812 
2813  break;
2814 
2815  } while (1);
2816 
2817  gdh_Unlock;
2818 
2819  if (np != NULL && ODD(sts)) {
2820  if (equal)
2821  cvolc_SetObjectInfo(
2822  &sts, np, arp, NULL, NULL, UINT_MAX, ap, bufp, bufsize);
2823  else
2824  cvolc_SetObjectInfo(&sts, np, arp, ccp, rarp, ridx, ap, bufp, bufsize);
2825  }
2826 
2827  if (ccpLocked) {
2828  gdb_Lock;
2829  cmvolc_UnlockClass(NULL, ccpLocked);
2830  gdb_Unlock;
2831  }
2832 
2833  return sts;
2834 }
2835 
2845  unsigned int nentries,
2848  void* object[],
2854  pwr_tBoolean is_aref[],
2858  pwr_tSubid subid[]
2861  )
2862 {
2863  pwr_tStatus sts = GDH__SUCCESS;
2864  sub_sClient* cp;
2865  pool_sQlink* lh;
2866  pwr_tUInt32 i;
2867  char* s;
2868  pwr_sAttrRef* arp;
2869 
2870  gdh_ScopeLock
2871  {
2872  /* Allocate a temporary list header */
2873 
2874  lh = pool_Qalloc(NULL, gdbroot->pool);
2875 
2876  for (i = 0; i < nentries; i++) {
2877  /* Build subcli structure */
2878 
2879  if (is_aref[i]) {
2880  s = NULL;
2881  arp = object[i];
2882  } else {
2883  s = object[i];
2884  arp = NULL;
2885  }
2886 
2887  cp = subc_Create(s, arp, lh);
2888 
2889  if (subid)
2890  subid[i] = cp->sid;
2891  }
2892 
2893  /* Try to get it running */
2894 
2895  subc_ActivateList(lh, pwr_cNObjid);
2896 
2897  /* Get rid of temporary root */
2898 
2899  pool_Free(NULL, gdbroot->pool, lh);
2900  }
2901  gdh_ScopeUnlock;
2902 
2903  return sts;
2904 }
2905 
2918  pwr_sAttrRef* aref,
2919  pwr_tSubid* sid
2920  )
2921 {
2922  pwr_tStatus sts = GDH__SUCCESS;
2923  pwr_tBoolean true_flag = TRUE;
2924 
2925  if (aref == NULL)
2926  return GDH__BADARG;
2927  if (sid == NULL)
2928  return GDH__BADARG;
2929 
2930  sts = gdh_SubRefObjectInfoList(1, (void*)&aref, &true_flag, sid);
2931 
2932  return sts;
2933 }
2934 
2945  char* name,
2946  pwr_tSubid* sid
2947  )
2948 {
2949  pwr_tStatus sts = GDH__SUCCESS;
2950  pwr_tBoolean false_flag = FALSE;
2951 
2952  if (name == NULL)
2953  return GDH__BADARG;
2954  if (sid == NULL)
2955  return GDH__BADARG;
2956 
2957  sts = gdh_SubRefObjectInfoList(1, (void*)&name, &false_flag, sid);
2958 
2959  return sts;
2960 }
2961 
2971  unsigned int nentries,
2972  pwr_tSubid* sid
2973  )
2974 {
2975  pwr_tStatus retsts = GDH__SUCCESS;
2976  pwr_tStatus sts = GDH__SUCCESS;
2977  sub_sClient* cp = NULL;
2978  pool_sQlink* lh;
2979  pwr_tUInt32 i;
2980  cdh_uRefId rid;
2981 
2982  if (sid == NULL)
2983  return GDH__BADARG;
2984 
2985  gdh_ScopeLock
2986  {
2987  /* Allocate a temporary root */
2988 
2989  lh = pool_Qalloc(NULL, gdbroot->pool);
2990 
2991  for (i = 0; i < nentries; i++) {
2992  rid.pwr = sid[i];
2993 
2994  if (rid.r.vid_3 != cdh_eVid3_subid) /* Verify Subid. */
2995  sts = GDH__NOSUBCLI;
2996  else
2997  cp = hash_Search(&sts, gdbroot->subc_ht, &sid[i]);
2998 
2999  if (EVEN(sts)) {
3000  retsts = (sts & ~STS_M_SEVERITY) | STS_K_INFO;
3001  } else {
3002  /* Move the subscription client to the temporary list. */
3003 
3004  pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll);
3005  pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, lh);
3006 
3007  /* Tell the caller this was a valid subid by zeroing it
3008  leaving the invalid ones in the list... */
3009 
3010  sid[i] = pwr_cNSubid;
3011  }
3012  }
3013 
3014  /* Cancel all clients in the temporary list. */
3015 
3016  subc_CancelList(lh);
3017 
3018  /* Get rid of temporary root. */
3019 
3020  pool_Free(NULL, gdbroot->pool, lh);
3021  }
3022  gdh_ScopeUnlock;
3023 
3024  return retsts;
3025 }
3026 
3034  pwr_tSubid sid
3035  )
3036 {
3037  pwr_tStatus sts = GDH__SUCCESS;
3038  pwr_tSubid sidlst = sid;
3039 
3040  sts = gdh_SubUnrefObjectInfoList(1, &sidlst);
3041  if (cdh_SubidIsNotNull(sidlst))
3042  sts = (sts & ~STS_M_SEVERITY) | STS_K_ERROR;
3043 
3044  return sts;
3045 }
3046 
3053 {
3054  gdh_ScopeLock
3055  {
3056  subc_CancelUser(gdbroot->my_pid);
3057  }
3058  gdh_ScopeUnlock;
3059 }
3060 
3065  pwr_tSubid sid,
3066  void* bp,
3067  unsigned int bsize
3068  )
3069 {
3070  pwr_tStatus sts = GDH__SUCCESS;
3071  sub_sClient* cp;
3072  const void* p = NULL;
3073  net_sSubData* dp;
3074  mvol_sAttribute attribute;
3075  mvol_sAttribute* ap;
3076 
3077  if (bp == NULL)
3078  return GDH__BADARG;
3079  memset(&attribute, 0, sizeof(attribute));
3080 
3081  gdh_ScopeLock
3082  {
3083  cp = hash_Search(&sts, gdbroot->subc_ht, &sid);
3084  if (cp == NULL)
3085  break;
3086 
3087  if (EVEN(cp->sts)) {
3088  sts = cp->sts;
3089  break;
3090  }
3091 
3092  if ((cp->nid == gdbroot->db->nid) && (cp->userdata == pool_cNRef)) {
3093  /* Handle local object references without user buffers. */
3094 
3095  ap = vol_ArefToAttribute(
3096  &sts, &attribute, &cp->aref, gdb_mLo_global, vol_mTrans_all);
3097  if (ap == NULL)
3098  break;
3099 
3100  p = vol_AttributeToAddress(&sts, ap);
3101  } else {
3102  /* Handle all other object references. */
3103 
3104  if (cp->old) {
3105  sts = GDH__SUBOLD;
3106  } else {
3107  dp = pool_Address(NULL, gdbroot->pool, cp->subdata);
3108  if (dp == NULL)
3109  errh_Bugcheck(GDH__WEIRD, "gdh_SubData");
3110  p = &dp->data[0];
3111  }
3112  }
3113 
3114  /* If all is fine, copy data to user buffer. */
3115 
3116  if (ODD(sts)) {
3117  if (cp->cclass != pool_cNRef) {
3118  gdb_sCclass* ccp;
3119  ndc_sRemoteToNative* tbl;
3120  pwr_tUInt32 size;
3121  pwr_tBoolean first = 1;
3122 
3123  ccp = pool_Address(NULL, gdbroot->pool, cp->cclass);
3124  if (ccp == NULL)
3125  errh_Bugcheck(GDH__WEIRD, "gdh_SubData, get cached class address");
3126 
3127  if (!ccp->flags.b.rnConv)
3128  errh_Bugcheck(GDH__WEIRD, "gdh_SubData, no conversion table");
3129 
3130  tbl = pool_Address(NULL, gdbroot->pool, ccp->rnConv);
3131  if (tbl == NULL)
3132  errh_Bugcheck(GDH__WEIRD, "gdh_SubData, get cached class address");
3133 
3134  size = MIN(bsize, cp->aref.Size);
3135  ndc_ConvertRemoteToNativeTable(&sts, ccp, tbl, &cp->raref, &cp->aref,
3136  bp, p, &size, cp->aref.Offset, 0, 0, &first, cp->nid);
3137 
3138  } else
3139  memcpy(bp, p, MIN(bsize, cp->aref.Size));
3140  }
3141  }
3142  gdh_ScopeUnlock;
3143 
3144  return sts;
3145 }
3146 
3151  unsigned int* size
3152  )
3153 {
3154  pwr_tStatus sts = GDH__SUCCESS;
3155  sub_sClient* cp;
3156 
3157  if (size == NULL)
3158  return GDH__BADARG;
3159 
3160  gdh_ScopeLock
3161  {
3162  cp = hash_Search(&sts, gdbroot->subc_ht, &sid);
3163  if (cp == NULL)
3164  break;
3165 
3166  if (EVEN(cp->sts)) {
3167  sts = cp->sts;
3168  } else {
3169  *size = cp->aref.Size;
3170  }
3171  }
3172  gdh_ScopeUnlock;
3173 
3174  return sts;
3175 }
3176 
3187  pwr_tSubid sid,
3188  void** buffer,
3190  unsigned int buffersize
3191  )
3192 {
3193  pwr_tStatus sts = GDH__SUCCESS;
3194  sub_sClient* cp;
3195 
3196  if (buffer == NULL)
3197  return GDH__BADARG;
3198 
3199  gdh_ScopeLock
3200  {
3201  cp = hash_Search(&sts, gdbroot->subc_ht, &sid);
3202  if (cp == NULL)
3203  break;
3204 
3205  if (cp->userdata == pool_cNRef) {
3206  cp->userdata = pool_RefAlloc(NULL, gdbroot->rtdb, buffersize);
3207  cp->usersize = buffersize;
3208  *buffer = pool_Address(NULL, gdbroot->rtdb, cp->userdata);
3209  } else {
3210  if (cp->usersize >= buffersize) {
3215  *buffer = pool_Address(NULL, gdbroot->rtdb, cp->userdata);
3216  } else {
3217  sts = GDH__SUBALRBUF;
3218  }
3219  } /* Previous buffer */
3220  }
3221  gdh_ScopeUnlock;
3222 
3223  return sts;
3224 }
3225 
3235  pwr_tInt32 dt,
3237  pwr_tInt32 tmo
3239  )
3240 {
3241  subc_SetDefaults(dt, tmo);
3242  return GDH__SUCCESS;
3243 }
3244 
3266  unsigned int n,
3267  gdh_sObjRef* objref,
3271  pwr_tSubid* sid
3273  )
3274 {
3275  pwr_tStatus sts, rsts = GDH__SUCCESS;
3276  pwr_tUInt32 i;
3277  OBJREF_STRUCT* objrefp;
3278  pwr_tSubid* subidarr;
3279  pwr_tUInt32* xrefarr;
3280  pwr_sAttrRef aref;
3281  char** object;
3282  char** objp;
3283  pwr_tUInt32 nsub;
3284  pwr_tBoolean dl;
3285  pwr_tDlid dlid;
3286  pwr_tBoolean* isattrref;
3287 
3288  /* Allocate space for the object array and the subid array
3289  needed by SubRefObjectInfoList. If we assume that
3290  all entries in objref will be subscriptions the logic becomes simple! */
3291 
3292  object = calloc(n, sizeof(*object));
3293  xrefarr = calloc(n, sizeof(pwr_tUInt32));
3294  subidarr = calloc(n, sizeof(pwr_tSubid));
3295  isattrref = calloc(n, sizeof(pwr_tBoolean));
3296 
3297  /* Go through the objrefs. Set up direct links if local reference,
3298  accumulate in object[] array for a later call to set up subscriptions
3299  if this is a remote object. */
3300 
3301  nsub = 0; /* Keep track of subscription count */
3302 
3303  objrefp = &objref[0];
3304  objp = &object[0];
3305  for (i = 0; i < n; i++, objrefp++) {
3306  sts = gdh_NameToAttrref(pwr_cNObjid, objrefp->fullname, &aref);
3307  if (EVEN(sts)) {
3308  pwr_tAName an;
3309  pwr_tOid oid;
3310  char* s;
3311  pwr_tStatus lsts;
3312 
3313  if ( sts == GDH__NODYNLOCOBJ) {
3314  rsts = sts;
3315  continue;
3316  }
3317 
3318  dl = 0;
3319 
3320  /* Check if this is an erroneous local attribute */
3321  strcpy(an, objrefp->fullname);
3322  if ((s = strchr(an, '.'))) {
3323  *s = 0;
3324  lsts = gdh_NameToObjid(an, &oid);
3325  if (ODD(lsts)) {
3326  gdh_GetObjectLocation(oid, &dl);
3327  if (dl) {
3328  rsts = sts;
3329  continue;
3330  }
3331  }
3332  }
3333  } else {
3334  gdh_GetObjectLocation(aref.Objid, &dl);
3335  }
3336 
3337  /* If dl == TRUE, then direct link, else subscribe! */
3338 
3339  if (dl) {
3340  dlid = pwr_cNDlid;
3341  objrefp->adrs = NULL;
3342  gdh_DLRefObjectInfoAttrref(&aref, &objrefp->adrs, &dlid);
3343  if (sid != NULL)
3344  sid[i] = dlid;
3345  } else {
3346  *objp = (char*)&objrefp->fullname;
3347  isattrref[nsub] = FALSE;
3348  xrefarr[nsub++] = i;
3349  objp++;
3350  }
3351  } /* For all objref struct entries */
3352 
3353  /* Establish subscriptions. */
3354 
3355  if (nsub > 0) {
3356  gdh_SubRefObjectInfoList(nsub, (void*)object, isattrref, subidarr);
3357 
3358  /* Associate buffers and return pwr_tSubid if requested. */
3359 
3360  for (i = 0; i < nsub; i++) {
3361  objrefp = &objref[xrefarr[i]];
3362  if (objrefp->bufsize == 0) {
3363  free(subidarr);
3364  free(xrefarr);
3365  free(isattrref);
3366  free(object);
3367  return GDH__BADARG;
3368  }
3369  gdh_SubAssociateBuffer(subidarr[i], &objrefp->adrs, objrefp->bufsize);
3370  if (sid != NULL)
3371  sid[xrefarr[i]] = subidarr[i];
3372  }
3373  }
3374 
3375  /* Free all resources. */
3376 
3377  free(subidarr);
3378  free(xrefarr);
3379  free(isattrref);
3380  free(object);
3381 
3382  return rsts;
3383 }
3384 
3427  char* name,
3428  void** infop,
3429  pwr_tSubid* sid,
3430  unsigned int size
3431  )
3432 {
3433  pwr_tStatus sts = GDH__SUCCESS;
3434  gdh_sObjRef objref;
3435 
3436  if (infop == NULL)
3437  return GDH__BADARG;
3438  if (name == NULL)
3439  return GDH__BADARG;
3440  if (strlen(name) >= sizeof(objref.fullname))
3441  return GDH__NAMELEN;
3442 
3443  objref.bufsize = size;
3444 
3445  strncpy((char*)&objref.fullname, name, sizeof(objref.fullname));
3446 
3447  sts = gdh_RefObjectInfoList(1, &objref, sid);
3448  if (ODD(sts) && objref.adrs == NULL)
3449  return GDH__RTDBNULL;
3450  if (ODD(sts))
3451  *infop = objref.adrs;
3452 
3453  return sts;
3454 }
3455 
3471  pwr_tSubid sid
3472  )
3473 {
3474  pwr_tStatus sts = GDH__SUCCESS;
3475  cdh_uRefId refid;
3476 
3477  refid.pwr = sid;
3478 
3479  if (refid.r.vid_3 == cdh_eVid3_dlid) {
3480  sts = gdh_DLUnrefObjectInfo(sid);
3481  } else if (refid.r.vid_3 == cdh_eVid3_subid) {
3482  sts = gdh_SubUnrefObjectInfo(sid);
3483  } else {
3484  sts = GDH__NOSUBCLI;
3485  }
3486 
3487  return sts;
3488 }
3489 
3499 {
3502 
3503  return GDH__SUCCESS;
3504 }
3505 
3515  pwr_tObjid oid,
3516  pwr_tUInt32 alarmlevel
3517  )
3518 {
3519  pwr_tStatus sts = GDH__SUCCESS;
3520  gdb_sObject* op;
3521 
3522  gdh_ScopeLock
3523  {
3524  op = vol_OidToObject(
3525  &sts, oid, gdb_mLo_owned, vol_mTrans_none, cvol_eHint_none);
3526  if (op == NULL)
3527  break;
3528 
3529  touchObject(op);
3530 
3531  vol_SetAlarmLevel(&sts, op, alarmlevel);
3532  }
3533  gdh_ScopeUnlock;
3534 
3535  return sts;
3536 }
3537 
3546  pwr_tObjid oid,
3547  pwr_tUInt32 blocklevel
3548  )
3549 {
3550  pwr_tStatus sts = GDH__SUCCESS;
3551  gdb_sObject* op;
3552 
3553  gdh_ScopeLock
3554  {
3555  op = vol_OidToObject(
3556  &sts, oid, gdb_mLo_owned, vol_mTrans_none, cvol_eHint_none);
3557  if (op == NULL)
3558  break;
3559 
3560  touchObject(op);
3561 
3562  vol_SetBlockLevel(&sts, op, blocklevel);
3563  }
3564  gdh_ScopeUnlock;
3565 
3566  return sts;
3567 }
3568 
3572 void gdh_StoreRtdbPointer(unsigned long* rp, void* p)
3573 {
3574  pool_tRef r;
3575 
3576  if (rp == NULL)
3577  return;
3578 
3579  if (p == NULL) {
3580  r = pool_cNRef;
3581  } else {
3582  r = pool_Reference(NULL, gdbroot->rtdb, p);
3583  if (r == pool_cNRef)
3584  errh_Bugcheck(GDH__RTDBNULL, "gdh_StoreRtdbPointer");
3585  }
3586  *rp = r;
3587 }
3588 
3593 void* gdh_TranslateRtdbPointer(unsigned long r)
3594 {
3595  return pool_Address(NULL, gdbroot->rtdb, r);
3596 }
3597 
3598 pwr_tStatus gdh_IsAlias(pwr_tObjid oid, pwr_tBoolean* is_alias)
3599 {
3600  pwr_tStatus sts = GDH__SUCCESS;
3601  gdb_sObject* op;
3602 
3603  if (is_alias == NULL)
3604  return GDH__BADARG;
3605 
3606  gdh_ScopeLock
3607  {
3608  op = vol_OidToObject(
3609  &sts, oid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_none);
3610  if (op != NULL) {
3611  touchObject(op);
3612  *is_alias = (pwr_tBoolean)op->g.flags.b.isAliasClient;
3613  }
3614  }
3615  gdh_ScopeUnlock;
3616 
3617  return sts;
3618 }
3619 
3620 pwr_tStatus gdh_IsMountClean(pwr_tObjid oid, pwr_tBoolean* is_mount_clean)
3621 {
3622  pwr_tStatus sts = GDH__SUCCESS;
3623  gdb_sObject* op;
3624 
3625  if (is_mount_clean == NULL)
3626  return GDH__BADARG;
3627 
3628  gdh_ScopeLock
3629  {
3630  op = vol_OidToObject(
3631  &sts, oid, gdb_mLo_global, vol_mTrans_none, cvol_eHint_none);
3632  if (op != NULL) {
3633  touchObject(op);
3634  if (!op->l.flags.b.isOwned) {
3635  *is_mount_clean = 1;
3636  sts = GDH__REMOTE;
3637  break;
3638  }
3639  *is_mount_clean = (pwr_tBoolean)op->u.n.flags.b.isMountClean;
3640  }
3641  }
3642  gdh_ScopeUnlock;
3643 
3644  return sts;
3645 }
3646 
3647 pwr_tStatus gdh_SetCache(
3648  pwr_tUInt32 activation_level, /* Level when trimming starts. */
3649  pwr_tUInt32 trimmed_level /* Trimmed cache level. */
3650  )
3651 {
3652  return GDH__OBSOLETE;
3653 }
3654 
3679  pwr_tVid* vid
3680  )
3681 {
3682  pool_sQlink* vl;
3683  gdb_sVolume* vp;
3684 
3685  gdh_ScopeLock
3686  {
3687  vl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->vol_lh);
3688  if (vl == NULL || vl == &gdbroot->db->vol_lh)
3689  return GDH__NOSUCHVOL;
3690 
3691  vp = pool_Qitem(vl, gdb_sVolume, l.vol_ll);
3692 
3693  *vid = vp->g.vid;
3694  }
3695  gdh_ScopeUnlock;
3696  return GDH__SUCCESS;
3697 }
3698 
3707 {
3708  pool_sQlink* vl;
3709  gdb_sVolume* vp;
3710  pwr_tStatus sts;
3711  pwr_tStatus rsts = GDH__NOSUCHVOL;
3712 
3713  gdh_ScopeLock
3714  {
3715  for (vl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->vol_lh);
3716  vl != &gdbroot->db->vol_lh; vl = pool_Qsucc(&sts, gdbroot->pool, vl)) {
3717  vp = pool_Qitem(vl, gdb_sVolume, l.vol_ll);
3718  if (vp->g.vid == pvid) {
3719  for (vl = pool_Qsucc(&sts, gdbroot->pool, vl);
3720  vl != &gdbroot->db->vol_lh;
3721  vl = pool_Qsucc(&sts, gdbroot->pool, vl)) {
3722  vp = pool_Qitem(vl, gdb_sVolume, l.vol_ll);
3723  if (vp->l.flags.b.isLoaded || vp->l.flags.b.isCached) {
3724  *vid = vp->g.vid;
3725  rsts = GDH__SUCCESS;
3726  break;
3727  }
3728  }
3729  if (rsts == GDH__SUCCESS || vl == &gdbroot->db->vol_lh)
3730  break;
3731  }
3732  }
3733  }
3734  gdh_ScopeUnlock;
3735 
3736  return rsts;
3737 }
3738 
3745  char* name,
3746  int size
3747  )
3748 {
3749  gdb_sVolume* vp;
3750  pwr_tStatus sts;
3751  pwr_tStatus rsts = GDH__SUCCESS;
3752 
3753  gdh_ScopeLock
3754  {
3755  vp = hash_Search(&sts, gdbroot->vid_ht, &vid);
3756  if (vp != NULL) {
3757  if (strlen(vp->g.name.orig) >= size)
3758  rsts = GDH__NAMEBUF;
3759  strncpy(name, vp->g.name.orig, size);
3760  } else
3761  rsts = GDH__NOSUCHVOL;
3762  }
3763  gdh_ScopeUnlock;
3764 
3765  return rsts;
3766 }
3767 
3772  gdh_sVolumeInfo* info
3773  )
3774 {
3775  gdb_sVolume* vp;
3776  pwr_tStatus sts;
3777  pwr_tStatus rsts = GDH__SUCCESS;
3778 
3779  gdh_ScopeLock
3780  {
3781  vp = hash_Search(&sts, gdbroot->vid_ht, &vid);
3782  if (vp != NULL) {
3783  info->isCached = vp->l.flags.b.isCached ? 1 : 0;
3784  info->isLoaded = vp->l.flags.b.isLoaded ? 1 : 0;
3785  info->isMounted = vp->l.flags.b.isMounted ? 1 : 0;
3786  info->time = net_NetTimeToTime(&vp->g.time);
3787  info->cid = vp->g.cid;
3788  info->nid = vp->g.nid;
3789  strcpy(info->name, vp->g.name.orig);
3790  } else
3791  rsts = GDH__NOSUCHVOL;
3792  }
3793  gdh_ScopeUnlock;
3794 
3795  return rsts;
3796 }
3797 
3802  )
3803 {
3804  *vid = gdbroot->my_volume->g.vid;
3805  return GDH__SUCCESS;
3806 }
3807 
3808 pwr_tStatus gdh_GetObjectBodyDef(
3809  pwr_tCid cid, gdh_sAttrDef** bodydef, int* rows, pwr_tOid oid)
3810 {
3811  gdb_sClass* cp;
3812  gdb_sObject* bop;
3813  gdb_sObject* aop;
3814  gdb_sObject* op;
3815  pwr_sParam* adef;
3816  pwr_sObjBodyDef* bdef;
3817  int acnt = 0;
3818  gdh_sAttrDef* bd;
3819  pwr_tStatus sts;
3820  pwr_tStatus rsts = GDH__SUCCESS;
3821  pwr_tOid noid;
3822  gdb_sObject* a_super[20];
3823  int scnt = 0;
3824  int i, j;
3825 
3826  gdh_ScopeLock
3827  {
3828  cp = hash_Search(&sts, gdbroot->cid_ht, &cid);
3829  if (cp == 0) {
3830  rsts = GDH__NOSUCHCLASS;
3831  goto error_sts;
3832  }
3833 
3834  bop = pool_Address(&sts, gdbroot->pool, cp->bor);
3835  if (bop == NULL) {
3836  rsts = GDH__ATTRIBUTE;
3837  goto error_sts;
3838  }
3839 
3840  bdef = pool_Address(NULL, gdbroot->rtdb, bop->u.n.body);
3841  acnt += bdef->NumOfParams;
3842 
3843  /* Count attributes */
3844  a_super[scnt++] = vol_OidToObject(
3845  &sts, bop->g.soid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
3846  while (a_super[scnt - 1]) {
3847  adef = pool_Address(NULL, gdbroot->rtdb, a_super[scnt - 1]->u.n.body);
3848 
3849  if (streq(a_super[scnt - 1]->g.f.name.orig, "Super")
3850  && cdh_tidIsCid(adef->TypeRef)) {
3851  cp = hash_Search(&sts, gdbroot->cid_ht, &adef->TypeRef);
3852 
3853  if (cp == 0) {
3854  if (!cdh_ObjidIsNull(oid)) {
3855  op = vol_OidToObject(
3856  &sts, oid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_none);
3857 
3858  if (!(op->l.flags.m & gdb_mLo_native)) {
3859  cmvolc_GetNonExistingClass(&sts, op, adef->TypeRef);
3860  cp = hash_Search(&sts, gdbroot->cid_ht, &adef->TypeRef);
3861  if (cp == NULL) {
3862  rsts = GDH__NOSUCHCLASS;
3863  goto error_sts;
3864  }
3865  } else {
3866  rsts = GDH__NOSUCHCLASS;
3867  goto error_sts;
3868  }
3869  } else {
3870  rsts = GDH__NOSUCHCLASS;
3871  goto error_sts;
3872  }
3873  }
3874 
3875  bop = pool_Address(&sts, gdbroot->pool, cp->bor);
3876  if (bop == NULL) {
3877  rsts = GDH__ATTRIBUTE;
3878  goto error_sts;
3879  }
3880 
3881  bdef = pool_Address(NULL, gdbroot->rtdb, bop->u.n.body);
3882  acnt += bdef->NumOfParams - 1;
3883 
3884  a_super[scnt++] = vol_OidToObject(
3885  &sts, bop->g.soid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
3886  } else
3887  break;
3888  }
3889 
3890  /* Allocate buffer */
3891  bd = (gdh_sAttrDef*)calloc(acnt, sizeof(gdh_sAttrDef));
3892 
3893  acnt = 0;
3894  for (i = scnt - 1; i >= 0; i--) {
3895  aop = a_super[i];
3896  while (aop) {
3897  adef = pool_Address(NULL, gdbroot->rtdb, aop->u.n.body);
3898  if (!(aop == a_super[i] && streq(aop->g.f.name.orig, "Super"))) {
3899  for (j = 0; j < i; j++)
3900  strcat(bd[acnt].attrName, "Super.");
3901  strcat(bd[acnt].attrName, aop->g.f.name.orig);
3902  bd[acnt].attrClass = aop->g.cid;
3903  bd[acnt].attr = (pwr_uParDef*)adef;
3904  if (i > 0)
3905  bd[acnt].flags = gdh_mAttrDef_Super;
3906  acnt++;
3907  }
3908  noid.vid = aop->g.oid.vid;
3909  noid.oix = aop->g.sib.flink;
3910  aop = vol_OidToObject(
3911  &sts, noid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_next);
3912  if (aop && aop == a_super[i])
3913  break;
3914  }
3915  }
3916 
3917  if (scnt > 1) {
3918  /* Detect shadowed attributes */
3919  for (j = 0; j < acnt - 1; j++) {
3920  char* s1 = strrchr(bd[j].attrName, '.');
3921  if (!s1)
3922  s1 = bd[j].attrName;
3923  else
3924  s1++;
3925  for (i = j + 1; i < acnt; i++) {
3926  char* s2 = strrchr(bd[i].attrName, '.');
3927  if (!s2)
3928  s2 = bd[i].attrName;
3929  else
3930  s2++;
3931  if (str_NoCaseStrcmp(s1, s2) == 0) {
3932  bd[j].flags |= gdh_mAttrDef_Shadowed;
3933  break;
3934  }
3935  }
3936  }
3937  }
3938  *bodydef = bd;
3939  *rows = acnt;
3940 
3941  error_sts : {
3942  }
3943  }
3944  gdh_ScopeUnlock;
3945  return rsts;
3946 }
3947 
3948 pwr_tStatus gdh_GetTrueObjectBodyDef(
3949  pwr_tCid cid, gdh_sAttrDef** bodydef, int* rows)
3950 {
3951  gdb_sClass* cp;
3952  gdb_sObject* bop;
3953  gdb_sObject* aop;
3954  pwr_sParam* adef;
3955  pwr_sObjBodyDef* bdef;
3956  int acnt = 0;
3957  gdh_sAttrDef* bd;
3958  pwr_tStatus sts;
3959  pwr_tStatus rsts = GDH__SUCCESS;
3960  pwr_tOid noid;
3961 
3962  gdh_ScopeLock
3963  {
3964  cp = hash_Search(&sts, gdbroot->cid_ht, &cid);
3965  if (cp == 0) {
3966  rsts = GDH__NOSUCHCLASS;
3967  goto error_sts;
3968  }
3969 
3970  bop = pool_Address(&sts, gdbroot->pool, cp->bor);
3971  if (bop == NULL) {
3972  rsts = GDH__ATTRIBUTE;
3973  goto error_sts;
3974  }
3975 
3976  bdef = pool_Address(NULL, gdbroot->rtdb, bop->u.n.body);
3977  acnt = bdef->NumOfParams;
3978 
3979  /* Allocate buffer */
3980  bd = (gdh_sAttrDef*)calloc(acnt, sizeof(gdh_sAttrDef));
3981 
3982  acnt = 0;
3983  aop = vol_OidToObject(
3984  &sts, bop->g.soid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
3985  while (aop) {
3986  adef = pool_Address(NULL, gdbroot->rtdb, aop->u.n.body);
3987  strcpy(bd[acnt].attrName, aop->g.f.name.orig);
3988  bd[acnt].attrClass = aop->g.cid;
3989  bd[acnt].attr = (pwr_uParDef*)adef;
3990  acnt++;
3991 
3992  noid.vid = aop->g.oid.vid;
3993  noid.oix = aop->g.sib.flink;
3994  aop = vol_OidToObject(
3995  &sts, noid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_next);
3996  if (aop->g.oid.oix == bop->g.soid.oix)
3997  break;
3998  }
3999  *bodydef = bd;
4000  *rows = acnt;
4001 
4002  error_sts : {
4003  }
4004  }
4005  gdh_ScopeUnlock;
4006  return rsts;
4007 }
4008 
4009 pwr_tStatus gdh_GetAttrRefAdef(pwr_sAttrRef* arp, gdh_sAttrDef* attrdef)
4010 {
4011  pwr_sParam* adef;
4012  mvol_sAttribute Attribute;
4013  mvol_sAttribute* ap;
4014  pwr_tStatus sts;
4015  pwr_tStatus rsts = GDH__SUCCESS;
4016 
4017  gdh_ScopeLock
4018  {
4019  ap = vol_ArefToAttribute(
4020  &sts, &Attribute, arp, gdb_mLo_global, vol_mTrans_all);
4021  if (ap == NULL)
4022  rsts = GDH__ATTRIBUTE;
4023  else {
4024  touchObject(ap->op);
4025 
4026  adef = pool_Address(NULL, gdbroot->rtdb, ap->aop->u.n.body);
4027  strcpy(attrdef->attrName, ap->aop->g.f.name.orig);
4028  attrdef->attrClass = ap->aop->g.cid;
4029  attrdef->attr = (pwr_uParDef*)adef;
4030  }
4031  }
4032  gdh_ScopeUnlock;
4033  return rsts;
4034 }
4035 
4055  pwr_tCid* supercid,
4056  pwr_tObjid oid
4057  )
4058 {
4059  gdb_sClass* cp;
4060  gdb_sObject* op;
4061  pwr_tCid sid;
4062  pwr_tStatus sts = GDH__SUCCESS;
4063 
4064  gdh_ScopeLock
4065  {
4066  cp = hash_Search(&sts, gdbroot->cid_ht, &cid);
4067  if (cp) {
4068  if (!(cp->attr[0].flags.m & PWR_MASK_SUPERCLASS))
4069  sts = GDH__NOSUCHCLASS;
4070  else {
4071  sid = *supercid = cp->attr[0].tid;
4072  if (!cdh_ObjidIsNull(oid)) {
4073  op = vol_OidToObject(
4074  &sts, oid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_none);
4075  if (!(op->l.flags.m & gdb_mLo_native)) {
4076  cp = hash_Search(&sts, gdbroot->cid_ht, &sid);
4077  if (cp == NULL) {
4078  cmvolc_GetNonExistingClass(&sts, op, sid);
4079  cp = hash_Search(&sts, gdbroot->cid_ht, &sid);
4080  if (cp == NULL) {
4081  sts = GDH__NOSUCHCLASS;
4082  }
4083  }
4084  }
4085  }
4086  }
4087  } else if (!cdh_ObjidIsNull(oid)) {
4088  op = vol_OidToObject(
4089  &sts, oid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_none);
4090  cmvolc_GetNonExistingClass(&sts, op, cid);
4091  cp = hash_Search(&sts, gdbroot->cid_ht, &cid);
4092  if (cp) {
4093  if (!(cp->attr[0].flags.m & PWR_MASK_SUPERCLASS))
4094  sts = GDH__NOSUCHCLASS;
4095  else
4096  *supercid = cp->attr[0].tid;
4097  } else {
4098  sts = GDH__NOSUCHCLASS;
4099  }
4100  }
4101  }
4102  gdh_ScopeUnlock;
4103 
4104  return sts;
4105 }
4106 
4118  gdh_sValueDef** vd,
4119  int* rows
4120  )
4121 {
4122  gdb_sObject* top;
4123  gdb_sObject* vop;
4124  pwr_tOid valoid;
4125  int vcnt;
4126  pwr_tStatus sts = GDH__SUCCESS;
4127  pwr_sValue* valp;
4128 
4129  gdh_ScopeLock
4130  {
4131  top = vol_OidToObject(&sts, cdh_TypeIdToObjid(tid), gdb_mLo_local,
4132  vol_mTrans_none, cvol_eHint_none);
4133  if (top == NULL)
4134  goto error_sts;
4135  if (!top->g.flags.b.isParent) {
4136  sts = GDH__NOSUCHOBJ;
4137  goto error_sts;
4138  }
4139 
4140  vcnt = 0;
4141  valoid = top->g.soid;
4142  while (1) {
4143  vop = vol_OidToObject(
4144  &sts, valoid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
4145  if (vop == NULL)
4146  goto error_sts;
4147 
4148  if (vop->g.cid == pwr_eClass_Value)
4149  vcnt++;
4150 
4151  valoid.oix = vop->g.sib.flink;
4152 
4153  if (valoid.oix == top->g.soid.oix)
4154  break;
4155  }
4156 
4157  /* Allocate buffer */
4158  *vd = (gdh_sValueDef*)calloc(vcnt, sizeof(gdh_sValueDef));
4159  *rows = vcnt;
4160 
4161  vcnt = 0;
4162  valoid = top->g.soid;
4163 
4164  while (1) {
4165  vop = vol_OidToObject(
4166  &sts, valoid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
4167  if (vop == NULL)
4168  goto error_sts;
4169 
4170  if (vop->g.cid == pwr_eClass_Value) {
4171  valp = (pwr_sValue*)vol_ObjectToAddress(&sts, vop);
4172  if (valp == NULL)
4173  goto error_sts;
4174 
4175  strcpy((*vd)[vcnt].Name, vop->g.f.name.orig);
4176  (*vd)[vcnt].Value = valp;
4177  vcnt++;
4178  }
4179 
4180  valoid.oix = vop->g.sib.flink;
4181 
4182  if (valoid.oix == top->g.soid.oix)
4183  break;
4184  }
4185  error_sts : {
4186  }
4187  }
4188  gdh_ScopeUnlock;
4189 
4190  return sts;
4191 }
4192 
4204  gdh_sBitDef** bd,
4205  int* rows
4206  )
4207 {
4208  gdb_sObject* top;
4209  gdb_sObject* bop;
4210  pwr_tOid boid;
4211  int bcnt;
4212  pwr_tStatus sts = GDH__SUCCESS;
4213  pwr_sBit* bp;
4214 
4215  gdh_ScopeLock
4216  {
4217  top = vol_OidToObject(&sts, cdh_TypeIdToObjid(tid), gdb_mLo_local,
4218  vol_mTrans_none, cvol_eHint_none);
4219  if (top == NULL)
4220  goto error_sts;
4221  if (!top->g.flags.b.isParent) {
4222  sts = GDH__NOSUCHOBJ;
4223  goto error_sts;
4224  }
4225 
4226  bcnt = 0;
4227  boid = top->g.soid;
4228 
4229  while (1) {
4230  bop = vol_OidToObject(
4231  &sts, boid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
4232  if (bop == NULL)
4233  goto error_sts;
4234 
4235  if (bop->g.cid == pwr_eClass_Bit)
4236  bcnt++;
4237 
4238  boid.oix = bop->g.sib.flink;
4239 
4240  if (boid.oix == top->g.soid.oix)
4241  break;
4242  }
4243 
4244  /* Allocate buffer */
4245  *bd = (gdh_sBitDef*)calloc(bcnt, sizeof(gdh_sBitDef));
4246  *rows = bcnt;
4247 
4248  bcnt = 0;
4249  boid = top->g.soid;
4250  while (1) {
4251  bop = vol_OidToObject(
4252  &sts, boid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
4253  if (bop == NULL)
4254  goto error_sts;
4255 
4256  if (bop->g.cid == pwr_eClass_Bit) {
4257  bp = (pwr_sBit*)vol_ObjectToAddress(&sts, bop);
4258  if (bp == NULL)
4259  goto error_sts;
4260 
4261  strcpy((*bd)[bcnt].Name, bop->g.f.name.orig);
4262  (*bd)[bcnt].Bit = bp;
4263  bcnt++;
4264  }
4265 
4266  boid.oix = bop->g.sib.flink;
4267 
4268  if (boid.oix == top->g.soid.oix)
4269  break;
4270  }
4271  error_sts : {
4272  }
4273  }
4274  gdh_ScopeUnlock;
4275 
4276  return sts;
4277 }
4278 
4284  pwr_tDisableAttr* disabled
4285  )
4286 {
4287  pwr_tStatus sts;
4288  pwr_sAttrRef daref;
4289  mvol_sAttribute* ap;
4290  mvol_sAttribute attribute;
4291 
4292  gdh_ScopeLock
4293  {
4294  memset(&attribute, 0, sizeof(attribute));
4295 
4296  ap = vol_ArefToAttribute(
4297  &sts, &attribute, arp, gdb_mLo_global, vol_mTrans_all);
4298  if (ap != NULL)
4299  touchObject(ap->op);
4300  }
4301  gdh_ScopeUnlock;
4302 
4303  if (ap != 0 && ap->adef != 0 && ap->adef->Info.Flags & PWR_MASK_DISABLEATTR) {
4304  daref = cdh_ArefToDisableAref(arp);
4305  sts = gdh_GetObjectInfoAttrref(&daref, disabled, sizeof(*disabled));
4306  return sts;
4307  } else
4308  return GDH__NOATTR;
4309 }
4310 
4311 pwr_tStatus gdh_FWriteObjectR(
4312  FILE* fp, char* ap, char* aname, pwr_tAttrRef* arp, pwr_tCid cid)
4313 {
4314  pwr_tOName name;
4315  char value_str[512];
4316  gdh_sAttrDef* bd;
4317  int i, j, rows, elements;
4318  char idx[20];
4319  pwr_tStatus sts;
4320  pwr_tAttrRef aref;
4321  int len;
4322  char attrName[40];
4323 
4324  sts = gdh_GetObjectBodyDef(cid, &bd, &rows, arp->Objid);
4325  if (EVEN(sts))
4326  return sts;
4327 
4328  for (i = 0; i < rows; i++) {
4329  if (bd[i].attr->Param.Info.Flags & PWR_MASK_RTVIRTUAL
4330  || (bd[i].attr->Param.Info.Flags & PWR_MASK_PRIVATE
4331  && bd[i].attr->Param.Info.Flags & PWR_MASK_POINTER))
4332  continue;
4333 
4334  strcpy(name, aname);
4335  strcat(name, ".");
4336  strcat(name, bd[i].attrName);
4337  strcpy(attrName, bd[i].attrName);
4338 
4339  if (bd[i].attr->Param.Info.Flags & PWR_MASK_ARRAY)
4340  elements = bd[i].attr->Param.Info.Elements;
4341  else
4342  elements = 1;
4343 
4344  for (j = 0; j < elements; j++) {
4345  if (bd[i].attr->Param.Info.Flags & PWR_MASK_ARRAY) {
4346  sprintf(idx, "[%d]", j);
4347  strcpy(name, aname);
4348  strcat(name, ".");
4349  strcat(name, bd[i].attrName);
4350  strcat(name, idx);
4351  strcpy(attrName, bd[i].attrName);
4352  strcat(attrName, idx);
4353  }
4354 
4355  sts = gdh_ArefANameToAref(arp, attrName, &aref);
4356  if (EVEN(sts))
4357  return sts;
4358 
4359  if (bd[i].attr->Param.Info.Flags & PWR_MASK_CLASS) {
4360  sts = gdh_FWriteObjectR(fp, ap + bd[i].attr->Param.Info.Offset
4361  + j * bd[i].attr->Param.Info.Size / elements,
4362  name, &aref, bd[i].attr->Param.Info.Type);
4363  } else {
4364  sts = gdh_AttrValueToString(bd[i].attr->Param.Info.Type,
4365  bd[i].attr->Param.TypeRef, ap + bd[i].attr->Param.Info.Offset
4366  + j * bd[i].attr->Param.Info.Size / elements,
4367  value_str, sizeof(value_str), &len, 0);
4368  if (ODD(sts)) {
4369  switch (bd[i].attr->Param.Info.Type) {
4370  case pwr_eType_String:
4371  case pwr_eType_Text:
4372  case pwr_eType_Objid:
4373  case pwr_eType_AttrRef:
4374  case pwr_eType_ClassId:
4375  case pwr_eType_TypeId:
4376  case pwr_eType_CastId:
4377  case pwr_eType_Time:
4378  fprintf(fp, "%s \"%s\"\n", &name[1], value_str);
4379  break;
4380  default:
4381  fprintf(fp, "%s %s\n", &name[1], value_str);
4382  break;
4383  }
4384  } else {
4385  fprintf(fp, "# %s Value could not be converted\n", &name[1]);
4386  }
4387  }
4388  }
4389  }
4390  free(bd);
4391 
4392  return GDH__SUCCESS;
4393 }
4394 
4405  pwr_tAttrRef* arp
4406  )
4407 {
4408  pwr_tFileName fname;
4409  FILE* fp;
4410  char* ap;
4411  pwr_tStatus sts;
4412  pwr_tTid tid;
4413 
4414  sts = gdh_GetAttrRefTid(arp, &tid);
4415  if (EVEN(sts))
4416  return sts;
4417 
4418  if (!cdh_tidIsCid(tid))
4419  return GDH__NOOBJECT;
4420 
4421  if (arp->Flags.b.Object && arp->Size == 0) {
4422  sts = gdh_GetObjectSize(arp->Objid, &arp->Size);
4423  if (EVEN(sts))
4424  return sts;
4425  } else if (arp->Size == 0)
4426  return GDH__BADARG;
4427 
4428  ap = calloc(1, arp->Size);
4429  if (!ap)
4430  return GDH__INSVIRMEM;
4431 
4432  sts = gdh_GetObjectInfoAttrref(arp, ap, arp->Size);
4433  if (EVEN(sts))
4434  return sts;
4435 
4436  dcli_translate_filename(fname, filename);
4437  fp = fopen(fname, "w");
4438  if (!fp)
4439  return GDH__FILE;
4440 
4441  sts = gdh_FWriteObjectR(fp, ap, "", arp, tid);
4442 
4443  fclose(fp);
4444  free(ap);
4445  return sts;
4446 }
4447 
4460  pwr_tAttrRef* arp
4461  )
4462 {
4463  pwr_tFileName fname;
4464  FILE* fp;
4465  char* ap;
4466  pwr_tStatus sts;
4467  pwr_tTid tid;
4468  char line[512];
4469  char line_elem[2][512];
4470  int nr;
4471  pwr_tTypeId a_tid;
4472  unsigned int a_size;
4473  unsigned int a_offs;
4474  unsigned int a_elem;
4475  char buffer[512];
4476  pwr_tAttrRef aref;
4477 
4478  sts = gdh_GetAttrRefTid(arp, &tid);
4479  if (EVEN(sts))
4480  return sts;
4481 
4482  if (!cdh_tidIsCid(tid))
4483  return GDH__NOOBJECT;
4484 
4485  sts = gdh_AttrRefToPointer(arp, (void**)&ap);
4486  if (EVEN(sts))
4487  return sts;
4488 
4489  dcli_translate_filename(fname, filename);
4490  fp = fopen(fname, "r");
4491  if (!fp)
4492  return GDH__FILE;
4493 
4494  while (dcli_read_line(line, sizeof(line), fp)) {
4495  str_trim(line, line);
4496  if (line[0] == '#')
4497  continue;
4498  if (streq(line, ""))
4499  continue;
4500 
4501  nr = dcli_parse(line, " ", "", (char*)line_elem,
4502  sizeof(line_elem) / sizeof(line_elem[0]), sizeof(line_elem[0]), 1);
4503  if (nr != 2)
4504  continue;
4505 
4506  sts = gdh_ArefANameToAref(arp, line_elem[0], &aref);
4507  if (EVEN(sts))
4508  continue;
4509 
4510  sts = gdh_GetAttributeCharAttrref(&aref, &a_tid, &a_size, &a_offs, &a_elem);
4511  if (EVEN(sts))
4512  continue;
4513 
4514  switch (a_tid) {
4515  case pwr_eType_String:
4516  case pwr_eType_Text:
4517  case pwr_eType_Objid:
4518  case pwr_eType_AttrRef:
4519  case pwr_eType_ClassId:
4520  case pwr_eType_TypeId:
4521  case pwr_eType_CastId:
4522  case pwr_eType_Time:
4523  if (line_elem[1][0] == '"'
4524  && line_elem[1][strlen(line_elem[1]) - 1] == '"') {
4525  line_elem[1][strlen(line_elem[1]) - 1] = 0;
4526  sts = gdh_AttrStringToValue(
4527  a_tid, &line_elem[1][1], buffer, sizeof(buffer), a_size);
4528  } else
4529  sts = gdh_AttrStringToValue(
4530  a_tid, line_elem[1], buffer, sizeof(buffer), a_size);
4531  break;
4532  default:
4533  sts = gdh_AttrStringToValue(
4534  a_tid, line_elem[1], buffer, sizeof(buffer), a_size);
4535  }
4536  if (EVEN(sts))
4537  continue;
4538 
4539  sts = gdh_SetObjectInfoAttrref(&aref, buffer, a_size);
4540  }
4541 
4542  fclose(fp);
4543  return sts;
4544 }
4545 
4550  pwr_tTid tid,
4551  void* value_ptr,
4552  char* str,
4553  int size,
4554  int* len,
4555  char* format
4556  )
4557 {
4558  int sts;
4559 
4560  switch (type_id) {
4561  case pwr_eType_Boolean: {
4562  if (!format)
4563  *len = sprintf(str, "%d", *(pwr_tBoolean*)value_ptr);
4564  else
4565  *len = sprintf(str, format, *(pwr_tBoolean*)value_ptr);
4566  break;
4567  }
4568  case pwr_eType_Float32: {
4569  if ( *(float *)value_ptr == FLT_MIN) {
4570  strcpy( str, "FltMin");
4571  *len = strlen(str);
4572  }
4573  else if ( *(float *)value_ptr == -FLT_MIN) {
4574  strcpy( str, "FltNMin");
4575  *len = strlen(str);
4576  }
4577  else if ( *(float *)value_ptr == FLT_MAX) {
4578  strcpy( str, "FltMax");
4579  *len = strlen(str);
4580  }
4581  else if ( *(float *)value_ptr == -FLT_MAX) {
4582  strcpy( str, "FltNMax");
4583  *len = strlen(str);
4584  } else {
4585  if (!format)
4586  *len = sprintf(str, "%.7g", *(float*)value_ptr);
4587  else
4588  *len = sprintf(str, format, *(float*)value_ptr);
4589  }
4590  break;
4591  }
4592  case pwr_eType_Float64: {
4593  if (!format)
4594  *len = sprintf(str, "%.17g", *(double*)value_ptr);
4595  else
4596  *len = sprintf(str, format, *(double*)value_ptr);
4597  break;
4598  }
4599  case pwr_eType_Char: {
4600  if (!format)
4601  *len = sprintf(str, "%c", *(char*)value_ptr);
4602  else
4603  *len = sprintf(str, format, *(char*)value_ptr);
4604  break;
4605  }
4606  case pwr_eType_Int8: {
4607  if (!format)
4608  *len = sprintf(str, "%d", *(char*)value_ptr);
4609  else
4610  *len = sprintf(str, format, *(char*)value_ptr);
4611  break;
4612  }
4613  case pwr_eType_Int16: {
4614  if (!format)
4615  *len = sprintf(str, "%hd", *(short*)value_ptr);
4616  else
4617  *len = sprintf(str, format, *(short*)value_ptr);
4618  break;
4619  }
4620  case pwr_eType_Int32: {
4621  if (*(int*)value_ptr == INT_MIN) {
4622  strcpy(str, "IntMin");
4623  *len = strlen(str);
4624  } else if (*(int*)value_ptr == INT_MAX) {
4625  strcpy(str, "IntMax");
4626  *len = strlen(str);
4627  } else {
4628  if (!format)
4629  *len = sprintf(str, "%d", *(int*)value_ptr);
4630  else
4631  *len = sprintf(str, format, *(int*)value_ptr);
4632  }
4633  break;
4634  }
4635  case pwr_eType_Int64: {
4636  if (!format)
4637  *len = sprintf(str, pwr_dFormatInt64, *(pwr_tInt64*)value_ptr);
4638  else
4639  *len = sprintf(str, format, *(pwr_tInt64*)value_ptr);
4640  break;
4641  }
4642  case pwr_eType_UInt8: {
4643  if (!format)
4644  *len = sprintf(str, "%u", *(unsigned char*)value_ptr);
4645  else
4646  *len = sprintf(str, format, *(unsigned char*)value_ptr);
4647  break;
4648  }
4649  case pwr_eType_UInt16: {
4650  if (!format)
4651  *len = sprintf(str, "%hu", *(unsigned short*)value_ptr);
4652  else
4653  *len = sprintf(str, format, *(unsigned short*)value_ptr);
4654  break;
4655  }
4656  case pwr_eType_UInt32:
4657  case pwr_eType_Mask:
4658  case pwr_eType_DisableAttr: {
4659  if (!format)
4660  *len = sprintf(str, "%u", *(unsigned int*)value_ptr);
4661  else
4662  *len = sprintf(str, format, *(unsigned int*)value_ptr);
4663  break;
4664  }
4665  case pwr_eType_UInt64: {
4666  if (!format)
4667  *len = sprintf(str, pwr_dFormatUInt64, *(pwr_tUInt64*)value_ptr);
4668  else
4669  *len = sprintf(str, format, *(pwr_tUInt64*)value_ptr);
4670  break;
4671  }
4672  case pwr_eType_Enum: {
4673  if (!format)
4674  *len = sprintf(str, "%u", *(unsigned int*)value_ptr);
4675  else
4676  *len = sprintf(str, format, *(unsigned int*)value_ptr);
4677  break;
4678  }
4679  case pwr_eType_String: {
4680  strncpy(str, (char*)value_ptr, size);
4681  str[size - 1] = 0;
4682  *len = strlen(str);
4683  break;
4684  }
4685  case pwr_eType_Text: {
4686  char *s, *t;
4687 
4688  for (s = (char*)value_ptr, t = str; *s != 10 && *s != 0; s++, t++) {
4689  if (t - str >= size - 1)
4690  break;
4691  *t = *s;
4692  }
4693  *t = 0;
4694  *len = strlen(str);
4695  break;
4696  }
4697  case pwr_eType_Objid: {
4698  pwr_tOName hiername;
4699  pwr_tObjid objid;
4700 
4701  objid = *(pwr_tObjid*)value_ptr;
4702  if (!objid.oix)
4703  sts = gdh_ObjidToName(
4704  objid, hiername, sizeof(hiername), cdh_mName_volumeStrict);
4705  else
4706  sts = gdh_ObjidToName(objid, hiername, sizeof(hiername), cdh_mNName);
4707  if (EVEN(sts)) {
4708  strcpy(str, "");
4709  *len = 0;
4710  break;
4711  }
4712  *len = sprintf(str, "%s", hiername);
4713  break;
4714  }
4715  case pwr_eType_AttrRef: {
4716  pwr_tAName hiername;
4717  pwr_sAttrRef* attrref;
4718 
4719  attrref = (pwr_sAttrRef*)value_ptr;
4720  sts = gdh_AttrrefToName(attrref, hiername, sizeof(hiername), cdh_mNName);
4721  if (EVEN(sts)) {
4722  strcpy(str, "");
4723  *len = 0;
4724  break;
4725  }
4726  *len = sprintf(str, "%s", hiername);
4727  break;
4728  }
4729  case pwr_eType_DataRef: {
4730  pwr_tAName hiername;
4731  pwr_tDataRef* dataref;
4732 
4733  dataref = (pwr_tDataRef*)value_ptr;
4734  sts = gdh_AttrrefToName(
4735  &dataref->Aref, hiername, sizeof(hiername), cdh_mNName);
4736  if (EVEN(sts)) {
4737  strcpy(str, "");
4738  *len = 0;
4739  break;
4740  }
4741  *len = sprintf(str, "%s", hiername);
4742  break;
4743  }
4744  case pwr_eType_Time: {
4745  char timstr[64];
4746 
4747  if (memcmp(value_ptr, &pwr_cAtMin, sizeof(pwr_tTime)) == 0) {
4748  strcpy(timstr, "AtZero");
4749  sts = GDH__SUCCESS;
4750  } else if (memcmp(value_ptr, &pwr_cAtMax, sizeof(pwr_tTime)) == 0) {
4751  strcpy(timstr, "AtMax");
4752  sts = GDH__SUCCESS;
4753  } else if (format && format[0] == '%' && format[2] == 't') {
4754  switch (format[1]) {
4755  case '1':
4756  // Format %1t, only time, no hundredth
4757  sts = time_AtoAscii(
4758  (pwr_tTime*)value_ptr, time_eFormat_Time, timstr, sizeof(timstr));
4759  timstr[8] = 0;
4760  break;
4761  case '2':
4762  // Format %2t, only time, with hundredth
4763  sts = time_AtoAscii(
4764  (pwr_tTime*)value_ptr, time_eFormat_Time, timstr, sizeof(timstr));
4765  break;
4766  case '3':
4767  // Format %3t, compressed date and time, no hundredth
4768  sts = time_AtoAscii((pwr_tTime*)value_ptr,
4769  time_eFormat_ComprDateAndTime, timstr, sizeof(timstr));
4770  timstr[17] = 0;
4771  break;
4772  case '4':
4773  // Format %4t, date only
4774  sts = time_AtoAscii((pwr_tTime*)value_ptr, time_eFormat_DateAndTime,
4775  timstr, sizeof(timstr));
4776  timstr[11] = 0;
4777  break;
4778  case '5':
4779  // Format %5t, compressed date only
4780  sts = time_AtoAscii((pwr_tTime*)value_ptr,
4781  time_eFormat_ComprDateAndTime, timstr, sizeof(timstr));
4782  timstr[8] = 0;
4783  break;
4784  case '6':
4785  // Format %6t, time before to date
4786  sts = time_AtoAscii((pwr_tTime*)value_ptr, time_eFormat_TimeAndDate,
4787  timstr, sizeof(timstr));
4788  timstr[17] = 0;
4789  break;
4790  default:
4791  sts = time_AtoAscii((pwr_tTime*)value_ptr, time_eFormat_DateAndTime,
4792  timstr, sizeof(timstr));
4793  }
4794  } else
4795  sts = time_AtoAscii((pwr_tTime*)value_ptr, time_eFormat_DateAndTime,
4796  timstr, sizeof(timstr));
4797  if (EVEN(sts))
4798  strcpy(timstr, "-");
4799  *len = sprintf(str, "%s", timstr);
4800  break;
4801  }
4802  case pwr_eType_DeltaTime: {
4803  char timstr[64];
4804 
4805  if (memcmp(value_ptr, &pwr_cDtMin, sizeof(pwr_tDeltaTime)) == 0)
4806  strcpy(timstr, "DtMin");
4807  else if (memcmp(value_ptr, &pwr_cDtMax, sizeof(pwr_tDeltaTime)) == 0)
4808  strcpy(timstr, "DtMax");
4809  else {
4810  sts = time_DtoAscii(
4811  (pwr_tDeltaTime*)value_ptr, 1, timstr, sizeof(timstr));
4812  if (EVEN(sts))
4813  strcpy(timstr, "Undefined time");
4814  }
4815  *len = sprintf(str, "%s", timstr);
4816  break;
4817  }
4818  case pwr_eType_ObjectIx: {
4819  cdh_ObjectIxToString(str, size, *(pwr_tObjectIx*)value_ptr, 1);
4820  *len = strlen(str);
4821  break;
4822  }
4823  case pwr_eType_ClassId: {
4824  pwr_tOName hiername;
4825  pwr_tObjid objid;
4826 
4827  objid = cdh_ClassIdToObjid(*(pwr_tClassId*)value_ptr);
4828  sts = gdh_ObjidToName(objid, hiername, sizeof(hiername), cdh_mNName);
4829  if (EVEN(sts)) {
4830  strcpy(str, "");
4831  *len = 0;
4832  break;
4833  }
4834  *len = sprintf(str, "%s", hiername);
4835  break;
4836  }
4837  case pwr_eType_TypeId:
4838  case pwr_eType_CastId: {
4839  pwr_tOName hiername;
4840  pwr_tObjid objid;
4841 
4842  objid = cdh_TypeIdToObjid(*(pwr_tTypeId*)value_ptr);
4843  sts = gdh_ObjidToName(objid, hiername, sizeof(hiername), cdh_mNName);
4844  if (EVEN(sts)) {
4845  strcpy(str, "");
4846  *len = 0;
4847  break;
4848  }
4849  *len = sprintf(str, "%s", hiername);
4850  break;
4851  }
4852  case pwr_eType_VolumeId: {
4853  cdh_VolumeIdToString(str, size, *(pwr_tVolumeId*)value_ptr, 1, 0);
4854  *len = strlen(str);
4855  break;
4856  }
4857  case pwr_eType_RefId: {
4858  cdh_SubidToString(str, size, *(pwr_tSubid*)value_ptr, 1);
4859  *len = strlen(str);
4860  break;
4861  }
4862  case pwr_eType_NetStatus:
4863  case pwr_eType_Status: {
4864  if (!format)
4865  *len = sprintf(str, "%u", *(unsigned int*)value_ptr);
4866  else
4867  *len = sprintf(str, format, *(unsigned int*)value_ptr);
4868  break;
4869  }
4870  default:
4871  return GDH__CONVERT;
4872  }
4873  return GDH__SUCCESS;
4874 }
4875 
4880  char* value_str,
4881  void* buffer_ptr,
4882  int buff_size,
4883  int attr_size
4884  )
4885 {
4886  int sts;
4887 
4888  switch (type_id) {
4889  case pwr_eType_Boolean: {
4890  if (sscanf(value_str, "%d", (pwr_tBoolean*)buffer_ptr) != 1)
4891  return GDH__CONVERT;
4892  if (*(pwr_tBoolean*)buffer_ptr > 1)
4893  return GDH__CONVERT;
4894  break;
4895  }
4896  case pwr_eType_Float32: {
4897  if (streq(value_str, "FltMin"))
4898  *(float*)buffer_ptr = FLT_MIN;
4899  else if (streq(value_str, "FltNMin"))
4900  *(float*)buffer_ptr = -FLT_MIN;
4901  else if (streq(value_str, "FltMax"))
4902  *(float*)buffer_ptr = FLT_MAX;
4903  else if (streq(value_str, "FltNMax"))
4904  *(float*)buffer_ptr = -FLT_MAX;
4905  else if (sscanf(value_str, "%f", (float*)buffer_ptr) != 1)
4906  return GDH__CONVERT;
4907  break;
4908  }
4909  case pwr_eType_Float64: {
4910  pwr_tFloat64 d;
4911  if (sscanf(value_str, "%lf", &d) != 1)
4912  return GDH__CONVERT;
4913  memcpy(buffer_ptr, (char*)&d, sizeof(d));
4914 
4915  break;
4916  }
4917  case pwr_eType_Char: {
4918  if (sscanf(value_str, "%c", (char*)buffer_ptr) != 1)
4919  return GDH__CONVERT;
4920  break;
4921  }
4922  case pwr_eType_Int8: {
4923  pwr_tInt8 i8;
4924  pwr_tInt16 i16;
4925  if (sscanf(value_str, "%hd", &i16) != 1)
4926  return GDH__CONVERT;
4927  i8 = i16;
4928  memcpy(buffer_ptr, (char*)&i8, sizeof(i8));
4929  break;
4930  }
4931  case pwr_eType_Int16: {
4932  if (sscanf(value_str, "%hd", (short*)buffer_ptr) != 1)
4933  return GDH__CONVERT;
4934  break;
4935  }
4936  case pwr_eType_Int32:
4937  case pwr_eType_Status:
4938  case pwr_eType_NetStatus: {
4939  if (streq(value_str, "IntMin"))
4940  *(int*)buffer_ptr = INT_MIN;
4941  else if (streq(value_str, "IntMax"))
4942  *(int*)buffer_ptr = INT_MAX;
4943  else if (sscanf(value_str, "%d", (int*)buffer_ptr) != 1)
4944  return GDH__CONVERT;
4945  break;
4946  }
4947  case pwr_eType_Int64: {
4948  if (sscanf(value_str, pwr_dFormatInt64, (pwr_tInt64*)buffer_ptr) != 1)
4949  return GDH__CONVERT;
4950  break;
4951  }
4952  case pwr_eType_UInt8: {
4953  pwr_tUInt8 i8;
4954  pwr_tUInt16 i16;
4955  if (sscanf(value_str, "%hu", &i16) != 1)
4956  return GDH__CONVERT;
4957  i8 = i16;
4958  memcpy(buffer_ptr, (char*)&i8, sizeof(i8));
4959  break;
4960  }
4961  case pwr_eType_UInt16: {
4962  if (sscanf(value_str, "%hu", (unsigned short*)buffer_ptr) != 1)
4963  return GDH__CONVERT;
4964  break;
4965  }
4966  case pwr_eType_UInt32:
4967  case pwr_eType_Mask:
4968  case pwr_eType_DisableAttr: {
4969  if (sscanf(value_str, "%lu", (unsigned long*)buffer_ptr) != 1)
4970  return GDH__CONVERT;
4971  break;
4972  }
4973  case pwr_eType_UInt64: {
4974  if (sscanf(value_str, pwr_dFormatUInt64, (pwr_tUInt64*)buffer_ptr) != 1)
4975  return GDH__CONVERT;
4976  break;
4977  }
4978  case pwr_eType_String:
4979  case pwr_eType_Text: {
4980  if ((int)strlen(value_str) >= attr_size)
4981  return GDH__CONVERT;
4982  strncpy((char*)buffer_ptr, value_str,
4983  attr_size < buff_size ? attr_size : buff_size);
4984  break;
4985  }
4986  case pwr_eType_Objid: {
4987  pwr_tObjid objid;
4988 
4989  if (streq(value_str, "0"))
4990  objid = pwr_cNObjid;
4991  else {
4992  sts = gdh_NameToObjid(value_str, &objid);
4993  if (EVEN(sts))
4994  return sts;
4995  }
4996  memcpy(buffer_ptr, &objid, sizeof(objid));
4997  break;
4998  }
4999  case pwr_eType_ClassId: {
5000  pwr_tClassId classid;
5001  pwr_tObjid objid;
5002 
5003  sts = gdh_NameToObjid(value_str, &objid);
5004  if (EVEN(sts))
5005  return sts;
5006  classid = cdh_ClassObjidToId(objid);
5007  memcpy(buffer_ptr, (char*)&classid, sizeof(classid));
5008  break;
5009  }
5010  case pwr_eType_TypeId:
5011  case pwr_eType_CastId: {
5012  pwr_tTypeId val_typeid;
5013  pwr_tObjid objid;
5014 
5015  sts = gdh_NameToObjid(value_str, &objid);
5016  if (EVEN(sts))
5017  return sts;
5018  val_typeid = cdh_TypeObjidToId(objid);
5019  memcpy(buffer_ptr, (char*)&val_typeid, sizeof(val_typeid));
5020  break;
5021  }
5022  case pwr_eType_ObjectIx: {
5023  pwr_tObjectIx objectix;
5024 
5025  sts = cdh_StringToObjectIx(value_str, &objectix);
5026  if (EVEN(sts))
5027  return sts;
5028  memcpy(buffer_ptr, (char*)&objectix, sizeof(objectix));
5029  break;
5030  }
5031  case pwr_eType_VolumeId: {
5032  pwr_tVolumeId volumeid;
5033 
5034  sts = cdh_StringToVolumeId(value_str, &volumeid);
5035  if (EVEN(sts))
5036  return sts;
5037  memcpy(buffer_ptr, (char*)&volumeid, sizeof(volumeid));
5038  break;
5039  }
5040  case pwr_eType_RefId: {
5041  pwr_tRefId subid;
5042 
5043  sts = cdh_StringToSubid(value_str, &subid);
5044  if (EVEN(sts))
5045  return sts;
5046  memcpy(buffer_ptr, (char*)&subid, sizeof(subid));
5047  break;
5048  }
5049  case pwr_eType_AttrRef: {
5050  pwr_sAttrRef attrref;
5051 
5052  if (streq(value_str, "0"))
5053  attrref = pwr_cNAttrRef;
5054  else {
5055  sts = gdh_NameToAttrref(pwr_cNObjid, value_str, &attrref);
5056  if (EVEN(sts))
5057  return sts;
5058  }
5059  memcpy(buffer_ptr, &attrref, sizeof(attrref));
5060  break;
5061  }
5062  case pwr_eType_DataRef: {
5063  pwr_tDataRef dataref;
5064 
5065  sts = gdh_NameToAttrref(pwr_cNObjid, value_str, &dataref.Aref);
5066  if (EVEN(sts))
5067  return sts;
5068  dataref.Ptr = 0;
5069  memcpy(buffer_ptr, &dataref, sizeof(dataref));
5070  break;
5071  }
5072  case pwr_eType_Time: {
5073  pwr_tTime time;
5074 
5075  if (streq(value_str, "AtZero"))
5076  memcpy(buffer_ptr, &pwr_cAtMin, sizeof(pwr_tTime));
5077  else if (streq(value_str, "AtMax"))
5078  memcpy(buffer_ptr, &pwr_cAtMax, sizeof(pwr_tTime));
5079  else {
5080  sts = time_AsciiToA(value_str, &time);
5081  if (EVEN(sts))
5082  return GDH__CONVERT;
5083  memcpy(buffer_ptr, (char*)&time, sizeof(time));
5084  }
5085  break;
5086  }
5087  case pwr_eType_DeltaTime: {
5088  pwr_tDeltaTime deltatime;
5089 
5090  if (streq(value_str, "DtMin"))
5091  memcpy(buffer_ptr, &pwr_cDtMin, sizeof(pwr_tDeltaTime));
5092  else if (streq(value_str, "DtMax"))
5093  memcpy(buffer_ptr, &pwr_cDtMax, sizeof(pwr_tDeltaTime));
5094  else {
5095  sts = time_AsciiToD(value_str, &deltatime);
5096  if (EVEN(sts))
5097  return GDH__CONVERT;
5098  memcpy(buffer_ptr, (char*)&deltatime, sizeof(deltatime));
5099  }
5100  break;
5101  }
5102  case pwr_eType_Enum: {
5103  if (sscanf(value_str, "%lu", (unsigned long*)buffer_ptr) != 1)
5104  return GDH__CONVERT;
5105  break;
5106  }
5107  }
5108  return GDH__SUCCESS;
5109 }
5110 
5111 pwr_tStatus gdh_SearchFile(pwr_tOid oid, char* dir, char* pattern,
5112  pwr_tString40* filelist[], int* filecnt)
5113 {
5114  pwr_tStatus sts;
5115  gdb_sObject* op;
5116  int is_cached = 0;
5117 
5118  if (oid.vid == 0) {
5119  sts = dcli_get_files(dir, pattern, filelist, filecnt);
5120  return sts;
5121  }
5122 
5123  gdh_ScopeLock
5124  {
5125  op = vol_OidToObject(
5126  &sts, oid, gdb_mLo_global, vol_mTrans_all, cvol_eHint_none);
5127 
5128  if (op->l.flags.b.isCached) {
5129  is_cached = 1;
5130  cvolc_FileList(&sts, op, dir, pattern, filelist, filecnt);
5131  }
5132  }
5133  gdh_ScopeUnlock;
5134 
5135  if (!is_cached)
5136  sts = dcli_get_files(dir, pattern, filelist, filecnt);
5137  return sts;
5138 }
5139 
5140 pwr_tStatus gdh_SetObjectReadOnly(pwr_tOid oid)
5141 {
5142  pwr_tStatus sts = GDH__SUCCESS;
5143  gdb_sObject* op;
5144 
5145  gdh_ScopeLock
5146  {
5147  op = vol_OidToObject(
5148  &sts, oid, gdb_mLo_native, vol_mTrans_all, cvol_eHint_none);
5149  if (op == NULL)
5150  break;
5151 
5152  op->u.n.lflags.b.readOnly = 1;
5153  }
5154  gdh_ScopeUnlock;
5155 
5156  return sts;
5157 }
5158 
5166  pwr_sSecurity* security
5167  )
5168 {
5169  pwr_tStatus sts;
5170  pwr_tAttrRef aref;
5171  pwr_tOid oid;
5172  pwr_tCid cid;
5173  pwr_tOName name;
5174 
5175  sts = gdh_ObjidToName(
5176  gdbroot->db->nod_oid, name, sizeof(name), cdh_mName_volumeStrict);
5177  if (EVEN(sts))
5178  return sts;
5179  strcat(name, "-Security");
5180 
5181  sts = gdh_NameToObjid(name, &oid);
5182  if (EVEN(sts))
5183  return sts;
5184 
5185  sts = gdh_GetObjectClass(oid, &cid);
5186  if (EVEN(sts))
5187  return sts;
5188 
5189  if (cid != pwr_eClass_Security)
5190  return GDH__NOSUCHOBJ;
5191 
5192  aref = cdh_ObjidToAref(oid);
5193  return gdh_GetObjectInfoAttrref(&aref, security, sizeof(*security));
5194 }
5195 
5196 void gdh_RegisterLogFunction(void (*func)(char*, void*, unsigned int))
5197 {
5198  gdh_log_cb = func;
5199 }
5200 
5201 pwr_tStatus gdh_GetSubClassList(pwr_tCid cid, pwr_tCid* subcid)
5202 {
5203  return gdh_GetNextSubClass(cid, 0, subcid);
5204 }
5205 
5206 pwr_tStatus gdh_GetNextSubClass(
5207  pwr_tCid cid, pwr_tCid psubcid, pwr_tCid* subcid)
5208 {
5209  pwr_tStatus sts;
5210  pwr_tOid oid;
5211  pwr_tCid cd_cid;
5212  pwr_tCid super_cid;
5213 
5214  if (psubcid == 0)
5215  sts = gdh_GetClassList(pwr_eClass_ClassDef, &oid);
5216  else {
5217  oid = cdh_ClassIdToObjid(psubcid);
5218  sts = gdh_GetNextObject(oid, &oid);
5219  }
5220  for (; ODD(sts); sts = gdh_GetNextObject(oid, &oid)) {
5221  cd_cid = cdh_ClassObjidToId(oid);
5222 
5223  sts = gdh_GetSuperClass(cd_cid, &super_cid, pwr_cNOid);
5224  if (EVEN(sts))
5225  continue;
5226 
5227  if (super_cid == cid) {
5228  *subcid = cd_cid;
5229  return GDH__SUCCESS;
5230  }
5231  }
5232  return GDH__NOSUCHCLASS;
5233 }
5234 
5235 pwr_tStatus gdh_GetGlobalClassList(int cidcnt, pwr_tCid* cid, int attrobjects,
5236  pwr_tAttrRef* classlist[], int* listcnt)
5237 {
5238  pwr_tStatus sts;
5239  qcom_sNode mynode, node;
5240  pwr_tNid nid;
5241  pwr_tAttrRef* clist;
5242  int ccnt;
5243  int i;
5244  pwr_tObjid oid;
5245  pwr_tAttrRef aref;
5246 
5247  array_tCtx arr = array_New(sizeof(pwr_tAttrRef), 20);
5248 
5249  /* Add local objects */
5250  if (attrobjects) {
5251  for (i = 0; i < cidcnt; i++) {
5252  for (sts = gdh_GetClassListAttrRef(cid[i], &aref); ODD(sts);
5253  sts = gdh_GetNextAttrRef(cid[i], &aref, &aref)) {
5254  array_Push(arr, &aref);
5255  }
5256  }
5257  } else {
5258  for (i = 0; i < cidcnt; i++) {
5259  for (sts = gdh_GetClassList(cid[i], &oid); ODD(sts);
5260  sts = gdh_GetNextObject(oid, &oid)) {
5261  aref = cdh_ObjidToAref(oid);
5262  array_Push(arr, &aref);
5263  }
5264  }
5265  }
5266 
5267  qcom_MyNode(&sts, &mynode);
5268  for (nid = qcom_cNNid; qcom_NextNode(&sts, &node, nid); nid = node.nid) {
5269  if (node.nid == mynode.nid)
5270  continue;
5271 
5272  cvolc_ClassList(&sts, node.nid, cidcnt, cid, attrobjects, &clist, &ccnt);
5273  if (EVEN(sts))
5274  continue;
5275 
5276  array_Concat(arr, clist, ccnt);
5277  }
5278 
5279  if (arr->size)
5280  *classlist = array_Copy(arr);
5281  else {
5282  *classlist = 0;
5283  sts = GDH__NOSUCHOBJ;
5284  }
5285  *listcnt = arr->size;
5286 
5287  array_Delete(arr);
5288  return GDH__SUCCESS;
5289 }
5290 
5291 pwr_tStatus gdh_GetLocalClassList(int cidcnt, pwr_tCid* cid, int attrobjects,
5292  pwr_tAttrRef* classlist[], int* listcnt)
5293 {
5294  pwr_tStatus sts;
5295  int i;
5296  pwr_tObjid oid;
5297  pwr_tAttrRef aref;
5298 
5299  array_tCtx arr = array_New(sizeof(pwr_tAttrRef), 20);
5300 
5301  /* Add local objects */
5302  if (attrobjects) {
5303  for (i = 0; i < cidcnt; i++) {
5304  for (sts = gdh_GetClassListAttrRef(cid[i], &aref); ODD(sts);
5305  sts = gdh_GetNextAttrRef(cid[i], &aref, &aref)) {
5306  array_Push(arr, &aref);
5307  }
5308  }
5309  } else {
5310  for (i = 0; i < cidcnt; i++) {
5311  for (sts = gdh_GetClassList(cid[i], &oid); ODD(sts);
5312  sts = gdh_GetNextObject(oid, &oid)) {
5313  aref = cdh_ObjidToAref(oid);
5314  array_Push(arr, &aref);
5315  }
5316  }
5317  }
5318 
5319  if (arr->size)
5320  *classlist = array_Copy(arr);
5321  else {
5322  *classlist = 0;
5323  sts = GDH__NOSUCHOBJ;
5324  }
5325  *listcnt = arr->size;
5326 
5327  array_Delete(arr);
5328  return GDH__SUCCESS;
5329 }
5330 
5331 pwr_tStatus gdh_CheckLocalObject(pwr_tOid oid)
5332 {
5333  pwr_tStatus sts;
5334  gdb_sObject *op;
5335 
5336  gdh_ScopeLock {
5337  op = vol_OidToObject(&sts, oid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
5338  } gdh_ScopeUnlock;
5339 
5340  if (op == NULL)
5341  return sts;
5342  return GDH__SUCCESS;
5343 }
5344 
5345 pwr_tStatus gdh_TidToType(pwr_tTid tid, pwr_eType *type)
5346 {
5347  pwr_tOid oid = cdh_TypeIdToObjid(tid);
5348  pwr_eType *p;
5349  gdb_sObject *op;
5350  pwr_tStatus sts = GDH__SUCCESS;
5351 
5352  gdh_ScopeLock
5353  {
5354  op = vol_OidToObject(
5355  &sts, oid, gdb_mLo_native, vol_mTrans_all, cvol_eHint_none);
5356  if (op != NULL) {
5357  p = (pwr_eType *)vol_ObjectToAddress(&sts, op);
5358  if ( p != NULL)
5359  *type = *p;
5360  }
5361  }
5362  gdh_ScopeUnlock;
5363 
5364  return sts;
5365 }
5366 
5367 pwr_tStatus gdh_MountDynClients(void)
5368 {
5369  gdb_sObject *op;
5370  pwr_tOid oid;
5371  pwr_tStatus sts = GDH__SUCCESS;
5372 
5373  for (sts = gdh_GetClassList(pwr_eClass_MountDynObject, &oid);
5374  ODD(sts);
5375  sts = gdh_GetNextObject(oid, &oid)) {
5376 
5377  gdh_ScopeLock
5378  {
5379  op = vol_OidToObject(&sts, oid, gdb_mLo_native, vol_mTrans_none,
5380  cvol_eHint_none);
5381  if (cdh_ObjidIsNull(op->g.soid))
5382  vol_MountDynObject(&sts, op);
5383  }
5384  gdh_ScopeUnlock;
5385  }
5386  return sts;
5387 }
5388 
5389 
5397 void gdh_GetTimeDL(pwr_tTime* atp,
5398  pwr_tTime* time
5399  )
5400 {
5401  lck_Lock(lck_eLock_Time);
5402  *time = *atp;
5403  lck_Unlock(lck_eLock_Time);
5404 }
5405 
5413 void gdh_SetTimeDL(pwr_tTime* atp,
5414  pwr_tTime* time
5415  )
5416 {
5417  if (time) {
5418  lck_Lock(lck_eLock_Time);
5419  *atp = *time;
5420  lck_Unlock(lck_eLock_Time);
5421  } else {
5422  /* Set current time */
5423  lck_Lock(lck_eLock_Time);
5424  time_GetTime(atp);
5425  lck_Unlock(lck_eLock_Time);
5426  }
5427 }
5428 
5437  pwr_tDeltaTime* dtp,
5438  pwr_tDeltaTime* time
5439  )
5440 {
5441  lck_Lock(lck_eLock_Time);
5442  *time = *dtp;
5443  lck_Unlock(lck_eLock_Time);
5444 }
5445 
5454  pwr_tDeltaTime* dtp,
5455  pwr_tDeltaTime* time
5456  )
5457 {
5458  lck_Lock(lck_eLock_Time);
5459  *dtp = *time;
5460  lck_Unlock(lck_eLock_Time);
5461 }
5462 
5470 void gdh_GetStrDL(char* sp,
5471  char* str,
5472  int size
5473  )
5474 {
5475  lck_Lock(lck_eLock_Str);
5476  strncpy(str, sp, size);
5477  lck_Unlock(lck_eLock_Str);
5478 }
5479 
5487 void gdh_SetStrDL(char* sp,
5488  const char* str,
5489  int size
5490  )
5491 {
5492  lck_Lock(lck_eLock_Str);
5493  strncpy(sp, str, size);
5494  lck_Unlock(lck_eLock_Str);
5495 }
5496 
5507  pwr_tTime* time
5508  )
5509 {
5510  pwr_tStatus sts;
5511 
5512  lck_Lock(lck_eLock_Time);
5513  sts = gdh_GetObjectInfo(name, (pwr_tAddress)time, sizeof(pwr_tTime));
5514  lck_Unlock(lck_eLock_Time);
5515  return sts;
5516 }
5517 
5528  pwr_tTime* time
5529  )
5530 {
5531  pwr_tStatus sts;
5532 
5533  lck_Lock(lck_eLock_Time);
5534  sts = gdh_SetObjectInfo(name, (void*)time, sizeof(pwr_tTime));
5535  lck_Unlock(lck_eLock_Time);
5536  return sts;
5537 }
5538 
5549  pwr_tDeltaTime* time
5550  )
5551 {
5552  pwr_tStatus sts;
5553 
5554  lck_Lock(lck_eLock_Time);
5555  sts = gdh_GetObjectInfo(name, (void*)time, sizeof(pwr_tDeltaTime));
5556  lck_Unlock(lck_eLock_Time);
5557  return sts;
5558 }
5559 
5570  pwr_tDeltaTime* time
5571  )
5572 {
5573  pwr_tStatus sts;
5574 
5575  lck_Lock(lck_eLock_Time);
5576  sts = gdh_SetObjectInfo(name, (void*)time, sizeof(pwr_tDeltaTime));
5577  lck_Unlock(lck_eLock_Time);
5578  return sts;
5579 }
5580 
5591  char* str,
5592  int size
5593  )
5594 {
5595  pwr_tStatus sts;
5596 
5597  lck_Lock(lck_eLock_Str);
5598  sts = gdh_GetObjectInfo(name, (void*)str, size);
5599  lck_Unlock(lck_eLock_Str);
5600  return sts;
5601 }
5602 
5613  const char* str,
5614  int size
5615  )
5616 {
5617  pwr_tStatus sts;
5618 
5619  lck_Lock(lck_eLock_Str);
5620  sts = gdh_SetObjectInfo(name, (void*)str, size);
5621  lck_Unlock(lck_eLock_Str);
5622  return sts;
5623 }
5624 
5632 {
5633  gdb_sClass* cp;
5634  pwr_sClassDef *cdef;
5635  pwr_tStatus sts = GDH__SUCCESS;
5636 
5637  gdh_ScopeLock
5638  {
5639  cp = hash_Search(&sts, gdbroot->cid_ht, &cid);
5640  if (cp != NULL)
5641  cdef = pool_Address(NULL, gdbroot->rtdb, cp->cbr);
5642  }
5643  gdh_ScopeUnlock;
5644  if (cdef == NULL)
5645  return sts;
5646 
5647  info->Editor = cdef->Editor;
5648  info->Flags = cdef->Flags;
5649  info->Method = cdef->Method;
5650  info->PopEditor = cdef->PopEditor;
5651 
5652  return GDH__SUCCESS;
5653 }
5654 
5662 {
5663  return gdbroot == 0 ? 0 : 1;
5664 }
Include file for Time management.
#define cdh_tidIsCid(Tid)
Check if type id is a class id.
Definition: co_cdh.h:115
char * cdh_VolumeIdToString(char *s, int size, pwr_tVid vid, int prefix, int suffix)
Converts a volume identifier, 'vid' to a string.
Definition: co_cdh.c:1401
int cdh_ObjidIsNull(pwr_tOid Object)
Test if object identity is null.
Definition: co_cdh.c:110
void cdh_ObjectIxToString(char *s, int size, pwr_tOix oix, int prefix)
Converts a object index, 'oix' to a string.
Definition: co_cdh.c:1216
pwr_tStatus cdh_StringToVolumeId(const char *s, pwr_tVid *tid)
Convert VolumeId string to id.
Definition: co_cdh.c:995
void cdh_SubidToString(char *s, int size, pwr_tSubid sid, int prefix)
Converts a subscription identifier, 'sid' to a string.
Definition: co_cdh.c:1450
pwr_tStatus cdh_StringToObjectIx(const char *s, pwr_tOix *oix)
Converts ObjectIx string to index.
Definition: co_cdh.c:1042
void cdh_OidToString(char *s, int size, pwr_tOid oid, int prefix)
Converts a object identifier, 'oid' to a string.
Definition: co_cdh.c:1316
pwr_tCid cdh_ClassObjidToId(pwr_tOid Object)
Convert Objid to ClassId.
Definition: co_cdh.c:227
pwr_tOid cdh_ClassIdToObjid(pwr_tCid Class)
Convert ClassId to Objid.
Definition: co_cdh.c:249
pwr_tTid cdh_TypeObjidToId(pwr_tOid Object)
Convert Objid to TypeId.
Definition: co_cdh.c:275
void cdh_ArefToString(char *s, int size, pwr_sAttrRef *aref, int prefix)
Converts an attribute reference , 'aref' to a string.
Definition: co_cdh.c:1231
pwr_sAttrRef cdh_ObjidToAref(pwr_tObjid Objid)
Converts an objid to an attrref.
Definition: co_cdh.c:354
pwr_tOid cdh_TypeIdToObjid(pwr_tTid Type)
Convert TypeId to Objid.
Definition: co_cdh.c:321
@ gdh_mAttrDef_Shadowed
Definition: rt_gdh.h:136
@ gdh_mAttrDef_Super
Definition: rt_gdh.h:137
pwr_tStatus gdh_SubAssociateBuffer(pwr_tSubid sid, void **buffer, unsigned int buffersize)
Associate a buffer with the subscription.
Definition: rt_gdh.c:3186
pwr_tStatus gdh_GetNextSibling(pwr_tObjid oid, pwr_tObjid *new_oid)
Get the object identity of the next sibling (i.e. the next object with the same parent).
Definition: rt_gdh.c:1465
pwr_tStatus gdh_SubRefObjectInfoList(unsigned int nentries, void *object[], pwr_tBoolean is_aref[], pwr_tSubid subid[])
Sets up a list of subscriptions to an object/attribute.
Definition: rt_gdh.c:2844
pwr_tStatus gdh_GetObjectDLCount(pwr_tObjid oid, pwr_tUInt32 *count)
Gets the direct link count of an object.
Definition: rt_gdh.c:1251
pwr_tStatus gdh_SetObjectInfoStr(const char *name, const char *str, int size)
Store a string value in an attribute. Sets the string lock to ensure that the string is not modified ...
Definition: rt_gdh.c:5612
pwr_tStatus gdh_MountObjidToPointer(pwr_tObjid oid, void **p)
Get a pointer to a mount object.
Definition: rt_gdh.c:2464
pwr_tStatus gdh_GetClassList(pwr_tClassId cid, pwr_tObjid *oid)
Get the object identity of the first object in the list of objects of a specified class.
Definition: rt_gdh.c:1627
pwr_tBoolean gdh_IsInitialized()
Check if gdh is initialized. Returns TRUE if gdh is initialized, else FALSE.
Definition: rt_gdh.c:5661
pwr_tStatus gdh_NameToAttrref(pwr_tObjid poid, const char *name, pwr_sAttrRef *arp)
Converts from name string to attribute reference.
Definition: rt_gdh.c:2314
pwr_tStatus gdh_ClassAttrToAttrref(pwr_tClassId cid, const char *name, pwr_sAttrRef *arp)
Converts a class and attribute string to attrref format.
Definition: rt_gdh.c:319
pwr_tStatus gdh_GetEnumValueDef(pwr_tTid tid, gdh_sValueDef **vd, int *rows)
Get definition information for an enumeration type.
Definition: rt_gdh.c:4117
pwr_tStatus gdh_ArefANameToAref(pwr_sAttrRef *arp, const char *aname, pwr_sAttrRef *oarp)
Get the attribute reference for an attribute in an object attribute reference, where the attribute is...
Definition: rt_gdh.c:192
pwr_tStatus gdh_GetObjectInfoAttrref(pwr_sAttrRef *arp, void *bufp, unsigned int bufsize)
Fetch the data of an attribute or a whole object body.
Definition: rt_gdh.c:916
pwr_tStatus gdh_GetObjectInfoStr(const char *name, char *str, int size)
Fetch a string value from an attribute. Sets the string lock to ensure that the string is not modifie...
Definition: rt_gdh.c:5590
pwr_tStatus gdh_NethandlerRunning(void)
Check if the Nethandler has started.
Definition: rt_gdh.c:2284
pwr_tStatus gdh_DeleteObjectTree(pwr_tObjid oid)
Remove a local object tree.
Definition: rt_gdh.c:548
pwr_tStatus gdh_GetMaskBitDef(pwr_tTid tid, gdh_sBitDef **bd, int *rows)
Get definition information for a mask type.
Definition: rt_gdh.c:4203
pwr_tStatus gdh_GetParent(pwr_tObjid oid, pwr_tObjid *new_oid)
Get the object identity of the parent of an object.
Definition: rt_gdh.c:1281
pwr_tStatus gdh_FReadObject(char *filename, pwr_tAttrRef *arp)
Read a textfile into an object.
Definition: rt_gdh.c:4459
pwr_tStatus gdh_GetClassListAttrRef(pwr_tClassId cid, pwr_sAttrRef *arp)
Get the attribute reference of the first object in the list of objects of a specified class....
Definition: rt_gdh.c:1712
void gdh_SetDeltaTimeDL(pwr_tDeltaTime *dtp, pwr_tDeltaTime *time)
Thread save function to store a direct linked delta time value. Sets the time lock to ensure that the...
Definition: rt_gdh.c:5453
pwr_tStatus gdh_GetNextObject(pwr_tObjid oid, pwr_tObjid *new_oid)
Get the object identity of the next object in the list of objects of a certain class.
Definition: rt_gdh.c:1659
pwr_tStatus gdh_ArefDisabled(pwr_sAttrRef *arp, pwr_tDisableAttr *disabled)
Check if an attribute is disabled.
Definition: rt_gdh.c:4283
pwr_tStatus gdh_MoveObject(pwr_tObjid oid, pwr_tObjid poid)
Move a local object.
Definition: rt_gdh.c:2162
pwr_tStatus gdh_GetClassInfo(pwr_tCid cid, gdh_sClassInfo *info)
Get class info. Returns information from $ClassDef object.
Definition: rt_gdh.c:5631
void gdh_DLUnrefObjectInfoAll(void)
Removes all direct links set up by this process.
Definition: rt_gdh.c:656
pwr_tStatus gdh_GetObjectInfo(const char *name, pwr_tAddress bufp, pwr_tUInt32 bufsize)
Fetch data from an object or an attribute.
Definition: rt_gdh.c:789
void gdh_GetTimeDL(pwr_tTime *atp, pwr_tTime *time)
Thread save function to fetch a direct linked absolute time value. Sets the time lock to ensure that ...
Definition: rt_gdh.c:5397
pwr_tStatus gdh_SetAlarmLevel(pwr_tObjid oid, pwr_tUInt32 alarmlevel)
This routine sets the alarm level for a certain object.
Definition: rt_gdh.c:3514
void gdh_SetTimeDL(pwr_tTime *atp, pwr_tTime *time)
Thread save function to store a direct linked absolute time value. Sets the time lock to ensure that ...
Definition: rt_gdh.c:5413
pwr_tStatus gdh_ClassAttrrefToAttr(pwr_tClassId cid, pwr_sAttrRef *arp, char *name, int size)
Get the attribute name from a class and attrref.
Definition: rt_gdh.c:369
pwr_tStatus gdh_SetAlarmBlockLevel(pwr_tObjid oid, pwr_tUInt32 blocklevel)
Sets the alarm block level for a certain object.
Definition: rt_gdh.c:3545
pwr_tStatus gdh_GetChild(pwr_tObjid oid, pwr_tObjid *new_oid)
Get the object identity of the first child of an object.
Definition: rt_gdh.c:1430
pwr_tStatus gdh_GetObjectClass(pwr_tObjid oid, pwr_tClassId *cid)
Get the class identifier of an object.
Definition: rt_gdh.c:1107
pwr_tStatus gdh_SetObjectInfoDeltaTime(const char *name, pwr_tDeltaTime *time)
Store a delta time value in an attribute. Sets the time lock to ensure that the time is not modified ...
Definition: rt_gdh.c:5569
pwr_tStatus gdh_ObjidToPointer(pwr_tObjid oid, void **p)
Gets the address of the data of an object, given its object identity.
Definition: rt_gdh.c:2431
pwr_tStatus gdh_ObjidToName(pwr_tObjid oid, char *namebuf, pwr_tUInt32 size, pwr_tBitMask nametype)
Get the name of an object identified by its object identity.
Definition: rt_gdh.c:2371
pwr_tStatus gdh_SubData(pwr_tSubid sid, void *bp, unsigned int bsize)
Fetch the data associated with a subscription.
Definition: rt_gdh.c:3064
void gdh_SetStrDL(char *sp, const char *str, int size)
Thread save function to store a direct linked string value. Sets the string lock to ensure that the s...
Definition: rt_gdh.c:5487
pwr_tStatus gdh_ClassNameToId(const char *name, pwr_tClassId *cid)
Get the class identity corresponding to a class specified by name.
Definition: rt_gdh.c:413
pwr_tStatus gdh_GetVolumeInfo(pwr_tVid vid, gdh_sVolumeInfo *info)
Get info for a volume.
Definition: rt_gdh.c:3771
pwr_tStatus gdh_GetSecurityInfo(pwr_sSecurity *security)
Get security information.
Definition: rt_gdh.c:5165
pwr_tStatus gdh_UnrefObjectInfoAll(void)
Terminates all subscriptions set up by this process.
Definition: rt_gdh.c:3498
pwr_tStatus gdh_GetNextObjectAttrRef(pwr_tClassId cid, pwr_sAttrRef *arp, pwr_sAttrRef *new_arp)
Get the attrref of the next attribute object of a specified class in a specified object.
Definition: rt_gdh.c:1792
pwr_tStatus gdh_Init(const char *name)
Initialize the process to the Proview runtime environment.
Definition: rt_gdh.c:2065
pwr_tStatus gdh_GetNodeObject(pwr_tNodeId nid, pwr_tObjid *oid)
Return the objid of the node object for a node identified by a node identifier (of type pwr_tNodeId).
Definition: rt_gdh.c:1822
pwr_tStatus gdh_SubRefObjectInfoAttrref(pwr_sAttrRef *aref, pwr_tSubid *sid)
This routine returns a subid to the information that is denoted by 'aref'. The name can be either an ...
Definition: rt_gdh.c:2917
pwr_tStatus gdh_AttrStringToValue(int type_id, char *value_str, void *buffer_ptr, int buff_size, int attr_size)
Convert an attribute string to value.
Definition: rt_gdh.c:4879
pwr_tStatus gdh_AttrrefToName(pwr_sAttrRef *arp, char *name, unsigned int size, pwr_tBitMask nametype)
Translate an attribute referece to a name.
Definition: rt_gdh.c:128
pwr_tStatus gdh_GetAlarmInfo(pwr_tObjid oid, pwr_tUInt32 *a, pwr_tUInt32 *maxa, pwr_tUInt32 *b, pwr_tUInt32 *maxb, pwr_tUInt32 *alarmvisibility)
Get the alarm status for a certain object.
Definition: rt_gdh.c:670
pwr_tStatus gdh_GetObjectInfoDeltaTime(const char *name, pwr_tDeltaTime *time)
Fetch an delta time value from an attribute. Sets the time lock to ensure that the time is not modifi...
Definition: rt_gdh.c:5548
pwr_tStatus gdh_UnrefObjectInfo(pwr_tSubid sid)
Terminates the subscription defined by the subscription identity.
Definition: rt_gdh.c:3470
pwr_tStatus gdh_RefObjectInfo(char *name, void **infop, pwr_tSubid *sid, unsigned int size)
The routine returns an address to the data that is denoted by Name. The name can be either an object ...
Definition: rt_gdh.c:3426
pwr_tStatus gdh_SetObjectInfo(const char *name, void *bufp, unsigned int bufsize)
Change the value of an attribute or the whole body of an object.
Definition: rt_gdh.c:2579
pwr_tStatus gdh_GetPreviousSibling(pwr_tObjid oid, pwr_tObjid *new_oid)
Get the object identity of the previous sibling (i.e. the previous object with the same parent).
Definition: rt_gdh.c:1509
pwr_tStatus gdh_DeleteObject(pwr_tObjid oid)
Remove a local object.
Definition: rt_gdh.c:513
pwr_tStatus gdh_NameToObjid(const char *name, pwr_tObjid *oid)
Get the object identity of an object with name 'name'.
Definition: rt_gdh.c:2202
pwr_tStatus gdh_DLUnrefObjectInfo(pwr_tDlid dlid)
Terminate direct linking of an object or an object attribute.
Definition: rt_gdh.c:637
pwr_tStatus gdh_SubSize(pwr_tSubid sid, unsigned int *size)
Fetch the data size associated with a subscription.
Definition: rt_gdh.c:3150
pwr_tStatus gdh_GetNodeInfo(pwr_tNodeId nid, gdh_sNodeInfo *ip)
Return info for a node identified by a node identifier (of type pwr_tNodeId).
Definition: rt_gdh.c:1854
pwr_tStatus gdh_SubUnrefObjectInfoList(unsigned int nentries, pwr_tSubid *sid)
Terminates a list of subscriptions.
Definition: rt_gdh.c:2970
pwr_tStatus gdh_SubUnrefObjectInfo(pwr_tSubid sid)
Terminates subscription of an object or an attribute.
Definition: rt_gdh.c:3033
pwr_tStatus gdh_GetObjectSize(pwr_tObjid oid, pwr_tUInt32 *size)
Get the size of the body of an object.
Definition: rt_gdh.c:1025
void gdh_StoreRtdbPointer(unsigned long *rp, void *p)
Convert pointer to rtdb relative pointer.
Definition: rt_gdh.c:3572
pwr_tStatus gdh_AttrArefToObjectAref(pwr_sAttrRef *arp, pwr_sAttrRef *oarp)
Get the attribute reference to an object or attribute object, from the attribute reference to an attr...
Definition: rt_gdh.c:257
void gdh_SubUnrefObjectInfoAll(void)
Terminates all subscriptions set up by this user (job/process).
Definition: rt_gdh.c:3052
pwr_tStatus gdh_SetSubscriptionDefaults(pwr_tInt32 dt, pwr_tInt32 tmo)
Sets default subscription timers for future subscription requests.
Definition: rt_gdh.c:3234
pwr_tStatus gdh_GetSubscriptionOldness(pwr_tSubid sid, pwr_tBoolean *old, pwr_tTime *lastupdate, pwr_tStatus *status)
Checks the oldness of a certain subscription.
Definition: rt_gdh.c:1358
pwr_tStatus gdh_GetVolumeList(pwr_tVid *vid)
Get the first volume.
Definition: rt_gdh.c:3678
pwr_tStatus gdh_SetObjectInfoAttrref(pwr_sAttrRef *arp, void *bufp, unsigned int bufsize)
Change the data of an object or an attribute.
Definition: rt_gdh.c:2722
pwr_tStatus gdh_AttrValueToString(pwr_eType type_id, pwr_tTid tid, void *value_ptr, char *str, int size, int *len, char *format)
Convert a string to attribute value.
Definition: rt_gdh.c:4549
pwr_tStatus gdh_GetObjectLocation(pwr_tObjid oid, pwr_tBoolean *location)
Return the location of an object.
Definition: rt_gdh.c:1219
pwr_tStatus gdh_NameToPointer(const char *name, void **p)
Get the address of the data of an object, given its name.
Definition: rt_gdh.c:2240
pwr_tStatus gdh_GetAttributeFlags(pwr_sAttrRef *arp, unsigned int *flags)
Get the flags of an attribute.
Definition: rt_gdh.c:1994
pwr_tStatus gdh_GetAttrRefTid(pwr_sAttrRef *arp, pwr_tTid *tid)
Get the type or class identifier of an attribute reference.
Definition: rt_gdh.c:1145
pwr_tStatus gdh_GetRootList(pwr_tObjid *oid)
Get the first root object in the object tree.
Definition: rt_gdh.c:1571
pwr_tStatus gdh_DLRefObjectInfoAttrref(pwr_sAttrRef *arp, void **infop, pwr_tDlid *dlid)
Request a direct link to the data denoted by an attribute reference.
Definition: rt_gdh.c:578
pwr_tStatus gdh_VolumeIdToName(pwr_tVid vid, char *name, int size)
Get the name for a volume denoted by volume identity.
Definition: rt_gdh.c:3744
void * gdh_TranslateRtdbPointer(unsigned long r)
Convert rtdb relative pointer to absolute pointer.
Definition: rt_gdh.c:3593
void gdh_GetStrDL(char *sp, char *str, int size)
Thread save function to fetch a direct linked string value. Sets the string lock to ensure that the s...
Definition: rt_gdh.c:5470
pwr_tStatus gdh_AttrRefToPointer(pwr_sAttrRef *arp, void **p)
Gets the address of the data of an attribute reference.
Definition: rt_gdh.c:2493
pwr_tStatus gdh_GetObjectClassList(pwr_tCid cid, pwr_tOid oid, pwr_sAttrRef *arp)
Get the attribute reference of the first attribute object of a specified class in the specified objec...
Definition: rt_gdh.c:1768
pwr_tStatus gdh_GetNextAttrRef(pwr_tClassId cid, pwr_sAttrRef *arp, pwr_sAttrRef *new_arp)
Get the attrref of the next object in the list of objects of a certain class. The object can be a sol...
Definition: rt_gdh.c:1742
void gdh_GetDeltaTimeDL(pwr_tDeltaTime *dtp, pwr_tDeltaTime *time)
Thread save function to fetch a direct linked delta time value. Sets the time lock to ensure that the...
Definition: rt_gdh.c:5436
pwr_tStatus gdh_GetObjectInfoTime(const char *name, pwr_tTime *time)
Fetch an absolute time value from an attribute. Sets the time lock to ensure that the time is not mod...
Definition: rt_gdh.c:5506
pwr_tStatus gdh_GetPreviousObject(pwr_tObjid oid, pwr_tObjid *new_oid)
Get the object identity of the previous object in the list of objects of a certain class.
Definition: rt_gdh.c:2031
pwr_tStatus gdh_SubRefObjectInfoName(char *name, pwr_tSubid *sid)
Get the address of the data that is denoted by 'name'.
Definition: rt_gdh.c:2944
pwr_tStatus gdh_GetAttributeCharacteristics(char *name, pwr_tTypeId *tid, pwr_tUInt32 *size, pwr_tUInt32 *offs, pwr_tUInt32 *elem)
Get the characteristics of an attribute, given its name and the class it belongs to.
Definition: rt_gdh.c:1892
pwr_tStatus gdh_GetNextVolume(pwr_tVid pvid, pwr_tVid *vid)
Get the next volume in the volume list.
Definition: rt_gdh.c:3706
pwr_tStatus gdh_RenameObject(pwr_tObjid oid, char *name)
Rename a local object.
Definition: rt_gdh.c:2534
pwr_tStatus gdh_GetLocalParent(pwr_tObjid oid, pwr_tObjid *new_oid)
Get the object identity of the local parent of an object.
Definition: rt_gdh.c:1320
pwr_tStatus gdh_GetAttributeCharAttrref(pwr_sAttrRef *arp, pwr_tTypeId *tid, unsigned int *size, unsigned int *offs, unsigned int *elem)
Get the characteristics of an attribute.
Definition: rt_gdh.c:1949
pwr_tStatus gdh_GetNodeIndex(pwr_tNodeId *nid)
Get the node identity of the local node.
Definition: rt_gdh.c:729
pwr_tStatus gdh_GetRootVolume(pwr_tVid *vid)
Get info for a volume.
Definition: rt_gdh.c:3801
pwr_tStatus gdh_CreateObject(char *name, pwr_tClassId cid, unsigned int size, pwr_tObjid *oid, pwr_tObjid req_oid, pwr_tBitMask flags, pwr_tObjid soid)
Create an object in a dynamic volume.
Definition: rt_gdh.c:455
pwr_tStatus gdh_RefObjectInfoList(unsigned int n, gdh_sObjRef *objref, pwr_tSubid *sid)
This routine returns addresses to the information that is denoted by "objref[].fullname".
Definition: rt_gdh.c:3265
pwr_tStatus gdh_SetObjectInfoTime(const char *name, pwr_tTime *time)
Store an absolute time value in an attribute. Sets the time lock to ensure that the time is not modif...
Definition: rt_gdh.c:5527
pwr_tStatus gdh_GetDynamicAttrSize(pwr_tObjid oid, char *name, pwr_tUInt32 *size)
Get the size of a dynamic attribute.
Definition: rt_gdh.c:1055
pwr_tStatus gdh_FWriteObject(char *filename, pwr_tAttrRef *arp)
Write the content of an object to textfile.
Definition: rt_gdh.c:4404
pwr_tStatus gdh_GetSuperClass(pwr_tCid cid, pwr_tCid *supercid, pwr_tObjid oid)
Get the superclass for a class.
Definition: rt_gdh.c:4054
pwr_tStatus gdh_GetObjectNodeIndex(pwr_tObjid oid, pwr_tNodeId *nid)
Get the node identity of the owner node of an object.
Definition: rt_gdh.c:750
pwr_tBoolean qcom_NextNode(pwr_tStatus *sts, qcom_sNode *node, pwr_tNodeId nid)
Get the next qcom node. If nid is pwr_cNNodeId the first node is returned.
Definition: rt_qcom.c:565
pwr_tBoolean qcom_MyNode(pwr_tStatus *sts, qcom_sNode *node)
Get the local qcom node.
Definition: rt_qcom.c:496
@ time_eFormat_ComprDateAndTime
Date and time compressed format, 70-01-01 00:00:00.
Definition: co_time.h:76
@ time_eFormat_TimeAndDate
Time and date format, 01:00:00 30/01/87.
Definition: co_time.h:83
@ time_eFormat_Time
Display time only 01:00:00.00.
Definition: co_time.h:75
@ 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
int time_GetTime(pwr_tTime *ts)
Get current time.
Definition: co_time.c:1427
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:623
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
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:460
unsigned int pwr_tBitMask
Bitmask type.
Definition: pwr.h:123
#define pwr_cNDlid
Zero direct link identity constant.
Definition: pwr.h:586
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
char pwr_tFileName[255+1]
FileName type.
Definition: pwr.h:398
unsigned int pwr_tCid
Class identity type.
Definition: pwr.h:273
char pwr_tString40[40]
40 byte string type.
Definition: pwr.h:420
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:585
unsigned char pwr_tUInt8
8-bit unsigned integer type.
Definition: pwr.h:225
int pwr_tStatus
Status type.
Definition: pwr.h:284
void * pwr_tAddress
Generic pointer type.
Definition: pwr.h:121
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:618
pwr_tRid pwr_tRefId
Reference identity type.
Definition: pwr.h:310
unsigned int pwr_tTid
Type identity type.
Definition: pwr.h:278
unsigned int pwr_tDisableAttr
DisableAttr type.
Definition: pwr.h:464
pwr_tVolumeId pwr_tNid
Node identity type.
Definition: pwr.h:297
unsigned short pwr_tUInt16
16-bit unsigned integer type.
Definition: pwr.h:229
#define STS_K_INFO
Definition: rt_gdh.c:95
#define STS_K_ERROR
Definition: rt_gdh.c:94
Include file for Gdh Global Data Handler.
Parse name struct.
Definition: co_cdh.h:684
pwr_uParDef * attr
Definition: rt_gdh.h:148
pwr_eClass attrClass
Definition: rt_gdh.h:146
unsigned long flags
Definition: rt_gdh.h:147
pwr_tObjName attrName
Definition: rt_gdh.h:144
pwr_mClassDef Flags
Definition: rt_gdh.h:127
char nodename[32]
Definition: rt_gdh.h:97
pwr_tUInt32 nix
Definition: rt_gdh.h:96
pwr_tUInt32 upcnt
Definition: rt_gdh.h:102
pwr_tObjid objid
Definition: rt_gdh.h:99
pwr_tNodeId nodidx
Definition: rt_gdh.h:95
gdh_eLinkState linkstate
Definition: rt_gdh.h:100
pwr_tTime timedown
Definition: rt_gdh.h:104
pwr_tTime timeup
Definition: rt_gdh.h:103
pwr_tAName fullname
Definition: rt_gdh.h:74
unsigned int bufsize
Definition: rt_gdh.h:76
void * adrs
Definition: rt_gdh.h:75
char name[32]
Definition: rt_gdh.h:116
pwr_tCid cid
Definition: rt_gdh.h:117
pwr_tTime time
Definition: rt_gdh.h:115
pwr_tBoolean isLoaded
Definition: rt_gdh.h:113
pwr_tBoolean isCached
Definition: rt_gdh.h:112
pwr_tNid nid
Definition: rt_gdh.h:118
pwr_tBoolean isMounted
Definition: rt_gdh.h:114
Attribute reference.
Definition: pwr.h:557
pwr_tUInt32 Size
Attribute size.
Definition: pwr.h:561
pwr_tCid Body
Typeid of attribute, body or class.
Definition: pwr.h:559
pwr_tOid Objid
Object identity.
Definition: pwr.h:558
pwr_mAttrRef Flags
Attribute flags.
Definition: pwr.h:562
pwr_tUInt32 Offset
Offset in body.
Definition: pwr.h:560
Delta time type.
Definition: pwr.h:369
Object identity type.
Definition: pwr.h:263
Data for a Qcom node.
Definition: rt_qcom.h:219
pwr_tNodeId nid
node index
Definition: rt_qcom.h:220
Name string format description.
Definition: co_cdh.h:566
struct cdh_mName::@4 b
Bit mask representation.
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
struct pwr_mAttrRef::@1 b
Bitmask representation.