home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 196.img / WWIV412.ZIP / SKELETON.C < prev    next >
C/C++ Source or Header  |  1989-01-03  |  5KB  |  206 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <io.h>
  4. #include <fcntl.h>
  5. #include <dos.h>
  6. #include <stdlib.h>
  7.  
  8.  
  9. #define v407
  10.  
  11.  
  12. int    usernum,             /* user number for the user */
  13.        age,                 /* age of the user */
  14.        screenchars,         /* chars/line user has specified */
  15.        screenlines,         /* lines/screen user has specified */
  16.        sl,                  /* sec lev for user (0-255) */
  17.        so,                  /* non-zero if user is sysop (sl=255) */
  18.        cs,                  /* non-zero if user is co-sysop */
  19.        okansi,              /* non-zero if user can support ANSI */
  20.        incom,               /* non-zero if user is calling remotely */
  21.        comport;             /* com port user is on */
  22. char   name[81],            /* name/alias of user */
  23.        realname[81],        /* real name of user */
  24.        callsign[10],        /* amateur radio callsign of user */
  25.        sex,                 /* sex of user, M or F */
  26.        laston[81],          /* date user was last on */
  27.        gfiles[81],          /* directory for text files, ends in \ */
  28.        data[81],            /* directory for non-text files, ends in \ */
  29.        sysoplog[81],        /* full path & filename for sysop log */
  30.        curspeed[81];        /* speed user is on at, "KB" if local */
  31. double gold,                /* gold user has */
  32.        timeallowed,         /* number of seconds before user logged off */
  33.        version;             /* version of WWIV running under */
  34.  
  35.  
  36. #ifdef v407
  37.  
  38. /* function pointers for BBS functions.  ONLY used for 4.07 or later. */
  39.  
  40. void far interrupt (*inli)(char *, char *, int, int);
  41. void far interrupt (*checka)(int *, int *);
  42. void far interrupt (*pla)(char *, int *);
  43. void far interrupt (*outchr)(char);
  44. void far interrupt (*outstr)(char *);
  45. void far interrupt (*nl)();
  46. void far interrupt (*pl)(char *);
  47. int  far interrupt (*empty)();
  48. char far interrupt (*inkey)();
  49. unsigned char far interrupt (*getkey)();
  50. void far interrupt (*input)(char *, int);
  51. void far interrupt (*inputl)(char *, int);
  52. int  far interrupt (*yn)();
  53. int  far interrupt (*ny)();
  54. void far interrupt (*ansic)(int);
  55. char far interrupt (*onek)(char *);
  56. void far interrupt (*prt)(int, char *);
  57. void far interrupt (*mpl)(int);
  58.  
  59. void far **funcs;
  60.  
  61. #endif
  62.  
  63. int read_in_data(char *fn)
  64. {
  65.   char buf[1024];
  66.   char *ptr[30],*ss,s[81];
  67.   int i,f,len,i1;
  68.   float fl;
  69.  
  70.   f=open(fn,O_RDONLY | O_BINARY);
  71.   if (f<0) {
  72.     return(-1);
  73.   }
  74.   i1=1;
  75.   ptr[0]=buf;
  76.   len=read(f,(void *)buf,1024);
  77.   close(f);
  78.   for (i=0; i<len; i++)
  79.     if (buf[i]==13) {
  80.       buf[i]=0;
  81.       ptr[i1++]=&buf[i+2];
  82.     }
  83.   while (*ptr[6]==32)
  84.     ++(ptr[6]);
  85.   while (*ptr[15]==32)
  86.     ++(ptr[15]);
  87.   usernum=atoi(ptr[0]);
  88.   strcpy(name,ptr[1]);
  89.   strcpy(realname,ptr[2]);
  90.   strcpy(callsign,ptr[3]);
  91.   age=atoi(ptr[4]);
  92.   sex=*ptr[5];
  93.   sscanf(ptr[6],"%f",&fl);
  94.   gold=(double)fl;
  95.   strcpy(laston,ptr[7]);
  96.   screenchars=atoi(ptr[8]);
  97.   screenlines=atoi(ptr[9]);
  98.   sl=atoi(ptr[10]);
  99.   so=atoi(ptr[11]);
  100.   cs=atoi(ptr[12]);
  101.   okansi=atoi(ptr[13]);
  102.   incom=atoi(ptr[14]);
  103.   sscanf(ptr[15],"%f",&fl);
  104.   timeallowed=(double)fl;
  105.   strcpy(gfiles,ptr[16]);
  106.   strcpy(data,ptr[17]);
  107.   strcpy(sysoplog,gfiles);
  108.   strcat(sysoplog,ptr[18]);
  109.   strcpy(curspeed,ptr[19]);
  110.   comport=atoi(ptr[20]);
  111.  
  112.   version=-1.0;
  113.   ss=getenv("BBS");
  114.   if (strncmp(ss,"WWIV",4)) {
  115. #ifdef v407
  116.     printf("\nThis program MUST be run under WWIV v4.07 or later.\n");
  117.     exit(0);
  118. #else
  119.     printf("\nWARNING: Not running under WWIV\n");
  120.     return(0);
  121. #endif
  122.   }
  123.   strcpy(s,&(ss[6]));
  124.   i=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
  125.   version=((double)i)/100.0;
  126.  
  127. #ifdef v407
  128.  
  129.   if (i<407) {
  130.     printf("\nThis program requires WWIV v4.07 or later.\n");
  131.     exit(0);
  132.   }
  133.  
  134.   funcs=(void far *)getvect(0x6a);
  135.   inli=funcs[0];
  136.   checka=funcs[1];
  137.   pla=funcs[2];
  138.   outchr=funcs[3];
  139.   outstr=funcs[4];
  140.   nl=funcs[5];
  141.   pl=funcs[8];
  142.   empty=funcs[9];
  143.   inkey=funcs[10];
  144.   getkey=funcs[11];
  145.   input=funcs[12];
  146.   inputl=funcs[13];
  147.   yn=funcs[14];
  148.   ny=funcs[15];
  149.   ansic=funcs[16];
  150.   onek=funcs[17];
  151.   prt=funcs[18];
  152.   mpl=funcs[19];
  153.  
  154. #endif
  155.  
  156.   return(0);
  157. }
  158.  
  159.  
  160. void main(int argc, char *argv[])
  161. {
  162.   char s[81];
  163.  
  164.   if (argc<2)
  165.     strcpy(s,"chain.txt");
  166.   else
  167.     strcpy(s,argv[1]);
  168.  
  169.   if (read_in_data(s)==-1) {
  170.     printf("\nData file not found\n\n");
  171.     abort();
  172.   }
  173.  
  174.  
  175.   printf("%d\n%s\n%s\n%s\n%d\n%c\n%f\n%s\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%f\n%s\n%s\n%s\n%s\n%d\n",
  176.           usernum,
  177.           name,
  178.           realname,
  179.           callsign,
  180.           age,
  181.           sex,
  182.           gold,
  183.           laston,
  184.           screenchars,
  185.           screenlines,
  186.           sl,
  187.           so,
  188.           cs,
  189.           okansi,
  190.           incom,
  191.           timeallowed,
  192.           gfiles,
  193.           data,
  194.           sysoplog,
  195.           curspeed,
  196.           comport);
  197.  
  198. #ifdef v407
  199.   sprintf(s,"Running under WWIV v%4.2f.",version);
  200.   nl();
  201.   pl(s);
  202.   nl();
  203. #endif
  204.  
  205. }
  206.