Exemplo n.º 1
0
Arquivo: email.c Projeto: bbs-io/mbse
/*
 *  Reply message, in Msg.From and Msg.Subject must be the
 *  name to reply to and the subject.
 */
void Reply_Email(int IsReply)
{
    int     i, j, x;
    char    to[101], from[101], subj[101], msgid[101], replyto[101], replyaddr[101], *tmp, *buf, qin[9], temp[81];
    faddr   *Dest = NULL;

    snprintf(from, 101, "%s", Msg.To);
    snprintf(to, 101, "%s", Msg.From);
    snprintf(replyto, 101, "%s", Msg.ReplyTo);
    snprintf(replyaddr, 101, "%s", Msg.ReplyAddr);

    if (strncasecmp(Msg.Subject, "Re:", 3) && IsReply) {
	snprintf(subj, 101, "Re: %s", Msg.Subject);
    } else {
	snprintf(subj, 101, "%s", Msg.Subject);
    }
    mbse_CleanSubject(subj);
    Syslog('m', "Reply msg to %s, subject %s", to, subj);
    Syslog('m', "Msgid was %s", Msg.Msgid);
    snprintf(msgid, 101, "%s", Msg.Msgid);

    x = 0;
    Line = 1;
    WhosDoingWhat(READ_POST, NULL);
    clear();
    snprintf(temp, 81, "   %-70s", sMailbox);
    pout(BLUE, LIGHTGRAY, temp);
    snprintf(temp, 81, "#%-5u", EmailBase.Highest + 1);
    pout(RED, LIGHTGRAY, temp);
    Enter(1);

    colour(CFG.HiliteF, CFG.HiliteB);
    if (utf8)
	chartran_init((char *)"CP437", (char *)"UTF-8", 'B');
    PUTSTR(chartran(sLine_str()));
    chartran_close();
    Enter(1);

    for (i = 0; i < (TEXTBUFSIZE + 1); i++)
	Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char));
    Line = 1;
    Msg_New();

    snprintf(Msg.Replyid, sizeof(Msg.Replyid), "%s", msgid);
    snprintf(Msg.ReplyTo, sizeof(Msg.ReplyTo), "%s", replyto);
    snprintf(Msg.ReplyAddr, sizeof(Msg.ReplyAddr), "%s", replyaddr);

    /* From     : */
    pout(YELLOW, BLACK, (char *) Language(209));
    if (CFG.EmailMode != E_PRMISP) {
	/*
	 * If not permanent connected to the internet, use fidonet.org style addressing.
	 */
	Dest = fido2faddr(CFG.EmailFidoAka);
	snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.sUserName, ascinode(Dest, 0x2f), exitinfo.sUserName);
    } else {
	snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName);
    }
    for (i = 0; i < strlen(Msg.From); i++) {
	if (Msg.From[i] == ' ')
	    Msg.From[i] = '_';
	if (Msg.From[i] == '@')
	    break;
    }
    pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.From);
    Enter(1);
    Syslog('b', "Setting From: %s", Msg.From);

    /* To       : */
    snprintf(Msg.To, 101, "%s", to);
    pout(YELLOW, BLACK, (char *) Language(208));
    pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.To);
    Enter(1);

    /* Enter to keep Subject. */
    pout(LIGHTRED, BLACK, (char *) Language(219));
    Enter(1);
    /* Subject  : */
    pout(YELLOW, BLACK, (char *) Language(210));
    snprintf(Msg.Subject, 101, "%s", subj);
    pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.Subject);

    x = strlen(subj);
    colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
    GetstrP(subj, 50, x);

    if (strlen(subj))
	strcpy(Msg.Subject, subj);

    Msg.Private = TRUE;
    Enter(1);

