home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / OSNPOLL.ZIP / OSNPOLL.C next >
C/C++ Source or Header  |  1989-07-21  |  5KB  |  144 lines

  1. /*
  2.  
  3.  NPOLL.EXE is program for creating a file in the Opus outbound directory
  4.  that will cause calls to be placed.
  5.  
  6.  You're welcome to use this program and the source code in any way you see
  7.  fit so long as you adhere to the "freindly, legal and free" copyright that
  8.  most of OPUS is involved with.  Please remember that the best way to force
  9.  utility writers to stop releasing code is to abuse their generosity.
  10.  
  11.  This was <originally> written and compiled with Borland's Turbo C.
  12.  
  13.  
  14.  The new Version is OSNPOLL.EXE modified by Steve Lesner @ 141/260.
  15.  It was real simple.  I just used 2 Doscalls.lib file functions and
  16.  shook out some possible OS/2 Errors.  Enjoy and remember to share your
  17.  OS/2 code.  There's not much out there for us OS/2 Fans and we gotta
  18.  make it happen!
  19.  
  20. */
  21.  
  22.  
  23. #define INCL_DOS
  24.  
  25. #include <os2.h>
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <conio.h>
  29. #include <string.h>
  30.  
  31.  
  32. void usage(void);
  33.  
  34.  
  35.     int     i,node[25],net[25];
  36.     char     *sptr;
  37.     char     firstchar[25];
  38.     int     add_count=0;
  39.     char     *path="\\WWBBS\\MAIL\\Outbound";
  40.  
  41.          /* I set this up as the default path to create the poll
  42.             files.  Keep in mind that if you do not use the
  43.             -P Option, you will have to change the above path
  44.             var to your own outbound and recompile with
  45.             cl /c /AS /Zpe /Zl /G2 /W3 osnpoll.c and link it
  46.             with doscalls and slibce(p). */
  47.  
  48.     char     s[80];
  49.  
  50.     USHORT     fp;
  51.     unsigned action;
  52.  
  53.  
  54.  
  55. void main(argc,argv)
  56. char    *argv[];
  57. int     argc;
  58.  
  59. {
  60. int    send;
  61.  
  62. /* Process the "-" switches   */
  63.     if (argc < 2)
  64.         usage();
  65.     for (i=1; i<argc; i++){
  66.         sptr=argv[i];
  67.         if(sptr[0] == '-'){
  68.                 switch(tolower(sptr[1])){
  69.  
  70.                         case 'h' :     if (strlen(sptr)>3){
  71.                                         firstchar[add_count]='H';
  72.                                         sscanf(sptr+2,"%d/%d",&net[add_count],&node[add_count]);
  73.                                         add_count++;
  74.                                      }
  75.                                      else printf("\n No address listed, skipping\n");
  76.                                      break;
  77.  
  78.                         case 'n' :     if (strlen(sptr)>3){
  79.                                         firstchar[add_count]='F';
  80.                                         sscanf(sptr+2,"%d/%d",&net[add_count],&node[add_count]);
  81.                                         add_count++;
  82.                                      }
  83.                                      else printf("\n No address listed, skipping\n");
  84.                                      break;
  85.  
  86.                         case 'c' :     if (strlen(sptr)>3){
  87.                                         firstchar[add_count]='C';
  88.                                         sscanf(sptr+2,"%d/%d",&net[add_count],&node[add_count]);
  89.                                         add_count++;
  90.                                      }
  91.                                      else printf("\n No address listed, skipping\n");
  92.                                      break;
  93.  
  94.  
  95.                         case 'p'  :  path = sptr+2;
  96.                                      break;
  97.  
  98.                         default   :  cprintf("I don't understand '%s' skipping it.\r\n",sptr);
  99.                                      break;
  100.                 }
  101.             }
  102.         }
  103.  
  104.  /* This is so you can enter either "C:\Opus\Outbound" or C:\Opus\Outbound\" */
  105.  
  106.         if (path[strlen(path)-1] == '\\')
  107.                 path[strlen(path)-1]='\0';
  108.  
  109.  
  110.  
  111.         for (send=0;send<add_count;send++){
  112.             sprintf(s,"%s\\%04X%04X.%cLO", path,net[send],node[send],firstchar[send]);
  113.         if (DosOpen((char far *) s,
  114.             (USHORT far *) &fp,
  115.             (unsigned far *) &action,
  116.             0l,
  117.             0,
  118.             0x11,
  119.             0x11,
  120.             0L))
  121.         {
  122.             cprintf("Can't open FLO file (%s), errno=%d\r\n",s,2);
  123.                     usage();
  124.             }
  125.         DosClose(fp);
  126.             printf("Poll generated for %d/%d\n",net[send],node[send]);
  127.         }
  128. }
  129.  
  130.  
  131. void usage()
  132. {
  133.  
  134.     printf("nPOLL -[N,H,C]net/node -Ppath\n\n");
  135.     printf("-Nnet/node ...... Mark this as a 'Normal' file for net/node\n");
  136.     printf("-Hnet/node ...... Mark this as a 'Hold for pickup' file for net/node\n");
  137.     printf("-Cnet/node ...... Mark this as a 'Continuous Send (Crash)' file for net/node\n");
  138.     printf("-P ......... Path to your outbound holding area. If you don't \n");
  139.     printf("             specify one, nPOLL will use \\WWBBS\\MAIL\\OUTBOUND.\n\n");
  140.     printf("  You can poll more than one address just by adding more -c/-h/-o\n");
  141.     printf("  address to the command line (up to 15), mixing their tags.\n\n");
  142.         exit(1);
  143. }
  144.