home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
muglog.zip
/
LOGIN.C
next >
Wrap
C/C++ Source or Header
|
1995-05-19
|
2KB
|
114 lines
#define CM_OS2
#define INCL_32
#define INCL_DOSFILEMGR
#define INCL_DOSMISC
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <upm.h>
#include <os2.h>
int GetUseridPassword(char *userid, char* password);
char * _cgetsNoEcho(char *buffer);
void DisplayLogo(void);
int main(int argc, char** argv)
{
char userid[9];
char password[9];
int i;
DisplayLogo();
for(i = 0; i < 3; i++)
{
if (0 == GetUseridPassword(userid, password))
return 0;
printf("3004-007 You entered an invalid login name or password.\r\n");
}
return 1;
} /* main */
void DisplayLogo(void)
{
struct
{
ULONG major;
ULONG minor;
ULONG revision;
} ver;
int i;
DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_REVISION, &ver, sizeof(ver));
if ((ver.major == 20) && (ver.minor == 30))
{
ver.major = 30;
ver.minor = 0;
}
/* Clear the screen */
for (i = 0; i < 32; i++)
_cputs("\r\n");
printf("OS/2 Version %d.%d\r\n(c) Copyrights by IBM\r\n", (ver.major/10), ver.minor);
return;
} /* DisplayLogo */
int GetUseridPassword(char *userid, char* password)
{
char inputBuffer[12];
char *p; /* Work pointer */
LSINT LSFAR LSPAS rc;
/* Get userid */
_cputs("login: ");
inputBuffer[0] = 0x08; /* Max length of string for userid */
p = _cgets(inputBuffer);
strcpy(userid, p);
/* Get password */
_cputs("\r\n");
_cputs(userid);
_cputs("'s Password: ");
inputBuffer[0] = 0x08; /* Max length of string for userid */
p = _cgetsNoEcho(inputBuffer);
strcpy(password, p);
_cputs("\r\n");
/* Validate the userid and password with UPM */
strupr(userid);
strupr(password);
rc = upmelgn(userid, password, "", UPM_LOCAL, UPM_USER);
return (UPM_OK == rc) ? 0 : 1;
} /* GetUseridPassword */
char * _cgetsNoEcho(char *buffer)
{
char *p;
int i;
p = buffer+1;
memset(p,'\0',(int)buffer[0]);
for(i = 0; i < (int)buffer[0]; i++)
{
*p = _getch();
if ((*p == '\r') || (*p == '\n'))
{
*p = '\0';
return (buffer+1);
}
p++;
}
return (buffer+1);
}