Appendix B C API Code Samples

prevnext

Report Global Objects


Description

This example reports usages of all global objects.

Sample Code

 1	 static void reportGlobalObjects()  {
 2	     UdbEntity    *ents; 
 3	     int          entsSize; 
 4	     UdbReference *refs;  
 5	     int          refsSize;  
 6	     int         i,j;
 7	 
 8	    udbListEntity(&ents, &entsSize);
 9	    udbListEntityFilter (ents, udbKindParse("global object ~static"),
 10	                         &ents, &entsSize);  
 11	    printf ("\nGlobal Objects:\n");
 12	    for (i=0; i<entsSize; i++) {
 13	       printf (" %s \n", udbEntityNameLong(ents[i]) );
 14	       udbListReference(ents[i], &refs, &refsSize);	 
 15	       for (j=0; j<refsSize; j++) {
 16	          printf ("   %s: %s [%s (%d)] \n",
 17	               udbKindShortname(udbReferenceKind(refs[j])),
 18	               udbEntityNameShort(udbReferenceEntity(refs[j])),
 19	               udbEntityNameShort(udbReferenceFile(refs[j])),
 20	               udbReferenceLine(refs[j]) );
 21	      }
 22	      udbListReferenceFree(refs); 
 23	    }
 24	    udbListEntityFree(ents);
 25	 }

Explanation of Sample Code

lines 2-3: Declare variables for list of entities and the list size. In this case, the list will be filtered to include only global objects.

lines 4-5: Declare variables for references for a particular entity, in this case a global object.

line 7: Retrieve list of all entities.

line 8-9: Filter the entity list to contain only global objects, replacing the original entity list with the filtered list.

line 10: Print the header.

line 11: Loop through the list of global objects.

lines 12: Print the name of the global object.

line 13: Retrieve the references for the current global object.

line 14: Loop through all references of the global object.

lines 15-19: Print reference information of the global object, including the kind of reference, the name of the entity being referenced, and the file and line number where the reference occurs.

line 21: Free the Reference list.

line 23: Free the entity list.

Sample Output

 Global Objects:
  _TIFFerrorHandler
    Define: tif_msrc.c [tif_msrc.c (180)]
    Type: TIFFErrorHandler [tif_msrc.c (180)]
    Set: tif_msrc.c [tif_msrc.c (180)]
  PaintX_ProxyFileInfo
    Define: PaintX_p.c [PaintX_p.c (369)]
    Type: ExtendedProxyFileInfo [PaintX_p.c (369)]
    Set: PaintX_p.c [PaintX_p.c (369)]
  INTERNALBPP
    Define: PictureDecoder.cpp [PictureDecoder.cpp (7)]
    Set: PictureDecoder.cpp [PictureDecoder.cpp (7)]
    Use: LoadPicture [PictureDecoder.cpp (41)]
    Use: LoadResPicture [PictureDecoder.cpp (283)]

prevnext


Scientific Toolworks, Inc.
http://www.scitools.com
Voice: (802) 763-2995
Fax: (802) 763-3066
support@scitools.com
sales@scitools.com