From: usys@phoenix.abg.sub.org (Uwe C. Schroeder)
Newsgroups: comp.dcom.fax
Subject: ZyXeEL fax software Part 1 of 1
Keywords: Software for standalone SYSV 3.2
Date: 9 Nov 92 21:21:16 GMT
Distribution: comp
Organization: Anwendungssysteme, Augsburg

Here is the alpha release of my fax software for ZyXEL modems.

------------------------- snip snip --------------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  CAVEAT COPYING PORTING REQUIREMENTS tty.c init.c write.c
#   read.c response.c rcv.c snd.c fax.c dir.c process.c queue.c log.c
#   tty.h conf.h send.c receive.c spooler.c S101fax Makefile printfax
# Wrapped by usys@phoenix on Mon Nov  9 16:15:12 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'CAVEAT' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'CAVEAT'\"
else
echo shar: Extracting \"'CAVEAT'\" \(1884 characters\)
sed "s/^X//" >'CAVEAT' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
XIn future there will be enhancements to the getty like functions in the
Xspooler. Iam working on the voice facility of the zyxel modems. This
Xmeans, that in a future release the spooler will react like an answering
Xmachine controlable by DTMF signals. The current problem to do so
Xis the terrible low volume of the playback signal.END_OF_FILE
if test 1884 -ne `wc -c <'CAVEAT'`; then
    echo shar: \"'CAVEAT'\" unpacked with wrong size!
fi
# end of 'CAVEAT'
fi
if test -f 'COPYING' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'COPYING'\"
else
echo shar: Extracting \"'COPYING'\" \(1552 characters\)
sed "s/^X//" >'COPYING' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
END_OF_FILE
if test 1552 -ne `wc -c <'COPYING'`; then
    echo shar: \"'COPYING'\" unpacked with wrong size!
fi
# end of 'COPYING'
fi
if test -f 'PORTING' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'PORTING'\"
else
echo shar: Extracting \"'PORTING'\" \(1802 characters\)
sed "s/^X//" >'PORTING' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
XPorting to other platforms might not be too hard. Have a close look
Xat the tty functions. Currently I use 2 filedescriptors to get the
Xhardware handshaking correct. Perhaps on other platforms there are
Xioctl's to get the hardware handshake running.
END_OF_FILE
if test 1802 -ne `wc -c <'PORTING'`; then
    echo shar: \"'PORTING'\" unpacked with wrong size!
fi
# end of 'PORTING'
fi
if test -f 'REQUIREMENTS' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'REQUIREMENTS'\"
else
echo shar: Extracting \"'REQUIREMENTS'\" \(1950 characters\)
sed "s/^X//" >'REQUIREMENTS' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
XThis software package currently needs the fas driver to be installed.
XIt works only with ZyXEL modems, because it uses the ZyXEL fax mode and
Xnot the class2 standard.
X
XIt was developed for System V 3.2 stanalone machines on Intel architecture.
X
XYou will need the following external software:
X
X	ghostscript 2.5.2 or higher with dfax driver
X	psify
X	dvialw (this will be replaced by dvips sometime)
X
END_OF_FILE
if test 1950 -ne `wc -c <'REQUIREMENTS'`; then
    echo shar: \"'REQUIREMENTS'\" unpacked with wrong size!
fi
# end of 'REQUIREMENTS'
fi
if test -f 'tty.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tty.c'\"
else
echo shar: Extracting \"'tty.c'\" \(2895 characters\)
sed "s/^X//" >'tty.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X#include <termio.h>
X
X#include "conf.h"
X#include "tty.h"
X
X
Xstruct termio save_term;
X
Xint
Xopen_tty(name,w)
X     char *name;
X     int w;
X{
X  struct termio t;
X  int fd;
X
X  if(w != 1) w = 0;
X
X  if(w)
X    {
X      while((fd=open(name, O_WRONLY)) < 0) sleep(60);
X    }
X  else
X    {
X      if((fd=open(name, O_WRONLY)) < 0)
X	{
X	  perror("open failed");
X	  exit(8);
X	}
X    }
X  
X  if(ioctl(fd,TCGETA,&t) <0)
X    {
X      perror("ioctl TCGETA failed");
X      exit(9);
X    }
X
X  t.c_cflag = EXTA | CS8 ;
X  t.c_lflag = 0;
X  t.c_iflag = 0;
X  t.c_oflag = 0;
X
X  if(ioctl(fd,TCSETA,&t) <0)
X    {
X      perror("ioctl TCSETA failed");
X      exit(9);
X    }
X
X  return fd;
X}
X
Xint
Xopen_read_tty(name, w)
X     char *name;
X     int w;
X{
X  struct termio t;
X  int fd;
X  
X  if(w != 1) w = 0;
X
X  if(w)
X    {
X      while((fd=open(name, O_WRONLY)) < 0) sleep(60);
X    }
X  else
X    {
X      if((fd=open(name, O_RDONLY)) < 0)
X	{
X	  perror("open failed");
X	  exit(8);
X	}
X    }
X  
X  if(ioctl(fd,TCGETA,&t) <0)
X    {
X      perror("ioctl TCGETA failed");
X      exit(9);
X    }
X
X  t.c_cflag = EXTA | CS8 | CREAD ;
X  t.c_lflag = 0;
X  t.c_iflag = 0;
X  t.c_oflag = 0;
X
X  if(ioctl(fd,TCSETA,&t) <0)
X    {
X      perror("ioctl TCSETA failed");
X      exit(9);
X    }
X
X  return fd;
X}
X
Xint
Xclose_tty(fd)
X     int fd;
X{
X  close(fd);
X}
END_OF_FILE
if test 2895 -ne `wc -c <'tty.c'`; then
    echo shar: \"'tty.c'\" unpacked with wrong size!