//  Check_Attach();

    /*
     *  Quote original message now, format the original users
     *  initials into qin. If its a [email protected] the use the
     *  first 8 characters of the name part.
     */
    snprintf(Message[1], TEXTBUFSIZE +1, "%s wrote to %s:", to, from);
    memset(&qin, 0, sizeof(qin));
    if (strchr(to, '@')) {
	tmp = xstrcpy(strtok(to, "@"));
	tmp[8] = '\0';
	snprintf(qin, 9, "%s", tmp);
	free(tmp);
    } else {
	x = TRUE;
	j = 0;
	for (i = 0; i < strlen(to); i++) {
	    if (x && isalpha(to[i])) {
		qin[j] = to[i];
		j++;
		x = FALSE;
	    }
	    if (to[i] == ' ' || to[i] == '.')
		x = TRUE;
	    if (j == 6)
		break;
	}
    }

    Line = 2;
    tmp = calloc(PATH_MAX, sizeof(char));
    buf = calloc(TEXTBUFSIZE +1, sizeof(char));

    snprintf(tmp, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name);
    if ((qf = fopen(tmp, "r")) != NULL) {
	while ((fgets(buf, TEXTBUFSIZE, qf)) != NULL) {
	    Striplf(buf);
	    snprintf(Message[Line], TEXTBUFSIZE +1, "%s> %s", (char *)qin, buf);
	    Line++;
	    if (Line == TEXTBUFSIZE)
		break;
	}
	fclose(qf);
    } else
	WriteError("$Can't read %s", tmp);

    free(buf);
    free(tmp);

    if (Edit_Msg())
	Save_Email(IsReply);

    for (i = 0; i < (TEXTBUFSIZE + 1); i++)
	free(Message[i]);
}
Exemplo n.º 2
0
Arquivo: email.c Projeto: bbs-io/mbse
void Write_Email(void)
{
    faddr   *Dest = NULL;
    int	    i;
    char    *orgbox;

    if (HasNoEmail())
	return;

    orgbox = xstrcpy(sMailbox);
    SetEmailArea((char *)"mailbox");

    WhosDoingWhat(READ_POST, NULL);
    clear();

    for (i = 0; i < (TEXTBUFSIZE + 1); i++)
	Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char));
    Line = 1;

    Msg_New();

    Enter(1);
    colour(LIGHTBLUE, BLACK);
    /* Posting message in area: */
    pout(LIGHTBLUE, BLACK, (char *) Language(156));
    PUTSTR((char *)"\"mailbox\"");
    Enter(2);

    /* From   : */
    pout(YELLOW, BLACK, (char *) Language(157));
    if (CFG.EmailMode != E_PRMISP) {
	/*
	 * If not permanent connected to the internet, use fidonet.org style addressing.
	 */
	Dest = fido2faddr(CFG.EmailFidoAka);
	snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.sUserName, ascinode(Dest, 0x2f), exitinfo.sUserName);
    } else
	snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName);
    
    for (i = 0; i < strlen(Msg.From); i++) {
        if (Msg.From[i] == ' ')
            Msg.From[i] = '_';
        if (Msg.From[i] == '@')
            break;
    }
    
    pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.From);
    Syslog('b', "Setting From: %s", Msg.From);
    Enter(1);

    /* To     : */
    pout(YELLOW, BLACK, (char *) Language(158));
    colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
    alarm_on();
    GetstrU(Msg.To, 63);

    if ((strcmp(Msg.To, "")) == 0) {
	for (i = 0; i < (TEXTBUFSIZE + 1); i++)
	    free(Message[i]);
	SetEmailArea(orgbox);
	free(orgbox);
	return;
    }

    /* Subject  :  */
    pout(YELLOW, BLACK, (char *) Language(161));
    colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
    alarm_on();
    GetstrP(Msg.Subject, 65, 0);
    mbse_CleanSubject(Msg.Subject);

    if ((strcmp(Msg.Subject, "")) == 0) {
	Enter(1);
	/* Abort Message [y/N] ?: */
	pout(CYAN, BLACK, (char *) Language(162));
	alarm_on();

	if (toupper(Readkey()) == Keystroke(162, 0)) {
	    for (i = 0; i < (TEXTBUFSIZE + 1); i++)
		free(Message[i]);
	    SetEmailArea(orgbox);
	    free(orgbox);
	    return;
	}
    }

    Msg.Private = TRUE;

    if (Edit_Msg()) {
	Save_Email(FALSE);
    }

    for (i = 0; i < (TEXTBUFSIZE + 1); i++)
	free(Message[i]);

    SetEmailArea(orgbox);
    free(orgbox);
}
Exemplo n.º 3
0
/*
 * Edit signature file with a simple line editor.
 */
