Hylafax Mailing List Archives

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Patch to faxstat (with patch this time)



This patch allows specification of the ModemFmt, JobFmt & RcvFmt in the
environment. This way the changes in the format string can be made on
the fly. It also adds two new option -m & -n, which turn off the server
& modem status reports and turn off the headers. This is all designed to
make it easier to parse the output.

As a side effect I also fixed a bug which stopped the ModemFmt from
working. I ended up having to create a new function in FaxClient.c++ to
update the server with new format strings if they have changed. This was
previous done as a side effect of printing the header.

You can install this patch from the hylafax source dir.

Any problems let me know.

Damian 
-- 
 ______________________________________________________________________
* Damian Ivereigh     *      ||        ||      * Cisco Systems, Inc.   *
* MIS Printer Admin   *    .||||.    .||||.    * 408-526-4413          *
* Linux Bigot         * ..:||||||:..:||||||:.. * 800-800-1180 x64413   *
* damian@cisco.com    *   cisco Systems, Inc.  * Fax:   408-527-2563   *
*______________________________________________________________________*Index: faxstat/faxstat.c++
===================================================================
RCS file: /usr/local/cvsroot/source/hylafax/faxstat/faxstat.c++,v
retrieving revision 1.1.1.1
retrieving revision 1.1.2.1
diff -c -r1.1.1.1 -r1.1.2.1
*** faxstat.c++	1998/07/01 21:50:45	1.1.1.1
--- faxstat.c++	1998/07/01 22:43:37	1.1.2.1
***************
*** 1,4 ****
! /*	$Id: faxstat.c++,v 1.1.1.1 1998/07/01 21:50:45 damian Exp $ */
  /*
   * Copyright (c) 1990-1996 Sam Leffler
   * Copyright (c) 1991-1996 Silicon Graphics, Inc.
--- 1,4 ----
! /*	$Id: faxstat.c++,v 1.1.2.1 1998/07/01 22:43:37 damian Exp $ */
  /*
   * Copyright (c) 1990-1996 Sam Leffler
   * Copyright (c) 1991-1996 Silicon Graphics, Inc.
***************
*** 57,68 ****
      resetConfig();
      readConfig(FAX_SYSCONF);
      readConfig(FAX_USERCONF);
  
      fxStrArray dirs;
-     dirs.append(FAX_STATUSDIR);		// server status
      fxBool checkInfo = FALSE;
      int c;
!     while ((c = getopt(argc, argv, "h:adgfilrsv")) != -1)
  	switch (c) {
  	case 'a':			// display archived jobs
  	    dirs.append(FAX_ARCHDIR);
--- 57,70 ----
      resetConfig();
      readConfig(FAX_SYSCONF);
      readConfig(FAX_USERCONF);
+     readConfigEnv();
  
      fxStrArray dirs;
      fxBool checkInfo = FALSE;
+     fxBool modemInfo = TRUE;
+     fxBool showHeader = TRUE;
      int c;
!     while ((c = getopt(argc, argv, "h:adgfilmnrsv")) != -1)
  	switch (c) {
  	case 'a':			// display archived jobs
  	    dirs.append(FAX_ARCHDIR);
***************
*** 85,90 ****
--- 87,98 ----
  	case 'l':			// use local timezone for dates & times
  	    setTimeZone(TZ_LOCAL);
  	    break;
+ 	case 'm':			// disable modem info line
+ 	    modemInfo = FALSE;
+ 	    break;
+ 	case 'n':			// disable header line
+ 	    showHeader = FALSE;
+ 	    break;
  	case 'r':			// display receive queue
  	    dirs.append(FAX_RECVDIR);
  	    break;
***************
*** 100,116 ****
      fxStr emsg;
      if (callServer(emsg)) {
  	if (login(NULL, emsg)) {
  	    if (checkInfo)
  		(void) recvData(writeStdout, NULL, emsg, 0,
  		    "RETR " FAX_STATUSDIR "/any." FAX_INFOSUF);
  	    for (u_int i = 0, n = dirs.length(); i < n; i++) {
  		header = (i > 0 ? "\n" : "");
  		if (dirs[i] == FAX_SENDDIR || dirs[i] == FAX_DONEDIR) {
! 		    getJobStatusHeader(header);
! 		    header.append('\n');
  		} else if (dirs[i] == FAX_RECVDIR) {
! 		    getRecvStatusHeader(header);
! 		    header.append('\n');
  		}
  		if (!listWithHeader(dirs[i], emsg))
  		    break;
--- 108,131 ----
      fxStr emsg;
      if (callServer(emsg)) {
  	if (login(NULL, emsg)) {
+ 	    updPendingConfig();
+ 	    if (modemInfo)
+ 		listWithHeader(FAX_STATUSDIR, emsg);
  	    if (checkInfo)
  		(void) recvData(writeStdout, NULL, emsg, 0,
  		    "RETR " FAX_STATUSDIR "/any." FAX_INFOSUF);
  	    for (u_int i = 0, n = dirs.length(); i < n; i++) {
  		header = (i > 0 ? "\n" : "");
  		if (dirs[i] == FAX_SENDDIR || dirs[i] == FAX_DONEDIR) {
! 		    if (showHeader) {
! 		    	getJobStatusHeader(header);
! 		    	header.append('\n');
! 		    }
  		} else if (dirs[i] == FAX_RECVDIR) {
! 		    if (showHeader) {
! 		    	getRecvStatusHeader(header);
! 		    	header.append('\n');
! 		    }
  		}
  		if (!listWithHeader(dirs[i], emsg))
  		    break;
Index: util/FaxClient.c++
===================================================================
RCS file: /usr/local/cvsroot/source/hylafax/util/FaxClient.c++,v
retrieving revision 1.1.1.1
retrieving revision 1.1.2.1
diff -c -r1.1.1.1 -r1.1.2.1
*** FaxClient.c++	1998/07/01 21:50:43	1.1.1.1
--- FaxClient.c++	1998/07/01 22:43:37	1.1.2.1
***************
*** 1,4 ****
! /*	$Id: FaxClient.c++,v 1.1.1.1 1998/07/01 21:50:43 damian Exp $ */
  /*
   * Copyright (c) 1990-1996 Sam Leffler
   * Copyright (c) 1991-1996 Silicon Graphics, Inc.
--- 1,4 ----
! /*	$Id: FaxClient.c++,v 1.1.2.1 1998/07/01 22:43:37 damian Exp $ */
  /*
   * Copyright (c) 1990-1996 Sam Leffler
   * Copyright (c) 1991-1996 Silicon Graphics, Inc.
***************
*** 300,305 ****
--- 300,343 ----
  }
  
  fxBool
+ FaxClient::readConfigEnv(void)
+ {
+     fxBool ret=TRUE;
+     const char* cp;
+ 
+     cp = getenv("FAXJOBFMT");
+     if (cp && *cp != '\0')
+ 	ret = ret && setJobStatusFormat(cp);
+ 
+     cp = getenv("FAXRCVFMT");
+     if (cp && *cp != '\0')
+ 	ret = ret && setRecvStatusFormat(cp);
+ 
+     cp = getenv("FAXMODEMFMT");
+     if (cp && *cp != '\0')
+ 	ret = ret && setModemStatusFormat(cp);
+ 
+     cp = getenv("FAXFILEFMT");
+     if (cp && *cp != '\0')
+ 	ret = ret && setFileStatusFormat(cp);
+ 
+     return (ret);
+ }
+ 
+ fxBool
+ FaxClient::updPendingConfig(void)
+ {
+     fxBool ret=TRUE;
+ 
+     ret = ret && setStatusFormatPending("JOBFMT", FS_JFMTPEND, jobFmt);
+     ret = ret && setStatusFormatPending("RCVFMT", FS_RFMTPEND, recvFmt);
+     ret = ret && setStatusFormatPending("MDMFMT", FS_MFMTPEND, modemFmt);
+     ret = ret && setStatusFormatPending("FILEFMT", FS_FFMTPEND, fileFmt);
+ 
+     return(ret);
+ }
+ 
+ fxBool
  FaxClient::callServer(fxStr& emsg)
  {
      if (host.length() == 0) {		// if host not specified by -h
***************
*** 1414,1419 ****
--- 1452,1479 ----
      } else
  	state |= flag;
      fmt = value;
+     return (TRUE);
+ }
+ 
+ /*
+  * Set the specified status format string
+  *  in the client and the server if we have an update pending.
+  */
+ fxBool
+ FaxClient::setStatusFormatPending(const char* cmd, u_int flag,
+     fxStr& fmt)
+ {
+     if (state&flag) {		// set pending; do it
+ 	if (isLoggedIn()) {
+ 	    if (command("%s \"%s\"", cmd, (const char*) fmt) == COMPLETE) {
+ 		state &= ~flag;
+ 	    }
+ 	    else {
+ 		printError("%s", (const char*) lastResponse);
+ 		return (FALSE);
+ 	    }
+ 	}
+     }
      return (TRUE);
  }
  