fi
# end of 'tty.c'
fi
if test -f 'init.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'init.c'\"
else
echo shar: Extracting \"'init.c'\" \(2153 characters\)
sed "s/^X//" >'init.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X
X#include "conf.h"
X
Xinit_modem(fd,rfd)
X     int fd, rfd;
X{
X  int tries;
X
X  for(tries = 0; tries < MODEM_INIT_TRIES; tries ++)
X    {
X      fdprintf(fd,"ATZE0\r\n");
X      get_result(rfd,"OK");
X      fdprintf(fd,"AT&N32\r\n");
X      get_result(rfd,"OK");
X      fdprintf(fd,"AT+FCLASS=6\r\n");
X      get_result(rfd,"OK");      
X      fdprintf(fd,"AT#V1#T0#R0#L2#C7#B0#P+49 821 706892\r\n");
X      get_result(rfd,"OK");/**/
X
X      fdprintf(fd,"AT\r\n");
X      if(get_result(rfd,"OK")==0)
X	{
X	  logto("Fax is syncron");
X	  return 0;
X	}
X    }
X}
END_OF_FILE
if test 2153 -ne `wc -c <'init.c'`; then
    echo shar: \"'init.c'\" unpacked with wrong size!
fi
# end of 'init.c'
fi
if test -f 'write.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'write.c'\"
else
echo shar: Extracting \"'write.c'\" \(1966 characters\)
sed "s/^X//" >'write.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X#include <varargs.h>
X
X#include "conf.h"
X
Xint fdprintf(va_alist)
X     va_dcl
X{
X  va_list ap;
X  int fd;
X  char *format;
X  char buf[1024];
X  
X  va_start(ap);
X  fd = va_arg(ap, int);
X  format = va_arg(ap, char *);
X  vsprintf(buf, format, ap);
X  va_end(ap);
X  
X  if(debug)printf("writing: %.*s",strlen(buf),buf);
X  return (write(fd, buf, strlen(buf)));
X}
X
END_OF_FILE
if test 1966 -ne `wc -c <'write.c'`; then
    echo shar: \"'write.c'\" unpacked with wrong size!
fi
# end of 'write.c'
fi
if test -f 'read.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'read.c'\"
else
echo shar: Extracting \"'read.c'\" \(2294 characters\)
sed "s/^X//" >'read.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X
X#include "conf.h"
X
X/* reads a line of characters, terminated by a newline */
X/* returns number ob chars read (w/o zero) */
Xint fdgets(fd, buf, nbytes)
X     char *buf;
X     int nbytes, fd;
X{
X  int i;
X  char *bp;
X  unsigned char ch;
X  
X  bp = buf;
X  
X  for (i = 0; i < nbytes; i++) {
X    while(read(fd,&ch,1) < 1);
X    if (ch == '\n') break;
X    if(debug) printf("%c",ch);
X    *bp++ = ch;
X  }
X  
X  *bp = '\0';
X  return(i);
X}
X
X/* read with hang on ty line */
Xint
Xread_hang(fd,buf,bytes)
X     int fd,bytes;
X     char *buf;
X{
X  int i;
X  char *bp;
X  unsigned char ch;
X  
X  bp = buf;
X  
X  for (i = 0; i < bytes; i++) {
X    while(read(fd,&ch,1) < 1);
X    *bp++ = ch;
X  }
X  return(i);
X}
END_OF_FILE
if test 2294 -ne `wc -c <'read.c'`; then
    echo shar: \"'read.c'\" unpacked with wrong size!
fi
# end of 'read.c'
fi
if test -f 'response.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'response.c'\"
else
echo shar: Extracting \"'response.c'\" \(3397 characters\)
sed "s/^X//" >'response.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X
X#include "conf.h"
X
Xint
Xget_result(fd,exp)
X     int fd;
X     char *exp;
X{
X  int bytes;
X  char buf[128];
X
X  for(;;)
X    {
X      bytes=fdgets(fd,buf,sizeof(buf));
X
X      if(debug && bytes > 0)
X        printf("get_result: got %d: %.*s\r\n",bytes,bytes,buf);
X      if(!strncmp(exp,buf,strlen(exp)))
X	{
X	  logto("get_result: got %s",buf);
X	  return 0;
X	}
X      else
X	logto("get_result: got %d: %.*s\r\n",bytes,bytes,buf);
X    }
X  return (-1);
X}
X
X
Xint
Xget_fax_connect(fd)
X     int fd;
X{
X  char buf[256];
X  int bytes;
X
X  for(;;)
X    {
X      bytes=fdgets(fd,buf,sizeof(buf));
X      
X      if(debug) printf("get_fax_con: got %d: %.*s\r\n",bytes,bytes,buf); 
X      if(bytes >4) /* think we got it */
X	{
X	  if(!strncmp(buf,"CONNECT FAX",11))
X	    {
X	      logto("%.*s",bytes,buf);
X	      return 0;
X	    }
X	  if(!strncmp(buf,"BUSY",4))
X	    {
X	      logto("Number BUSY");
X	      return -1;
X	    }
X	  if(!strncmp(buf,"NO ANSWER",9))
X	    {
X	      logto("Number NO ANSWER");
X	      return -1;
X	    }
X	  if(!strncmp(buf,"NO CARRIER",10))
X	    {
X	      logto("Number NO CARRIER");
X	      return -1;
X	    }
X	}
X    }
X}
X
X
Xint
Xget_fax_disconnect(fd)
X     int fd;
X{
X  char buf[256];
X  int bytes;
X
X  for(;;)
X    {
X      bytes=fdgets(fd,buf,sizeof(buf));
X      
X      if(debug) printf("get_fax_discon: got %d: %.*s\r\n",bytes,bytes,buf); 
X      if(bytes >2) /* think we got it */
X	{
X	  if(!strncmp(buf,"DISCONNECT",10))
X	    {
X	      if(!strncmp(&buf[10],"0",1))
X		 {
X		   logto("%.*s",bytes,buf);
X		   return 0;
X		 }
X	      else
X		{
X		  logto("%.*s",bytes,buf);
X		  return -1;
X		}
X	    }
X	  if(!strncmp(buf,"NO ANSWER",9))
X	    {
X	      logto("Number NO ANSWER");
X	      return -1;
X	    }
X	  if(!strncmp(buf,"NO CARRIER",10))
X	    {
X	      logto("Number NO CARRIER");
X	      return -1;
X	    }
X	}
X    }
X}
X
END_OF_FILE
if test 3397 -ne `wc -c <'response.c'`; then
    echo shar: \"'response.c'\" unpacked with wrong size!
