home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / top2src.zip / SPAWN.C < prev    next >
C/C++ Source or Header  |  2000-07-13  |  5KB  |  159 lines

  1. #include "top.h"
  2.  
  3. /*  Copyright 1993 - 2000 Paul J. Sidorsky
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License, version 2, as
  7.     published by the Free Software Foundation.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program; if not, write to the Free Software
  16.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  17. */
  18.  
  19. char load_spawn_progs(void)
  20.     {
  21.     FILE *spfil;
  22.     XINT d;
  23.     unsigned char loadstr[513];
  24.  
  25.     spfil = fopen("SPAWN.CFG", "rt");
  26.     if (spfil == NULL)
  27.         {
  28.         return 0;
  29.         }
  30.  
  31.     rewind(spfil);
  32.     while(!feof(spfil))
  33.         {
  34.         if (fgets(loadstr, 512, spfil) != NULL)
  35.             {
  36.             if (fgets(loadstr, 512, spfil) != NULL)
  37.                 {
  38.                 if (fgets(loadstr, 512, spfil) != NULL)
  39.                     {
  40.                     numspawnprog++;
  41.                     }
  42.                 }
  43.             }
  44.         }
  45.  
  46.     spawnprog = malloc(numspawnprog * sizeof(spawn_prog_typ));
  47.     if (spawnprog == NULL)
  48.         {
  49.         fclose(spfil);
  50.         return 0;
  51.         }
  52.  
  53.     rewind(spfil);
  54.  
  55.     for (d = 0; d < numspawnprog; d++)
  56.         {
  57.         memset(&spawnprog[d], 0, sizeof(spawn_prog_typ));
  58.         fgets(loadstr, 512, spfil);
  59.         stripcr(loadstr);
  60.         strncpy(spawnprog[d].name, loadstr, 40);
  61.         fgets(loadstr, 512, spfil);
  62.         stripcr(loadstr);
  63.         strncpy(spawnprog[d].cmds, loadstr, 80);
  64.         fgets(loadstr, 512, spfil);
  65.         stripcr(loadstr);
  66.         strncpy(spawnprog[d].cmdline, loadstr, 128);
  67.         }
  68.  
  69.     fclose(spfil);
  70.  
  71.     return 1;
  72.     }
  73.  
  74. char check_spawn_cmds(XINT cmdwds)
  75.     {
  76.     XINT d, c, t;
  77.     unsigned char cmdstr[256];
  78.  
  79.     if (cmdwds > 1)
  80.         {
  81.         return 0;
  82.         }
  83.  
  84.     for (d = 0; d < numspawnprog; d++)
  85.         {
  86.         if (checkcmdmatch(get_word(0), spawnprog[d].cmds))
  87.             {
  88.             top_output(OUT_SCREEN, getlang("SpawnPrefix"));
  89.             memset(cmdstr, 0, 256);
  90.             for (c = 0, t = 0; c < strlen(spawnprog[c].cmdline); c++)
  91.                 {
  92.                 if (spawnprog[d].cmdline[c] == '*')
  93.                     {
  94.                     c++;
  95.                     if (spawnprog[d].cmdline[c] == 'A');
  96.                         {
  97.                         strcat(cmdstr, od_control.user_handle);
  98.                         t = strlen(cmdstr);
  99.                         }
  100.                     if (spawnprog[d].cmdline[c] == 'B');
  101.                         {
  102.                         ultoa(od_control.od_baud, outnum[0], 10);
  103.                         strcat(cmdstr, outnum[0]);
  104.                         t = strlen(cmdstr);
  105.                         }
  106.                     if (spawnprog[d].cmdline[c] == 'F');
  107.                         {
  108.                         strcat(cmdstr, );
  109.                         t = strlen(cmdstr);
  110.                         }
  111.                     if (spawnprog[d].cmdline[c] == 'G');
  112.                         {
  113.                         itoa(od_control.user_ansi, outnum[0], 10);
  114.                         strcat(cmdstr, outnum[0]);
  115.                         t = strlen(cmdstr);
  116.                         }
  117.                     if (spawnprog[d].cmdline[c] == '');
  118.                         {
  119.                         strcat(cmdstr, );
  120.                         t = strlen(cmdstr);
  121.                         }
  122.                     if (spawnprog[d].cmdline[c] == '');
  123.                         {
  124.                         strcat(cmdstr, );
  125.                         t = strlen(cmdstr);
  126.                         }
  127.                     if (spawnprog[d].cmdline[c] == '');
  128.                         {
  129.                         strcat(cmdstr, );
  130.                         t = strlen(cmdstr);
  131.                         }
  132.                     if (spawnprog[d].cmdline[c] == '');
  133.                         {
  134.                         strcat(cmdstr, );
  135.                         t = strlen(cmdstr);
  136.                         }
  137.                     if (spawnprog[d].cmdline[c] == '');
  138.                         {
  139.                         strcat(cmdstr, );
  140.                         t = strlen(cmdstr);
  141.                         }
  142.                     if (spawnprog[d].cmdline[c] == '');
  143.                         {
  144.                         strcat(cmdstr, );
  145.                         t = strlen(cmdstr);
  146.                         }
  147.                     }
  148.                 }
  149.  
  150.             od_spawn(spawnprog[d].cmdline);
  151.             top_output(OUT_SCREEN, getlang("SpawnSuffix"));
  152.             return 1;
  153.             }
  154.         }
  155.  
  156.     return 0;
  157.     }
  158.  
  159.