Category : BBS Programs+Doors
Archive   : CINCLUDE.ZIP
Filename : USER.C
Output of file : USER.C contained in archive : CINCLUDE.ZIP
** File ID: USER.C
** Purpose: To demo walking the USER.BBS binary tree. This will list all
** users that have up/downloaded with their total up/down qnty's.
*/
#include
#include
#include
#include "user.h"
typedef int (*PFI) ();
static struct USER user, ours;
static int fd;
static int urec[8 * 1024];
static int nodes= 0;
static struct USE {
unsigned int up;
unsigned int down;
int access;
char name[26];
} use[1000];
static getr (rec)
int rec;
{
int stat;
long loc;
loc = rec;
loc *= sizeof (struct USER);
lseek (fd, loc, 0);
stat = read (fd, &user, sizeof (user));
if (stat == 0)
return (0);
if (stat != sizeof(user))
return (-1);
convert ();
return (1);
}
static convert ()
{
memcpy (&ours, &user, sizeof(struct USER));
memcpy (ours.name, &user.name[1], user.name[0]);
ours.name[user.name[0]] = '\0';
memcpy (ours.loc, &user.loc[1], user.loc[0]);
ours.loc[user.loc[0]] = '\0';
memcpy (ours.systype, &user.systype[1], user.systype[0]);
ours.systype[user.systype[0]] = '\0';
memcpy (ours.phoneno, &user.phoneno[1], user.phoneno[0]);
ours.phoneno[user.phoneno[0]] = '\0';
}
static collect (node)
int node;
{
int stat;
long loc, calls;
stat = getr (node);
if (stat <= 0)
{
printf ("\nRead error on USER.BBS\n");
exit (1);
}
if (user.left && (user.left != -1))
{
collect (user.left);
stat = getr (node);
if (stat <= 0)
{
printf ("\nRead error on USER.BBS\n");
exit (1);
}
}
if (ours.uploads || ours.downloads)
{
strcpy (use[nodes].name, ours.name);
use[nodes].access = ours.access;
use[nodes].up = ours.uploads;
use[nodes].down = ours.downloads;
nodes++;
}
if (user.right && (user.right != -1))
collect (user.right);
}
static show ()
{
int i;
printf ("User Lev | User Name | K's Up | K's Down\n");
printf ("----------+--------------------------+--------+---------\n");
for (i= 0; i < nodes; ++i)
{
printf ( " %3d | %-25s| %5d | %5d\n",
use[i].access, use[i].name, use[i].up, use[i].down
);
}
}
main ()
{
int i;
long l;
fd = open ("user.bbs", O_RDONLY | O_BINARY);
if (fd < 0)
{
printf ("Unable to open USER.BBS\n");
exit (1);
}
lseek (fd, (long) sizeof(struct USER), 0);
if (read(fd, &user, sizeof(user)) != sizeof(user))
{
printf ("Read error on the initial record of USER.BBS\n");
exit (1);
}
printf ("Collecting Statistics for Users\n");
collect (1);
show ();
close (fd);
exit (0);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/