home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / XBBS7200.ZIP / XBBS7200.TAR / xbbsgen / xbbsgen.c
Encoding:
C/C++ Source or Header  |  1992-08-15  |  9.9 KB  |  345 lines

  1. #include <sys/types.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <sys/stat.h>
  5. #define    TAR    "tar"
  6. #define    ARC    "arc"
  7. #define ZIP    "zip"
  8. #define CONFIG    "/.config.bbs"
  9. struct stat statbuf;
  10. long atol();
  11. main()
  12. {
  13.     FILE *instream;
  14.     char    buffer[99], user[99], temp[99], bbs_soft[99], config_file[99];
  15.     int    i, result;
  16.     long    j;
  17.     printf("\nInput the full path name for the users home directory: ");
  18.     scanf("%s", user);
  19.     printf("\n");
  20.     strcpy(config_file, user);
  21.     strcat(config_file, CONFIG);
  22.     result = stat(config_file, &statbuf);
  23.     if(!result)
  24.     {
  25.         printf("\nThere already is a configuration file, please delete it or rename it!\n");
  26.         exit(1);
  27.     }
  28.     if((instream=fopen(config_file,"w")) == NULL)
  29.     {
  30.         printf("\nError opening configuration file for generation!\n");
  31.         exit(1);
  32.     }
  33.     printf("\nInput the directory name where the bbs software can be found: ");
  34.     scanf("%s", bbs_soft);
  35.     printf("\n");
  36.     strcpy(buffer,bbs_soft);
  37.     strcat(buffer, "/welcome.bbs\n");
  38.     fprintf(instream, "%s", buffer);
  39.     strcpy(buffer,bbs_soft);
  40.     strcat(buffer, "/bulletin.bbs\n");
  41.     fprintf(instream, "%s", buffer);
  42.     strcpy(buffer,bbs_soft);
  43.     strcat(buffer, "/newuser.bbs\n");
  44.     fprintf(instream, "%s", buffer);
  45.     strcpy(buffer,bbs_soft);
  46.     strcat(buffer,"/system.bbs\n");
  47.     fprintf(instream, "%s", buffer);
  48.     strcpy(buffer, bbs_soft);
  49.     strcat(buffer, "/callers.bbs\n");
  50.     fprintf(instream, "%s", buffer);
  51.     strcpy(buffer, bbs_soft);
  52.     strcat(buffer, "/lastcall.bbs\n");
  53.     fprintf(instream, "%s", buffer);
  54.     strcpy(buffer, bbs_soft);
  55.     strcat(buffer, "/users.bbs");
  56.     result = stat(buffer, &statbuf);
  57.     if( result != 0 )
  58.     {
  59.         strcpy(temp, "> ");
  60.         strcat(temp, buffer);
  61.         (void)system(temp);
  62.         strcpy(temp, "chown bbs ");
  63.         strcat(temp, buffer);
  64.         strcat(temp, "; chgrp root ");
  65.         strcat(temp, buffer);
  66.         strcat(temp, "; chmod 660 ");
  67.         strcat(temp, buffer);
  68.         (void)system(temp);
  69.     }
  70.     fprintf(instream, "%s\n", buffer);
  71.     strcpy(buffer, bbs_soft);
  72.     strcat(buffer, "/unixmsg.bbs\n");
  73.     fprintf(instream, "%s", buffer);
  74.     strcpy(buffer, bbs_soft);
  75.     strcat(buffer, "/dlmsg.bbs\n");
  76.     fprintf(instream, "%s", buffer);
  77.     strcpy(buffer, bbs_soft);
  78.     strcat(buffer, "/humor.bbs\n");
  79.     fprintf(instream, "%s", buffer);
  80.     strcpy(buffer, bbs_soft);
  81.     strcat(buffer, "/help.bbs\n");
  82.     fprintf(instream, "%s", buffer);
  83.     strcpy(buffer, bbs_soft);
  84.     strcat(buffer, "/helpfile.bbs\n");
  85.     fprintf(instream, "%s", buffer);
  86.     strcpy(buffer, bbs_soft);
  87.     strcat(buffer, "/helpmsg.bbs\n");
  88.     fprintf(instream, "%s", buffer);
  89.     strcpy(buffer, bbs_soft);
  90.     strcat(buffer, "/userpriv.bbs");
  91.     result = stat(buffer, &statbuf);
  92.     if( result != 0 )
  93.     {
  94.         strcpy(temp, "> ");
  95.         strcat(temp, buffer);
  96.         (void)system(temp);
  97.         strcpy(temp, "chown bbs ");
  98.         strcat(temp, buffer);
  99.         strcat(temp, "; chgrp root ");
  100.         strcat(temp, buffer);
  101.         strcat(temp, "; chmod 660 ");
  102.         strcat(temp, buffer);
  103.         (void)system(temp);
  104.     }
  105.     fprintf(instream, "%s\n", buffer);
  106.     strcpy(buffer, bbs_soft);
  107.     strcat(buffer, "/mainpriv.bbs\n");
  108.     fprintf(instream, "%s", buffer);
  109.     strcpy(buffer, bbs_soft);
  110.     strcat(buffer, "/filepriv.bbs\n");
  111.     fprintf(instream, "%s", buffer);
  112.     strcpy(buffer, bbs_soft);
  113.     strcat(buffer, "/question.bbs\n");
  114.     fprintf(instream, "%s", buffer);
  115.     strcpy(buffer, bbs_soft);
  116.     strcat(buffer, "/answer.bbs\n");
  117.     fprintf(instream, "%s", buffer);
  118.     strcpy(buffer, bbs_soft);
  119.     strcat(buffer, "/features.bbs\n");
  120.     fprintf(instream, "%s", buffer);
  121.     strcpy(buffer, bbs_soft);
  122.     strcat(buffer, "/listfile.bbs\n");
  123.     fprintf(instream, "%s", buffer);
  124.     strcpy(buffer, bbs_soft);
  125.     strcat(buffer, "/today > /tmp/today\n");
  126.     fprintf(instream, "%s", buffer);
  127.     strcpy(buffer, bbs_soft);
  128.     strcat(buffer, "/\n");
  129.     fprintf(instream, "%s", buffer);
  130.     strcpy(buffer, bbs_soft);
  131.     strcat(buffer, "/areas.bbs\n");
  132.     fprintf(instream, "%s", buffer);
  133.     strcpy(buffer, bbs_soft);
  134.     strcat(buffer, "/msgareas.bbs\n");
  135.     fprintf(instream, "%s", buffer);
  136.     strcpy(buffer, user);
  137.     strcat(buffer, "/\n");
  138.     fprintf(instream, "%s", buffer);
  139.     printf("\nInput the full path name for checksum: ");
  140.     scanf("%s", temp);
  141.     strcpy(buffer, temp);
  142.     strcat(buffer, " r \n");
  143.     fprintf(instream, "%s", buffer);
  144.     strcpy(buffer, temp);
  145.     strcat(buffer, " s \n");
  146.     fprintf(instream, "%s", buffer);
  147.     printf("\nInput the full path name for crc: ");
  148.     scanf("%s", temp);
  149.     strcpy(buffer, temp);
  150.     strcat(buffer, " r \n");
  151.     fprintf(instream, "%s", buffer);
  152.     strcpy(buffer, temp);
  153.     strcat(buffer, " s \n");
  154.     fprintf(instream, "%s", buffer);
  155.     printf("\nInput the full path name for ymod: ");
  156.     scanf("%s", temp);
  157.     strcpy(buffer, temp);
  158.     strcat(buffer, " r \n");
  159.     fprintf(instream, "%s", buffer);
  160.     strcpy(buffer, temp);
  161.     strcat(buffer, " s \n");
  162.     fprintf(instream, "%s", buffer);
  163.     printf("\nInput the full path name for rb: ");
  164.     scanf("%s", temp);
  165.     strcpy(buffer, temp);
  166.     strcat(buffer, "\n");
  167.     fprintf(instream, "%s", buffer);
  168.     printf("\nInput the full path name for sb: ");
  169.     scanf("%s", temp);
  170.     strcpy(buffer, temp);
  171.     strcat(buffer, " -k \n");
  172.     fprintf(instream, "%s", buffer);
  173.     printf("\nInput the full path name for rz: ");
  174.     scanf("%s", temp);
  175.     strcpy(buffer, temp);
  176.     strcat(buffer, "\n");
  177.     fprintf(instream, "%s", buffer);
  178.     printf("\nInput the full path name for sz: ");
  179.     scanf("%s", temp);
  180.     strcpy(buffer, temp);
  181.     strcat(buffer, " \n");
  182.     fprintf(instream, "%s", buffer);
  183.     printf("\nInput the full path name for kermit: ");
  184.     scanf("%s", temp);
  185.     strcpy(buffer, temp);
  186.     strcat(buffer, " -i -q -s \n");
  187.     fprintf(instream, "%s", buffer);
  188.     strcpy(buffer, temp);
  189.     strcat(buffer, " -i -w -q -r\n");
  190.     fprintf(instream, "%s", buffer);
  191.     strcpy(buffer, "ls ");
  192.     strcat(buffer, user);
  193.     strcat(buffer, " > /tmp/flist\n");
  194.     fprintf(instream, "%s", buffer);
  195.     printf("\nInput the full path name for sealink: ");
  196.     scanf("%s", temp);
  197.     strcpy(buffer, temp);
  198.     strcat(buffer, " -r \n");
  199.     fprintf(instream, "%s", buffer);
  200.     strcpy(buffer, temp);
  201.     strcat(buffer, " -s \n");
  202.     fprintf(instream, "%s", buffer);
  203.     printf("\nInput the first name of the sysop: ");
  204.     scanf("%s", temp);
  205.     fix_name(temp);
  206.     strcpy(buffer, temp);
  207.     printf("\nInput the last name of the sysop: ");
  208.     scanf("%s", temp);
  209.     fix_name(temp);
  210.     strcat(buffer, " ");
  211.     strcat(buffer, temp);
  212.     fprintf(instream, "%s\n", buffer);
  213.     printf("\nInput the number of SECONDS you will allow for a login: ");
  214.     scanf("%s", temp);
  215.     j = atol(temp);
  216.     if(j < 60L ) j=60L;
  217.     if(j > 32767L) j=32767L;
  218.     sprintf(buffer, "%ld", j);
  219.     fprintf(instream, "%s\n", buffer);
  220.     printf("\nInput the number of SECONDS you will allow for usage: ");
  221.     scanf("%s", temp);
  222.     j = atol(temp);
  223.     if(j < 60L ) j=60L;
  224.     if(j > 32767L) j=32767L;
  225.     sprintf(buffer, "%ld", j);
  226.     fprintf(instream, "%s\n", buffer);
  227.     printf("\nInput the number of SECONDS you will allow for response: ");
  228.     scanf("%s", temp);
  229.     j = atol(temp);
  230.     if(j < 60L ) j=60L;
  231.     if(j > 32767L) j=32767L;
  232.     sprintf(buffer, "%ld", j);
  233.     fprintf(instream, "%s\n", buffer);
  234.     printf("\nInput the privilege level for new users: ");
  235.     scanf("%s", temp);
  236.     j = atol(temp);
  237.     if(j < 1L ) j=1L;
  238.     if(j > 32767L) j=32767L;
  239.     sprintf(buffer, "%ld", j);
  240.     fprintf(instream, "%s\n", buffer);
  241.     printf("\nInput the maximum privilege level allowed to users: ");
  242.     scanf("%s", temp);
  243.     j = atol(temp);
  244.     if(j < 1L ) j=1L;
  245.     if(j > 32767L) j=32767L;
  246.     sprintf(buffer, "%ld", j);
  247.     fprintf(instream, "%s\n", buffer);
  248.     printf("\nInput the maximum number of seconds allowed to users: ");
  249.     scanf("%s", temp);
  250.     j = atol(temp);
  251.     if(j < 1L ) j=1L;
  252.     if(j > 32767L) j=32767L;
  253.     sprintf(buffer, "%ld", j);
  254.     fprintf(instream, "%s\n", buffer);
  255.     printf("\nInput the daily number of KILOBYTES allowed to users: ");
  256.     scanf("%s", temp);
  257.     j = atol(temp);
  258.     if(j < 1L ) j=1L;
  259.     if(j > 32767L) j=32767L;
  260.     sprintf(buffer, "%ld", j);
  261.     fprintf(instream, "%s\n", buffer);
  262.     printf("\nInput the full path name for tar: ");
  263.     scanf("%s", temp);
  264.     strcpy(buffer, temp);
  265.     strcat(buffer, " -tvf \n");
  266.     fprintf(instream, "%s", buffer);
  267.     printf("\nInput the full path name for zcat( link to compress): ");
  268.     scanf("%s", temp);
  269.     strcpy(buffer, temp);
  270.     strcat(buffer, " \n");
  271.     fprintf(instream, "%s", buffer);
  272. /*
  273.  *    Starting with version 7.102, external arc and zip programs are
  274.  *    no longer needed! To be compatible with the older .config.bbs files,
  275.  *    we will just put something there for old time sake!
  276.  *
  277.  *    printf("\nInput the full path name for arc: ");
  278.  *    scanf("%s", temp);
  279.  *    strcpy(buffer, temp);
  280.  *    strcat(buffer, " -v \n");
  281.  *    fprintf(instream, "%s", buffer);
  282.  *    printf("\nInput the full path name for unzip: ");
  283.  *    scanf("%s", temp);
  284.  *    strcpy(buffer, temp);
  285.  *    strcat(buffer, " -v \n");
  286.  *    fprintf(instream, "%s", buffer);
  287. */
  288.  
  289.     fprintf(instream, "/usr/bin/arc -v \n");   /*  fake arc  */
  290.     fprintf(instream, "/usr/bin/zip -v \n");   /*  fake zip  */
  291.  
  292.  
  293.     printf("\nInput the full path name of the dev driver for local monitoring: ");
  294.     scanf("%s", buffer);
  295.     fprintf(instream, "%s\n", buffer);
  296.     printf("\nInput the full path name for the console device driver: ");
  297.     scanf("%s", buffer);
  298.     fprintf(instream, "%s\n", buffer);
  299.     printf("\nInput the full path name for the SHELL and command switch");
  300.     printf("\nyou wish to use for the U(nix) option in the main menu.");
  301.     printf("\nExample: /bin/sh ");
  302.     printf("\n?  ");
  303.     scanf("%s", buffer);
  304.     fprintf(instream, "%s -i\n", buffer);
  305. logloop:
  306.     printf("\nDo wish to have the software do a message scan when the user\n");
  307.     printf("logs on? 1=yes, 0=no ..... ");
  308.     scanf("%s", temp);
  309.     i = atoi(temp);
  310.     if( i > 1 || i < 0) goto logloop;
  311.     sprintf(buffer, "%d", i);
  312.     fprintf(instream, "%s\n", buffer);
  313.     printf("\nInput the full path name to be used for the USENET reader.\n");
  314.     printf("Example: /usr/bin/readnews : ");
  315.     scanf("%s", buffer);
  316.     fprintf(instream, "%s\n", buffer);
  317.     printf("\nInput the full path name to be used for the USENET poster.\n");
  318.     printf("Example: /usr/bin/postnews : ");
  319.     scanf("%s", buffer);
  320.     fprintf(instream, "%s\n", buffer);
  321.     fclose(instream);
  322.     printf("\n\n\nConfiguration file has been generated!\n\n\n");
  323. }
  324. fix_name(adr) char *adr ;
  325.     {
  326.     char *adrs, *str_ptr;
  327.     char tempbf[30];
  328.     adrs = adr ;
  329.     while(*adrs)
  330.         {
  331.         *adrs = tolower(*adrs) ;
  332.         adrs++ ;
  333.         }
  334.     while (1)
  335.         {
  336.         str_ptr = strrchr(adr, ' ');
  337.         if(str_ptr == NULL) break;
  338.         *str_ptr++ = '\0';
  339.         strcpy(tempbf, adr);
  340.         strcat(tempbf, str_ptr);
  341.         strcpy(adr,tempbf);
  342.         }
  343.     *adr = toupper(*adr) ;
  344.     }
  345.