int editsignature(void)
{
    FILE    *fp;
    int	    i, x;
    char    *temp, *temp1;

    temp  = calloc(PATH_MAX, sizeof(char));
    temp1 = calloc(PATH_MAX, sizeof(char));
    snprintf(temp, PATH_MAX, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);

    while (TRUE) {
	Enter(1);
	/* Functions available: */
	poutCR(CFG.HiliteF, CFG.HiliteB, (char *) Language(113));
	Enter(1);
	/* (L)ist, (R)eplace text, (E)dit line, (A)bort, (S)ave */
	pout(YELLOW, RED, (char *) Language(114));
	Enter(2);

	/* Select: */
  	pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(115));

	alarm_on();
	i = toupper(Readkey());
	Enter(1);

	if (i == Keystroke(114, 3)) {
	    /* Aborting... */
	    pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(116));
	    Syslog('+', "User aborted .signature editor");
	    free(temp);
	    free(temp1);
	    return TRUE;

	} else if (i == Keystroke(114, 2)) {
	    Enter(1);
	    /* Edit which line: */
	    snprintf(temp, 80, " %s", (char *) Language(118));
	    pout(CFG.HiliteF, CFG.HiliteB, temp);
	    colour(CFG.InputColourF, CFG.InputColourB);
	    GetstrC(temp, 3);

	    if ((strcmp(temp, "")) == 0)
		break;

	    i = atoi(temp);
	    if ((i < 1) || (i > MAXSIGLINES)) {
		Enter(1);
		/* Line does not exist. */
		poutCR(LIGHTRED, BLACK, (char *) Language(119));
		break;
	    }

	    x = strlen(sLiNE[i-1]);
	    snprintf(temp, 80, "%d:", i);
	    pout(LIGHTRED, BLACK, temp);
	    pout(CFG.InputColourF, CFG.InputColourB, sLiNE[i-1]);
	    GetstrP(sLiNE[i-1], LENSIGLINES-1, x);

	} else if (i == Keystroke(114, 0)) {
	    /* List lines */
	    toprow();
	    for (i = 0; i < MAXSIGLINES; i++) {
		snprintf(temp, 80, "%d:", i+1);
		pout(LIGHTRED, BLACK, temp);
		poutCR(CFG.MoreF, CFG.MoreB, sLiNE[i]);
	    }
	    botrow();

	} else if (i == Keystroke(114, 4)) {
	    Enter(1);
	    /* Saving... */
	    pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(340));

	    /* Open TextFile for Writing NextUser Info */
	    snprintf(temp, PATH_MAX, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
	    if ((fp = fopen(temp, "w")) == NULL) {
		WriteError("$Can't open %s", temp);
		free(temp);
		free(temp1);
		return TRUE;
	    }
	    for (i = 0; i < MAXSIGLINES; i++) {
		if (strlen(sLiNE[i]))
		    fprintf(fp, "%s\n", sLiNE[i]);
	    }
	    fclose(fp);
		
	    Syslog('+', "User Saved .signature");
	    free(temp);
	    free(temp1);
	    return TRUE;

	} else if (i == Keystroke(114, 1)) {
	    Enter(1);
	    /* Edit which line: */
	    pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(118));
	    colour(CFG.InputColourF, CFG.InputColourB);
	    GetstrC(temp, 3);

	    if ((strcmp(temp, "")) == 0)
		break;

	    i = atoi(temp);

	    if ((i < 1) || (i > MAXSIGLINES)) {
		Enter(1);
		/* Line does not exist. */
		poutCR(LIGHTRED, BLACK, (char *) Language(119));
		break;
	    }

	    Enter(1);
	    /* Line reads: */
	    poutCR(CFG.MoreF, CFG.MoreB, (char *) Language(186));
	    snprintf(temp, 81, "%d:%s", i, sLiNE[i-1]);
	    poutCR(CFG.MoreF, CFG.MoreB, temp);

	    Enter(1);
	    /* Text to replace: */
	    pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(195));
	    colour(CFG.InputColourF, CFG.InputColourB);
	    GetstrC(temp, LENSIGLINES-1);

	    if ((strcmp(temp, "")) == 0)
		break;

	    /* Replacement text: */
	    pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(196));
	    colour(CFG.InputColourF, CFG.InputColourB);
	    GetstrC(temp1, LENSIGLINES-1);

	    if ((strcmp(temp1, "")) == 0)
		break;
	    strreplace(sLiNE[i-1], temp, temp1);

	} else
	    Enter(1);
    }

    free(temp);
    free(temp1);
    return FALSE;
}