示例#1
0
int main(void) {
    char *sp;
    char input[512];
    int bytes_received = 0;
    fd_set fds;
    int ready_fds;
    struct timeval timeout;
    timeout.tv_sec = 0;
    timeout.tv_usec = 0;
    int ret;

    // cgc_read input
    while (1) {
        FD_ZERO(&fds);
        FD_SET(FD_FROM_MAIN, &fds);
        ret = fdwait(FD_FROM_MAIN + 1, &fds, NULL, &timeout, &ready_fds);
        bytes_received = receive_until_fd(FD_FROM_MAIN, input, sizeof(input), '\n');
        bytes_received = force_newline(input, sizeof(input), bytes_received);
        if (equals(input, "terminate\n")) {
            goto EXIT;
        }
        if (bytes_received > 0) {
            char *args[15];
            int i = 0;
            args[i++] = "mailsend";
            // parse input
            char *p = input;
            while (i < 14) {
                while(isspace(*p)) p++;
                if (!*p)
                    break;
                if (*p && !isspace(*p)) {
                    args[i++] = p;
                    while (*p && !isspace(*p)) p++;
                    *p++ = '\0';
                }
            }
            // Null terminate argument list
            args[i] = 0;

            mailsend(i, args);

            // Tell main program rsh is done
            send_all_fd(FD_TO_MAIN, "\0\n", 2);       
        }
    } 

    EXIT:
    // cgc_exit
    return 0;
}
示例#2
0
文件: mlapl.c 项目: Ntools/EnigmaEnc
static void mail_send(char *to, char *val[], int ac)
{
	FILE *fp;
	char cmd[BUFSIZ];
	char *prm[10];
	int i;

	if((fp = fopen("/tmp/kodai.tmp", "w")) == NULL) return;
	for(i = 0;i < ac;++i) fprintf(fp, "%s\n", val[i]);
	fclose(fp);
#if 0
	sprintf(cmd, "-S smtp.hiug.ne.jp -F Mailinglist -s \"ML Attach Result\" -f /tmp/kodai.tmp %s", to);
	mailsend(cmd);
/* #else */
	prm[0] = "-S"; prm[1] = "localhost";
	prm[2] = "-F"; prm[3] = "Mailinglist";
	prm[4] = "-s"; prm[5] = "ML Attach Result";
	prm[6] = "-f"; prm[7] = "/tmp/kodai.tmp";
	prm[8] = to;
	smail(9, prm);
#endif
}