fi
# end of 'response.c'
fi
if test -f 'rcv.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rcv.c'\"
else
echo shar: Extracting \"'rcv.c'\" \(3135 characters\)
sed "s/^X//" >'rcv.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X#include <unistd.h>
X
X#include "conf.h"
X
Xint
Xwrite_obuf(f, obuf,bc)
X     FILE *f;
X     unsigned char *obuf;
X     int bc;
X{
X  if(fwrite(obuf,sizeof(unsigned char),bc+1,f) != bc+1)
X    {
X      logto("FATAL: cant write buffer");
X      return(-1);
X    }
X  return 0;
X}
X
Xint
Xrec_file(f,rfd,fd)
X     FILE *f;
X     int rfd,fd;
X{
X  int sbytes, bc=0, i;
X  unsigned char obuf[1024];
X  unsigned char dbuf[11];
X  unsigned char fch;
X
X  while(1)
X    {
X      if((sbytes=read_hang(rfd,&fch,1))< 0)
X	{
X	  perror("read failed!");
X	  close(f);
X	  return(-1);
X	}
X      else
X	{
X	  if(bc < 1023)
X	    {
X	      if(fch == 'D') /* perhaps DISCONNECT */
X		{
X		  dbuf[0] = fch;
X		  if((sbytes=read_hang(rfd,&dbuf[1],10))< 0)
X		    {
X		      perror("read failed!");
X		      fclose(f);
X		      return(-1);
X		    }
X		  if(!strncmp(dbuf,"DISCONNECT",10)) /* ok, file ends here */
X		    { /* write remaining buffer */
X		      write_obuf(f,obuf,bc);
X		      fclose(f);
X		      if(dbuf[10] == '0')
X			return(0);
X		      else
X			return -1;
X		    }
X		  else /* sorry, it was data */
X		    {
X		      for(i=0;i<10;i++,bc++)
X			{
X			  if(bc < 1023)
X			    obuf[bc]=dbuf[i];
X			  else
X			    {
X			      obuf[bc]=dbuf[i];
X			      if(write_obuf(f,obuf,bc)==0)
X				bc=0;
X			      else
X				{
X				  fclose(f);
X				  return(-1);
X				}
X			    }
X			}
X		    }
X		}
X	      else
X		{
X		  obuf[bc]=fch;
X		  bc++;
X		}
X	    }
X	  else
X	    {
X	      obuf[bc]=fch;
X	      if(write_obuf(f,obuf,bc) == 0)
X		bc=0;
X	      else
X		{
X		  fclose(f);
X		  return(-1);
X		}
X	    }
X	}
X    }
X}
X
END_OF_FILE
if test 3135 -ne `wc -c <'rcv.c'`; then
    echo shar: \"'rcv.c'\" unpacked with wrong size!
fi
# end of 'rcv.c'
fi
if test -f 'snd.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'snd.c'\"
else
echo shar: Extracting \"'snd.c'\" \(2765 characters\)
sed "s/^X//" >'snd.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X#include <unistd.h>
X
X#include "conf.h"
X
Xsend_file(f,rfd,fd)
X     FILE *f;
X     int rfd,fd;
X{
X  unsigned char fch[512];
X  long flen;
X  int sbytes=0, wbytes, zero=0;
X
X
X  fseek(f,0,SEEK_END);
X  flen = ftell(f);
X  rewind(f);
X
X      while(flen > 0)
X	{
X	  if((sbytes=fread(&fch,sizeof(unsigned char),512,f)) > 0)
X	    {
X	      flen-=sbytes;
X	      printf("read: %.*s\r\n",sbytes,fch);
X	      if(write(fd,&fch,sbytes)< 0)
X		{
X		  perror("write failed!");
X		  logto("FATAL: write failed!");
X		  fclose(f);
X		  return(-1);
X		}
X	      else
X		{
X		  printf("write: %.*s\r\n",sbytes,fch);
X		  wbytes +=sbytes;
X		}
X	    }
X	  else
X	    {
X	      if(debug)printf("fread failed !\r\n");
X	      logto("fread failed !\r\n");
X	    }
X	}
X  if(debug)printf("END: read %d, wrote %d bytes\r\n",sbytes,wbytes);
X  logto("END: read %d, wrote %d bytes\r\n",sbytes,wbytes);
X  if(get_fax_disconnect(rfd)==0)
X    {
X      if(debug) printf("Transmission OK\r\n");
X      logto("Transmission OK\r\n");
X      return(0);
X    }
X  else
X    {
X      if(debug) printf("Transmission FAILED !\r\n");
X      logto("Transmission FAILED !\r\n");
X      return(-1);
X    }
X  fclose(f);
X  return(-1);
X}
X
END_OF_FILE
if test 2765 -ne `wc -c <'snd.c'`; then
    echo shar: \"'snd.c'\" unpacked with wrong size!
fi
# end of 'snd.c'
fi
if test -f 'fax.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fax.c'\"
else
echo shar: Extracting \"'fax.c'\" \(1963 characters\)
sed "s/^X//" >'fax.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X
X#include "conf.h"
X
Xint
Xmodem_dial(fd,rfd,phone)
X     int fd,rfd;
X     char *phone;
X{
X  if(debug) printf("Dialing...%s\r\n",phone);
X  fdprintf(fd,"ATDP %s\r\n",phone);
X  return get_fax_connect(rfd);
X}
X
Xint
Xmodem_answer(fd,rfd)
X     int fd,rfd;
X{
X  if(debug) printf("Answering Fax...\r\n");
X  fdprintf(fd,"ATA\r\n");
X  return get_fax_connect(rfd);
X}
END_OF_FILE
if test 1963 -ne `wc -c <'fax.c'`; then
    echo shar: \"'fax.c'\" unpacked with wrong size!
