home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
bbs_door
/
cdrutil.arj
/
CDRUTIL.C
Wrap
C/C++ Source or Header
|
1990-09-15
|
7KB
|
214 lines
/*
Copyright (C) 1988-1990 The GAP Development Company
ALL RIGHTS RESERVED
RESTRICTIONS APPLY
This source code is considered to be confidential information proprietary
to The GAP Development Company. It is prohibited and punishable by law
to use or duplicate any part of this information without express consent
from GAP Development Company.
This source code is licensed to registered GAPCDR users and at all times
remains the property of GAP Development Company. This source code may
not, under any circumstance, be placed in a library for general use, nor
may it be used by any person not registered with GAP Development Company
as a Licensed GAPCDR user.
Any GAPCDR Licensee is granted express permission to use this file,
and incorporate the routines contained herein in any program that
the licensee creates that uses GAPCDR.
All other uses of this file are STRICTLY PROHIBITED.
CDRUTIL.C
Utility functions for GAPCDR
New utility functions for GAPCDR will be included here as they
become available.
*/
#define LINT_ARGS
#pragma check_stack(off) // we dont need stack checking
#pragma pack(1) // Structures MUST be packed
#include <stdio.h>
#include <string.h>
#include <gapcdr.h> // door include file
extern void pascal rw_doorsys(void);
// Function to read the DOOR.SYS file, make changes to security
// level and time credits, and write out a new file.
// Has no error checking so you may want to check for EOF, error
// writing to stream, etc.
// GAPBBS will read the fields from DOOR.SYS that are marked with
// an '*' in the DOORSYS.TXT file
void pascal rw_doorsys(void)
{
register short r;
short level;
short tcredit;
short shortnum;
long longnum;
char newdoor [81];
char olddoor [81];
FILE *doorsys;
FILE *oldsys;
sprintf(olddoor, "%s\\DOOR.OLD", bbs_dir); // name for old DOOR.SYS
sprintf(newdoor, "%s\\DOOR.SYS", bbs_dir); // name for new DOOR.SYS
// first see if there is an old DOOR.SYS file and remove it if there
if ( (access1(olddoor)) == 0) // file is there
unlink(olddoor); // remove it
// rename the file, return if unsuccessful
if ( (rename(newdoor,olddoor)) != 0)
return;
// open the original DOOR.SYS (DOORSYS.OLD), return if unsuccessful
if ( (oldsys = fopen(olddoor,"rt")) == NULL)
return;
// open the new DOOR.SYS, if unsuccessful, close old file and return
if ( (doorsys = fopen(newdoor,"w+t")) == NULL)
{
fclose(oldsys);
return;
}
// read old file, write new file
for (r = 1; r < 15; r++)
{
fgets(anystring,99,oldsys); // read old file
fputs(anystring,doorsys); // write new file
}
fscanf(oldsys,"%d",&level); // get security level
fgets(anystring,99,oldsys); // get the CR/LF
// if you intend to change the security level, do it here
fprintf(doorsys,"%d\n",level); // write security level
for (r = 1; r < 8; r++)
{
fgets(anystring,99,oldsys); // read old file
fputs(anystring,doorsys); // write new file
}
do_again:
fgets(anystring,99,oldsys); // forums registered in
fputs(anystring,doorsys); // write it
if ((strlen(anystring)) == 98) // if there is more to read
goto do_again; // then read it in
for (r = 1; r < 5; r++)
{
fgets(anystring,99,oldsys); // read old file
fputs(anystring,doorsys); // write new file
}
fscanf(oldsys,"%ld",&longnum); // get Upload Count
fgets(anystring,99,oldsys); // get the CR/LF
// if you intend to change the number of uploads, do it here
fprintf(doorsys,"%ld\n",longnum); // write number of uploads
fscanf(oldsys,"%ld",&longnum); // get Download Count
fgets(anystring,99,oldsys); // get the CR/LF
// if you intend to change the number of downloads, do it here
fprintf(doorsys,"%ld\n",longnum); // write number of downloads
fscanf(oldsys,"%ld",&longnum); // get current bytes
fgets(anystring,99,oldsys); // get the CR/LF
// if you intend to change the current download bytes, do it here
// Note that this long number is the current bytes / 1000
// if you change this field, you will truncate the current bytes
// since GAP keeps track of each byte!
fprintf(doorsys,"%ld\n",longnum); // write current down bytes (/1000)
for (r = 1; r < 12; r++)
{
fgets(anystring,99,oldsys); // read old file
fputs(anystring,doorsys); // write new file
}
fscanf(oldsys,"%d",&tcredit); // get time credits
fgets(anystring,99,oldsys); // get the CR/LF
// if you intend to change the time credits, do it here
// time credits can be either positive or negative
fprintf(doorsys,"%d\n",tcredit); // write time credits
for (r = 1; r < 5; r++)
{
fgets(anystring,99,oldsys); // read old file
fputs(anystring,doorsys); // write new file
}
fscanf(oldsys,"%d",&shortnum); // get Current Files Downloaded
fgets(anystring,99,oldsys); // get the CR/LF
// if you intend to change current files downloaded today, do it here
fprintf(doorsys,"%d\n",shortnum); // write current files downloaded
fscanf(oldsys,"%ld",&longnum); // get total bytes uploaded
fgets(anystring,99,oldsys); // get the CR/LF
// if you intend to change total bytes uploaded, do it here
// Note that this long number is the total bytes / 1000
// if you change this field, you will truncate the total bytes uploaded
// since GAP keeps track of each byte!
fprintf(doorsys,"%d\n",longnum); // write total bytes uploaded
fscanf(oldsys,"%ld",&longnum); // get current bytes downloaded
fgets(anystring,99,oldsys); // get the CR/LF
// if you intend to change total bytes downloaded, do it here
// Note that this long number is the total bytes / 1000
// if you change this field, you will truncate the total bytes downloaded
// since GAP keeps track of each byte!
fprintf(doorsys,"%d\n",longnum); // write total bytes downloaded
for (r = 1; r < 4; r++) // do the rest of the file
{
fgets(anystring,99,oldsys); // read old file
fputs(anystring,doorsys); // write new file
}
fclose(oldsys); // close old file
fclose(doorsys); // close new file
}