Index: util/FaxClient.h
===================================================================
RCS file: /usr/local/cvsroot/source/hylafax/util/FaxClient.h,v
retrieving revision 1.1.1.1
retrieving revision 1.1.2.1
diff -c -r1.1.1.1 -r1.1.2.1
*** FaxClient.h	1998/07/01 21:50:44	1.1.1.1
--- FaxClient.h	1998/07/01 22:43:37	1.1.2.1
***************
*** 1,4 ****
! /*	$Id: FaxClient.h,v 1.1.1.1 1998/07/01 21:50:44 damian Exp $ */
  /*
   * Copyright (c) 1990-1996 Sam Leffler
   * Copyright (c) 1991-1996 Silicon Graphics, Inc.
--- 1,4 ----
! /*	$Id: FaxClient.h,v 1.1.2.1 1998/07/01 22:43:37 damian Exp $ */
  /*
   * Copyright (c) 1990-1996 Sam Leffler
   * Copyright (c) 1991-1996 Silicon Graphics, Inc.
***************
*** 154,159 ****
--- 154,160 ----
  
      const fxStr& getStatusFormat(u_int flag, const char* cmd, fxStr& fmt);
      fxBool setStatusFormat(const char* cmd, u_int flag, fxStr&, const char*);
+     fxBool setStatusFormatPending(const char* cmd, u_int flag, fxStr& fmt);
      void makeHeader(const char* fmt, const FaxFmtHeader fmts[], fxStr& header);
  
      virtual fxBool setupUserIdentity(fxStr& emsg);
***************
*** 162,167 ****
--- 163,170 ----
  
      virtual void resetConfig(void);
      virtual void setupConfig(void);
+     virtual fxBool updPendingConfig(void);
+     virtual fxBool readConfigEnv(void);
      virtual fxBool setConfigItem(const char* tag, const char* value);
      virtual void configError(const char* fmt ...);
      virtual void configTrace(const char* fmt ...);
Index: man/faxstat.1
===================================================================
RCS file: /usr/local/cvsroot/source/hylafax/man/faxstat.1,v
retrieving revision 1.1
diff -c -r1.1 faxstat.1
*** faxstat.1	1998/07/01 21:50:46	1.1
--- faxstat.1	1998/07/14 23:25:40
***************
*** 151,156 ****
--- 151,162 ----
  .B \-l
  Display times and dates in the local timezone of the server.
  .TP 10
+ .B \-m
+ Disable display of modem and server status info.
+ .TP 10
+ .B \-n
+ Disable display of header lines (good for parsing by a script).
+ .TP 10
  .B \-r
  Display the receive queue status for each server.
  The
***************
*** 176,206 ****
  reads configuration information from the file
  .B ${LIBDATA}/hyla.conf
  and then from the file
! .BR ~/.hylarc .
  Configuration files follow the conventions described in
  .IR hylafax (1).
  The following configuration parameters are recognized:
  .sp .5
! .nf
! .ta \w'AutoCoverPage    'u +\w'boolean    'u +\w'\s-1\fIsee below\fP\s+1    'u
! \fBTag	Type	Default	Description\fP
! FileFmt	string	\s-1\fIsee below\fP\s+1	format string for file status results
! Host	string	\s-1localhost\s+1	host to contact for service
! JobFmt	string	\s-1\fIsee below\fP\s+1	format string for job status results
! ModemFmt	string	\s-1\fIsee below\fP\s+1	format string for modem status results
! Port	integer	\s-14559\s+1	port to use in contacting server
! Protocol	string	\s-1tcp\s+1	protocol to use in contacting server
! RcvFmt	string	\s-1\fIsee below\fP\s+1	format string for received facsimile status results
! TimeZone	string	\s-1GMT\s+1	timezone to use for reporting dates and times
! Verbose	boolean	\s-1No\s+1	whether or not to enable protocol tracing
! .fi
  .PP
  The configuration parameters are explained below:
  .TP 14
  .B FileFmt
  The format string to use when returning file status information with the
  .B \-f
! option.
  Formats are specified using 
  .IR printf (3S)-\c
  style conventions but using the field identifiers listed below.
--- 182,233 ----
  reads configuration information from the file
  .B ${LIBDATA}/hyla.conf
  and then from the file
! .BR ~/.hylarc
! then finally in some cases environment variables (see below).
  Configuration files follow the conventions described in
  .IR hylafax (1).
  The following configuration parameters are recognized:
  .sp .5
! .ta \w'Tag       'u +\w'Env. Var.   'u +\w'Type     'u +\w'\s-1\fIsee below\fP\s+1    'u
! .TP 43
! \fBTag	Env. Var.	Type	Default\fP
! \fBDescription\fP
! .TP 43
! FileFmt	FAXFILEFMT	string	\s-1\fIsee below\fP\s+1
! format string for file status results
! .TP 43
! Host	FAXSERVER	string	\s-1localhost\s+1
! host to contact for service
! .TP 43
! JobFmt	FAXJOBFMT	string	\s-1\fIsee below\fP\s+1
! format string for job status results
! .TP 43
! ModemFmt	FAXMODEMFMT	string	\s-1\fIsee below\fP\s+1
! format string for modem status results
! .TP 43
! Port	-	integer	\s-14559\s+1
! port to use in contacting server
! .TP 43
! Protocol	FAXSERVICE	string	\s-1tcp\s+1
! protocol to use in contacting server
! .TP 43
! RcvFmt	FAXRCVFMT	string	\s-1\fIsee below\fP\s+1
! format string for received facsimile status results
! .TP 43
! TimeZone	-	string	\s-1GMT\s+1s
! timezone to use for reporting dates and times
! .TP 43
! Verbose	-	boolean	\s-1No\s+1
! whether or not to enable protocol tracing
  .PP
  The configuration parameters are explained below:
  .TP 14
  .B FileFmt
  The format string to use when returning file status information with the
  .B \-f
! option. (Equivalent to the
! .B FAXFILEFMT
! environment variable.)
  Formats are specified using 
  .IR printf (3S)-\c
  style conventions but using the field identifiers listed below.
***************
*** 233,239 ****
  The host to contact for service.
  (Equivalent to the
  .B \-h
! option.)
  .TP 14
  .B JobFmt
  The format string to use when returning job status information for
--- 260,268 ----
  The host to contact for service.
  (Equivalent to the
  .B \-h
! option or the
! .B FAXSERVER
! environment variable.)
  .TP 14
  .B JobFmt
  The format string to use when returning job status information for
***************
*** 241,248 ****
  .B \-s
  and
  .B \-d
! options.
! Formats are specified using 
  .IR printf (3S)-\c
  style conventions but using the field identifiers listed below.
  Each item can include field width, precision, left-justification,
--- 270,278 ----
  .B \-s
  and
  .B \-d
! options. (Equivalent to the
! .B FAXJOBFMT
! environment variable.) Formats are specified using 
  .IR printf (3S)-\c
  style conventions but using the field identifiers listed below.
  Each item can include field width, precision, left-justification,
***************
*** 375,381 ****
  .TP 14
  .B ModemFmt
  The format string to use when returning modem status information.
! Formats are specified using 
  .IR printf (3S)-\c
  style conventions but using the field identifiers listed below.
  Each item can include field width, precision, left-justification,
--- 405,413 ----
  .TP 14
  .B ModemFmt
  The format string to use when returning modem status information.
! (Equivalent to the
! .B FAXMODEMFMT
! environment variable.) Formats are specified using 
  .IR printf (3S)-\c
  style conventions but using the field identifiers listed below.
  Each item can include field width, precision, left-justification,
***************
*** 413,419 ****
  .B RcvFmt
  The format string to use when returning status information for the
  .B \-r
! option.
  Formats are specified using 
  .IR printf (3S)-\c
  style conventions but using the field identifiers listed below.
--- 445,453 ----
  .B RcvFmt
  The format string to use when returning status information for the
  .B \-r
! option. (Equivalent to the
! .B FAXRCVFMT
! environment variable.)
  Formats are specified using 
  .IR printf (3S)-\c
  style conventions but using the field identifiers listed below.



Home
Report any problems to webmaster@hylafax.org

HylaFAX is a trademark of Silicon Graphics Corporation.
Internet connectivity for hylafax.org is provided by:
VirtuALL Private Host Services