fi
# end of 'fax.c'
fi
if test -f 'dir.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dir.c'\"
else
echo shar: Extracting \"'dir.c'\" \(2739 characters\)
sed "s/^X//" >'dir.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X#include <dirent.h>
X#include <sys/time.h>
X#include <strings.h>
X
X#include "conf.h"
X
XDIR *
Xdir_setup()
X{
X  DIR *dirp;
X
X  if (chdir(FAX_SPOOL_OUT) < 0) {
X    logto("can't change to spool directory: %s\n", FAX_SPOOL_OUT);
X    return (DIR *)NULL;
X  }
X
X  if ((dirp = opendir(".")) == NULL) {
X    logto("can't open fax spool directory: %s\n", FAX_SPOOL_OUT);
X    return (DIR *)NULL;
X  }
X  return dirp;
X}
X
X
Xint
Xproc_outfile(rfd,fd)
X     int rfd,fd;
X{
X  char *ptr;
X  DIR *dirp = dir_setup();
X  struct dirent *dp;
X
X  if(dirp == (DIR *)NULL)
X    return -1;
X
X  for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X    if ((ptr = strrchr(dp->d_name, '.')) != NULL) {
X      if (strcmp(ptr+1, "qf") == 0) {
X        if (debug)
X          logto("found queue file: %s\n", dp->d_name);
X        *ptr = '\0';
X	close_tty(rfd);
X	close_tty(fd);
X	fd=open_tty(FAX_TTY);
X	rfd=open_read_tty(FAX_TTY);
X        if(send_process(dp->d_name,rfd,fd) == 0)
X	  {
X	    unlink(dp->d_name);
X	    close_tty(rfd);
X	    close_tty(fd);
X	    closedir(dirp);
X	    return (0);
X	  }
X	close_tty(rfd);
X	close_tty(fd);
X      }
X    }
X  }
X  return -1;
X  closedir(dirp);
X}
END_OF_FILE
if test 2739 -ne `wc -c <'dir.c'`; then
    echo shar: \"'dir.c'\" unpacked with wrong size!
fi
# end of 'dir.c'
fi
if test -f 'process.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'process.c'\"
else
echo shar: Extracting \"'process.c'\" \(3393 characters\)
sed "s/^X//" >'process.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X
X#include "conf.h"
X
Xint
Xsend_process(fname,rfd,fd)
X     char *fname;
X     int rfd,fd;
X{
X  FILE *f, *g3;
X  int exflag = 0;
X  char phone[80];
X  char g3name[80];
X  char qfname[512];
X  char cmdbuf[128];
X  char line[80];
X
X  if(debug) printf("got queue_file %s\r\n",fname);
X  logto("got queue_file %s\r\n",fname);
X  
X  strcpy(qfname,fname);
X  strcat(qfname,".qf");
X  if((f = fopen(qfname,"r")) == (FILE *)NULL)
X    {
X      logto("Sorry, couldn't open %s\r\n",fname);
X    }
X  else
X    {
X      rewind(f);
X      if(sscanf(fgets(line,79,f),"EXECUTE: %d",&exflag) != 0)
X	{
X	  switch(exflag)
X	    {
X	    case EX_FAX:
X	      if(sscanf(fgets(line,79,f),"PHONENUMBER: %s",phone) != 0)
X		if(sscanf(fgets(line,79,f),"G3FILE: %s",g3name) != 0)
X		  {
X		    fclose(f);
X		    logto("Sending file %s to number %s\r\n",g3name,phone);
X		    if((g3 = fopen(g3name,"r")) == (FILE *)NULL)
X		      {
X			logto("Sorry, can't open %s for reading\r\n",g3name);
X			return(-1);
X		      }
X		    init_modem(fd,rfd);
X		    if(modem_dial(fd,rfd,phone) == 0)
X		      {
X			if(send_file(g3,rfd,fd)==0)
X			  {
X			    unlink(g3name);
X			    return(0);
X			  }
X			return -1;
X		      }
X		  }
X		else
X		  {
X		    logto("Not Sending file %s to number %s\r\n",g3name,phone);
X		    fclose(f);
X		  }
X	      break;
X	    case EX_CMD: /* execute command over serial line */
X	      if(sscanf(fgets(line,79,f),"COMMAND: %s",cmdbuf) != 0)
X		{
X		  fdprintf(fd,"ATZ\r\n");		  
X		  close(rfd);
X		  close(fd);
X		  if(system(cmdbuf)!= 0)
X		    logto("Sorry, command failed\n");
X		  fd = open_tty(FAX_RTTY,TTY_WAIT);
X		  rfd = open_tty(FAX_RTTY, TTY_WAIT);
X		  init_modem(fd,rfd);
X		  return(0);
X		}
X	      else
X		logto("Sorry can't execute command\n");
X	      break;
X	    }
X	}
X      else
X	logto("Illegal format of queuefile !\n");
X    }
X}
X
X
END_OF_FILE
if test 3393 -ne `wc -c <'process.c'`; then
    echo shar: \"'process.c'\" unpacked with wrong size!
fi
# end of 'process.c'
fi
if test -f 'queue.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'queue.c'\"
else
echo shar: Extracting \"'queue.c'\" \(2472 characters\)
sed "s/^X//" >'queue.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X
X#include "conf.h"
X
Xint
Xqueuefile(tn, ifn, qfname)
X     char *tn, *ifn, *qfname;
X{
X  FILE *qf;
X  char tmp[512];
X
X  sprintf(qfname,"%s/%s",FAX_SPOOL_OUT,mktemp("OUTXXXXXX"));
X  strcpy(tmp,qfname);
X  strcat(tmp,".qf");
X  if((qf = fopen(tmp,"w+")) == (FILE *)NULL)
X    {
X      printf("can't open queuefile %s !\n",tmp);
X      exit(1);
X    }
X
X  fprintf(qf,"EXECUTE: 0\n");
X  fprintf(qf,"PHONENUMBER: %s\n",tn);
X  fprintf(qf,"G3FILE: %s.g3\n",qfname);
X  return(0);
X}
X
Xint
Xexqueuefile(cmd)
X     char *cmd;
X{
X  FILE *qf;
X  char tmp[512];
X  char qfname[512];
X
X  sprintf(qfname,"%s/%s",FAX_SPOOL_OUT,mktemp("OUTXXXXXX"));
X  strcpy(tmp,qfname);
X  strcat(tmp,".qf");
X  if((qf = fopen(tmp,"w+")) == (FILE *)NULL)
X    {
X      printf("can't open queuefile %s !\n",tmp);
X      exit(1);
X    }
X
X  fprintf(qf,"EXECUTE: 1\n");
X  fprintf(qf,"COMMAND: %s\n",cmd);
X  return(0);
X}
END_OF_FILE
if test 2472 -ne `wc -c <'queue.c'`; then
    echo shar: \"'queue.c'\" unpacked with wrong size!
