/*Last Modified: 30-APR-1992 08:44:44.42, By: MARK */
/*
* The following routines display events in a really pretty fashion.
*
* They also allow one to easily enter an event
*/
/*** Map the month names to numbers ***/
/*** TODO, gotta check if the month is hosed! ***/
for (i=0; i < 12; i++) {
if (strncasecmp(EventResponses[1], Months[i], 3) == 0) {
fprintf(TmpFile, "%s", Dates[i]);
break;
}
}
/*** Output the day of the month ***/
switch (strlen(EventResponses[2])) {
case 2:
fprintf(TmpFile, "%s", EventResponses[2]);
break;
case 1:
fprintf(TmpFile, "0%s", EventResponses[2]);
break;
case 3:
/*** Error! ***/
/*** TODO display a message ***/
return(FALSE);
break;
}
/** Yes, the elusive time! **/
/** Make sure the hour is correct **/
if (isdigit(EventResponses[0][0]) && (EventResponses[0][1] == ':')) {
fputc('0', TmpFile);
fputc(EventResponses[0][0], TmpFile);
}
else if (isdigit(EventResponses[0][0]) && isdigit(EventResponses[0][1])) {
fputc(EventResponses[0][0], TmpFile);
fputc(EventResponses[0][1], TmpFile);
}
else
/*** Error!!! ***/
return(FALSE);
/** Now for the minutes **/
cp = EventResponses[0];
while (*cp != ':')
cp++;
cp++;
fputc(*cp, TmpFile);
fputc(*(cp+1), TmpFile);
/** Put out the seconds 00 **/
fputc('0', TmpFile);
fputc('0', TmpFile);
/*** Length min and length max ***/
fprintf(TmpFile, " %s %s\n", EventResponses[4], EventResponses[5]);
/*** TODO need to convert USERCAP to the real username ***/
fprintf(TmpFile, "From: %s\n", USERCAP);
fprintf(TmpFile, "Summary: %s\n", EventResponses[8]);
fprintf(TmpFile, "Location: %s\n", EventResponses[9]);
/*** Write out the recurs line ***/
if (EventResponses[6][0] == 'y' ||EventResponses[6][0] == 'Y') {
fprintf(TmpFile, "Recurs: %s\n", EventResponses[7]);
}
/*** Get the event from the net ***/
sockfd = OpenGopherConn(ZeGopher);
Draw_Status("Receiving Event...");
refresh();
/** Send out the request **/
writestring(sockfd, ZeGopher->sPath);
writestring(sockfd, "\tfetch\r\n");
/** Check the result of the command. See if we screwed up... **/
length = readline(sockfd, inputline, MAXLINE);
if (inputline[0]=='-') {
CursesErrorMsg(inputline + 2);
return;
}
/*** Load the event into the form ***/
EventFileToForm(tmpfile, SaveGoph.sTitle);
fclose(tmpfile);
break;
case 'D':
case 'd':
/*** Decline the invitation ***/
sockfd = OpenGopherConn(ZeGopher);
/** Send out the request **/
writestring(sockfd, ZeGopher->sPath);
writestring(sockfd, "\tmodpers\t");
writestring(sockfd, USERCAP);
writestring(sockfd, "\r\n");
/** Modify our status field ***/
writestring(sockfd, "Status: Absent\r\n");
writestring(sockfd, ".\r\n");
/*** Get the result of the modpers command ***/
inputline[0] = '-';
length = readline(sockfd, inputline, MAXLINE);
if (inputline[0] == '-') {
CursesErrorMsg(inputline + 2);
}
close(sockfd);
/*** Now we must get the form again ***/
sprintf(tmpfilename, "/tmp/gopher.%d",getpid());
if ((tmpfile = fopen(tmpfilename, "w")) == NULL) {
CursesErrorMsg("Couldn't make a tmp file!");
return;
}
GetEventFile(&SaveGoph, tmpfile);
/*** Reopen the file as read-only ***/
fclose(tmpfile);
/*** Load the event into the form ***/
EventFileToForm(tmpfile, SaveGoph.sTitle);
fclose(tmpfile);
break;
case 'a':
case 'A':
/*** Accept the invitation ***/
sockfd = OpenGopherConn(&SaveGoph);
/** Send out the request **/
writestring(sockfd, SaveGoph.sPath);
writestring(sockfd, "\tmodpers\t");
writestring(sockfd, USERCAP);
writestring(sockfd, "\r\n");
/** Modify our status field ***/
writestring(sockfd, "Status: attending\r\n");
writestring(sockfd, ".\r\n");
/*** Get the result of the modpers command ***/
inputline[0] = '-';
length = readline(sockfd, inputline, MAXLINE);
if (inputline[0] == '-') {
CursesErrorMsg(inputline + 2);
}
close(sockfd);
/*** Now we must get the form again ***/
sprintf(tmpfilename, "/tmp/gopher.%d",getpid());
if ((tmpfile = fopen(tmpfilename, "w")) == NULL) {
CursesErrorMsg("Couldn't make a tmp file!");
return;
}
GetEventFile(&SaveGoph, tmpfile);
/*** Reopen the file as read-only ***/
fclose(tmpfile);