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