home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / capit1.exe / CAPIT.C next >
C/C++ Source or Header  |  1992-06-24  |  25KB  |  595 lines

  1. //   ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  2. //   █                                                                    █
  3. //   █ module:      capit.c                                               █
  4. //   █ written by:  David Harris [dh]                                     █
  5. //   █ abstract:    This module duplicates the functionality of the       █
  6. //   █              CAPTURE.EXE utility.                                  █
  7. //   █                                                                    █
  8. //   █ environment: NetWare 2.15 - 3.11, NETX v3.22 or v3.26              █
  9. //   █              Borland C++ v3.0 or Microsoft C v6.0                  █
  10. //   █              NetWare C Interface-DOS v1.2                          █
  11. //   █                                                                    █
  12. //   █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
  13. //   █ maintenance history:                                               █
  14. //   █ level    date      pi   description                                █
  15. //   █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
  16. //   █  001   03/24/92    dh   initial release.                           █
  17. //   █  002   06/15/92    dh   Fixed setting of local printer device to   █
  18. //   █                         actual device instead of 0                 █
  19. //   █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
  20. //   █ Disclaimer:                                                        █
  21. //   █   Novell, Inc. makes no representations or warranties with respect █
  22. //   █   to any NetWare software, and specifically disclaims any express  █
  23. //   █   or implied warranties of merchantability, title, or fitness for  █
  24. //   █   a particular purpose.                                            █
  25. //   █                                                                    █
  26. //   █   Distribution of any NetWare software is forbidden without the    █
  27. //   █   express written consent of Novell, Inc.  Further, Novell         █
  28. //   █   reserves the right to discontinue distribution of any NetWare    █
  29. //   █   software.                                                        █
  30. //   █                                                                    █
  31. //   █   Novell is not responsible for lost profits or revenue, loss of   █
  32. //   █   use of the software, loss of data, costs of re-creating lost     █
  33. //   █   data, the cost of any substitute equipment or program, or claims █
  34. //   █   by any party other than you.  Novell strongly recommends a       █
  35. //   █   backup be made before any software is installed.   Technical     █
  36. //   █   support of this software may be provided at the discretion of    █
  37. //   █   Novell.                                                          █
  38. //   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42. #include <ctype.h>
  43. #include "nit.h"
  44. #include <niterror.h>
  45. #ifdef __TURBOC__
  46.    #include <dir.h>
  47. #else
  48.    #include <direct.h>
  49. #endif
  50.  
  51. // Generic, non-compiler-specific macros to build and split far pointers
  52. #define xMK_FP( seg,ofs )( (void _far * )((unsigned long)((unsigned long)(seg) << 16 ) +( unsigned long)( (ofs) & 0xFFFF )))
  53. #define xFP_SEG( fp )((unsigned)( (unsigned long)(void far *)(fp) >> 16))
  54. #define xFP_OFF( fp )(((unsigned)( (unsigned long)(void far *)(fp) & 0xFFFF)))
  55.  
  56. // Globals
  57. char fsName[80], queueName[48];
  58.  
  59. BYTE majorVersion, minorVersion, revisionLevel, oldLPT;
  60.  
  61. WORD objectType, oldConnectionID;
  62.  
  63. CAPTURE_FLAGS setCaptureFlags;
  64. CAPTURE_FLAGS getCaptureFlags;
  65.  
  66.  
  67. // Prototypes
  68. void usage(void);
  69. void exitout(int);
  70. void ShowSettings(void);
  71.  
  72. void main(int argc, char **argv)
  73. {
  74.    int retCode = 0, count, count2;
  75.    char *tempArg;
  76.  
  77.    char fileName[255], vName[16];
  78.    char dirName[255], VOLPath[255];
  79.    char objectName[48];
  80.  
  81.    BYTE localPrinterToCaptureTo;
  82.    BYTE qSpecified = FALSE, capFile = FALSE;
  83.    BYTE loginTime[7];
  84.  
  85.    WORD captureFileConnectionID, printServerConnectionID, serverNumber;
  86.  
  87.    long objectID, queueID;
  88.  
  89.  
  90.    oldConnectionID = GetDefaultConnectionID();
  91.    oldLPT = localPrinterToCaptureTo = GetDefaultLocalPrinter();
  92.    if (argc>1)
  93.    {
  94.       if (argv[1][0]!='?')
  95.       {
  96.  
  97. // Get shell version to handle problems in certain shells
  98.          retCode = GetNetWareShellVersion(&majorVersion,
  99.                                           &minorVersion,
  100.                                           &revisionLevel);
  101.          if (retCode == 0)
  102.          {
  103.             printf("Shell version too old\n");
  104.             exit(1);
  105.          }
  106.          else
  107.             printf("Shell v%d.%02d", majorVersion, minorVersion);
  108.             if (revisionLevel > 0)
  109.                printf(" %c\n", revisionLevel + 'A' - 1);
  110.             else
  111.                printf("\n");
  112.  
  113. // Process the command line options so we know the LPT of concern right away
  114.          for (count=1; count<argc; count++)
  115.          {
  116.             if (argv[count][0] == '-' || argv[count][0]=='/')
  117.                argv[count]++;  // Remove option prefix
  118.             if (toupper(argv[count][0]) == 'L')
  119.             {
  120.                if (argv[count][1] == '=')
  121.                   localPrinterToCaptureTo = atoi(&argv[count][2]) - 1;
  122.                else
  123.                   localPrinterToCaptureTo = atoi(&argv[count][1]) - 1;
  124.                if (localPrinterToCaptureTo >2)
  125.                {
  126.                   printf("Device out of range: %s\n", localPrinterToCaptureTo+1);
  127.                   exitout(1);
  128.                }
  129.             }
  130.          }
  131.  
  132. // Now that we know the LPT of concern, lets set up the default printer, etc.
  133.          SetDefaultLocalPrinter(localPrinterToCaptureTo);
  134.          GetDefaultCaptureFlags(&setCaptureFlags);
  135.  
  136. // If version 3.xx or higher shell, buffer pointers are no longer swapped,
  137. // but the NetWare C Interface-DOS v1.2 swaps the incomming buffer, so fix it
  138.          if (majorVersion > 2)
  139.          {
  140.             setCaptureFlags.printerSetupBuffer =
  141.                (char far *)LongSwap((long)setCaptureFlags.printerSetupBuffer);
  142.             setCaptureFlags.printerResetBuffer =
  143.                (char far *)LongSwap((long)setCaptureFlags.printerResetBuffer);
  144.          }
  145.          queueID = setCaptureFlags.printQueueID;
  146.          retCode = GetLPTCaptureStatus(&serverNumber);
  147.          retCode = 0;
  148.          if (retCode == 0)  // Reset flags if not currently captured
  149.          {
  150.             setCaptureFlags.status = 0x00;
  151.             setCaptureFlags.flags = 0x00;
  152.             setCaptureFlags.tabSize = 0x08;
  153.             setCaptureFlags.serverPrinter = 0x00;
  154.             setCaptureFlags.numberOfCopies = 0x01;
  155.             setCaptureFlags.formType = 0x00;
  156. //  Fixed 6/15/92, dh
  157. //            setCaptureFlags.localLPTDevice = 0x00;
  158.             setCaptureFlags.localLPTDevice = localPrinterToCaptureTo;
  159. //
  160.             setCaptureFlags.flushCaptureTimeoutCount = 0x00;
  161.             setCaptureFlags.flushCaptureOnDeviceClose = FALSE;
  162.             setCaptureFlags.maxLines = 66;
  163.             setCaptureFlags.maxChars = 132;
  164.             setCaptureFlags.maxChars = 20;
  165.             setCaptureFlags.formName[0] = '\0';
  166.             setCaptureFlags.LPTCaptureFlag = FALSE;
  167.             setCaptureFlags.fileCaptureFlag = FALSE;
  168.             setCaptureFlags.printQueueFlag = FALSE;
  169.             setCaptureFlags.printQueueID = 0x00;
  170.          }
  171.          retCode = GetLPTCaptureStatus(&printServerConnectionID);
  172.  
  173. // Process the remainder of the command line options
  174.          for (count=1; count<argc; count++)
  175.          {
  176.             if (argv[count][0]=='-' || argv[count][0]=='/')
  177.                argv[count]++;  // Remove option prefix
  178.             strupr(argv[count]);
  179.             tempArg = argv[count];
  180.             switch (argv[count][0])
  181.             {
  182.                case 'L':   // Local port (got it earlier, thanks anyway)
  183.                   break;
  184.                case 'S':   // Options that begin with 'S'
  185.                   ++argv[count];
  186.                   switch (argv[count][0])
  187.                   {
  188.                      case 'H':  // Show settings
  189.                         ShowSettings();
  190.                         break;
  191.                      default:  // Server name
  192.                         if (argv[count][0] == '=') ++argv[count];
  193.                         retCode = GetConnectionID(argv[count], &printServerConnectionID);
  194.                         if (retCode != 0)
  195.                         {
  196.                            printf("Error 0x%X getting connection ID for: %s\n",
  197.                               retCode, argv[count]);
  198.                            exitout(1);
  199.                         }
  200. // Check to make sure we are logged in, not just attached (we can get the queue
  201. // id when attached, but we can only capture when we're logged in)
  202.                         SetPreferredConnectionID(printServerConnectionID);
  203.                         GetConnectionInformation(GetConnectionNumber(),
  204.                            objectName, &objectType, &objectID, loginTime);
  205.                         if (objectID == 0)
  206.                         {
  207.                            printf("Not logged into %s\n", argv[count]);
  208.                            exitout(1);
  209.                         }
  210.                         SetPreferredConnectionID(oldConnectionID);
  211.                         break;
  212.                   }
  213.                   break;
  214.                case 'Q':  // Queue name
  215.                   ++argv[count];
  216.                   if (argv[count][0] == '=') ++argv[count];
  217.                   strncpy(queueName, argv[count], 47);
  218.                   queueName[47] = '\0';
  219.                   qSpecified = TRUE;
  220.                   break;
  221.                case 'N':  // Options that begin with 'N'
  222.                   ++argv[count];
  223.                   switch (argv[count][0])
  224.                   {
  225.                      case 'A': // Options that begin with "NA"
  226.                         ++argv[count];
  227.                         switch (argv[count][0])
  228.                         {
  229.                            case 'M':  // User name
  230.                               ++argv[count];
  231.                               if (argv[count][0] == '=') ++argv[count];
  232.                               retCode = SetBannerUserName(argv[count]);
  233.                               if (retCode != 0)
  234.                               {
  235.                                  printf("Error setting banner name: %s\n", argv[count]);
  236.                                  exitout(1);
  237.                               }
  238.                               break;
  239.                            default:  // Auto endcap disabled
  240.                               setCaptureFlags.flushCaptureOnDeviceClose = TRUE;
  241.                               break;
  242.                         }
  243.                         break;
  244.                      case 'B':  // No banner
  245.                         setCaptureFlags.flags = setCaptureFlags.flags & (~0x80);
  246.                         for (count2=0; count2<13; count2++)
  247.                         {
  248.                            setCaptureFlags.bannerText[count2] = 0x00;
  249.                         }
  250.                         break;
  251.                      case 'F':  // No automatic form feed
  252.                         setCaptureFlags.flags = setCaptureFlags.flags | 0x08;
  253.                         break;
  254.                      case 'N':  // Options that begin with "NN"
  255.                         ++argv[count];
  256.                         switch (argv[count][0])
  257.                         {
  258.                            case 'O':  // Options that begin with "NNO"
  259.                               ++argv[count];
  260.                               switch (argv[count][0])
  261.                               {
  262.                                  case 'T': //No NOTify
  263.                                     setCaptureFlags.flags = setCaptureFlags.flags &
  264.                                        (~0x10);
  265.                                     break;
  266.                               }
  267.                               break;
  268.  
  269.                         }
  270.                      case 'O':  // Options that beging with "NO"
  271.                         ++argv[count];
  272.                         switch (argv[count][0])
  273.                         {
  274.                            case 'T':  // NOTify
  275.                               setCaptureFlags.flags = setCaptureFlags.flags |
  276.                                  0x10;
  277.                               break;
  278.                         }
  279.                         break;
  280.                      case 'T':  // No tab expansion
  281.                         setCaptureFlags.flags = setCaptureFlags.flags & (~0x40);
  282.                         break;
  283.                      default:
  284.                         printf("Invalid option:%s\n", tempArg);
  285.                         break;
  286.                   }
  287.                   break;
  288.                case 'F':  // Options that begin with 'F'
  289.                   ++argv[count];
  290.                   switch (argv[count][0])
  291.                   {
  292.                      case 'F':  // Automatic form feed
  293.                         ++argv[count];
  294.                         setCaptureFlags.flags = setCaptureFlags.flags & (~0x08);
  295.                         break;
  296.                      default:  // Form type
  297.                         if (argv[count][0] == '=') ++argv[count];
  298.                         if (isdigit(argv[count][0]))
  299.                            setCaptureFlags.formType = atoi(argv[count]);
  300.                         else
  301.                            strcpy(setCaptureFlags.formName, argv[count]);
  302.                         break;
  303.                   }
  304.                   break;
  305.                case 'T':  // Options that begin with 'T'
  306.                   ++argv[count];
  307.                   switch (argv[count][0])
  308.                   {
  309.                      case 'I':  // Timeout
  310.                         ++argv[count];
  311.                         if (argv[count][0] == '=') ++argv[count];
  312.                         setCaptureFlags.flushCaptureTimeoutCount = IntSwap(atoi(argv[count])*18);
  313.                         break;
  314.                      default:  // Tab expansion
  315.                         if (argv[count][0] == '=') ++argv[count];
  316.                         setCaptureFlags.flags = setCaptureFlags.flags | 0x40;
  317.                         setCaptureFlags.tabSize = atoi(argv[count]);
  318.                         break;
  319.                   }
  320.                   break;
  321.                case 'B':  // Banner name
  322.                   ++argv[count];
  323.                   if (argv[count][0] == '=') ++argv[count];
  324.                   setCaptureFlags.flags = setCaptureFlags.flags | 0x80;
  325.                   strncpy(setCaptureFlags.bannerText, argv[count], 12);
  326.                   break;
  327.                case 'C':  // Options that begin with 'C'
  328.                   ++argv[count];
  329.                   switch(argv[count][0])
  330.                   {
  331.                      case 'R':  // Create file
  332.                         ++argv[count];
  333.                         if (argv[count][0] == '=') ++argv[count];
  334.                         ConvertNameToFullPath(argv[count], VOLPath);
  335.                         ParsePath(argv[count], fsName, vName, dirName);
  336.                         retCode =
  337.                            GetConnectionID(fsName, &captureFileConnectionID);
  338.                         if (retCode != 0)
  339.                         {
  340.                            printf("Error 0x%X getting connection ID for capture file\n");
  341.                            exitout(1);
  342.                         }
  343.                         strcpy(VOLPath, vName);
  344.                         strcat(VOLPath, ":");
  345.                         strcat(VOLPath, dirName);
  346. // This path will be invalid if it was taken from a fake root
  347.                         capFile = TRUE;
  348.                         setCaptureFlags.fileCaptureFlag = TRUE;
  349.                         break;
  350.                      default:  // # of copies
  351.                         if (argv[count][0] == '=') ++argv[count];
  352.                         setCaptureFlags.numberOfCopies = atoi(argv[count]);
  353.                         break;
  354.                   }
  355.                   break;
  356.                case 'A':  // Auto endcap enabled
  357.                   ++argv[count];
  358.                   if (argv[count][0] == '=') ++argv[count];
  359.                   setCaptureFlags.flushCaptureOnDeviceClose = FALSE;
  360.                   break;
  361.                default:
  362.                   printf("Invalid option: %s\n", tempArg);
  363.                   break;
  364.             }
  365.          }
  366.  
  367. // End, Set, Start...must be in this order!
  368. // End the current capture
  369.          EndLPTCapture();
  370.  
  371. // The LPTCaptureFlag must be cleared or else the shell will think the
  372. // Queue ID belongs to the server that was being captured to previously.
  373.          if (capFile)
  374.          {
  375.             SetPreferredConnectionID(captureFileConnectionID);
  376.             retCode = SpecifyCaptureFile(0, VOLPath);
  377.             SetPreferredConnectionID(oldConnectionID);
  378.             if (retCode != 0)
  379.             {
  380.                printf("Error 0x%X capturing to : %s\n", retCode, fileName);
  381.                exitout(1);
  382.             }
  383.          }
  384. // Which printer server are we talking to?
  385.          SetPreferredConnectionID(printServerConnectionID);
  386.  
  387. // Which queue are we sending to?
  388.          if (!capFile)
  389.          {
  390.             if (qSpecified)
  391.             {
  392.                retCode = GetBinderyObjectID(queueName, OT_PRINT_QUEUE,
  393.                   &queueID);
  394.                if (retCode != 0)
  395.                {
  396.                   printf("Error 0x%X getting object id for: %s\n", retCode,
  397.                      argv[count]);
  398.                   exitout(1);
  399.                }
  400.             }
  401.             setCaptureFlags.LPTCaptureFlag = FALSE;
  402.             retCode = SetCapturePrintQueue(localPrinterToCaptureTo,
  403.                printServerConnectionID, queueID);
  404.             if (retCode != 0)
  405.             {
  406.                printf("Error 0x%X setting print queue\n", retCode);
  407.                exitout(1);
  408.             }
  409.          }
  410.  
  411. // Set the flags, THEN start the capture...
  412.          retCode = SetDefaultCaptureFlags((SET_CAPTURE_FLAGS *)&setCaptureFlags);
  413.          if (retCode != 0)
  414.          {
  415.             printf("Error setting capture flags: 0x%X\n", retCode);
  416.             exitout(1);
  417.          }
  418. // Start the capture
  419.          retCode = StartLPTCapture();
  420.          if (retCode != 0 && retCode != 255)
  421.          {
  422.             printf("Error starting capture: 0x%X\n", retCode);
  423.             exitout(1);
  424.          }
  425.  
  426. // Report to user what we just captured
  427.          GetDefaultCaptureFlags(&getCaptureFlags);
  428.          printf("Device LPT%d: re-routed to ", localPrinterToCaptureTo+1);
  429.          if (capFile)
  430.             printf("file %s on server %s\n", VOLPath, fsName);
  431.          else
  432.          {
  433.             GetFileServerName(printServerConnectionID, fsName);
  434.             if (getCaptureFlags.printQueueFlag)
  435.             {
  436.                GetBinderyObjectName(getCaptureFlags.printQueueID,
  437.                   queueName, &objectType);
  438.                printf("queue %s ", queueName);
  439.             }
  440.             else
  441.                printf("printer %d ", getCaptureFlags.serverPrinter);
  442.             printf("on server %s.\n", fsName);
  443.          }
  444.          exitout(retCode);
  445.       }
  446.       else usage();
  447.    }
  448.    else usage();
  449. }
  450.  
  451. /****************************************************************************
  452.  ShowSettings: Process /SH parameter by showing capture settings for each
  453.                printer
  454.  ****************************************************************************/
  455. void ShowSettings(void)
  456. {
  457.    int count, retCode;
  458.    WORD currentConnectionID;
  459.    char temp[64];
  460.  
  461. // Check each printer port we can capture
  462.    for (count = 0; count < 3; count++)
  463.    {
  464.       printf("LPT%d:  ", count + 1);
  465.       SetDefaultLocalPrinter(count);
  466.       retCode = GetLPTCaptureStatus(¤tConnectionID);
  467. // Are we capturing?
  468.       if (retCode != 0)
  469.       {
  470.          GetDefaultCaptureFlags(&getCaptureFlags);
  471. // If version 3.xx or higher shell, buffer pointers are no longer swapped,
  472. // but the NetWare C Interface-DOS v1.2 swaps the incomming buffer
  473.          if (majorVersion > 2)
  474.          {
  475.             setCaptureFlags.printerSetupBuffer =
  476.                (char far *)LongSwap((long)setCaptureFlags.printerSetupBuffer);
  477.             setCaptureFlags.printerResetBuffer =
  478.                (char far *)LongSwap((long)setCaptureFlags.printerResetBuffer);
  479.          }
  480.          SetPreferredConnectionID(currentConnectionID);
  481.          GetFileServerName(currentConnectionID, fsName);
  482.  
  483. // Display what we're capturing to (server queue/file name)
  484.          printf("Capturing data to %s ", fsName);
  485.          if (getCaptureFlags.fileCaptureFlag)
  486.             printf("in a file.\n");
  487.          else
  488.          {
  489.             if (getCaptureFlags.printQueueFlag)
  490.             {
  491.                GetBinderyObjectName(getCaptureFlags.printQueueID,
  492.                   queueName, &objectType);
  493.                printf("queue %s.\n", queueName);
  494.             }
  495.             else
  496.                printf("printer %d.\n", getCaptureFlags.serverPrinter);
  497.          }
  498.  
  499. // Will we notify the user when done?
  500.          printf("       Will %snotify user when job is printed.\n",
  501.             (getCaptureFlags.flags & 0x10) ? "" : "NOT ");
  502.  
  503. // Are we using capture defaults (not currently implemented)
  504.          printf("       Capture defaults: %-15s",
  505.             getCaptureFlags.status ? "Disabled" : "Enabled");
  506.  
  507. // Auto endcap when program goes back to DOS (or the LPT is closed)?
  508.          printf(" Automatic endcap: %-15s\n",
  509.             getCaptureFlags.flushCaptureOnDeviceClose ? "Disabled" : "Enabled");
  510.  
  511. // Display banner name/none if banner printing, no banner if no banner
  512.          printf("       Banner name     : ");
  513.          if (getCaptureFlags.flags && 0x80)
  514.             if (getCaptureFlags.bannerText[0] == '\0')
  515.                printf("%-15s", "LPT:");
  516.             else
  517.             {
  518.                sprintf(temp, "\"%s\"", getCaptureFlags.bannerText);
  519.                printf("%-15s", temp);
  520.             }
  521.          else
  522.             printf("%-15s", "(no banner)");
  523. // Do we send form feeds at the end of a job?
  524.          printf(" Form feeds      : %-8s\n",
  525.             (getCaptureFlags.flags & 0x08) ? "Disabled" : "Enabled");
  526.  
  527. // How many copies?
  528.          printf("       Copies          : %-15d",
  529.             getCaptureFlags.numberOfCopies);
  530.  
  531. // Are we expanding tabs?
  532.          printf(" Tabs            : ");
  533.          if (getCaptureFlags.flags & 0x40)
  534.             printf("Converted to %d spaces\n",
  535.                getCaptureFlags.tabSize);
  536.          else
  537.             printf("Not converted\n");
  538.  
  539. // What form are we printing to?
  540.          printf("       Form            : ");
  541.          sprintf(temp, "%02d (%s)", getCaptureFlags.formType,
  542.             (getCaptureFlags.formName[0] >= 32) ? getCaptureFlags.formName : "default");
  543.          printf("%-15s", temp);
  544.  
  545. // How soon do we assume the job is finished?
  546.          printf(" Timeout         : ");
  547.          if (getCaptureFlags.flushCaptureTimeoutCount == 0)
  548.             printf("Disabled\n");
  549.          else
  550.             printf("%u seconds\n", IntSwap(getCaptureFlags.flushCaptureTimeoutCount)/18);
  551.  
  552. // Just for fun, where are the setup/reset buffers?
  553.          printf("       Setup buffer    : %04X:%04X     ",
  554.             xFP_SEG(LongSwap((long)getCaptureFlags.printerSetupBuffer)),
  555.             xFP_OFF(LongSwap((long)getCaptureFlags.printerSetupBuffer)));
  556.          printf("  Reset buffer    : %04X:%04X\n",
  557.             xFP_SEG(LongSwap((long)getCaptureFlags.printerResetBuffer)),
  558.             xFP_OFF(LongSwap((long)getCaptureFlags.printerResetBuffer)));
  559.       }
  560.       else
  561.          printf("Capturing not currently active.\n");
  562.    }
  563.    SetDefaultLocalPrinter(oldLPT);
  564.    exitout(0);
  565.  
  566. }
  567.  
  568. /****************************************************************************
  569.  usage: Show usage for command line options
  570.  ****************************************************************************/
  571. void usage()
  572. {
  573.    fprintf(stderr, "CAPIT v1.02x\n");
  574.    fprintf(stderr, "Usage:\n   ");
  575.    fprintf(stderr, "CAPIT -<opt><param> [-<opt><param>]\n");
  576.    fprintf(stderr, "   Where <opt> is one of the following:\n");
  577.    fprintf(stderr, "       /SHow /Server=fileserver /Queue=queue name /Local=n\n");
  578.    fprintf(stderr, "       /Form=form or n /CReate=path /Copies=n /TImeout=n /Tabs=n\n");
  579.    fprintf(stderr, "       /No Tabs /Banner=bannername /NAMe=name /No Banner /FormFeed\n");
  580.    fprintf(stderr, "       /No Form Feed /Autoendcap /No Autoendcap.\n\n");
  581.    fcloseall();
  582.    exitout(-1);
  583. }
  584.  
  585. /****************************************************************************
  586.  exitout: Cleanup routine
  587.  ****************************************************************************/
  588. void exitout(int retCode)
  589. {
  590.    if (oldConnectionID != 0)
  591.       SetPreferredConnectionID(oldConnectionID);
  592.    exit(retCode);
  593. }
  594.  
  595.