home *** CD-ROM | disk | FTP | other *** search
- /* *********************************************************************************
-
- MODULE: EnterEmail Module
-
- DESCRIPTION: This EnterEmail Module is a simple module for MUBBS, the
- Multi-User Bulliten Board System Software.
-
- AUTHOR: Noam Freedman
-
- Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
-
- This program source code and it's compiled version IS NOT IN THE
- PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
- regarding use of this program source code and it's compiled version.
-
- Revision History:
- ============================================================
- 8/26/91 - Started programming
- 11/ 4/91 - Edited for release
- ============================================================
-
-
- ******************************************************************************** */
-
-
- #define INMAIN
-
- #include "MUBBS Module.h"
- #include "Email.h"
- #include <SetUpA4.h>
-
- /* my globals for this module */
-
- pascal void main (mode1,G1,P1)
- int mode1;
- struct GS *G1;
- Ptr P1;
- {
- Handle temph;
- float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
- RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
- asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
-
- G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
- mode[u]=mode1; /* set up our mode so that you can read it anywhere */
-
- switch (mode[u]) { /* any un-handled modes return error from this module */
- case 3:
- if (getinfo(P1) != 0){ /* mode 3 because we are passing a user pointer */
- G->moduleresult=0; /* mode 2 doesnt work here, we need a pointer */
- break;
- }
- enteremail(P1);
- G->moduleresult=0;
- break;
- case 98:
- versionck(version); /* just return after this call, don't modify anything */
- break;
- case 0:
- strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
- G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
- break;
- default:
- G->moduleresult=1; /* return bad code */
- };
-
- HUnlock(temph); /* unlocks this module, do this ! */
- RestoreA4(); /* call this when you are all done */
- }
-
-
- getinfo(S)
- struct EnterStruct *S;
- {
- char pad[100]; /* this is a fix for a problem */
- int num;
- char temp[40];
-
-
- if (!G->online[u]) { return(2); } /* do this check so we can log out if hang up */
-
- strcpy(S->FromUser,G->username[u]);
-
- if(S->ToUser[0] != 0) goto skipit; /* if users to name isn't blank */
-
- enterit:
- send("]]]");
- send("Enter the user's name (or \"Sysop\") : ");
- portsin(S->ToUser, 33);
- send(G->CR[u]);
-
- if (S->ToUser[0] == 0)
- {
- send("]]Message Aborted.]");
- S->result = 1;
- return(1);
- }
-
- strcpy(temp,S->ToUser);
- strtoupper(temp);
- if(strcmp(temp,"SYSOP") == 0) {
- strcpy (S->ToUser,G->sysopname); /* get the sysop's name */
- goto skipit;
- }
-
- if ( ! getuserinfo(S->ToUser)) { /* see if this user exists */
- send ("]There is no such user as \"%s\" on this system, please try again.]",S->ToUser);
- goto enterit;
- }
-
- skipit:
- if (S->ToUser[0] != 0)
- {
- send("]]Emailing \"%s\"",S->ToUser);
- send("]]Title: ");
- portsin(S->title, 69);
- if (S->title[0] != 0)
- {
- S->result = 0;
- return(0);
- }
- else
- {
- send("]]Message Aborted.]");
- S->result = 1;
- return(1);
- }
- }
- else
- {
- send("]]Message Aborted.]");
- S->result = 1;
- return(1);
- }
- }
-
- enteremail(S)
- struct EnterStruct *S;
- {
- char pad[100]; /* this is a fix for a problem */
- char ch;
- int a = 0, /* flag */
- i = 0, /* temp # holder */
- tf = FALSE, /* true/false flag */
- num; /* true/false flag when calling functions */
- S->numlines = 0; /* num lines */
-
- send("]]A line can contain 75 characters, max 50 lines.]");
- send("To end or edit, enter a carriage return on an empty line.]");
- send(" ---------1---------2---------3---------4---------5---------6---------7----!]");
-
- G->nocheck[u]=TRUE; /* no control checking on ouput ! */
- if( (S->numlines+1) < 9 )
- send(" %i: ",(S->numlines+1)); /* don't check for anything here */
- else
- send("%i: ",(S->numlines+1)); /* don't check for anything here */
- G->nocheck[u]=FALSE; /* turn it back on */
-
- while ( a == 0 )
- {
- if (!G->in()) {num = 2;goto byebye;} /* carrier detect or time out ? */
- ch = G->input[u];
- if ( ch == 13)
- {
- G->nocheck[u]=TRUE; /* no control checking on ouput ! */
- send(G->CR[u]); /* don't check for anything here */
- G->nocheck[u]=FALSE; /* turn it back on */
- if (S->numlines >= 49) i = 0;
- else S->numlines = S->numlines + 1;
-
- if (i == 0)
- {
- if(S->numlines <= 48) S->numlines = S->numlines - 2;
- num = askline(S);
- if (num != 0) goto byebye;
- }
- i = 0;
- S->emailtext[S->numlines][i]= '\0';
- G->nocheck[u]=TRUE; /* no control checking on ouput ! */
- if( (S->numlines+1) <= 9 )
- send(" %i: ",(S->numlines+1)); /* don't check for anything here */
- else
- send("%i: ",(S->numlines+1)); /* don't check for anything here */
- G->nocheck[u]=FALSE; /* turn it back on */
- }
- else
- if ( ch == 8 ) /* handle backspace */
- {
- if (i>0) {
- G->serout('\b');
- G->serout(' ');
- G->serout('\b');
- i = i - 1;
- S->emailtext[S->numlines][i] = '\0';
- }
- if (!G->online[u]) {num = 2;goto byebye;} /* time out ? */
- }
- else
- if ( i >= 74 )
- {
- G->serout(ch); /* doesn't check for "S" or "C" */
- if (!G->online[u]) {num = 2;goto byebye;} /* time out ? */
- i = 0;
- if (S->numlines >= 49) continue;
- S->numlines = S->numlines + 1;
- S->emailtext[S->numlines][i] = ch;
- S->emailtext[S->numlines][i+1] = '\0';
- G->nocheck[u]=TRUE; /* no control checking on ouput ! */
- send(G->CR[u]);
- if( (S->numlines+1) <= 9 )
- send(" %i: ",(S->numlines+1)); /* don't check for anything here */
- else
- send("%i: ",(S->numlines+1)); /* don't check for anything here */
- G->nocheck[u]=FALSE; /* turn it back on */
- }
- else
- {
- G->serout(ch); /* doesn't check for "S" or "C" */
- if (!G->online[u]) {num = 2;goto byebye;} /* time out ? */
- S->emailtext[S->numlines][i] = ch;
- S->emailtext[S->numlines][i+1] = '\0';
- i=i+1;
- }
- }
- byebye:
- S->result = num;
- }
-
-
- askline(S)
- struct EnterStruct *S;
- {
- char pad[100]; /* this is a fix for a problem */
- char tempstring[255], ch;
- int num = 0, /* flag */
- b = 0, /* flag */
- c = 0, /* temp variable */
- d = 0; /* temp variable */
-
- while ( b == 0 )
- {
- if (S->numlines == 0 && S->emailtext[0][0] == '\0') /* if no text at all */
- {
- send("]Message Cancelled.]");
- num = 1;
- b = 1;
- break;
- }
- if (!(cmd1("]]>> Continue, Delete line, Edit line, List, Save, Quit : ")))
- {
- G->online[u]=FALSE;
- b = 1;
- num = 2;
- }
- send(G->CR[u]);
- ch = G->input[u];
- switch (ch)
- {
- case 'C':
- if ( S->numlines <=48 )
- {
- S->numlines = S->numlines + 1;
- num = 0;
- b = 1;
- }
- else
- send("]Message is already 50 lines!]");
- break;
- case 'D':
- send("]Enter line number to delete, or RETURN to exit : ");
- portsin(tempstring,3);
- send(G->CR[u]);
- c = strtoint(tempstring);
- if (c <= 0) break;
- if (c > (S->numlines + 1)){
- send("]]There is no such line number.]]");
- break;
- }
- send("]Line #%d reads:]",c);
- send(S->emailtext[(c-1)]);
- cmd1("]]Are you sure you want to DELETE it (Y/N)? ");
- ch = G->input[u];
- send(G->CR[u]);
- if (ch=='Y'){
- for (d = (c-1); d <S->numlines; d++)
- strcpy(S->emailtext[d],S->emailtext[d+1]);
- S->numlines = S->numlines - 1;
- }
- else
- {
- send("]Line was not deleted.]");
- }
- break;
- case 'E':
- send("]]The edit-line option for the program has been unwritten as of yet.]");
- break;
- case 'S':
- if(S->numlines >49) S->numlines=49; /* just to make sure */
- num = 10;
- b = 1;
- break;
- case 'L':
- for (d = 0;d<=S->numlines && d<=49;d++)
- {
- if( (S->numlines+1) < 9 )
- send(" %i: %s]",(d+1),S->emailtext[d]);
- else
- send("%i: %s]",(d+1),S->emailtext[d]);
- if (G->cancel[u]) break; /* did they press cancel? */
- }
- send(G->CR[u]);
- break;
- case 'Q':
- cmd1("]Are you sure you want to quit (Y/N)? ");
- ch = G->input[u];
- send(G->CR[u]);
- if (ch=='Y')
- {
- send("]Message Cancelled.]");
- num = 1;
- b = 1;
- }
- break;
- }
-
- }
- return(num);
- }
-
- getuserinfo(gettemp) /* stolen from the "login" module code */
- char *gettemp;
- {
- char tempname[maxnamelength];
- char temp1[maxnamelength],temp2[maxnamelength];
- char tchar[258];
- int count;
- long pos;
- FILE *stream;
-
- if ((stream = fopen(":user:userlist", "r")) == NULL) {
- print("C> FILE ERROR - cannot open :bbsuser:userlist\n");
- send("]FILE ERROR - Can't open the user list file !]");
- return FALSE;
- }
- count = 0;
- pos=0;
- sprintf(temp2,"%-30s",gettemp); /* Prepare the user name for compare */
- strtoupper(temp2);
-
- while (TRUE){
-
- if(fseek(stream,pos,0) != 0) print("C> Fseek failed\n"); /* go to the record */
- fgets(tchar,33,stream); if (feof(stream)) goto goteof; sscanf(tchar,"%32[^~]",tempname); /* the user's name */
- strcpy(temp1,tempname); /* save the actual name for later */
- strtoupper(tempname);
- if (strcmp(tempname,temp2) == 0) {
- removespaces(temp1); /* takes out trailing spaces */
- strcpy(gettemp,temp1); /* make their name correct */
- fclose(stream);
- return TRUE;
- }
- otheruser(FALSE); /* do switch */
- if ((++count % 10) == 0) {sendnc (".");} /* show dots */
- pos=pos+801; /* move up a record */
- }
- goteof:
- fclose(stream);
- return FALSE; /* user was not found */
-
- }
-
-