home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / WWIV2.ZIP / SKELETON.C < prev    next >
C/C++ Source or Header  |  1992-12-03  |  8KB  |  232 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. #define v407                   /* Sets for WWIV v4.07 or later */
  9.  
  10. unsigned int  usernum,         /* user number for the user */
  11.               system_number=0, /* WWIV Node Number - 0=not networked */
  12.               okansi,          /* non-zero if user can support ANSI */
  13.               screenchars,     /* chars/line user has specified */
  14.               screenlines,     /* lines/screen user has specified */
  15.               sl,              /* sec lev for user (0-255) */
  16.               so,              /* non-zero if user is sysop (sl=255) */
  17.               cs,              /* non-zero if user is co-sysop */
  18.               age,             /* age of the user */
  19.               uploaded=0,      /* # files uploaded */
  20.               downloaded=0,    /* # files downloaded */
  21.               incom,           /* non-zero if user is calling remotely */
  22.               comport,         /* com port user is on */
  23.               com_speed=0,     /* com port baud rate */
  24.               modem_speed=0;   /* modem baud rate */
  25. unsigned char name[31],        /* name/alias of user */
  26.               realname[31],    /* real name of user */
  27.               callsign[9],     /* amateur radio callsign of user */
  28.               laston[9],       /* date user was last on */
  29.               sex,             /* sex of user, M or F */
  30.               parity[5],       /* parity 8N1 or 7E1 */
  31.               curspeed[81],    /* speed user is on at, "KB" if local */
  32.               data[81],        /* directory for non-text files, ends in \ */
  33.               gfiles[81],      /* directory for text files, ends in \ */
  34.               sysoplog[81],    /* full path & filename for sysop log */
  35.               sysopname[81],   /* name of sysop */
  36.               systemname[81];  /* name of BBS */
  37. double        gold,            /* gold user has */
  38.               timeallowed,     /* number of seconds before user logged off */
  39.               version=-1.0;    /* version of WWIV running under */
  40. long          timeon=0,        /* number of seconds since midnight logged on */
  41.               timespent=0,     /* number of seconds spent online so far */
  42.               uk=0,            /* # k uploaded */
  43.               dk=0;            /* # k downloaded */
  44.  
  45. #ifdef v407
  46. void far * far *funcs;
  47. void far interrupt (*inli)(char far *, char far *, int, int);
  48. void far interrupt (*checka)(int far *, int far *);
  49. void far interrupt (*pla)(char far *, int far *);
  50. void far interrupt (*outchr)(char);
  51. void far interrupt (*outstr)(char far *);
  52. void far interrupt (*nl)();
  53. void far interrupt (*pl)(char far *);
  54. int  far interrupt (*empty)();
  55. char far interrupt (*inkey)();
  56. unsigned char far interrupt (*getkey)();
  57. void far interrupt (*input)(char far *, int);
  58. void far interrupt (*inputl)(char far *, int);
  59. int  far interrupt (*yn)();
  60. int  far interrupt (*ny)();
  61. void far interrupt (*ansic)(int);
  62. char far interrupt (*onek)(char far *);
  63. void far interrupt (*prt)(int, char far *);
  64. void far interrupt (*mpl)(int);
  65. #endif
  66.  
  67. int read_in_data(char *fn)
  68. {
  69.   char buf[1024],*ptr[50],*ss;
  70.   float fl;
  71.   int i,i1,len;
  72.   unsigned short c_s,c_o;
  73.  
  74.   ss=getenv("BBS");
  75.   if (!ss || strncmp(ss,"WWIV",4)) {
  76. #ifdef v407
  77.     printf("\nThis program MUST be run under WWIV v4.07 or later.\n");
  78.     exit(1);
  79. #else
  80.     printf("\nWARNING: Not running under WWIV\n");
  81.     return(1);
  82. #endif
  83.   }
  84.   for(i=i1=0;i1<strlen(ss);i1++) {
  85.     if (!isdigit(ss[i1])) continue;
  86.     i*=10;
  87.     i+=ss[i1]-'0';
  88.   }
  89.   version=((double)i)/100.0;
  90. #ifdef v407
  91.   if (i<407) {
  92.     printf("\nThis program requires WWIV v4.07 or later.\n");
  93.     exit(2);
  94.   }
  95.   if (i<421) funcs=(void far *)getvect(0x6a);
  96.   else {
  97.     ss=getenv("WWIV_FP");
  98.     if (!ss) {
  99.       printf("\nWWIV_FP enviornment variable not set.\n\n");
  100.       exit(3);
  101.     }
  102.     c_s=strtol(ss,NULL,16);
  103.     c_o=strtol(ss+5,NULL,16);
  104.     if (c_s && c_o) funcs=(void far *)MK_FP(c_s,c_o);
  105.     else {
  106.       printf("\nWWIV_FP not set to valid value (%04lX:%04lX).\n\n",c_s,c_o);
  107.       exit(4);
  108.     }
  109.   }
  110.   inli=funcs[0];
  111.   checka=funcs[1];
  112.   pla=funcs[2];
  113.   outchr=funcs[3];
  114.   outstr=funcs[4];
  115.   nl=funcs[5];
  116.   pl=funcs[8];
  117.   empty=funcs[9];
  118.   inkey=funcs[10];
  119.   getkey=funcs[11];
  120.   input=funcs[12];
  121.   inputl=funcs[13];
  122.   yn=funcs[14];
  123.   ny=funcs[15];
  124.   ansic=funcs[16];
  125.   onek=funcs[17];
  126.   prt=funcs[18];
  127.   mpl=funcs[19];
  128. #endif
  129.   if ((i=open(fn,O_RDONLY|O_BINARY))<0) return(i);
  130.   len=read(i,(void *)buf,1024);
  131.   close(i);
  132.   for (i=i1=0;i<len;i++)
  133.     if (buf[i]=='\r') {
  134.       buf[i]=0;
  135.       ptr[++i1]=&buf[i+2];
  136.     }
  137.   ptr[0]=buf;
  138.   for (i=i1;i<50;i++) ptr[i]=NULL;
  139.   while (*ptr[6]==' ') ++(ptr[6]);
  140.   while (*ptr[15]==' ') ++(ptr[15]);
  141. #ifdef DEBUG
  142.   printf("%2u Parameters:\n",i1);
  143.   for(i=0;i<i1;i++) printf("Parameter %2u: \"%s\"\n",i,ptr[i]);
  144. #endif
  145.   usernum=atoi(ptr[0]);
  146.   strcpy(name,ptr[1]);
  147.   strcpy(realname,ptr[2]);
  148.   strcpy(callsign,ptr[3]);
  149.   age=atoi(ptr[4]);
  150.   sex=*ptr[5];
  151.   sscanf(ptr[6],"%f",&fl);
  152.   gold=(double)fl;
  153.   strcpy(laston,ptr[7]);
  154.   screenchars=atoi(ptr[8]);
  155.   screenlines=atoi(ptr[9]);
  156.   sl=atoi(ptr[10]);
  157.   so=atoi(ptr[11]);
  158.   cs=atoi(ptr[12]);
  159.   okansi=atoi(ptr[13]);
  160.   incom=atoi(ptr[14]);
  161.   sscanf(ptr[15],"%f",&fl);
  162.   timeallowed=(double)fl;
  163.   strcpy(gfiles,ptr[16]);
  164.   strcpy(data,ptr[17]);
  165.   sprintf(sysoplog,"%s%s",gfiles,ptr[18]);
  166.   strcpy(curspeed,ptr[19]);
  167.   if (curspeed[0]!='K') modem_speed=atoi(curspeed);
  168.   comport=atoi(ptr[20]);
  169.   strcpy(systemname,(ptr[21]!=NULL)?ptr[21]:"");
  170.   strcpy(sysopname,(ptr[22]!=NULL)?ptr[22]:"");
  171.   if (ptr[23]!=NULL) timeon=atol(ptr[23]);
  172.   if (ptr[24]!=NULL) timespent=atol(ptr[24]);
  173.   if (ptr[25]!=NULL) uk=atol(ptr[25]);
  174.   if (ptr[26]!=NULL) uploaded=atol(ptr[26]);
  175.   if (ptr[27]!=NULL) dk=atol(ptr[27]);
  176.   if (ptr[28]!=NULL) downloaded=atol(ptr[28]);
  177.   strcpy(parity,(ptr[29]!=NULL)?ptr[29]:"");
  178.   if (ptr[30]!=NULL) com_speed=atol(ptr[30]);
  179.   if (ptr[31]!=NULL) system_number=atol(ptr[31]);
  180.   return(0);
  181. }
  182.  
  183. void main(int argc, char *argv[])
  184. {
  185.   int rc;
  186.   char s[81];
  187.  
  188.   strcpy(s,(argc<2)?"CHAIN.TXT":argv[1]);
  189.   if ((rc=read_in_data(s)) != 0) {
  190.     printf("\nData file not found (RC=%d)\n\n",rc);
  191.     abort();
  192.   }
  193.   printf("user #%d\n",usernum);
  194.   printf("username %s\n",name);
  195.   printf("realname %s\n",realname);
  196.   printf("callsign %s\n",callsign);
  197.   printf("age %d\n",age);
  198.   printf("sex %c\n",sex);
  199.   printf("gold %f\n",gold);
  200.   printf("laston %s\n",laston);
  201.   printf("screensize %dx%d\n",screenchars,screenlines);
  202.   printf("sl %d\n",sl);
  203.   printf("sysop %s\n",so?"Yes":"No");
  204.   printf("cosysop %s\n",cs?"Yes":"No");
  205.   printf("ansi %s\n",okansi?"Yes":"No");
  206.   printf("incom %s\n",incom?"Yes":"No");
  207.   printf("timeallowed %f\n",timeallowed);
  208.   printf("gfiles %s\n",gfiles);
  209.   printf("data %s\n",data);
  210.   printf("sysoplog %s\n",sysoplog);
  211.   printf("curspeed %s\n",curspeed);
  212.   printf("com port %d\n",comport);
  213.   printf("systemname %s\n",systemname);
  214.   printf("sysopname %s\n",sysopname);
  215.   printf("timeon %ld\n",timeon);
  216.   printf("timespent %ld\n",timespent);
  217.   printf("uk %ld\n",uk);
  218.   printf("uploaded %d\n",uploaded);
  219.   printf("dk %ld\n",dk);
  220.   printf("downloaded %d\n",downloaded);
  221.   printf("parity %s\n",parity);
  222.   printf("com_speed %u\n",com_speed);
  223.   printf("modem_speed %u\n",modem_speed);
  224.   printf("system_number %u\n",system_number);
  225. #ifdef v407
  226.   sprintf(s,"Running under WWIV v%4.2f.",version);
  227.   nl();
  228.   pl(s);
  229.   nl();
  230. #endif
  231. }
  232.