home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dsque.exe / EXTSCMA.C < prev   
Text File  |  1994-11-07  |  6KB  |  233 lines

  1. /****************************************************************************
  2. **    File:    EXTSCMA.C
  3. **
  4. **    Desc:    This program extends the schema creating a new effective class 
  5. **            named QServer. This is a necessary step in preparation for
  6. **            creating an object of type QServer.
  7. **        
  8. **
  9. **        DISCLAIMER  
  10. **  
  11. **    Novell, Inc. makes no representations or warranties with respect to
  12. **    any NetWare software, and specifically disclaims any express or
  13. **    implied warranties of merchantability, title, or fitness for a
  14. **    particular purpose.  
  15. **
  16. **    Distribution of any NetWare software is forbidden without the
  17. **    express written consent of Novell, Inc.  Further, Novell reserves
  18. **    the right to discontinue distribution of any NetWare software.
  19. **    
  20. **    Novell is not responsible for lost profits or revenue, loss of use
  21. **    of the software, loss of data, costs of re-creating lost data, the
  22. **    cost of any substitute equipment or program, or claims by any party
  23. **    other than you.  Novell strongly recommends a backup be made before
  24. **    any software is installed.   Technical support for this software
  25. **    may be provided at the discretion of Novell.
  26. **
  27. **    Programmers:
  28. **
  29. **        Ini    Who                        Firm
  30. **        -----------------------------------------------------------------------
  31. **        KLB    Karl Bunnell                Novell Developer Support.
  32. **
  33. **    History:
  34. **
  35. **        When        Who    What
  36. **        -----------------------------------------------------------------------
  37. **        10-24-94    klb    First code.
  38. */
  39.  
  40. /****************************************************************************
  41. **    Include headers, macros, function prototypes, etc.
  42. */
  43.  
  44.     /*------------------------------------------------------------------------
  45.     **    MACROS
  46.     */
  47.     #define NWDOS
  48.  
  49.     /*------------------------------------------------------------------------
  50.     **    ANSI
  51.     */
  52.     #include <stdlib.h>
  53.     #include <string.h>
  54.     #include <stdio.h>
  55.  
  56.  
  57.     /*------------------------------------------------------------------------
  58.     **    NetWare
  59.     */
  60.     #include <nwnet.h>
  61.     #include <nwcalls.h>
  62.     #include <nwlocale.h>
  63.  
  64. void main (void)
  65. {
  66.     NWDSCCODE            cCode;
  67.     NWDSContextHandle    dContext;
  68.     DWORD                    flags;
  69.     NWDS_BUFFER       *classBuf;
  70.       LCONV                lconvInfo;
  71.     Class_Info_T      classInfo;
  72.     char              className[MAX_SCHEMA_NAME_CHARS+2];
  73.     char              superClass[MAX_SCHEMA_NAME_CHARS+2];
  74.  
  75.     cCode = NWCallsInit(NULL, NULL);
  76.     if (cCode)
  77.         {
  78.         printf("\nCall to NWCallsInit returned: %04X", cCode);
  79.         exit(1);
  80.         }
  81.  
  82.       NWLsetlocale(LC_ALL, "");
  83.  
  84.     NWLlocaleconv(&lconvInfo);
  85.  
  86.       cCode = NWInitUnicodeTables(lconvInfo.country_id, lconvInfo.code_page);
  87.  
  88.       if(cCode)
  89.         {
  90.           printf("NWInitUnicodeTables() returned: %04X\n", cCode);
  91.         goto _FreeUnicodeTables;
  92.         }
  93.  
  94.     dContext = NWDSCreateContext();
  95.     if (dContext == ERR_CONTEXT_CREATION)
  96.         {
  97.           printf("NWDSCreateContext returned: %04X\n", cCode);
  98.         goto _FreeContext; 
  99.         }
  100.  
  101.  
  102.    /*----------------------------------------------------------------
  103.     **    Get the current directory context flags so we can modify them.
  104.     */
  105.    cCode = NWDSGetContext(
  106.                 /* Contxt Handle    */ dContext,
  107.                 /* Key              */ DCK_FLAGS,
  108.                 /* Context Flags    */ &flags
  109.                 );
  110.  
  111.     if (cCode < 0)
  112.         {
  113.         printf("NWDSGetContext returned: %04X\n", cCode);
  114.         goto _FreeContext;
  115.         }
  116.  
  117.      /*-------------------------------------------------------------------
  118.    **   Turn typeless naming on.
  119.    **   Turn canonicalize names off.  This means we will get full names.
  120.    */
  121.  
  122.    flags |= DCV_TYPELESS_NAMES;
  123.    flags &= ~DCV_CANONICALIZE_NAMES;
  124.  
  125.    /*----------------------------------------------------------------
  126.     **    Set the directory context flags so they take effect.
  127.     */
  128.    cCode = NWDSSetContext(
  129.                 /* Context Handle */ dContext,
  130.                 /* Key            */ DCK_FLAGS,
  131.                 /* Set Flag Value */ &flags
  132.                 );
  133.  
  134.     if (cCode < 0)
  135.         {
  136.         printf("NWDSSetContext returned: %04X\n", cCode);
  137.         goto _FreeContext;
  138.         }
  139.  
  140.     strcpy(className, "QServer");
  141.     strcpy(superClass, "Server");
  142.  
  143.     classInfo.classFlags = DS_EFFECTIVE_CLASS;
  144.  
  145.     cCode = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &classBuf);
  146.     if( cCode < 0 )
  147.         {
  148.         printf("\nNWDSAllocBuf returned %04X", cCode);
  149.         goto _FreeUnicodeTables;
  150.         }
  151.  
  152.     cCode = NWDSInitBuf(dContext, DSV_DEFINE_CLASS, classBuf);
  153.     if( cCode < 0 )
  154.         {
  155.         printf("\nNWDSInitBuf returned %04X", cCode);
  156.         goto _FreeBuf;
  157.         }
  158.  
  159.     /*----------------------------------------------------------------
  160.     ** entries for super class names
  161.     */
  162.     cCode = NWDSBeginClassItem(dContext, classBuf);
  163.     if( cCode < 0 )
  164.         {
  165.         printf("\nNWDSBeginClassItem returned %04X", cCode);
  166.         goto _FreeBuf;
  167.         }
  168.  
  169.     cCode = NWDSPutClassItem(dContext, classBuf, superClass);
  170.     if( cCode < 0 )
  171.         {
  172.         printf("\nNWDSPutClassItem returned %04X", cCode);
  173.         goto _FreeBuf;
  174.         }
  175.  
  176.     /*----------------------------------------------------------------
  177.     ** entries for containment class names; which are none
  178.     */
  179.     cCode = NWDSBeginClassItem(dContext, classBuf);
  180.     if( cCode < 0 )
  181.         {
  182.         printf("\nNWDSBeginClassItem returned %04X", cCode);
  183.         goto _FreeBuf;
  184.         }
  185.  
  186.     /*----------------------------------------------------------------
  187.     ** entries for naming attribute names; same as Server
  188.     */
  189.     cCode = NWDSBeginClassItem(dContext, classBuf);
  190.     if( cCode < 0 )
  191.         {
  192.         printf("\nNWDSBeginClassItem returned %04X", cCode);
  193.         goto _FreeBuf;
  194.         }
  195.  
  196.     /*----------------------------------------------------------------
  197.     ** entries for mandatory attribute names; same as Server
  198.     */
  199.     cCode = NWDSBeginClassItem(dContext, classBuf);
  200.     if( cCode < 0 )
  201.         {
  202.         printf("\nNWDSBeginClassItem returned %04X", cCode);
  203.         goto _FreeBuf;
  204.         }
  205.  
  206.     /*----------------------------------------------------------------
  207.     ** entries for optional attribute names; same as server for now.
  208.     */
  209.     cCode = NWDSBeginClassItem(dContext, classBuf);
  210.     if( cCode < 0 )
  211.         {
  212.         printf("\nNWDSBeginClassItem returned %04X", cCode);
  213.         goto _FreeBuf;
  214.         }
  215.  
  216.  
  217.     cCode = NWDSDefineClass(dContext, className, &classInfo, classBuf);
  218.     if( cCode < 0 )
  219.         {
  220.         printf("\nNWDSDefineClass returned %04X", cCode);
  221.         goto _FreeBuf;
  222.         }
  223.  
  224. _FreeBuf:
  225.     NWDSFreeBuf(classBuf);
  226. _FreeContext:
  227.     NWDSFreeContext(dContext);
  228. _FreeUnicodeTables:
  229.     NWFreeUnicodeTables();
  230.  
  231.  
  232. }
  233.