home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / WWIV2.ZIP / NETINIT.C < prev    next >
C/C++ Source or Header  |  1992-01-01  |  3KB  |  85 lines

  1. /****************************************************************************
  2.  *
  3.  * This program should be used by registered WWIV sysops with modified
  4.  * userrecords.  Compile this with your modified vardec.h, and run it
  5.  * in your main WWIV directory.  It will appropriately update your
  6.  * config.dat file.
  7.  *
  8.  ****************************************************************************/
  9.  
  10. #include <stdio.h>
  11. #include <io.h>
  12. #include <fcntl.h>
  13. #include <dos.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include "vardec.h"
  17.  
  18.   int f,configfile,urlen,uroff,nl,no,uroff1,no1,uroff2;
  19.   configrec syscfg;
  20.   char ch,s[81];
  21.   userrec *u;
  22.  
  23.  
  24. void main()
  25. {
  26.   printf("The netinit program is a utility for registered WWIV sysops.\n");
  27.   printf("It is necessary to run netinit.exe ONLY if you are a registered WWIV sysop and\n");
  28.   printf("have modified some of the data in the vardec.h file.\n\n");
  29.   printf("Compile (with your modified vardec.h file) and run netinit, and it\n");
  30.   printf("will set the appropriate fields in the config.dat file.\n\n");
  31.  
  32.   configfile=open("CONFIG.DAT",O_RDWR | O_BINARY);
  33.   if (configfile<0) {
  34.     printf("CONFIG.DAT NOT FOUND.\n");
  35.     exit(1);
  36.   }
  37.   read(configfile,(&syscfg), sizeof(configrec));
  38.   close(configfile);
  39.  
  40.  
  41.   /* these are the default values */
  42.   urlen=700;
  43.   uroff=423;
  44.   uroff1=385;
  45.   uroff2=620;
  46.  
  47.   /* doesn't hurt to put them in here, even though they'll be overwritten */
  48.   if (syscfg.userreclen==0)
  49.     syscfg.userreclen=urlen;
  50.   if (syscfg.waitingoffset==0)
  51.     syscfg.waitingoffset=uroff;
  52.   if (syscfg.inactoffset==0)
  53.     syscfg.inactoffset=uroff1;
  54. #ifdef v421
  55.   if (syscfg.sysstatusoffset==0)
  56.     syscfg.sysstatusoffset=uroff2;
  57. #endif
  58.  
  59.   /* find the new values to use */
  60.   urlen=sizeof(userrec);
  61.   uroff=FP_OFF(&(u->waiting))-FP_OFF(u);
  62.   uroff1=FP_OFF(&(u->inact))-FP_OFF(u);
  63.   uroff2=FP_OFF(&(u->sysstatus))-FP_OFF(u);
  64.  
  65.   /* tell the user what the new values are */
  66.   printf("setting userreclen=%d, waitingoffset=%d, inactoffset=%d, sysstatusoffset=%d\n\n",
  67.     urlen, uroff, uroff1, uroff2);
  68.  
  69.   /* put the new values into the syscfg structure */
  70.   syscfg.userreclen=urlen;
  71.   syscfg.waitingoffset=uroff;
  72.   syscfg.inactoffset=uroff1;
  73. #ifdef v421
  74.   syscfg.sysstatusoffset=uroff2;
  75. #else
  76.   *((int *)(((char *)&syscfg)+5621))=uroff2;
  77. #endif
  78.  
  79.   /* store the new config.dat file */
  80.   configfile=open("CONFIG.DAT",O_RDWR | O_BINARY);
  81.   write(configfile,(void *) (&syscfg), sizeof(configrec));
  82.   close(configfile);
  83.   printf("\nConfiguration set.\n");
  84. }
  85.