Category : Files from Magazines
Archive   : DDJ-9008.ZIP
Filename : STEVENS.LST

 
Output of file : STEVENS.LST contained in archive : DDJ-9008.ZIP
_C PROGRAMMING COLUMN_
by Al Stevens

[LISTING ONE]

/* ---------- Display NetWare USERID ---------- */
#include
#include

char *GetUserid(void);

void main()
{
printf("\nUserid: %s", GetUserid());
}

/*
* Get the current logged on userid
*/

char *GetUserid(void)
{
static char userid[48];
WORD connection_number = GetConnectionNumber();
WORD objecttype;
long objectid;
BYTE logintime[7];

GetConnectionInformation(connection_number, userid,
&objecttype, &objectid, logintime);
return userid;
}


[LISTING TWO]

/* -------- getuser1.c ----------- */

#include
#include
#include

/* ----- request packet for get connection information ----- */
static struct {
int rlen; /* packet length-2 */
char func; /* NW function */
char station; /* station number */
} rqpacket = { 2, 22 };

/* ------ reply buffer for get connection information ----- */
static struct {
int rlen; /* packet length-2 */
long id; /* object id */
int type; /* type of object */
char userid[48]; /* name of object */
char time[8]; /* log on time */
} rsbuffer = { 62 };

char *GetUserid(void);

void main()
{
printf("\nUserid: %s", GetUserid());
}

char *GetUserid(void)
{
union REGS regs;
struct SREGS segs;

segread(&segs);
segs.es = segs.ds;
/* ------- get connection (station) number ------ */
regs.h.ah = 0xdc;
intdosx(®s, ®s, &segs);
rqpacket.station = regs.h.al;
/* ------- get connection information --------- */
regs.x.si = (unsigned) &rqpacket;
regs.x.di = (unsigned) &rsbuffer;
regs.h.ah = 0xe3;
intdosx(®s, ®s, &segs);
return rsbuffer.userid;
}


[LISTING THREE]

/* -------------- showusrs.c ---------------- */

#include
#include
#include

static long objid;

char *getusers(void);

void main()
{
char *userid;
objid = -1;
while ((userid = getusers()) != NULL)
printf("\n%s", userid);
}

/* ---------- scan bindery for users ------------- */
char *getusers(void)
{
static char name[48];
char hasproperties, flag, security;
WORD type;

if (ScanBinderyObject("*", OT_USER, &objid, name, &type,
&hasproperties, &flag, &security) == SUCCESSFUL)
return name;
return NULL;
}



[LISTING FOUR]

/* --------------- nwloaded.c ------------ */

#include
#include

int NetworkLoaded(void);

void main()
{
printf("\nThe network %s operating",
NetworkLoaded() ? "is" : "is not");
}

#define encr(lm) (0-(~(0-lm)))

/* ------- test network operating ----------- */
int NetworkLoaded(void)
{
int lockmode, encrypted;
union REGS regs;

regs.x.ax = 0xc600;
intdos(®s, ®s);
lockmode = regs.h.al;

encrypted = encr(lockmode);

regs.h.ah = 0xc6;
regs.h.al = encrypted;
intdos(®s, ®s);
lockmode = regs.h.al;

return encrypted != encr(lockmode);
}





  3 Responses to “Category : Files from Magazines
Archive   : DDJ-9008.ZIP
Filename : STEVENS.LST

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. 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/