home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 129_01 / ctdlchng.c < prev    next >
Text File  |  1985-03-10  |  8KB  |  208 lines

  1. #include <210ctdl.h>
  2. /*****************************************************************************/
  3. /*                ctdlchng.c                     */
  4. /*                                         */
  5. /*         Allows fast changes of ctdlcnfg.sys parameters          */
  6. /*****************************************************************************/
  7.  
  8. /*****************************************************************************/
  9. /*                history                      */
  10. /*                                         */
  11. /* 84Jun22 HAW    Created.                             */
  12. /*****************************************************************************/
  13.  
  14. /*****************************************************************************/
  15. /*                contents                     */
  16. /*                                         */
  17. /*    doerror()        Writes out an error msg              */
  18. /*    explanation()        Explains use of program              */
  19. /*    flip()            Flips a specified boolean value          */
  20. /*    main()            Main controller for this program         */
  21. /*    setval()        Sets the specified variable to a value         */
  22. /*****************************************************************************/
  23.  
  24. /*****************************************************************************/
  25. /*                External files                     */
  26. /*                                         */
  27. /*                210rooma.c                     */
  28. /*                210misc.c                     */
  29. /*                                         */
  30. /*    The files cited above must be linked in -- additionally, this file   */
  31. /*    must be compiled using the same -e address as Citadel.             */
  32. /*****************************************************************************/
  33.  
  34.  
  35. /*****************************************************************************/
  36. /*    doerror()    Writes out an error msg.                 */
  37. /*****************************************************************************/
  38. doerror(str)
  39. char *str;
  40. {
  41.     printf("The argument \"%s\" is invalid!\n", str);
  42. }
  43.  
  44. /*****************************************************************************/
  45. /*    explanation()    explanation of use of program                 */
  46. /*****************************************************************************/
  47. explanation()
  48. {
  49.     printf(
  50. "   IMPROPER USAGE: This program is used to change certain parameters\n");
  51.     printf(
  52. "of the CTDLCNFG.SYS file.  NOT ALL parameters may be changed.    However,\n");
  53.     printf(
  54. "using this program to change those accessible allows the SYSOP to bypass\n");
  55.     printf(
  56. "reconfiguration everytime s/he wishes to change a minor parameter of\n");
  57.     printf(
  58. "Citadel.  The file CTDLTABL.SYS should be on the logged in disk and in\n");
  59.     printf("the logged in user area.\n\n");
  60.     printf("USAGE:\n");
  61.     printf(
  62. "Z>CTDLCHNG <parameter1> <optional parameter2> <...> ... <last parameter>\n");
  63.     printf("\n");
  64.     printf(
  65. "Thus, there must be at least one parameter, and there may be more.  Err-\n");
  66.     printf(
  67. "oneous parameters will be noted to the user.  In the following list, a\n");
  68.     printf(
  69. "parameter that is just listed as a name is a parameter which may be either\n");
  70.     printf(
  71. "TRUE (1) or FALSE (0). Therefore, CTDCHNG, upon finding it on the argument\n");
  72.     printf(
  73. "list, will simply reverse its value. For integer parameters, the parameter\n");
  74.     printf(
  75. "name should be followed by an '=' and then an integer, signifying the\n");
  76.     printf(
  77. "new value.  The legal parameters (and as they appear on the command line)\n");
  78.     printf("are as follows\n");
  79.     printf("  CLOCK\n");
  80.     printf(
  81. "  MDATA=x    x in this case would be the data port. This should be\n");
  82.     printf("         decimal!\n");
  83.     printf(
  84. "  MEGAHZ=x   x in this case is the new clock speed of your computer.\n");
  85.     printf("  RCPM\n");
  86.     printf(
  87. "  HOMEDISK=x x in this case should be the new homedisk number (see\n");
  88.     printf("         CTDLCNFG.SYS)\n");
  89.     printf(
  90. "  HOMEUSER=x x in this case should be the new homeuser number (see\n");
  91.     printf("         CTDLCNFG.SYS)\n");
  92.     printf(
  93. "  MSGDISK=x  x in this case should be the new msgdisk number (see\n");
  94.     printf("         CTDLCNFG.SYS)\n");
  95.     printf("  LOGINOK\n");
  96.     printf("  READOK\n");
  97.     printf("  ENTEROK\n");
  98.     printf("  ROOMOK\n\n");
  99.     printf(
  100. "For example, to change stop letting unlogged users read msgs (i.e., your\n");
  101.     printf("CTDLCNFG.SYS of READOK was originally 1), type\n");
  102.     printf("A>CTDLCHNG READOK\n");
  103.     printf("and the program will change the value for you.\n\n");
  104.     printf(
  105. "P.S.: All integer values should be decimal here, unlike CTDLCNG.SYS\n\n");
  106. }
  107.  
  108. /*****************************************************************************/
  109. /*    flip()    Flips the boolean value of the specified variable.         */
  110. /*****************************************************************************/
  111. flip(str)
  112. char *str;
  113. {
  114.     if (strCmp(str, "ROOMOK"   ) == SAMESTRING)
  115.     printf("%s set to %d\n", str, nonAideRoomOk = !nonAideRoomOk);
  116.     else if (strCmp(str, "ENTEROK"  ) == SAMESTRING)
  117.     printf("%s set to %d\n", str, unlogEnterOk = !unlogEnterOk);
  118.     else if (strCmp(str, "READOK"   ) == SAMESTRING)
  119.     printf("%s set to %d\n", str, unlogReadOk = !unlogReadOk);
  120.     else if (strCmp(str, "LOGINOK"  ) == SAMESTRING)
  121.     printf("%s set to %d\n", str, unlogLoginOk = !unlogLoginOk);
  122.     else if (strCmp(str, "RCPM"     ) == SAMESTRING)
  123.     printf("%s set to %d\n", str, rcpm = !rcpm);
  124.     else if (strCmp(str, "CLOCK"    ) == SAMESTRING)
  125.     printf("%s set to %d\n", str, clock = !clock);
  126.     else if (strCmp(str, "ALLMAIL"  ) == SAMESTRING)
  127.     printf("%s set to %d\n", str, !(noMail = !noMail));
  128. }
  129.  
  130. #define FLIP    1
  131. #define NEWVAL    2
  132.  
  133. identify(str, val)
  134. char *str;
  135. int  *val;
  136. {
  137.     char notBoolean, *searchV, *searchB;
  138.     int  loc;
  139.  
  140.     searchB = "ROOMOK|ENTEROK|READOK|LOGINOK|RCPM|CLOCK|ALLMAIL";
  141.     searchV = "MSGDISK|HOMEUSER|HOMEDISK|MEGAHZ|MDATA";
  142.  
  143.     notBoolean = !((loc = index(str, "=")) == ERROR);
  144.  
  145.     if (!notBoolean)
  146.     return (index(searchB, str) == ERROR) ? ERROR : FLIP;
  147.     else {
  148.     str[loc] = '\0';
  149.     if (index(searchV, str) == ERROR) {
  150.         str[loc] = '=';
  151.         return ERROR;
  152.     }
  153.     *val = atoi(str + loc + 1);
  154.     return NEWVAL;
  155.     }
  156. }
  157.  
  158. /*****************************************************************************/
  159. /*    main()    the main controller                         */
  160. /*****************************************************************************/
  161. main(argc, argv)
  162. int  argc;
  163. char **argv;
  164. {
  165.     int i, val;
  166.  
  167.     if (argc < 2) exit(explanation());
  168.     readSysTab();
  169.     for (i = 1; i < argc; i++) {
  170.     switch (identify(argv[i], &val)) {
  171.         case FLIP  :    flip(argv[i])         ;    break;
  172.         case NEWVAL:    setval(argv[i], val)     ;    break;
  173.         case ERROR :    doerror(argv[i])         ;    break;
  174.         default    :    exit(printf("BUG-BUG-BUG!")) ;    break;
  175.     }
  176.     }
  177.     writeSysTab();
  178.  
  179.     printf(
  180. " ABSOLUTELY don't forget to change these values in CTDLCNFG.SYS.  No, you\n");
  181.     printf(
  182. "don't have to reconfigure now, but the next time you crash they had better\n");
  183.     printf(
  184. "be set or unknown, grisly things will happen to Citadel and you when you\n");
  185.     printf(" sleep!\n");
  186. }
  187.  
  188. /*****************************************************************************/
  189. /*    setval()    Sets the specified variable to val.             */
  190. /*****************************************************************************/
  191. setval(str, val)
  192. char *str;
  193. int  val;
  194. {
  195.     if (strCmp(str, "MSGDISK"  ) == SAMESTRING)
  196.     printf("%s set to %d\n", str, msgDisk = val);
  197.     else if (strCmp(str, "HOMEUSER" ) == SAMESTRING)
  198.     printf("%s set to %d\n", str, homeUser = val);
  199.     else if (strCmp(str, "HOMEDISK" ) == SAMESTRING)
  200.     printf("%s set to %d\n", str, homeDisk = val);
  201.     else if (strCmp(str, "MEGAHZ"   ) == SAMESTRING)
  202.     printf("%s set to %d\n", str, megaHz = val);
  203.     else if (strCmp(str, "MDATA"    ) == SAMESTRING)
  204.     printf("%s set to %d\n", str, mData = val);
  205. }
  206. ");
  207.     printf(
  208. "don't have to re