fi
# end of 'queue.c'
fi
if test -f 'log.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'log.c'\"
else
echo shar: Extracting \"'log.c'\" \(2413 characters\)
sed "s/^X//" >'log.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X#include <varargs.h>
X
X#include "conf.h"
X
XFILE *logfile;
X
XFILE *
Xopen_log()
X{
X  FILE *lf;
X  char path[512];
X
X    
X  sprintf(path,"%s/%s",FAX_LIB,FAX_LOGFILE);
X  if((lf = fopen(path,"a+")) == (FILE *)NULL)
X    {
X      perror("open logfile");
X      return (FILE *)NULL;
X    }
X  setvbuf(lf,(char *)NULL,_IONBF,0);
X  return lf;
X}
X
Xint
Xclose_log()
X{
X  if(logfile == (FILE *)NULL)
X    return 0;
X  else
X    {
X      fclose(logfile);
X      return 0;
X    }
X}
X
X  
Xint
Xlogto(va_alist)
X     va_dcl
X{
X  va_list ap;
X  char *format;
X  char buf[1024];
X
X  va_start(ap);
X  format = va_arg(ap, char *);
X  vsprintf(buf, format, ap);
X  va_end(ap);
X
X  if(logfile == (FILE *)NULL)
X    {
X      if((logfile = open_log())==(FILE *)NULL)
X	return -1;
X    }
X  else
X    {
X      fprintf(logfile,"%s\n",buf);
X      return 0;
X    }
X}
END_OF_FILE
if test 2413 -ne `wc -c <'log.c'`; then
    echo shar: \"'log.c'\" unpacked with wrong size!
fi
# end of 'log.c'
fi
if test -f 'tty.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tty.h'\"
else
echo shar: Extracting \"'tty.h'\" \(1554 characters\)
sed "s/^X//" >'tty.h' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
END_OF_FILE
if test 1554 -ne `wc -c <'tty.h'`; then
    echo shar: \"'tty.h'\" unpacked with wrong size!
fi
# end of 'tty.h'
fi
if test -f 'conf.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'conf.h'\"
else
echo shar: Extracting \"'conf.h'\" \(1952 characters\)
sed "s/^X//" >'conf.h' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
Xextern int debug;
X
X#define MODEM_INIT_TRIES 3
X#define FAX_SEND_TRIES 3
X
X#define FAX_TTY "/dev/ttyFAX"
X#define FAX_RTTY "/dev/ttyFAXS"
X
X#define FAX_SPOOL_OUT "/usr/spool/fax/outgoing"
X#define FAX_SPOOL_IN  "/usr/spool/fax/incoming"
X#define FAX_LIB "/usr/local/lib/faxlib"
X#define FAX_LOGFILE "Faxlog"
X#define QUEUE_INTERVAL 5
X
X/* DON'T TOUCH */
X#define EX_FAX 0
X#define EX_CMD 1
X#define TTY_WAIT 1
X
END_OF_FILE
if test 1952 -ne `wc -c <'conf.h'`; then
    echo shar: \"'conf.h'\" unpacked with wrong size!
fi
# end of 'conf.h'
fi
if test -f 'send.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'send.c'\"
else
echo shar: Extracting \"'send.c'\" \(5977 characters\)
sed "s/^X//" >'send.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/termio.h>
X#include <fcntl.h>
X#include <unistd.h>
X
X#include "conf.h"
X
X/* input file types */
X#define ASCII 0
X#define DVI   1
X#define PS    2
X#define G3    3
X
Xint debug = FALSE;
X
Xint
Xcheck_ftype(fname)
X     char *fname;
X{
X  FILE *f;
X  char buf[80];
X  char head[10];
X
X
X  if((f=fopen(fname,"r")) == (FILE *)NULL)
X    {
X      logto("check_ftype: can't open input file %s \r\n",fname);
X      exit(1);
X    }
X  if(fgets(buf,79,f) != (char *)NULL)
X    {
X      /* check for postscript */
X      if(!strncmp(buf,"%!PS-Adobe-",11))
X	return PS;
X
X      /* this is not sure !! it's the magic gs writes into a faxfile */
X      if(!strncmp(&buf[1],"PC RESEARCH",11))
X	return G3;
X
X      /* check for a dvi file */
X      sprintf(head,"%c%c%c%c%c",'\367','\002','\001','\203','\222');
X      if(!memcmp(buf,head,5))
X        return DVI;
X      else
X	{
X	  int i;
X	  for(i=0;i<5;i++)
X	    printf("TYPE: buf=%d head=%d\r\n",buf[i],head[i]);
X	}
X
X      return ASCII;
X    }  
X}
X
X
Xmain(argc,argv)
X     int argc;
X     char *argv[];
X{
X  int fd, rfd;
X  FILE *f;
X  unsigned char fch[512];
X  char tmp[512], tmpn[512];
X  long flen;
X  int sbytes=0, wbytes, c;
X  int errflg = FALSE;
X  int do_spool = FALSE;
X  int ifntype = ASCII;
X  int ex_type = EX_FAX;
X  int force_type = FALSE;
X  char *ex_cmd;
X  char *tn, *ifn;
X  extern int optind;
X  extern char *optarg;
X
X  /* parse parameters */
X  while ((c = getopt(argc, argv, "dshtpgc:")) != -1)
X    switch (c) {
X    case 'd':
X      debug = TRUE;
X      break;
X    case 'c':
X      ex_cmd = optarg;
X      ex_type = EX_CMD;
X      break;
X    case 's':
X      do_spool = TRUE;
X      break;
X    case 't': 
X      ifntype = DVI;
X      force_type = TRUE;
X      break;
X    case 'p': 
X      ifntype = PS;
X      force_type = TRUE;
X      break;
X    case 'g': 
X      ifntype = G3;
X      force_type = TRUE;
X      break;
X    case 'h':
X    case '?':
X      errflg = TRUE;;
X      break;
X    }
X  if (errflg) usage(argv[0]);
X
X  if(ex_type == EX_FAX)
X    {
X      if(argc - optind != 2)
X	usage(argv[0]);
X      
X      tn = argv[optind];
X      ifn = argv[optind+1];
X      
X      if(!do_spool)
X	{
X	  if((f=fopen(ifn,"r")) == (FILE *)NULL)
X	    {
X	      logto("%s: can't open input file %s \r\n",argv[0],argv[2]);
X	      exit(1);
X	    }
X	  fd=open_tty(FAX_TTY);
X	  rfd=open_read_tty(FAX_TTY);
X	  init_modem(fd,rfd);
X	  if(modem_dial(fd,rfd,tn)==0)
X	    {
X	      if(debug) printf("sending file %s\r\n",ifn);
X	      logto("sending file %s\r\n",ifn);
X	      send_file(f,rfd,fd);
X	    }
X	  close_tty(rfd);
X	  close_tty(fd);
X	}
X      else /* send to spooler */
X	{
X	  queuefile(tn, ifn, &tmpn[0]);
X	  strcat(tmpn,".g3");
X
X	  if(!force_type)
X	    ifntype = check_ftype(ifn);
X
X	  switch(ifntype){
X	  case G3:
X	    if(link(ifn,tmpn)<0)
X	      {
X		printf("can't copy input file to %s\n",tmpn);
X		exit(1);
X	      }
X	    break;
X	  case DVI:
X	    sprintf(tmp,"dvialw %s",ifn);
X	    if(system(tmp) != 0)
X	      {
X		printf("error converting file");
X		exit(1);
X	      }
X	    sprintf(tmp,"cat %s-alw | gs -q -sDEVICE=dfaxhigh -dNOPAUSE -sOutputFile=%s -",ifn,tmpn);
X	    if(system(tmp) != 0)
X	      {
X		printf("error converting file");
X		exit(1);
X	      }
X	    sprintf(tmp,"%s-alw",ifn);
X	    unlink(tmp);
X	    break;
X	  case PS:
X	    sprintf(tmp,"cat %s | gs -q -sDEVICE=dfaxhigh -dNOPAUSE -sOutputFile=%s -",ifn,tmpn);
X	    if(system(tmp) != 0)
X	      {
X		printf("error converting file");
X		exit(1);
X	      }
X	    if(debug) printf("%s spooled successfully\n",ifn);
X	    break;
X	  case ASCII:
X	  default:
X	    sprintf(tmp,"psify -sz12 -lm36 -h\"Uwe C. Schroeder, Anwendungssysteme\" %s | gs -q -sDEVICE=dfaxhigh -dNOPAUSE -sOutputFile=%s -",ifn,tmpn);
X	    if(system(tmp) != 0)
X	      {
X		printf("error converting file");
X		exit(1);
X	      }
X
X	    if(debug) printf("%s spooled successfully\n",ifn);
X	    break;
X	  }
X	}
X    }
X  else
X    {
X      exqueuefile(ex_cmd);
X    }
X}
Xint usage(name)
X     char *name;
X{
X  printf("\nusage: %s [-d] [-s] telno file.g3\n",name);
X  printf("\nor:    %s [-d] -c command\n",name);
X  printf("where:\n\t-d = debug\n\t-s = send to spooler\n");
X  printf("\t-p = input file is postscript\n");
X  printf("\t-t = input file is a TeX dvi format\n");
X  printf("\t-g = input file is a fax G3 format\n");
X  printf("\tdefault input file type is ASCII\n");
X  printf("\t-c = execute command (no args !), release serial line\n");
X  printf("\t     useful for executing uucico \n");
X  exit(0);
X}
END_OF_FILE
if test 5977 -ne `wc -c <'send.c'`; then
    echo shar: \"'send.c'\" unpacked with wrong size!
