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