diff options
Diffstat (limited to 'gnu/libexec/uucp/libunix/jobid.c')
-rw-r--r-- | gnu/libexec/uucp/libunix/jobid.c | 90 |
1 files changed, 79 insertions, 11 deletions
diff --git a/gnu/libexec/uucp/libunix/jobid.c b/gnu/libexec/uucp/libunix/jobid.c index c8b21cb..b7f9145 100644 --- a/gnu/libexec/uucp/libunix/jobid.c +++ b/gnu/libexec/uucp/libunix/jobid.c @@ -1,7 +1,7 @@ /* jobid.c Convert file names to jobids and vice versa. - Copyright (C) 1991, 1992 Ian Lance Taylor + Copyright (C) 1991, 1992, 1995 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -17,10 +17,10 @@ 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. + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. + c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. */ #include "uucp.h" @@ -31,10 +31,7 @@ #include "system.h" /* Translate a file name and an associated system into a job id. - These job ids are used by uustat. We use the system name attached - to the grade and sequence number. This won't work correctly if the - file name was actually created by some other version of uucp that - uses a different length for the sequence number. Too bad. */ + These job ids are used by uustat. */ char * zsfile_to_jobid (qsys, zfile, bgrade) @@ -46,10 +43,50 @@ zsfile_to_jobid (qsys, zfile, bgrade) char *zret; clen = strlen (qsys->uuconf_zname); + +#if ! SPOOLDIR_TAYLOR + + /* We use the system name attached to the grade and sequence number. + This won't work correctly if the file name was actually created + by some other version of uucp that uses a different length for + the sequence number. Too bad. */ + zret = zbufalc (clen + CSEQLEN + 2); memcpy (zret, qsys->uuconf_zname, clen); zret[clen] = bgrade; memcpy (zret + clen + 1, zfile + strlen (zfile) - CSEQLEN, CSEQLEN + 1); + +#else + + /* We use the system name followed by a dot, the grade, and the + sequence number. In this case, the sequence number is a long + string. */ + + { + size_t cseqlen; + + /* zfile is SYS/C./C.gseq. */ + zfile = strrchr (zfile, '/'); + +#if DEBUG > 0 + if (zfile == NULL + || zfile[1] != 'C' + || zfile[2] != '.' + || zfile[3] == '\0') + ulog (LOG_FATAL, "zsfile_to_jobid: Can't happen"); +#endif + + /* Make zfile point at .gseq. */ + zfile += 2; + + cseqlen = strlen (zfile); + zret = zbufalc (clen + cseqlen + 1); + memcpy (zret, qsys->uuconf_zname, clen); + memcpy (zret + clen, zfile, cseqlen + 1); + } + +#endif + return zret; } @@ -61,6 +98,7 @@ zsjobid_to_file (zid, pzsystem, pbgrade) char **pzsystem; char *pbgrade; { +#if ! SPOOLDIR_TAYLOR size_t clen; const char *zend; char *zsys; @@ -81,11 +119,7 @@ zsjobid_to_file (zid, pzsystem, pbgrade) zsys[clen - CSEQLEN - 1] = '\0'; /* This must correspond to zsfile_name. */ -#if ! SPOOLDIR_TAYLOR sprintf (abname, "C.%.7s%s", zsys, zend); -#else - sprintf (abname, "C.%s", zend); -#endif zret = zsfind_file (abname, zsys, *zend); @@ -98,4 +132,38 @@ zsjobid_to_file (zid, pzsystem, pbgrade) *pbgrade = *zend; return zret; +#else /* SPOOLDIR_TAYLOR */ + char *zdot; + size_t csyslen; + char *zsys; + char ab[15]; + char *zret; + + zdot = strrchr (zid, '.'); + if (zdot == NULL) + { + ulog (LOG_ERROR, "%s: Bad job id", zid); + return NULL; + } + + csyslen = zdot - zid; + zsys = zbufalc (csyslen + 1); + memcpy (zsys, zid, csyslen); + zsys[csyslen] = '\0'; + + ab[0] = 'C'; + strcpy (ab + 1, zdot); + + zret = zsfind_file (ab, zsys, zdot[1]); + + if (zret != NULL && pzsystem != NULL) + *pzsystem = zsys; + else + ubuffree (zsys); + + if (pbgrade != NULL) + *pbgrade = zdot[1]; + + return zret; +#endif /* SPOOLDIR_TAYLOR */ } |