fi
# end of 'send.c'
fi
if test -f 'receive.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'receive.c'\"
else
echo shar: Extracting \"'receive.c'\" \(2917 characters\)
sed "s/^X//" >'receive.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/termio.h>
X#include <fcntl.h>
X#include <unistd.h>
X#include <signal.h>
X
X#include "conf.h"
X
Xint debug = TRUE;
Xint fd, rfd, f, bc=0;
Xunsigned char obuf[1024];
X
X
Xvoid
Xend_by_sig(sig)
X     int sig;
X{
X  if(bc > 0)
X    write(f,obuf,bc+1);
X  close_tty(fd);
X  close_tty(rfd);
X  close(f);
X  if(debug)printf("CAUGHT SIGNAL %d",sig);
X  logto("CAUGHT SIGNAL %d",sig);
X  exit(sig);
X}
X
Xmain(argc,argv)
X     int argc;
X     char *argv[];
X{
X  int fd, rfd;
X  FILE *f;
X  unsigned char fch;
X  long flen;
X  int sbytes=0, wbytes;
X  void *sighand;
X  sighand = (void(*)())end_by_sig;
X
X  signal(SIGTERM,sighand);
X  signal(SIGKILL,sighand);
X  signal(SIGQUIT,sighand);
X  signal(SIGINT,sighand);
X  signal(SIGABRT,sighand);
X
X  if(argc != 2) 
X    usage(argv[0]);
X
X
X  if((f=fopen(argv[1],"w+")) == (FILE *)NULL)
X    {
X      perror("Error open output file");
X      logto("FATAL: %s: can't open output file %s \r\n",argv[0],argv[1]);
X      exit(1);
X    }
X  
X  fd=open_tty(FAX_RTTY);
X  rfd=open_read_tty(FAX_RTTY);
X  init_modem(fd,rfd);
X  if(modem_answer(fd,rfd)==0)
X    {
X      if(debug) printf("receiving file %s\r\n",argv[1]);
X      if(rec_file(f,rfd,fd)==0)
X	logto("--- Reveice %s ok ---\r\n",argv[1]);
X    }
X  close_tty(rfd);
X  close_tty(fd);
X}
X
Xint usage(name)
X     char *name;
X{
X  printf("\r\nusage: %s  outfile\r\n",name);
X  exit(0);
X}
END_OF_FILE
if test 2917 -ne `wc -c <'receive.c'`; then
    echo shar: \"'receive.c'\" unpacked with wrong size!
