home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
OSKBox.lzh
/
MAILBOX
/
CC
/
register.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-11
|
3KB
|
140 lines
#include <stdio.h>
#include <ctype.h>
#include <modes.h>
#include <errno.h>
#include "mailbox.h"
struct userstruct user;
main (argc, argv)
char *argv[];
{
char *name, *call;
char str[99];
int zip = -1;
struct msg_header head, *phead;
char *maildir = "MAIL/";
int outfile;
int date, time, tick;
short day;
if (argc < 3) {
printf ("register <call> <name>\n");
exit (0);
}
call = argv[1];
name = argv[2];
upper (call);
caps (name);
strcpy (user.uscall, call);
printf ("Thank you, %s. Would you like to register %s as your \"home BBS\"?\n",
name, MYCALL);
printf ("This means your mail will be routed here for you to pick up.\n");
if (!yes ()) {
printf ("\nOK, if you change your mind in the future, use the N)ame command again.\n");
exit (0);
}
do {
zip = -1;
printf ("\nWhat is your zip code? "); fflush (stdout);
gets (str);
if (feof (stdin)) exit (0);
if (!iszip (str)) {
printf ("Sorry, that doesn't look like a 5-digit zipcode to me, please try again.\n");
continue;
}
printf ("\n");
zip = atoi (str);
sprintf (str, "zip %d", zip);
if (system (str) == 0) {
printf ("Correct? ");
if (!yes ())
zip = -1;
}
} while (zip < 0);
_sysdate (0, &time, &date, &day, &tick);
open_mail ();
head.mhsize = 0;
head.mhtype = 'P';
head.mhstat = 'X';
strcpy (head.mhfrom, MYCALL);
strcpy (head.mhto, "WPAGE");
strcpy (head.mhbbs, WPAGESERVER);
strcpy (head.mhtit, "WP auto-update");
if ((outfile = creat_msg (&head, &phead)) == -1) {
printf ("Error %d creating message file %s.\n", errno, str);
close_mail ();
exit (0);
}
sprintf (str, "%s QTH %s ON %02d%02d%02d NAME %s ZIP %05d\n",
call, MYCALL,
(date >> 16) % 100,
(date >> 8) & 0xff,
date & 0xff,
name, zip);
write (outfile, str, strlen (str));
phead->mhsize = _gs_size (outfile);
close (outfile);
phead->mhstat = 'N';
update_mail ();
close_mail ();
log_send (phead, 0);
printf ("\nThank you for the information, it will be entered\n");
printf ("into the \"White Pages\" directory.\n");
}
yes ()
{
char str[99];
while (1) {
printf ("(Yes or No): "); fflush (stdout);
fgets (str, 99, stdin);
if (feof (stdin)) exit (0);
if (*str == 'Y' || *str == 'y')
return 1;
else if (*str == 'N' || *str == 'n')
return 0;
}
}
iszip (str)
char *str;
{
char *p;
upper (str);
if (strlen (str) == 5) {
for (p = str; *p; p++)
if (!isdigit (*p))
return 0;
}
else if (strlen (str) == 6) {
if (!isalpha (str[0]) ||
!isdigit (str[1]) ||
!isalpha (str[2]) ||
!isdigit (str[3]) ||
!isalpha (str[4]) ||
!isdigit (str[5]))
return 0;
}
else
return 0;
return 1;
}
caps (s)
char *s;
{
*s = toupper (*s);
s++;
while (*s) {
*s = tolower (*s);
s++;
}
}