home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 2
/
goldfish_vol2_cd1.bin
/
files
/
comm
/
misc
/
elcheapofax
/
faxcmd
/
rcs
/
faxsend.c,v
< prev
next >
Wrap
Text File
|
1993-12-21
|
5KB
|
281 lines
head 1.4;
access;
symbols
OCT93:1.4;
locks;
comment @ * @;
1.4
date 93.10.25.02.18.43; author Rhialto; state Exp;
branches;
next 1.3;
1.3
date 93.09.18.20.29.19; author Rhialto; state Exp;
branches;
next 1.2;
1.2
date 93.06.11.16.31.57; author Rhialto; state Exp;
branches;
next 1.1;
1.1
date 93.06.11.15.16.34; author Rhialto; state Exp;
branches;
next ;
desc
@Send faxes to the modem
@
1.4
log
@Make +FBOR flexible.
@
text
@/* $Id: faxsend.c,v 1.3 1993/09/18 20:29:19 Rhialto Exp $
* $Log: faxsend.c,v $
* Revision 1.3 1993/09/18 20:29:19 Rhialto
* Call faxmodem_sync() explicitly.
*
* Revision 1.2 1993/06/11 16:31:57 Rhialto
* First real RCS checkin
*
*/
/*
* This file is part of El Cheapo Fax. All modifications relative to the
* base source are (C) Copyright 1993 by Olaf 'Rhialto' Seibert.
* All rights reserved. The GNU General Public License applies.
*/
/*
This file is part of the NetFax system.
(c) Copyright 1989 by David M. Siegel.
All rights reserved.
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.
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <time.h>
#include "libfax.h"
int getopt(int, char **, char *);
static int do_send(FaxModem *fmp, int fd, int page, int last_page);
static int verbose = FALSE;
static FaxModem fm;
#define EXIT_ERROR 21
#define EXIT_NO_FILE 22
#define EXIT_OPEN_FAILED 23
#define EXIT_CALL_FAILED 24
#define EXIT_SEND_FAILED 25
#define EXIT_FINISH_FAILED 26
static int do_send(fmp, fd, page, last_page)
FaxModem *fmp;
int fd;
int page;
int last_page;
{
long start = time(0);
if (faxmodem_send_page(fmp, fd, last_page, MAX_PAGE_RETRIES) < 0)
return (-1);
if (verbose)
printf("page %d sent in %d seconds\n", page, time(0) - start);
return (0);
}
/*
* This function was introduced by Olaf 'Rhialto' Seibert.
*/
static void cleanup()
{
faxmodem_close(&fm);
}
main(argc, argv)
int argc;
char *argv[];
{
int c;
extern char *optarg;
extern int optind;
int errflg = 0;
char *fax_device = FAX_DEVICE;
char *phone;
long start;
log_set_level(LOG_WARNING);
while ((c = getopt(argc, argv, "b:l:vf:")) != -1)
switch (c) {
case 'b':
bor_value = atoi(optarg);
break;
case 'l':
log_set_level(atoi(optarg));
break;
case 'v':
verbose = TRUE;
break;
case 'f':
fax_device = optarg;
break;
case '?':
errflg++;
break;
}
if (errflg || optind >= argc) {
fprintf(stderr,
"Usage: %s [-f faxdevice] [-l loglevel] [-v] [-b bitorder] phone [files..]\n", argv[0]);
exit(EXIT_ERROR);
}
phone = argv[optind++];
if (optind < argc) {
int ind;
for (ind = optind; ind < argc; ind++) {
if (access(argv[ind], R_OK) < 0) {
fprintf(stderr, "can't access file: %s\n", argv[ind]);
exit(EXIT_NO_FILE);
}
}
}
atexit(cleanup);
if (faxmodem_open(&fm, fax_device) < 0 ||
faxmodem_sync(&fm, 10) < 0) {
fprintf(stderr, "open of fax failed\n");
exit(EXIT_OPEN_FAILED);
}
if (faxmodem_initiate_call(&fm, phone) < 0 || !FAX_CONNECTED(&fm)) {
fprintf(stderr, "call to %s failed\n", phone);
exit(EXIT_CALL_FAILED);
}
start = time(0);
if (verbose) {
printf("connected to %s\n", phone);
faxmodem_print_id_strings(&fm, stdout);
}
if (optind < argc) {
int page = 1;
for (; optind < argc; optind++) {
int fd;
if ((fd = open(argv[optind], O_RDONLY)) < 0) {
fprintf(stderr, "can't access file: %s\n", argv[optind]);
exit(EXIT_NO_FILE);
}
if (do_send(&fm, fd, page++, optind+1 == argc) < 0) {
fprintf(stderr, "sending failed on: %s\n", argv[optind]);
exit(EXIT_SEND_FAILED);
}
}
} else
if (do_send(&fm, 0, 1, TRUE) < 0) {
fprintf(stderr, "sending failed stdin\n");
exit(EXIT_SEND_FAILED);
}
if (faxmodem_hangup(&fm) < 0) {
fprintf(stderr, "hangup failed\n");
exit(EXIT_FINISH_FAILED);
}
if (verbose)
printf("total connect time was %d seconds\n", time(0) - start);
if (faxmodem_close(&fm) < 0) {
fprintf(stderr, "close failed\n");
exit(EXIT_FINISH_FAILED);
}
exit(0);
}
@
1.3
log
@Call faxmodem_sync() explicitly.
@
text
@d1 1
a1 1
/* $Id: faxsend.c,v 1.2 1993/06/11 16:31:57 Rhialto Exp $
d3 3
a47 2
#define MAX_TRIES 3
d63 1
a63 1
if (faxmodem_send_page(fmp, fd, last_page, MAX_TRIES) < 0)
d95 1
a95 1
while ((c = getopt(argc, argv, "l:vf:")) != -1)
d97 3
d116 1
a116 1
"Usage: %s [-f faxdevice] [-l loglevel] [-v] phone [files..]\n", argv[0]);
@
1.2
log
@First real RCS checkin
@
text
@d1 5
a5 2
/* $Id$
* $Log$
d129 2
a130 1
if (faxmodem_open(&fm, fax_device) < 0) {
@
1.1
log
@Initial revision
@
text
@d1 3
d89 1
a89 1
/*log_set_level(LOG_WARNING);*/
d108 2
a109 1
fprintf(stderr, "usage: %s phone [files..]\n", argv[0]);
@