fi
# end of 'receive.c'
fi
if test -f 'spooler.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'spooler.c'\"
else
echo shar: Extracting \"'spooler.c'\" \(4984 characters\)
sed "s/^X//" >'spooler.c' <<'END_OF_FILE'
X/*
X** (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X**
X** 
X** Permission to use, copy, and modify this software and its
X** documentation for non comercial  purpose is hereby granted 
X** without fee, provided that
X** the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation, and that the name of Uwe C. Schroeder not be used in
X** advertising or publicity pertaining to distribution of the software without
X** specific, written prior permission.  Uwe Schroeder makes no representations
X** about the suitability of this software for any purpose.  It is provided
X** "as is" without express or implied warranty.
X** This software may not be sold or distributed with commercial products
X** ( this includes distribution "for users convenience" ) without prior
X** written permission by the author.
X**
X** UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X** INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X** EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X** DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X** PERFORMANCE OF THIS SOFTWARE.
X**
X**
X** This is a alpha release, which means, that there are still several
X** known bugs.
X**
X** Please report bugs to:
X**
X**                     usys@phoenix.abg.sub.org
X**
X*/
X
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/termio.h>
X#include <fcntl.h>
X#include <sys/ioctl.h>
X#include <unistd.h>
X#include <dirent.h>
X#include <sys/time.h>
X#include <setjmp.h>
X#include <signal.h>
X
X#include "conf.h"
X
Xstatic int sigALRM();
Xstatic jmp_buf timeoutbuf;
Xint debug = FALSE;
Xint receive_mode=TRUE;
Xint scan_interval = QUEUE_INTERVAL;
X
Xstatic void
Xdaemonize()
X{
X  int s;
X  int pid;
X  
X  if ((pid = fork()) != 0) {
X      if (pid < 0)
X	perror("start_daemon: fork");
X      exit(0);
X    }
X  if(pid == 0) /* child */
X    {
X      if( close(0) < 0 
X	 || close(1) < 0 
X	 || close(2) < 0)
X	perror("close in daemonize");
X      setpgrp();
X    }
X  else
X    {
X      exit(0);
X    }
X}
X
X
Xint
Xrec_fax(f,rfd,fd)
X     FILE *f;
X     int rfd,fd;
X{
X  int result;
X  
X  if(modem_answer(fd,rfd)==0)
X    {
X      if((result=rec_file(f,rfd,fd))==0)
X	logto("--- Reveice ok ---\r\n");
X    }
X  return result;
X}
X
X
X
Xstatic int 
XsigALRM()
X{
X  longjmp(timeoutbuf, 1);
X}
X
Xmain(argc,argv)
X     int argc;
X     char *argv[];
X{
X  int fd, rfd;
X  FILE *f;
X  char tmp[20];
X  char tmpfn[512];
X  int faxno = 0, c;
X  int be_daemon = FALSE;
X  int errflg = FALSE;
X  void (*fu)();
X  extern char *optarg;
X  extern char *mktemp();
X  
X  fu = signal(SIGALRM,sigALRM);
X
X  /* parse parameters */
X  while ((c = getopt(argc, argv, "dDri:")) != -1)
X    switch (c) {
X    case 'd':
X      debug = TRUE;
X      break;
X    case 'D':
X      be_daemon = TRUE;
X      break;
X    case 'r':
X      receive_mode = FALSE;
X      break;
X    case 'i':
X      scan_interval = atoi(optarg);
X      break;
X    case '?':
X      errflg = TRUE;;
X      break;
X    }
X  if (errflg) usage(argv[0]);
X
X  if (be_daemon)
X    daemonize();
X  
X
X  if(debug) printf("Have set scan interval to %d seconds\n",scan_interval);
X
X  fd=open_tty(FAX_RTTY);
X  rfd=open_read_tty(FAX_RTTY);
X  init_modem(fd,rfd);
X  proc_outfile(rfd,fd);
X  fd=open_tty(FAX_RTTY);
X  rfd=open_read_tty(FAX_RTTY);
X  init_modem(fd,rfd);
X
X  while(TRUE)
X    {
X      int re;
X      if(debug) printf("in while loop\n");
X      if((re=setjmp(timeoutbuf))==0)
X	{
X	  if(debug) printf("in setjmp loop\n");
X	  fu = signal(SIGALRM,sigALRM);
X	  alarm(scan_interval);
X	  if(receive_mode)
X	    {
X	      if(get_result(rfd,"RING") == 0)
X		{
X		  alarm(0);
X		  signal(SIGALRM, fu);
X		  
X		  sprintf(tmp,"IN%d.XXXXXX",faxno);
X		  if((mktemp(tmp)) == (char *)NULL)
X		    {
X		      logto("SPOOLER: mktemp failed");
X		    }
X		  else
X		    {
X		      sprintf(tmpfn,"%s/%s",FAX_SPOOL_IN,tmp);
X		      if((f=fopen(tmpfn,"w")) == (FILE *)NULL)
X			{
X			  logto("SPOOLER: can't open output file %s \r\n",tmpfn);
X			}
X		      else
X			{
X			  setbuf(f,(char *)NULL,_IONBF,0); /* unbuffered io */
X			  if(rec_fax(f,rfd,fd) == 0)
X			    {
X			      logto("SPOOLER: got fax %s",tmp);
X			      faxno++;
X			    }
X			  else
X			    {
X			      logto("SPOOLER: can't receive %s",tmp);
X			    }
X			}
X		    }
X		} /* rings ?? */
X	    } /* rec_mode */
X	  else
X	    sleep(scan_interval);
X	} /* setjmp */
X      else
X	{
X	  if(debug) printf("in setjmp else\n");
X	  if(proc_outfile(rfd,fd) > -1)
X	    {
X	      fd=open_tty(FAX_RTTY);
X	      rfd=open_read_tty(FAX_RTTY);
X	      init_modem(fd,rfd);
X	    }
X	}
X    } /* while */
X  alarm(0);
X  signal(SIGALRM, fu);
X}
X
Xint usage(name)
X     char *name;
X{
X  printf("usage: %s [ Ddr ] [i val] \n",name);
X  printf("where:\n\tD = run as daemon\n\td = debug\n");
X  printf("\tr = disable fax reception\n\ti val = set scan interval to val\n");
X  exit(0);
X}
END_OF_FILE
if test 4984 -ne `wc -c <'spooler.c'`; then
    echo shar: \"'spooler.c'\" unpacked with wrong size!
fi
# end of 'spooler.c'
fi
if test -f 'S101fax' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'S101fax'\"
else
echo shar: Extracting \"'S101fax'\" \(62 characters\)
sed "s/^X//" >'S101fax' <<'END_OF_FILE'
X/usr/local/bin/faxspo -r -d -D -i 600
Xecho Faxspooler started
END_OF_FILE
if test 62 -ne `wc -c <'S101fax'`; then
    echo shar: \"'S101fax'\" unpacked with wrong size!
