home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / snapx2.exe / VWSCMA.EXE / VIEWSCMA.C next >
Text File  |  1995-01-04  |  20KB  |  884 lines

  1. /****************************************************************************
  2. **    File:    VIEWSCMA.C
  3. **
  4. **    Desc:    This program designed to display the NDS Schema. It lists all of
  5. **            classes and the attributes associated with each class. Also 
  6. **            demonstrated is how to add this program to the NWAdmin "Tools"         
  7. **            menu.        
  8. **        
  9. **
  10. **        DISCLAIMER  
  11. **  
  12. **    Novell, Inc. makes no representations or warranties with respect to
  13. **    any NetWare software, and specifically disclaims any express or
  14. **    implied warranties of merchantability, title, or fitness for a
  15. **    particular purpose.  
  16. **
  17. **    Distribution of any NetWare software is forbidden without the
  18. **    express written consent of Novell, Inc.  Further, Novell reserves
  19. **    the right to discontinue distribution of any NetWare software.
  20. **    
  21. **    Novell is not responsible for lost profits or revenue, loss of use
  22. **    of the software, loss of data, costs of re-creating lost data, the
  23. **    cost of any substitute equipment or program, or claims by any party
  24. **    other than you.  Novell strongly recommends a backup be made before
  25. **    any software is installed.   Technical support for this software
  26. **    may be provided at the discretion of Novell.
  27. **
  28. **    Programmers:
  29. **
  30. **        Ini    Who                        Firm
  31. **        -----------------------------------------------------------------------
  32. **        KLB    Karl Bunnell                Novell Developer Support.
  33. **
  34. **    History:
  35. **
  36. **        When        Who    What
  37. **        -----------------------------------------------------------------------
  38. **        10-13-94    klb    First code.
  39. */
  40.  
  41. /****************************************************************************
  42. **    Include headers, macros, function prototypes, etc.
  43. */
  44.  
  45.     /*------------------------------------------------------------------------
  46.     **    ANSI
  47.     */
  48.     #include <windows.h>
  49.     #include <toolhelp.h>
  50.     #include <string.h>
  51.     #include <stdio.h>
  52.  
  53.  
  54.     /*------------------------------------------------------------------------
  55.     **    NetWare
  56.     */
  57.     #include <nwnet.h>
  58.     #include <nwsnapin.h>
  59.     #include "viewscma.h"
  60.  
  61.  
  62.     /*------------------------------------------------------------------------
  63.     **    Prototypes
  64.     */
  65.  
  66.     #ifdef __cplusplus
  67.     extern "C"
  68.     {
  69.     #endif
  70.  
  71.     BOOL FAR PASCAL _export ViewSchemaDlgProc(HWND hDlg, UINT message, UINT wParam,
  72.                                     LONG lParam);
  73.     BOOL FAR PASCAL _export ViewAttrInfoDlgProc(HWND hDlg, UINT message, UINT wParam,
  74.                                         LONG lParam);
  75.  
  76.     N_EXTERN_LIBRARY( void ) ViewSchemaMenuAction(void);
  77.     N_EXTERN_LIBRARY( void ) ViewSchemaMenuValid(pnuint16 pFlags);
  78.     WORD UpdateClassDlgBoxes(HWND hDlg);
  79.     WORD InitClassDefListBox(HWND hDlg);
  80.     OpenAttrInfoDlgBox(HWND hDlg, int SOURCE_DLG);
  81.     ReadAttributeInfo(NWATTR_INFO *attrInfo);
  82.     ReadAllAttributes(HWND hDlg);
  83.     UpdateClassFlags(HWND hDlg, Class_Info_T *classInfo);
  84.     #ifdef __cplusplus           
  85.     }
  86.     #endif
  87.  
  88.     /*------------------------------------------------------------------------
  89.     **    Globals
  90.     */
  91.     HINSTANCE hDLL;
  92.     char      attrNameBuf[MAX_SCHEMA_NAME_BYTES];
  93.     char      classNameBuf[MAX_SCHEMA_NAME_BYTES];
  94.     int      superClassFlag = 0;
  95.     int      updateFlag = 0;
  96.     int      topFlag = 0;
  97.     
  98. /***************************************************************************
  99. **    DLL Entry Point
  100. */
  101. int FAR PASCAL LibMain (HINSTANCE hInstance, WORD wDataSeg, 
  102.                                 WORD cbHeapSize, LPSTR lpCmdLine)
  103. {
  104.     hDLL = hInstance;
  105.     if(cbHeapSize != 0)
  106.         UnlockData (0);
  107.     return 1;
  108. };
  109.  
  110. /***************************************************************************
  111. ** Function : InitSnapin(void)
  112. ** Description :                                                           
  113. **    Every Snapin DLL must provide this function. In this function,       
  114. **    snapin menu items (under Tools) are registered. Also, object procs   
  115. **    are registered.                                                      
  116. */                                                                         
  117. int _export FAR PASCAL InitSnapin()
  118. {
  119.     nuint16 ShowSchemaForm=0;
  120.  
  121.     /*-----------------------------------------------------------------------
  122.     ** Registering Menu Item                                    
  123.     */
  124.     NWARegisterMenu(
  125.     /* View Name      */  NWA_VIEW_BROWSER,      
  126.           /* Menu Parent ID */  0,
  127.           /* Menu Parent    */  NULL,
  128.           /* Menu Option    */  MF_STRING, 
  129.           /* Menu ID        */  &ShowSchemaForm,        
  130.           /* Menu String    */  "&View Schema",       
  131.           /* Menu Hint      */  "View Schema Definitions",  
  132.           /* Menu Act. Proc */  ViewSchemaMenuAction,  
  133.           /* Menu Valic Prc */  ViewSchemaMenuValid,   
  134.           /* Snapin Version */  NWA_SNAPIN_VERSION
  135.     );   
  136.  
  137.  
  138.     return NWA_RET_SUCCESS;
  139. }
  140.  
  141. /******************************************************************************
  142. ** Function : ViewSchemaMenuAction(void)                                   
  143. ** Description :                                                           
  144. **    Menu Action Callback Proc for ViewSchemaAction
  145. */                        
  146. N_GLOBAL_LIBRARY( void ) _export
  147. ViewSchemaMenuAction( void )
  148. {
  149.  HWND    hwnd;
  150.  MSG    msg;
  151.  
  152.  static FARPROC lpfnViewSchemaDlgProc;
  153.  
  154.  lpfnViewSchemaDlgProc = MakeProcInstance((FARPROC)ViewSchemaDlgProc, hDLL);
  155.  
  156. DialogBox(hDLL, "VIEW_SCMA", GetActiveWindow(), lpfnViewSchemaDlgProc);
  157.  
  158. FreeProcInstance(lpfnViewSchemaDlgProc);
  159. }
  160.  
  161. /*******************************************************************************
  162. ** Function : ViewSchemaMenuValid(void)                                    
  163. ** Description :                                                           
  164. **   Menu Valid Callback Proc for  Menu                          
  165. */
  166. N_GLOBAL_LIBRARY( void ) _export
  167. ViewSchemaMenuValid( pnuint16 pFlags )
  168. {
  169.     *pFlags=MF_ENABLED;
  170. }
  171.  
  172. BOOL FAR PASCAL _export ViewSchemaDlgProc(HWND hDlg, UINT message, UINT wParam,
  173.                                     LONG lParam)
  174. {
  175.  WORD            n;
  176.  
  177.  switch(message)
  178.     {
  179.      case WM_INITDIALOG:
  180.  
  181.      InitClassDefListBox(hDlg);
  182.      ReadAllAttributes(hDlg);
  183.      SetFocus(GetDlgItem(hDlg, CLASS_NAMES));
  184.      return FALSE;
  185.  
  186.      case WM_COMMAND:
  187.         switch(wParam)
  188.             {
  189.              case EXIT_DLG:
  190.                 EndDialog(hDlg, TRUE);
  191.                 return TRUE;
  192.  
  193.              case CLASS_NAMES:
  194.                 if (HIWORD (lParam) == LBN_SELCHANGE)
  195.                     {
  196.                     n = (WORD) SendDlgItemMessage(hDlg, CLASS_NAMES,
  197.                       LB_GETCURSEL, 0, 0L);
  198.                     SendDlgItemMessage(hDlg, CLASS_NAMES, LB_GETTEXT, n,
  199.                                 (LONG) (LPSTR) classNameBuf);
  200.                     superClassFlag = 0;
  201.                     UpdateClassDlgBoxes(hDlg);
  202.                     }
  203.                 break;
  204.  
  205.              case ATTR_NAMES:
  206.                     if (HIWORD (lParam) == LBN_DBLCLK)
  207.                         OpenAttrInfoDlgBox(hDlg, ATTR_NAMES);
  208.                                         break;
  209.                 
  210.              case MANDATORY_ATT:
  211.                     if (HIWORD (lParam) == LBN_SELCHANGE)
  212.                         OpenAttrInfoDlgBox(hDlg, MANDATORY_ATT);
  213.                                         break;
  214.  
  215.  
  216.              case OPTIONAL_ATT:
  217.                     if (HIWORD (lParam) == LBN_SELCHANGE)
  218.                         OpenAttrInfoDlgBox(hDlg, OPTIONAL_ATT);
  219.                                         break;
  220.  
  221.              case SUPER_CLASSES:
  222.                 if (HIWORD (lParam) == LBN_DBLCLK)
  223.                     {
  224.                     n = (WORD) SendDlgItemMessage(hDlg, SUPER_CLASSES,
  225.                       LB_GETCURSEL, 0, 0L);
  226.                       
  227.                     SendDlgItemMessage(hDlg, SUPER_CLASSES, LB_GETTEXT, n,
  228.                                 (LONG) (LPSTR) classNameBuf);
  229.                     topFlag = 0;
  230.                     updateFlag = 0;
  231.                     superClassFlag = 1;
  232.                     UpdateClassDlgBoxes(hDlg);
  233.                 
  234.                     }
  235.                 break;
  236.              
  237.             }
  238.                      break;
  239.     }
  240.  
  241.           return FALSE;
  242. }
  243.  
  244. OpenAttrInfoDlgBox(HWND hDlg, int SOURCE_DLG)
  245. {
  246.     static FARPROC lpfnViewAttrInfoDlgProc;
  247.           WORD    n;
  248.  
  249.     memset(attrNameBuf, 0, sizeof(attrNameBuf));
  250.  
  251.     n = (WORD) SendDlgItemMessage(hDlg, SOURCE_DLG,
  252.               LB_GETCURSEL, 0, 0L);
  253.  
  254.  
  255.         SendDlgItemMessage(hDlg, SOURCE_DLG, LB_GETTEXT, n,
  256.                   (LONG) (LPSTR) attrNameBuf);
  257.  
  258.     if(!strcmp(attrNameBuf, "(none)"))
  259.         return FALSE;
  260.  
  261.     lpfnViewAttrInfoDlgProc = MakeProcInstance((FARPROC)ViewAttrInfoDlgProc, hDLL);
  262.  
  263.     DialogBox(hDLL, "ATTR_INFO", GetActiveWindow(), lpfnViewAttrInfoDlgProc);
  264.  
  265.     FreeProcInstance(lpfnViewAttrInfoDlgProc);
  266.  
  267.  return FALSE;
  268. }
  269.  
  270. BOOL FAR PASCAL _export ViewAttrInfoDlgProc(HWND hDlg, UINT message, UINT wParam,
  271.                                     LONG lParam)
  272. {
  273.  NWATTR_INFO    attrInfo;
  274.  int        i;
  275.  char        boundsBuf[7];
  276.  WORD        n;
  277.  char        labelCompareBuf[30];
  278.  
  279.  switch(message)
  280.     {
  281.      case WM_INITDIALOG:
  282.      ReadAttributeInfo(&attrInfo);
  283.      SetDlgItemText(hDlg, ATTR_NAME, attrNameBuf);
  284.  
  285.      for(i=0; i < 9; ++i)
  286.         {
  287.          if(attrInfo.attrFlags & attrFlagsInfo[i].attrFlag)
  288.           SendDlgItemMessage(hDlg, ATTR_FLAGS, LB_ADDSTRING, 0,
  289.                         (LONG) (LPSTR) attrFlagsInfo[i].szLabel);
  290.  
  291.         }
  292.  
  293.      SetDlgItemText(hDlg, SYNTAX, syntax[attrInfo.attrSyntaxID]);
  294.             wsprintf(boundsBuf, "%04X", attrInfo.attrLower); 
  295.      SetDlgItemText(hDlg, LOWER,  boundsBuf);
  296.      wsprintf(boundsBuf, "%04X", attrInfo.attrUpper);
  297.      SetDlgItemText(hDlg, UPPER, boundsBuf);
  298.  
  299.      SetFocus(GetDlgItem(hDlg, ATTR_FLAGS));
  300.      return FALSE;
  301.  
  302.      case WM_COMMAND:
  303.         switch(wParam)
  304.             {
  305.              case EXIT_DLG2:
  306.                 EndDialog(hDlg, TRUE);
  307.                 return TRUE;
  308.                             
  309.              case ATTR_FLAGS:
  310.                 if (HIWORD (lParam) == LBN_SELCHANGE)
  311.                     {
  312.                     n = (WORD) SendDlgItemMessage(hDlg, ATTR_FLAGS,
  313.                                 LB_GETCURSEL, 0, 0L);
  314.                         SendDlgItemMessage(hDlg, ATTR_FLAGS, LB_GETTEXT, n,
  315.                                   (LONG) (LPSTR) labelCompareBuf );
  316.  
  317.                     for(i=0; i < 9; ++i)
  318.                       {
  319.                          if(strcmp(labelCompareBuf, attrFlagsInfo[i].szLabel) == 0)
  320.                             SetDlgItemText(hDlg, DESCRIPTION,
  321.                                  attrFlagsInfo[i].szDesc);
  322.                       }
  323.                     }
  324.                 break;
  325.  
  326.             }
  327.                      break;
  328.     }
  329.  
  330.           return FALSE;
  331. }
  332.  
  333.  
  334. ReadAttributeInfo(NWATTR_INFO *attrInfo)
  335. {
  336.     NWDSContextHandle    dContext;
  337.     NWDS_ITERATION        iterHandle = -1L;
  338.     NWDS_BUFFER        *outBuf, *inBuf;
  339.     NWDSCCODE        cCode;
  340.     NWCOUNT            attrCount;
  341.     char            attrName[MAX_SCHEMA_NAME_CHARS];
  342.     int            i;
  343.  
  344.  
  345.     dContext = NWDSCreateContext();
  346.  
  347.     if (dContext == ERR_CONTEXT_CREATION)
  348.         {
  349.         NWDSFreeContext(dContext);
  350.         return(dContext);
  351.         }
  352.  
  353.  
  354.     cCode = NWDSAllocBuf(
  355.              /* Buffer Size */ DEFAULT_MESSAGE_LEN,
  356.              /* Buff. Point.*/ &inBuf
  357.              );
  358.  
  359.     if (cCode < 0)
  360.             {
  361.             NWDSFreeContext(dContext);
  362.             return(cCode);
  363.             }
  364.  
  365.     cCode = NWDSAllocBuf(
  366.              /* Buffer Size */ DEFAULT_MESSAGE_LEN,
  367.              /* Buff. Point.*/ &outBuf
  368.              );
  369.  
  370.     if (cCode < 0)
  371.             {
  372.             NWDSFreeContext(dContext);
  373.             NWDSFreeBuf(inBuf);
  374.                          return(cCode);
  375.             }
  376.  
  377.  
  378.     cCode = NWDSInitBuf(
  379.           /* Context handle */ dContext,
  380.           /* Operation      */ DSV_READ_ATTR_DEF,
  381.           /* Buffer         */ inBuf
  382.           );
  383.  
  384.     if (cCode < 0)
  385.             {
  386.             NWDSFreeContext(dContext);
  387.             NWDSFreeBuf(outBuf);
  388.             NWDSFreeBuf(inBuf);
  389.             return(cCode);
  390.             }
  391.  
  392.  
  393.     cCode = NWDSPutAttrName(
  394.          /* Context Handle */ dContext,
  395.          /* In buffer      */ inBuf,
  396.          /* class name     */ attrNameBuf
  397.          );
  398.  
  399.     if (cCode < 0)
  400.             {
  401.             NWDSFreeContext(dContext);
  402.             NWDSFreeBuf(outBuf);
  403.             NWDSFreeBuf(inBuf);
  404.             return(cCode);
  405.             }
  406.  
  407.  
  408.     do
  409.         {
  410.         cCode = NWDSReadAttrDef(
  411.               /* Contxt Handle */ dContext,
  412.               /* Info Type     */ DS_ATTR_DEFS,
  413.               /* All classes ? */ FALSE,
  414.               /* Class Names   */ inBuf,
  415.               /* Iter handle   */ &iterHandle,
  416.               /* Result Buf    */ outBuf
  417.               );
  418.  
  419.         if (cCode < 0)
  420.               {
  421.                 NWDSFreeContext(dContext);
  422.                 NWDSFreeBuf(inBuf);
  423.                 NWDSFreeBuf(outBuf);
  424.                                     return(cCode);
  425.               }
  426.  
  427.         cCode = NWDSGetAttrCount(
  428.               /* Contxt Handle  */ dContext,
  429.               /* Result buffer  */ outBuf,
  430.               /* Class Def count*/ &attrCount
  431.               );
  432.  
  433.         if (cCode < 0)
  434.               {
  435.                 NWDSFreeContext(dContext);
  436.                 NWDSFreeBuf(outBuf);
  437.                 NWDSFreeBuf(inBuf);
  438.                 return(cCode);
  439.               }
  440.  
  441.  
  442.         for (i = 0; i < (int)attrCount; ++i)
  443.             {
  444.             cCode = NWDSGetAttrDef(
  445.                   /* Contxt Handle */ dContext,
  446.                   /* Result Buffer */ outBuf,
  447.                   /* Item Name     */ attrName,
  448.                   /* Class info    */ attrInfo
  449.                   );
  450.  
  451.             if (cCode < 0)
  452.                   {
  453.                   NWDSFreeContext(dContext);
  454.                   NWDSFreeBuf(outBuf);
  455.                   NWDSFreeBuf(inBuf);
  456.                   return(cCode);
  457.                   }
  458.  
  459.             }
  460.         } while(iterHandle != -1L);
  461.  
  462. NWDSFreeContext(dContext);
  463. NWDSFreeBuf(outBuf);
  464. NWDSFreeBuf(inBuf);
  465. return FALSE;
  466. }
  467.  
  468. WORD InitClassDefListBox(HWND hDlg)
  469. {
  470.  
  471.     NWDSContextHandle    dContext;
  472.     NWDS_ITERATION        iterHandle = -1L;
  473.     NWDS_BUFFER            *outBuf;
  474.     Class_Info_T       classInfo;
  475.     NWDSCCODE            cCode;
  476.     NWCOUNT                classDefCount, classItemCount;
  477.     char                   classDefName[MAX_SCHEMA_NAME_BYTES];
  478.     char                  classItemName[MAX_SCHEMA_NAME_BYTES];
  479.     char                   classDefItemName[50];
  480.     int                   i;
  481.  
  482.      dContext = NWDSCreateContext();
  483.  
  484.     if (dContext == ERR_CONTEXT_CREATION)
  485.         {
  486.         NWDSFreeContext(dContext);
  487.         return(dContext);
  488.         }
  489.  
  490.  
  491.     cCode = NWDSAllocBuf(
  492.              /* Buffer Size */ DEFAULT_MESSAGE_LEN,
  493.              /* Buff. Point.*/ &outBuf
  494.              );
  495.  
  496.     if (cCode < 0)
  497.             {
  498.             NWDSFreeContext(dContext);
  499.             return(cCode);
  500.             }
  501.  
  502.  
  503.     do
  504.         {
  505.         cCode = NWDSReadClassDef(
  506.               /* Contxt Handle */ dContext,
  507.               /* Info Type     */ DS_CLASS_DEF_NAMES,
  508.               /* All classes ? */ TRUE,
  509.               /* Class Names   */ NULL,
  510.               /* Iter handle   */ &iterHandle,
  511.               /* Result Buf    */ outBuf
  512.               );
  513.  
  514.         if (cCode < 0)
  515.               {
  516.                       NWDSFreeContext(dContext);
  517.                       NWDSFreeBuf(outBuf);
  518.                       return(cCode);
  519.               }
  520.  
  521.         cCode = NWDSGetClassDefCount(
  522.               /* Contxt Handle  */ dContext,
  523.               /* Result buffer  */ outBuf,
  524.               /* Class Def count*/ &classDefCount
  525.               );
  526.  
  527.         if (cCode < 0)
  528.               {
  529.                     NWDSFreeContext(dContext);
  530.                     NWDSFreeBuf(outBuf);
  531.                     return(cCode);
  532.               }
  533.  
  534.  
  535.         for (i = 0; i < (int)classDefCount; ++i)
  536.             {
  537.             cCode = NWDSGetClassDef(
  538.                   /* Contxt Handle */ dContext,
  539.                   /* Result Buffer */ outBuf,
  540.                   /* Item Name     */ classDefName,
  541.                   /* Class info    */ &classInfo
  542.                   );
  543.  
  544.             if (cCode < 0)
  545.                   {
  546.                         NWDSFreeContext(dContext);
  547.                                  NWDSFreeBuf(outBuf);
  548.                     return(cCode);
  549.                   }
  550.  
  551.             SendDlgItemMessage(hDlg, CLASS_NAMES, LB_ADDSTRING, 0,
  552.                         (LONG) (LPSTR) classDefName);
  553.  
  554.             }
  555.         } while(iterHandle != -1L);
  556.  
  557. NWDSFreeContext(dContext);
  558. NWDSFreeBuf(outBuf);
  559. return FALSE;
  560. }
  561.  
  562. WORD UpdateClassDlgBoxes(HWND hDlg)
  563. {
  564.     NWDSContextHandle    dContext;
  565.     NWDS_ITERATION        iterHandle = -1L;
  566.     NWDS_BUFFER            *outBuf, *className;
  567.     Class_Info_T       classInfo;
  568.     NWDSCCODE            cCode;
  569.     NWCOUNT                classDefCount, classItemCount;
  570.     char                    classDefName[MAX_SCHEMA_NAME_BYTES];
  571.     char                    classItemName[MAX_SCHEMA_NAME_BYTES];
  572.     char                    classDefItemName[50];
  573.     char                    *cptr;
  574.     int                    h, i, j, k;
  575.     long                    rval;
  576.     
  577.  
  578.     
  579.     if (!superClassFlag)
  580.         {
  581.         for(h = 0; h < 6; ++h)
  582.             SendDlgItemMessage(hDlg, (h + 102), LB_RESETCONTENT, 0, 0);
  583.         }
  584.  
  585.     else
  586.         {
  587.         for (j=0; j<6; ++j)
  588.             {
  589.             SendDlgItemMessage(hDlg, (j + 102), LB_ADDSTRING,
  590.                                         0, (LONG) (LPSTR) "____________________________");
  591.             }                            
  592.         }    
  593.         
  594.     dContext = NWDSCreateContext();
  595.  
  596.     if (dContext == ERR_CONTEXT_CREATION)
  597.         {
  598.         goto _FreeContext;
  599.         }
  600.  
  601.     cCode = NWDSAllocBuf(
  602.              /* Buffer Size */ DEFAULT_MESSAGE_LEN,
  603.              /* Buff. Point.*/ &outBuf
  604.              );
  605.  
  606.     if (cCode < 0)
  607.             {
  608.             goto _FreeContext;
  609.             }
  610.  
  611.     cCode = NWDSAllocBuf(
  612.              /* Buffer Size */ DEFAULT_MESSAGE_LEN,
  613.              /* Buff. Point.*/ &className
  614.              );
  615.  
  616.     if (cCode < 0)
  617.             {
  618.             goto _FreeOutBuf;
  619.             }
  620.  
  621.  
  622.     cCode = NWDSInitBuf(
  623.           /* Context handle */ dContext,
  624.           /* Operation      */ DSV_READ_CLASS_DEF,
  625.           /* Buffer         */ className
  626.           );
  627.  
  628.     if (cCode < 0)
  629.             {
  630.             goto _FreeInBuf;
  631.             }
  632.  
  633.  
  634.     cCode = NWDSPutClassName(
  635.          /* Context Handle */ dContext,
  636.          /* In buffer      */ className,
  637.          /* class name     */ classNameBuf
  638.          );
  639.  
  640.     if (cCode < 0)
  641.             {
  642.             goto _FreeInBuf;
  643.             }
  644.  
  645.  
  646.     do
  647.         {
  648.         cCode = NWDSReadClassDef(
  649.               /* Contxt Handle */ dContext,
  650.               /* Info Type     */ DS_CLASS_DEFS,
  651.               /* All classes ? */ FALSE,
  652.               /* Class Names   */ className,
  653.               /* Iter handle   */ &iterHandle,
  654.               /* Result Buf    */ outBuf
  655.               );
  656.  
  657.         if (cCode < 0)
  658.               {
  659.               goto _FreeInBuf;
  660.               }
  661.  
  662.         cCode = NWDSGetClassDefCount(
  663.               /* Contxt Handle  */ dContext,
  664.               /* Result buffer  */ outBuf,
  665.               /* Class Def count*/ &classDefCount
  666.               );
  667.  
  668.         if (cCode < 0)
  669.               {
  670.               goto _FreeInBuf;
  671.               }
  672.  
  673.  
  674.         for (i = 0; i < (int)classDefCount; ++i)
  675.             {
  676.             cCode = NWDSGetClassDef(
  677.                   /* Contxt Handle */ dContext,
  678.                   /* Result Buffer */ outBuf,
  679.                   /* Item Name     */ classDefName,
  680.                   /* Class info    */ &classInfo
  681.                   );
  682.  
  683.             if (cCode < 0)
  684.                   {
  685.                   goto _FreeInBuf;
  686.                   }
  687.  
  688.  
  689.  
  690.         for (j = 0; j < 5; ++j)
  691.             {
  692.             cCode = NWDSGetClassItemCount(
  693.                         /* Context Handle  */ dContext,
  694.                         /* Result Buffer   */ outBuf,
  695.                         /* item Count      */ &classItemCount
  696.                         );
  697.  
  698.             if (cCode < 0)
  699.                 {
  700.                 goto _FreeInBuf;
  701.                 }
  702.  
  703.  
  704.             for (k = 0; k < classItemCount; ++k)
  705.                 {
  706.                 cCode = NWDSGetClassItem(
  707.                             /* Context Handle */ dContext,
  708.                             /* Result buffer  */ outBuf,
  709.                             /* Item Name      */ classItemName
  710.                             );
  711.  
  712.                 if (cCode < 0)
  713.                         {
  714.                         goto _FreeInBuf;
  715.                         }
  716.  
  717.  
  718.                 if(superClassFlag == 1)
  719.                     {
  720.                     if ((j==0) || ((strcmp(classDefName, "Top") == 0) && (j == 3)))
  721.                         {
  722.                         rval = SendDlgItemMessage(hDlg, SUPER_CLASSES, LB_FINDSTRING, -1,
  723.                                         (LONG) (LPSTR) classItemName);
  724.                             
  725.                         if(rval == LB_ERR)
  726.                             updateFlag = 1;
  727.  
  728.                         rval = SendDlgItemMessage(hDlg, OPTIONAL_ATT, LB_FINDSTRING, -1,
  729.                                         (LONG) "ACL");
  730.                             
  731.                         if(rval == LB_ERR)
  732.                             topFlag = 1;
  733.                             
  734.                         }
  735.                         
  736.                         
  737.                     if(updateFlag ==1 && topFlag ==1)
  738.                         {
  739.                         SendDlgItemMessage(hDlg, (j + 102), LB_ADDSTRING,
  740.                                                 0, (LONG) (LPSTR) classItemName);
  741.                         }
  742.                     }
  743.                      
  744.                 else
  745.                     SendDlgItemMessage(hDlg, (j + 102), LB_ADDSTRING,
  746.                                             0, (LONG) (LPSTR) classItemName);
  747.  
  748.  
  749.                  }
  750.              
  751.                 if ((superClassFlag == 1) && (j == 0) && (updateFlag ==1) && (topFlag ==1))
  752.                     UpdateClassFlags(hDlg, &classInfo);
  753.              
  754.             }
  755.  
  756.  
  757.                 
  758.             if(!superClassFlag)
  759.                 UpdateClassFlags(hDlg, &classInfo);
  760.                                                     
  761.  
  762.  
  763.             }
  764.         } while(iterHandle != -1L);
  765.  
  766.         
  767.      
  768. _FreeInBuf:        
  769.     NWDSFreeBuf(className);
  770. _FreeOutBuf:
  771.     NWDSFreeBuf(outBuf);
  772. _FreeContext:
  773.     NWDSFreeContext(dContext);
  774. return FALSE;
  775. }
  776.  
  777. UpdateClassFlags(HWND hDlg, Class_Info_T *classInfo)
  778. {
  779.     int    i;
  780.     
  781.     for(i=0; i < 5; ++i)
  782.         {
  783.          if(classInfo->classFlags & classFlagsInfo[i].classFlag)
  784.           SendDlgItemMessage(hDlg, CLASS_FLAGS, LB_ADDSTRING, 0,
  785.                         (LONG) (LPSTR) classFlagsInfo[i].szLabel);
  786.  
  787.         }
  788. }
  789.  
  790. ReadAllAttributes(HWND hDlg)
  791. {
  792.     NWDSContextHandle    dContext;
  793.     NWDS_ITERATION    iterHandle = -1L;
  794.     NWDS_BUFFER        *outBuf;
  795.     NWDSCCODE        cCode;
  796.     NWCOUNT            attrCount;
  797.     Attr_Info_T     attributeInfo;
  798.     char                attrName[MAX_SCHEMA_NAME_CHARS];
  799.     int                i;
  800.  
  801.  
  802.     dContext = NWDSCreateContext();
  803.  
  804.     if (dContext == ERR_CONTEXT_CREATION)
  805.         {
  806.         NWDSFreeContext(dContext);
  807.         return(dContext);
  808.         }
  809.  
  810.  
  811.     cCode = NWDSAllocBuf(
  812.              /* Buffer Size */ DEFAULT_MESSAGE_LEN,
  813.              /* Buff. Point.*/ &outBuf
  814.              );
  815.  
  816.     if (cCode < 0)
  817.             {
  818.             NWDSFreeContext(dContext);
  819.                          return(cCode);
  820.             }
  821.  
  822.  
  823.  
  824.     do
  825.         {
  826.         cCode = NWDSReadAttrDef(
  827.               /* Contxt Handle */ dContext,
  828.               /* Info Type     */ DS_ATTR_DEFS,
  829.               /* All classes ? */ TRUE,
  830.               /* Class Names   */ NULL,
  831.               /* Iter handle   */ &iterHandle,
  832.               /* Result Buf    */ outBuf
  833.               );
  834.  
  835.         if (cCode < 0)
  836.               {
  837.                 NWDSFreeContext(dContext);
  838.                 NWDSFreeBuf(outBuf);
  839.                                     return(cCode);
  840.               }
  841.  
  842.         cCode = NWDSGetAttrCount(
  843.               /* Contxt Handle  */ dContext,
  844.               /* Result buffer  */ outBuf,
  845.               /* Class Def count*/ &attrCount
  846.               );
  847.  
  848.         if (cCode < 0)
  849.               {
  850.                 NWDSFreeContext(dContext);
  851.                 NWDSFreeBuf(outBuf);
  852.                 return(cCode);
  853.               }
  854.  
  855.  
  856.         for (i = 0; i < (int)attrCount; ++i)
  857.             {
  858.             cCode = NWDSGetAttrDef(
  859.                   /* Contxt Handle */ dContext,
  860.                   /* Result Buffer */ outBuf,
  861.                   /* Item Name     */ attrName,
  862.                   /* Class info    */ &attributeInfo
  863.                   );
  864.  
  865.             if (cCode < 0)
  866.                   {
  867.                   NWDSFreeContext(dContext);
  868.                   NWDSFreeBuf(outBuf);
  869.                   return(cCode);
  870.                   }
  871.  
  872.             SendDlgItemMessage(hDlg, ATTR_NAMES, LB_ADDSTRING, 0,
  873.                         (LONG) (LPSTR) attrName);
  874.             
  875.             }
  876.         } while(iterHandle != -1L);
  877.  
  878. NWDSFreeContext(dContext);                               
  879. NWDSFreeBuf(outBuf);
  880. return FALSE;
  881. }
  882.  
  883.  
  884.