home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
WWIVMODS
/
MODSUNKN.ZIP
/
LITTLE_C.TXT
< prev
next >
Wrap
Text File
|
1990-08-05
|
18KB
|
558 lines
MODNET9/10
Here are some small C programs that have come across lately. The first two
are convert programs for Elric's mods 34 and 37, respectively. The third is a
little program that will retuen the result codes of any key pressed. Handy
for needing to know what codes to use in programming. The two following are
two different programs for printing out your user list.
-=>mtb
─────────────────────────────────────────────────────────────────────────────
/* This applies to Elric 37 */
/* CONVERT Chains.DAT PROGRAM */
/* Command Parameters: */
/* CHAINCON */
/** Ok. signifigant changes to the convert software, as in I re-wrote the
whole thing mostly from scratch.
Just compile it, stick it in the main BBS dir, and type CHAINCON, and it
does the rest.
The only thing I will add is that it was compiled and tested under
Turbo C 2.0, and it was tested in the large memory model. Use whatever you
want, I think it should work in all of them.
Lord Elric 1@18251 LINK 1@8251 NET */
#include <stdio.h>
#include <string.h>
#include <mem.h>
#include <io.h>
#include <stdlib.h>
#include <fcntl.h>
#include "vardec.h"
/* DATA FOR OTHER PROGRAMS AVAILABLE */
typedef struct {
char filename[81], /* filename for .chn file */
description[81]; /* description of it */
unsigned char sl, /* seclev restriction */
ansir; /* if ANSI required */
unsigned short ar; /* AR restriction */
} oldchainfilerec;
void main()
{
FILE *infile,*outfile;
unsigned int l,num=0;
oldchainfilerec old[99];
chainfilerec new[99];
int configfile;
configrec syscfg;
char s[81],s1[81];
configfile=-1;
strcpy(s,"CONFIG.DAT");
configfile=open(s,O_RDWR | O_BINARY);
if (configfile<0) {
printf("%s NOT FOUND.\n",s);
printf("This program must be run from the main BBS directory\n");
exit(0);
}
read(configfile,(void *) (&syscfg), sizeof(configrec));
close(configfile);
sprintf(s1,"%sCHAINS.DAT",syscfg.datadir);
sprintf(s,"%sCHAINS.XXX",syscfg.datadir);
printf("\nNow renaming %s to %s\n",s1,s);
if (rename(s1,s) != 0) {
printf("\nCould not rename...please delete/rename file %s",s);
exit(0);
}
if ((infile=fopen(s,"rb"))==NULL) {
printf("\nCould not open input chains file %s\n",s);
abort();
}
num=fread(old,sizeof(oldchainfilerec),99,infile);
fclose(infile);
printf("\nSize of old chain record : %d",sizeof(oldchainfilerec));
printf("\nSize of new chain record : %d\n\n",sizeof(chainfilerec));
memset(&new,0,99*sizeof(chainfilerec));
for (l=0;l<num;l++) {
printf("Processing chain #%u of %u, %40s\n",l,num,old[l].description);
strcpy(new[l].description,old[l].description);
strcpy(new[l].filename,old[l].filename);
new[l].sl =old[l].sl;
new[l].ansir=old[l].ansir;
new[l].ar =old[l].ar;
new[l].gold=0;
}
if ((outfile=fopen(s1,"wb"))==NULL) {
printf("\nCould not open output chains file %s\n",s1);
rename(s,s1);
abort();
}
fwrite(new,sizeof(chainfilerec),num,outfile);
fclose(outfile);
unlink(s);
}
─────────────────────────────────────────────────────────────────────────────
/* CONVERT SUBS.DAT PROGRAM */
/* This applies to ELRIC 34 */
/* Written by The Black Dragon, 1989 */
/* (C) 1989 Black Dragon Enterprises */
/* Compiled and tested using Borland Turbo C - Version 1.5 */
/* License granted to freely distribute without compensation and to */
/* modify as needed "to get the job done." Use at your own risk. */
/* Distributed "as is". No warranty or guarentee */
/* Command Parameters: */
/* SUBCONVERT <old subs filename> <new subs filename> */
/** Hey, does this header look familiar. Well, if you have used Convert, then
it probably does, because I took that code and just modded it to
convert the subs data files instead of the user data files...no
sense re-inventing the wheel. Anyway, I leave the credit by the Black Dragon
intact and in place since a small portion of this is his anyway. Thanks
once again.
The only thing I will add is that it was compiled and tested under
Turbo C 2.0, and it was tested in the large memory model. Use whatever you
want, I think it should work in all of them.
Lord Elric 1@18251 LINK 1@8251 NET */
#include <stdio.h>
#include <string.h>
#include <mem.h>
#include <io.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys\stat.h>
#include "vardec.h" /* rename it from subboardrec to oldsubboardrec */
void main(int argc, char *argv[])
{
int f,g;
unsigned int loop,num=0;
unsigned long len;
oldsubboardrec old;
subboardrec new;
if (argc<3) {
printf("\nRequires 2 parameters.\n");
printf("Usage: SUBCON oldfile newfile \n");
abort();
}
if ((f=open(argv[1],O_RDWR|O_BINARY,S_IREAD|S_IWRITE))<=0) {
printf("\nCould not open input subs file %s\n",argv[1]);
abort();
}
if ((g=open(argv[2],O_RDWR|O_BINARY|O_CREAT|O_TRUNC,S_IREAD|S_IWRITE))<=0) {
printf("\nCould not open output subs file %s\n",argv[2]);
abort();
}
printf("\n\nSize of old sub record %d",sizeof(oldsubboardrec));
printf("\nSize of new sub record %d\n\n",sizeof(subboardrec));
len=filelength(f);
num=(len/sizeof(oldsubboardrec))+!(len%sizeof(oldsubboardrec));
for (loop=0;loop<num;loop++) {
if (sizeof(oldsubboardrec)==read(f,&old,sizeof(oldsubboardrec))) {
printf("\015Processing sub #%u of %u, %40s",loop,num-1,old.name);
memset(&new,0,sizeof(subboardrec)); /* Nice to clear out garbage */
strcpy(new.name,old.name); /* Now copy all data over */
strcpy(new.filename,old.filename);
new.key=old.key;
new.readsl=old.readsl;
new.postsl=old.postsl;
new.anony=old.anony;
new.age=old.age;
new.maxage=0;
new.sex=0;
new.gold=0;
new.ansi=0;
new.maxmsgs=old.maxmsgs;
new.ar=old.ar;
new.storage_type=old.storage_type;
new.type=old.type;
write(g,&new,sizeof(subboardrec)); /* User record converted here */
}
}
close(f);
close(g);
}
─────────────────────────────────────────────────────────────────────────────
Dave Wallace #19 @5803
Thu May 17 19:11:56 1990
RE: Ok serious question........
Their scan codes are different on AT-class machines. (Also, I know of at
least one AT-style keyboard with F-11 through F-30 but those keys are really
control- and alt- f1 thru f10!) But if you don't mind making a special
version of the BBS that might only work on your particular machine, try the
following program:
/* Warning: this is coded on-the-fly and may be buggy! The author is
used to Microsoft C, too, so you may have to translate. */
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void main(void);
void main()
{
for (;;)
{
printf ("\n>");
while (!kbhit())
;
for (;;)
{
char c;
c = getch();
if (c != 0)
{
printf ("%d\n", c);
break;
}
else
{
printf ("0 + %d\n", getch());
break;
}
}
if (c == '\n') break;
}
exit(0);
}
As I say, this is untried and written by a guy who's more used to Microsoft C
5.1 instead of Turbo. Note that some of the "funny" keys are TWO byte
sequences: zero plus some other code. Good luck.
──────────────────────────────────────────────────────────────────────────────
Rick Hung #331 @18
Fri May 11 01:58:30 1990
RE: Help..
there already is a mod for this... i wrote this little utility under request
from Zaphod, sysop of The Heart of Gold - here is the read.me file, and the
next post will be the source.
USERLiST - a utility to print the contents of WWIV's USER.LST to a text file.
Like Wayne, I'm releasing the code to the program. (Wow, what
a nice guy!). The reasons? First, the code is pretty simple,
o that it could've been written by somebody else.
Scond, I know that many of you sysops out there have added mods
such as the FROM mod...that requires a different compile for each
person.
Now, let me say some of the usual crap that accompanies mods
and the other crap. I hereby grant any user the right to modify,
delete, change, distribute, puke on, or anything else with the
code. I wrote it, released it, and that's it. I claim NO
responsibility for whatever happens from using this utility.
It has been tested, and it works fine. It could've been done
in a much better format, but since I didn't feel like screwing
around with the code any longer, and since the code IS released,
you can change anything to suit your needs.
USERLST.EXE accepts TWO arguments, and if not supplied, the
program will abort. The FIRST argument is the name of your
USER.LST file, or if you happened to change the name of it (yeah,
right), then that name. The second argument is the name of the
OUTPUT file.
There is ONE bug I have found... no matter what I do, it always
prints as the FIRST user everything set to NULL. Ah well...you
have the code, you can fix it. (The first record is always a
null - just simply a little bit of "bad-coding" from Wayne,
but it doesn't really harm anything...
...Rick
P.S. Aren't all of you glad now that I finally shut up? :)
──────────────────────────────────────────────────────────────────────────────
Rick Hung #331 @18
Fri May 11 02:03:23 1990
The Federation [818-407-0419]
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include "vardec.h"
int exist(char *string)
{
int f;
f=open(string,O_RDONLY | O_BINARY);
close(f);
if (f>0)
return(1);
else
return(0);
}
main(int argc, char *argv[])
{
int binfile;
FILE *txtfile;
userrec u;
unsigned int loop,num=0;
unsigned long len;
char s[81],s1[81];
if (argc<3) {
puts("\nRequires TWO parameters.\n");
puts("USERLST [path to USER.LST] [dest filename & path]\n");
abort();
}
if ((binfile=open(argv[1],O_RDWR|O_BINARY,S_IREAD|S_IWRITE))<=0) {
puts("\nCould not open USER.LST\n");
close(binfile);
abort();
}
if (exist(argv[2])) {
printf("\nCould not open output file %s. Same file exists.\n",argv[1]);
abort();
}
if (binfile<0) {
puts("\nNo users to process!\n");
close(binfile);
abort();
}
txtfile=fopen(argv[2],"a+");
len=filelength(binfile);
num=(len/sizeof(userrec))+!(len%sizeof(userrec));
for (loop=1; loop<num; ++loop) {
printf("\015Processing user #%u of %u",loop,num);
read(binfile,&u,sizeof(userrec));
if (u.inact == 0) {
fputs("WWIV BBS USER RECORD LISTING\n",txtfile);
fputs("~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n",txtfile);
sprintf(s,"USER's HANDLE : %s\n",u.name);
fputs(s,txtfile);
sprintf(s,"USER's REAL NAME : %s\n",u.realname);
fputs(s,txtfile);
sprintf(s,"USER's ADDRESS : %s\n",u.street);
fputs(s,txtfile);
sprintf(s," : %s %s\n",u.citystate,u.zip);
fputs(s,txtfile);
sprintf(s,"USER's CALL SIGN : %s\n",u.callsign);
fputs(s,txtfile);
sprintf(s,"USER's PHONE # : %s\n",u.phone);
fputs(s,txtfile);
sprintf(s,"USER's PASSWORD : %s\n",u.pw);
fputs(s,txtfile);
sprintf(s,"USER's LAST DATE ON : %s\n",u.laston);
fputs(s,txtfile);
sprintf(s,"USER's FIRST DATE ON : %s\n",u.firston);
fputs(s,txtfile);
sprintf(s,"SYSOP's NOTE ON USER : %s\n",u.note);
fputs(s,txtfile);
sprintf(s,"USER's SEX : %c",u.sex);
strcat(s,"\n");
fputs(s,txtfile);
sprintf(s,"USER's AGE : %d\n",u.age);
fputs(s,txtfile);
sprintf(s,"USER's BIRTHDATE :
%d-%d-%d\n",u.month,u.day,u.year);
fputs(s,txtfile);
sprintf(s,"Messages Posted : %d\n",u.msgpost);
fputs(s,txtfile);
sprintf(s,"Emails Sent : %d\n",u.emailsent);
fputs(s,txtfile);
sprintf(s,"Feedback Sent : %d\n",u.feedbacksent);
fputs(s,txtfile);
sprintf(s,"User's Ass Pts : %d\n",u.ass_pts);
fputs(s,txtfile);
sprintf(s,"Total Files Uploaded : %d\n",u.uploaded);
fputs(s,txtfile);
sprintf(s,"Total Files Downloaded : %d\n",u.downloaded);
fputs(s,txtfile);
sprintf(s,"Total Number of Logons : %d\n",u.logons);
fputs(s,txtfile);
sprintf(s,"Total Number of Messages Read : %d\n",u.msgread);
fputs(s,txtfile);
sprintf(s,"Uploaded Kbytes : %d\n",u.uk);
fputs(s,txtfile);
sprintf(s,"Downloaded Kbytes : %d\n",u.dk);
fputs(s,txtfile);
sprintf(s,"Total Gold : %d\n",u.gold);
fputs(s,txtfile);
sprintf(s,"Number of NET Emails : %d\n",u.emailnet);
fputs(s,txtfile);
sprintf(s,"Number of NET Posts : %d\n",u.postnet);
fputs(s,txtfile);
fputs("\r\n",txtfile);
}
}
close(binfile);
fputs("\n ...Courtesy of Rick
Hung",txtfile);
fclose(txtfile);
──────────────────────────────────────────────────────────────────────────────
Lord Darkster #1 @3114
Mon May 14 07:46:07 1990
/*
============================================================================
userrpt.c -- Lord Darkster -- Baltimore's Dark Side of the Moon -- @3114
============================================================================
I wrote this on the fly one day, so don't criticize the code. I take no
responsibility for it!
This thing is rediculously simple. Compile it, put it in your \DATA directory,
then use USERRPT >USERRPT.OUT to create a text file report. Then you
can print the report using COMPRESSED print. (it's 132 columns).
I run this thing every night in my external event, and the output goes to
my sysop file directory, where my remote can download it.
Don't want any money, just drop me some e-mail if you like it. Enjoy!
LD
============================================================================
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "vardec.h"
#include "vars.h"
#define PAGE_LEN 60
/* ******************************************************************* */
/* function prototypes */
/* ******************************************************************* */
void print_heading();
void print_user();
/* ******************************************************************* */
/* global vars */
/* ******************************************************************* */
int line_count = PAGE_LEN + 1;
userrec u;
int records_read=0;
int active_users=0;
main(argc, argv, envp)
int argc;
char *argv[];
char *envp;
{
FILE *userfile;
/* open user file */
if ((userfile=fopen("user.lst","rb")) == NULL)
{
printf("Error: Unable to open user.lst\n\n");
exit(1);
}
/* Loop and read users from "user.lst" */
while ((fread(&u,sizeof(u), 1, userfile)) > 0)
{
records_read++;
if (line_count > PAGE_LEN)
print_heading();
if (!u.inact && (records_read!=1)) /* skips first dummy record in file */
{ /* skips all deleted/inactive users */
print_user();
}
} /* while */
fcloseall();
printf("\n\n%d Active users selected.\n\n", active_users);
} /* main() */
/*=========================================== subroutines ===============*/
/**************************************** print report heading */
void print_heading()
{
if (active_users)
printf("%c\n",12);
printf(" # User Name/Alias S/A Last On First On #On SL DSL
MSGR MSGP EM FB NETE NETP UL DL UK DK Time On\n");
printf("--- -------------------- --- -------- -------- ----- --- ---
----- ----- ----- ---- ----- ----- ----- ----- ------ ------ --------\n");
/* note! you need to pull the MSGR and ----- lines up to the
lines above them with the turbo editor -- they wouldn't fit in 80
column posts!
*/
line_count=3;
} /* print_heading */
/**************************************** print the current user data */
void print_user()
{
printf("%3d",records_read-1);
printf(" %-20.20s",u.name);
printf(" %c",u.sex);
printf("%2d",u.age);
printf(" %-8.8s",u.laston);
printf(" %-8.8s",u.firston);
printf(" %5d",u.logons);
printf(" %3d",u.sl);
printf(" %3d",u.dsl);
printf(" %5d",u.msgread);
printf(" %5d",u.msgpost);
printf(" %5d",u.emailsent);
printf(" %4d",u.feedbacksent);
printf(" %5d",u.emailnet);
printf(" %5d",u.postnet);
printf(" %4d",u.uploaded);
printf(" %4d",u.downloaded);
printf(" %6d",u.uk);
printf(" %6d",u.dk);
printf(" %8.0f\n",u.timeon/60.0);
++active_users;
++line_count;
} /* print_user */