home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rxlan.zip
/
rxlan.c
< prev
next >
Wrap
Text File
|
1993-05-25
|
5KB
|
139 lines
/*
REXX-Utils for retrieving LAN-requester information
Copyright RZplus GmbH 1993
dedicated to public domain
*/
#define INCL_DOS
#include <os2.h>
#include <netcons.h>
#include <wksta.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rexxsaa.h>
SHORT APIENTRY RxNetInfo(
PSZ function_name, /* Function invocation name.*/
SHORT argc, /* Number of arguments. */
PRXSTRING argv, /* Function arguments. */
PSZ queue_name, /* Current queue name. */
PRXSTRING retval ) ; /* Value returned by funct. */
char *UserID();
char *DomainController();
/*******************************************************************/
/* Function: RxNetInfo() */
/* Description: Return requester information; */
/* Input: Name of desired information. */
/* Output: Desired information. Please see notes. */
/* Returns 0 if the function executed OK, */
/* -1 otherwise. The interpreter will fail */
/* if the function returns a negative result. */
/* */
/* This routine takes one parameter. The form of the call is: */
/* */
/* Information = RxNetInfo( request ) */
/* */
/* The value of the request parameter determines the information */
/* returned. Valid values are: */
/* */
/* request value returned */
/* ------- -------------- */
/* USERID Name of logged on user. */
/* DOMAIN Name of domain controller. */
/* */
/* The routine ignores the case of the request parameter. If */
/* the parameter is invalid or the argument count is not one, */
/* the function returns an empty string. */
/* */
/*******************************************************************/
SHORT APIENTRY RxNetInfo(
PSZ function_name, /* Function invocation name.*/
SHORT argc, /* Number of arguments. */
PRXSTRING argv, /* Function arguments. */
PSZ queue_name, /* Current queue name. */
PRXSTRING retval ) /* Value returned by funct. */
{
char request[ 64 ];
char *sResult;
SHORT rc = -1;
( void ) memset( retval -> strptr,
0,
( size_t ) retval -> strlength ) ;
retval -> strlength = 0 ;
if( ( argc == 1 ) && /* Arg count valid? */
( argv -> strlength < /* Request name not too */
sizeof( request ))) /* long? */
{
( void ) memset( request, /* zero the destination */
0, /* buffer. */
sizeof( request ) ) ;
( void ) memmove( request, /* Move request from the */
argv -> /* argument into the null */
strptr, /* terminated buffer. */
( size_t ) argv -> strlength ) ;
/* Which Information is needed */
if( !stricmp( request, "USERID" ))
{
sResult = UserID();
}
if( !stricmp( request, "DOMAIN" ))
{
sResult = DomainController();
}
if( strlen( sResult ))
{
( void ) strcpy( retval -> strptr,
sResult ) ;
retval -> strlength = strlen( sResult );
rc = 0;
}
else
{
rc = 1;
}
}
return( rc );
}
char *
UserID()
{
static char buffer[ 256 ];
USHORT netRet;
USHORT totalAvail = 0;
netRet = NetWkstaGetInfo( NULL, 0, buffer, sizeof( buffer ),
&totalAvail );
return( ( netRet ? "" : (( struct wksta_info_0 *)buffer)->wki0_username ));
}
char *
DomainController()
{
static char buffer[ 256 ];
USHORT netRet;
USHORT totalAvail = 0;
netRet = NetWkstaGetInfo( NULL, 0, buffer, sizeof( buffer ),
&totalAvail );
return( ( netRet ? "" : (( struct wksta_info_0 *)buffer)->wki0_logon_server ));
}