home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / UTIL / WWIVE / NETINIT.C < prev    next >
C/C++ Source or Header  |  1991-04-08  |  2KB  |  74 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;
  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.  
  46.   /* doesn't hurt to put them in here, even though they'll be overwritten */
  47.   if (syscfg.userreclen==0)
  48.     syscfg.userreclen=urlen;
  49.   if (syscfg.waitingoffset==0)
  50.     syscfg.waitingoffset=uroff;
  51.   if (syscfg.inactoffset==0)
  52.     syscfg.inactoffset=uroff1;
  53.  
  54.   /* find the new values to use */
  55.   urlen=sizeof(userrec);
  56.   uroff=FP_OFF(&(u->waiting))-FP_OFF(u->name);
  57.   uroff1=FP_OFF(&(u->inact))-FP_OFF(u->name);
  58.  
  59.   /* tell the user what the new values are */
  60.   printf("setting: userreclen=%d, waitingoffset=%d, inactoffset=%d\n\n",
  61.     urlen, uroff, uroff1);
  62.  
  63.   /* put the new values into the syscfg structure */
  64.   syscfg.userreclen=urlen;
  65.   syscfg.waitingoffset=uroff;
  66.   syscfg.inactoffset=uroff1;
  67.  
  68.   /* store the new config.dat file */
  69.   configfile=open("CONFIG.DAT",O_RDWR | O_BINARY);
  70.   write(configfile,(void *) (&syscfg), sizeof(configrec));
  71.   close(configfile);
  72.   printf("\nConfiguration set.\n");
  73. }
  74.