home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dsque.exe / DSSUBJOB.C < prev    next >
Text File  |  1994-10-25  |  7KB  |  264 lines

  1. /****************************************************************************
  2. **    File:    DSSUBJOB.C
  3. **
  4. **    Desc:    This program sumbits 3 letter DOS commands to a queue for servicing 
  5. **            by JSERVER.EXE.             
  6. **            
  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.     **    Prototypes
  46.     */
  47.     void createDSQueue(char * queueName);
  48.     void addOrDeleteInDSQueue(char * queueName);
  49.     void createDSQueueServer(char * queueServerName);
  50.  
  51.     
  52.     /*------------------------------------------------------------------------
  53.     **    MACROS
  54.     */
  55.     #define NWDOS
  56.  
  57.     /*------------------------------------------------------------------------
  58.     **    ANSI
  59.     */
  60.     #include <stdlib.h>
  61.     #include <string.h>
  62.     #include <stdio.h>
  63.     #include <conio.h>
  64.         #include <io.h>
  65.  
  66.     /*------------------------------------------------------------------------
  67.     **    NetWare
  68.     */
  69.     #include <nwnet.h>
  70.     #include <nwcalls.h>
  71.     #include <nwlocale.h>
  72.  
  73.  
  74.     /*------------------------------------------------------------------------
  75.     **    Globals
  76.     */
  77.  
  78. void main()
  79.     {
  80.     NWDSCCODE        dscCode;
  81.     NWCCODE            cCode;
  82.     NWCONN_HANDLE    connHandle;
  83.     NWOBJ_ID            servID;
  84.     NWOBJ_ID            queueID;
  85.     NWFILE_HANDLE  filehandle;
  86.       NWDSContextHandle dContext;
  87.     char                inBuf[255];
  88.     size_t            buflen;
  89.    char                   queueName[MAX_DN_CHARS];
  90.     char                  queueServerName[MAX_DN_CHARS];
  91.     NWQueueJobStruct        jobStructure;
  92.     DWORD                flags;
  93.       LCONV                lconvInfo;
  94.       char far             *countryPtr;
  95.  
  96.  
  97.     cCode = NWCallsInit(NULL,NULL);
  98.  
  99.     if (cCode)
  100.         {
  101.         printf("\nCall to NWCallsInit failed!! Error code %04X\n", cCode);
  102.         exit(1);
  103.         }
  104.  
  105.  
  106.       countryPtr = NWLsetlocale(LC_ALL, "");
  107.       printf("\nNWLsetl.. OK");
  108.  
  109.       NWLlocaleconv(&lconvInfo);
  110.       printf("\nCountry ID = %03d, Code Page = %04d\n",
  111.               lconvInfo.country_id, lconvInfo.code_page);
  112.  
  113.       cCode = NWInitUnicodeTables(lconvInfo.country_id, lconvInfo.code_page);
  114.  
  115.       if(cCode)
  116.         {
  117.           printf("NWInitUnicodeTables() = %04X\n",cCode);
  118.         NWFreeUnicodeTables(); 
  119.        exit(1);
  120.         }
  121.  
  122.       dContext = NWDSCreateContext();
  123.  
  124.       if(dContext == ERR_CONTEXT_CREATION)
  125.         {
  126.           printf("NWDSCreateContext() = %04X\n",dContext);
  127.         goto _FreeUnicodeTables;
  128.         }
  129.  
  130.  
  131.    /*----------------------------------------------------------------
  132.     **    Get the current directory context flags so we can modify them.
  133.     */
  134.    dscCode= NWDSGetContext(
  135.                 /* Contxt Handle    */ dContext,
  136.                 /* Key              */ DCK_FLAGS,
  137.                 /* Context Flags    */ &flags
  138.                 );
  139.  
  140.     if (dscCode< 0)
  141.         {
  142.         printf("NWDSGetContext returned: %04X\n", cCode);
  143.         goto _FreeContext;
  144.         }
  145.  
  146.      /*-------------------------------------------------------------------
  147.    **   Turn typeless naming on.
  148.    **   Turn canonicalize names off.  This means we will get full names.
  149.    */
  150.  
  151.    flags |= DCV_TYPELESS_NAMES;
  152.    flags &= ~DCV_CANONICALIZE_NAMES;
  153.  
  154.    /*----------------------------------------------------------------
  155.     **    Set the directory context flags so they take effect.
  156.     */
  157.    dscCode= NWDSSetContext(
  158.                 /* Context Handle */ dContext,
  159.                 /* Key            */ DCK_FLAGS,
  160.                 /* Set Flag Value */ &flags
  161.                 );
  162.  
  163.     if (dscCode< 0)
  164.         {
  165.         printf("NWDSSetContext returned: %04X\n", cCode);
  166.         goto _FreeContext;
  167.         }
  168.  
  169.  
  170.     cCode = NWGetDefaultConnectionID(&connHandle);
  171.  
  172.     if(cCode)
  173.         {
  174.         printf("Call to NWGetDefaultConnectionID failed!! Error Code %04X\n", cCode);
  175.         exit(2);
  176.         }
  177.  
  178.    printf("\nA Queue Name is required for this operation!\n");
  179.    printf("\nQueue Distinguished Name: ");
  180.    gets(queueName);
  181.  
  182.     cCode = NWDSMapNameToID(
  183.                 /* Context     */ dContext,
  184.                 /* Conn Handle    */ connHandle,
  185.                 /* Object name */ queueName,
  186.                 /* Queue ID    */ &queueID
  187.                 );
  188.  
  189.     if(cCode)
  190.         {
  191.         printf("Call to NWMapNameToID failed!! Error Code %04X\n", cCode);
  192.         exit(1);
  193.         }
  194.  
  195.  
  196.    printf("\nA Queue Server Name is required for this operation!\n");
  197.    printf("\nQueue Server Distinguished Name: ");
  198.    gets(queueServerName);
  199.  
  200.     cCode = NWDSMapNameToID(
  201.                 /* Context     */ dContext,
  202.                 /* Conn Handle    */ connHandle,
  203.                 /* Object name */ queueServerName,
  204.                 /* Queue ID    */ &servID
  205.                 );
  206.  
  207.     if(cCode)
  208.         {
  209.         printf("Call to NWMapNameToID failed!! Error Code %04X\n", cCode);
  210.         exit(1);
  211.         }
  212.  
  213.  
  214.     jobStructure.targetServerID = servID;
  215.  
  216.     memset(jobStructure.targetExecutionTime,0xFF,6);
  217.  
  218.     jobStructure.jobType = 1234;
  219.  
  220.     jobStructure.jobControlFlags = 0x08;
  221.  
  222.     cCode = NWCreateQueueFile2(
  223.                 /* Conn Handle   */  connHandle,
  224.                 /* Queue ID      */  queueID,
  225.                 /* Pass Job Struc*/  &jobStructure,
  226.                 /* File Handle   */  &filehandle
  227.                 );
  228.  
  229.  
  230.     if(cCode)
  231.         {
  232.         printf("Call to NWCreateQueueFile2 failed!! Error Code %04X\n", cCode);
  233.         exit(4);
  234.         }
  235.  
  236.  
  237.     printf("Please input a three character DOS command :");
  238.     scanf("%s",inBuf);
  239.     buflen = strlen(inBuf);
  240.  
  241.     write(filehandle,inBuf,buflen);
  242.  
  243.  
  244.     cCode = NWCloseFileAndStartQueueJob2(
  245.                 /* Connection Handle  */ connHandle,
  246.                 /* queue ID             */ queueID,
  247.                 /* JobNumber             */ jobStructure.jobNumber,
  248.                 /* File Handle        */ filehandle
  249.                 );
  250.  
  251.  
  252.     if(cCode)
  253.         {
  254.         printf("Call to NWCloseFileAndStartQueueJob2 failed!! Error Code %04X\n", cCode);
  255.         exit(5);
  256.         }
  257.  
  258. _FreeContext:
  259.     NWDSFreeContext(dContext);
  260. _FreeUnicodeTables:
  261.     NWFreeUnicodeTables();
  262.  
  263.     }    
  264.