Files
mars-nwe/opt/unxsendm.c
Mario Fetka f8317503df
All checks were successful
Source release / source-package (push) Successful in 40s
docs: normalize source license headers to gpl2 only
2026-06-03 00:46:27 +02:00

71 lines
1.8 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* This file is part of mars_nwe.
*
* Copyright (C) 1993-2000 Martin Stover, Marburg, Germany
* Copyright (C) 2026 Mario Fetka
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 only.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/* unxsendm.c 23-Oct-96 */
/* simple UNX program to work together with 'pipe-filesystem'
* and DOS sendm.exe to get sendmail functionality under DOS
* QUICK + DIRTY !!!
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/types.h>
#define MAXARGLEN 100
int bl_read(int fd, void *buf, int size)
{
fd_set fdin;
struct timeval t;
int result;
FD_ZERO(&fdin);
FD_SET(fd, &fdin);
t.tv_sec = 1; /* 1 sec should be enough */
t.tv_usec = 0;
result = select(fd+1, &fdin, NULL, NULL, &t);
if (result > 0)
result=read(fd, buf, size);
return(result);
}
int main(int argc, char *argv[])
{
int size;
char buf[1024];
close(2);
dup2(1,2); /* we want stdout and errout */
if (-1 < (size=bl_read(0, buf, MAXARGLEN))){
FILE *f;
char path[MAXARGLEN+200];
buf[size]='\0';
sprintf(path, "/usr/bin/sendmail %s", buf);
f=popen(path, "w");
if (NULL != f) {
if (write(1, "+++++\n", 6) < 0) {}
while (0 < (size=bl_read(0, buf, sizeof(buf)))){
fwrite(buf, size, 1, f);
}
pclose(f);
return(0);
}
perror(path);
} else
perror("read stdin");
return(1);
}