fi
# end of 'S101fax'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(3894 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# 
X# 
X# (c) 1992 Uwe C. Schroeder, Anwendungssysteme , Augsburg, Germany
X#
X#
X# Permission to use, copy, and modify this software and its
X# documentation for non comercial  purpose is hereby granted 
X# without fee, provided that
X# the above copyright notice appear in all copies and that both that
X# copyright notice and this permission notice appear in supporting
X# documentation, and that the name of Uwe C. Schroeder not be used in
X# advertising or publicity pertaining to distribution of the software without
X# specific, written prior permission.  Uwe Schroeder makes no representations
X# about the suitability of this software for any purpose.  It is provided
X# "as is" without express or implied warranty.
X# This software may not be sold or distributed with commercial products
X# ( this includes distribution "for users convenience" ) without prior
X# written permission by the author.
X#
X# UWE SCHROEDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
X# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
X# EVENT SHALL UWE SCHROEDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
X# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
X# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
X# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X# PERFORMANCE OF THIS SOFTWARE.
X#
X#
X# This is a alpha release, which means, that there are still several
X# known bugs.
X#
X# Please report bugs to:
X#
X#                     usys@phoenix.abg.sub.org
X#
X###############################################################################
X
XINSTDIR = /usr/local/bin/
XRC2DIR = /etc/rc2.d/
X
XADMIN= CAVEAT COPYING PORTING REQUIREMENTS
X
XHEADERS= tty.h conf.h
X
XCFLAGS = -O -g -fwritable-strings -DSYSV -DUSG -DDEBUG
X
XSRCS = tty.c init.c write.c read.c response.c rcv.c snd.c fax.c dir.c \
X	process.c queue.c log.c
X
XOBJS = tty.o init.o write.o read.o response.o rcv.o snd.o fax.o dir.o \
X	process.o queue.o log.o
X
XPRGSRC = send.c receive.c spooler.c
X
Xall: sendfax recfax faxspo
X
Xsendfax: $(OBJS) $(SRCS) send.o
X	$(CC) $(LDFLAGS) -o sendfax send.o $(OBJS) $(LIBS)
X
Xrecfax: $(OBJS) $(SRCS) receive.o
X	$(CC) $(LDFLAGS) -o recfax receive.o $(OBJS) $(LIBS)
X
Xfaxspo: $(OBJS) $(SRCS) spooler.o
X	$(CC) $(LDFLAGS) -o faxspo spooler.o $(OBJS) $(LIBS) 
X
Xinstall: all
X	strip faxspo sendfax recfax
X	cp faxspo $(INSTDIR)
X	cp sendfax $(INSTDIR)
X	cp recfax $(INSTDIR)
X	cp S101fax $(RC2DIR)
X	mknod /dev/ttyFAX c 3 49
X	mknod /dev/ttyFAXS c 3 81
X
Xshar: 
X	shar $(ADMIN) $(SRCS) $(HEADERS) $(PRGSRC) S101fax Makefile printfax > zf.shar
X
Xclean:
X	rm -f faxspo sendfax recfax *.o *~ core a.out
X
Xdepend:
X	makedepend $(SRCS)
X# DO NOT DELETE THIS LINE -- make depend depends on it.
X
Xtty.o: /usr/include/stdio.h /usr/include/sys/types.h /usr/include/fcntl.h
Xtty.o: /usr/include/sys/fcntl.h /usr/include/termio.h
Xtty.o: /usr/include/sys/termio.h conf.h tty.h
Xinit.o: /usr/include/stdio.h /usr/include/sys/types.h /usr/include/fcntl.h
Xinit.o: /usr/include/sys/fcntl.h conf.h
Xwrite.o: /usr/include/stdio.h /usr/include/sys/types.h /usr/include/fcntl.h
Xwrite.o: /usr/include/sys/fcntl.h /usr/include/varargs.h conf.h
Xread.o: /usr/include/stdio.h /usr/include/sys/types.h /usr/include/fcntl.h
Xread.o: /usr/include/sys/fcntl.h conf.h
Xresponse.o: /usr/include/stdio.h /usr/include/sys/types.h
Xresponse.o: /usr/include/fcntl.h /usr/include/sys/fcntl.h conf.h
Xrcv.o: /usr/include/stdio.h /usr/include/sys/types.h /usr/include/fcntl.h
Xrcv.o: /usr/include/sys/fcntl.h /usr/include/unistd.h conf.h
Xsnd.o: /usr/include/stdio.h /usr/include/sys/types.h /usr/include/fcntl.h
Xsnd.o: /usr/include/sys/fcntl.h /usr/include/unistd.h conf.h
Xfax.o: /usr/include/stdio.h /usr/include/sys/types.h /usr/include/fcntl.h
Xfax.o: /usr/include/sys/fcntl.h conf.h
Xlog.o: /usr/include/stdio.h /usr/include/sys/types.h /usr/include/fcntl.h
Xlog.o: /usr/include/sys/fcntl.h /usr/include/varargs.h conf.h
END_OF_FILE
if test 3894 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'printfax' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'printfax'\"
else
echo shar: Extracting \"'printfax'\" \(192 characters\)
sed "s/^X//" >'printfax' <<'END_OF_FILE'
X#!/bin/sh
X
X/usr/local/pbmplus/g3topbm $1.g3 \
X| /usr/local/pbmplus/ppmscale 1.4 \
X| /usr/local/pbmplus/ppmtopgm \
X| /usr/local/pbmplus/pgmtopbm \
X| /usr/local/pbmplus/pbmtolj -r 300 > /dev/lp
END_OF_FILE
if test 192 -ne `wc -c <'printfax'`; then
    echo shar: \"'printfax'\" unpacked with wrong size!
fi
chmod +x 'printfax'
# end of 'printfax'
fi
echo shar: End of shell archive.
exit 0

------------------------- snip snip --------------------------------

-- 
 _ _    _ ,                    || Realname: Uwe C. Schr"oder
- - /  - -                     || Organisation: Anwendungssysteme
  ('||  ||                     || Domain: usys@phoenix.abg.sub.org
 (( ||--||  _-_, '\\/\\  _-_,  ||----------------------------------------------
 (( ||--|| ||_.   || ;' ||_.   || Augsburg - Western Germany/Bavaria
 (( /   ||  ~ ||  ||/    ~ ||  ||----------------------------------------------
   -___-\\,,-_-   |/    ,-_-   || 
                 (             || Wer lesen kann ist klar im Vorteil
                  -_-          ||