From 68edc3001a5c91ca7e88f3aeab09279231b5fef2 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 25 Jan 2000 03:50:49 +0000 Subject: [PATCH] Moved MIME stuff to scheduler directory. Added initial device list support to backends. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@865 7a7537e8-13f0-0310-91df-b6672ffda945 --- backend/ipp.c | 11 +++-- backend/lpd.c | 11 +++-- backend/parallel.c | 49 ++++++++++++++++++-- backend/serial.c | 46 +++++++++++++++++-- backend/socket.c | 11 +++-- cups/Makefile | 58 ++++++++++-------------- scheduler/Makefile | 48 +++++++++++++++----- {cups => scheduler}/filter.c | 6 +-- {cups => scheduler}/mime.c | 82 ++-------------------------------- {cups => scheduler}/mime.h | 4 +- {cups => scheduler}/testmime.c | 4 +- {cups => scheduler}/type.c | 6 +-- 12 files changed, 186 insertions(+), 150 deletions(-) rename {cups => scheduler}/filter.c (98%) rename {cups => scheduler}/mime.c (82%) rename {cups => scheduler}/mime.h (97%) rename {cups => scheduler}/testmime.c (97%) rename {cups => scheduler}/type.c (99%) diff --git a/backend/ipp.c b/backend/ipp.c index dae88ea48..c4423d2de 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c,v 1.17 2000/01/04 13:45:32 mike Exp $" + * "$Id: ipp.c,v 1.18 2000/01/25 03:50:47 mike Exp $" * * IPP backend for the Common UNIX Printing System (CUPS). * @@ -83,7 +83,12 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ int copies; /* Number of copies remaining */ - if (argc < 6 || argc > 7) + if (argc == 1) + { + fputs("network ipp \"\" \"Internet Printing Protocol\"\n", stderr); + return (0); + } + else if (argc < 6 || argc > 7) { fprintf(stderr, "Usage: %s job-id user title copies options [file]\n", argv[0]); @@ -648,5 +653,5 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ /* - * End of "$Id: ipp.c,v 1.17 2000/01/04 13:45:32 mike Exp $". + * End of "$Id: ipp.c,v 1.18 2000/01/25 03:50:47 mike Exp $". */ diff --git a/backend/lpd.c b/backend/lpd.c index a7c76ec81..46688ca23 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -1,5 +1,5 @@ /* - * "$Id: lpd.c,v 1.14 2000/01/04 13:45:32 mike Exp $" + * "$Id: lpd.c,v 1.15 2000/01/25 03:50:47 mike Exp $" * * Line Printer Daemon backend for the Common UNIX Printing System (CUPS). * @@ -83,7 +83,12 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ int status; /* Status of LPD job */ - if (argc < 6 || argc > 7) + if (argc == 1) + { + fputs("network lpd \"\" \"LPD/LPR Host or Printer\"\n", stderr); + return (0); + } + else if (argc < 6 || argc > 7) { fprintf(stderr, "Usage: %s job-id user title copies options [file]\n", argv[0]); @@ -405,5 +410,5 @@ lpd_queue(char *hostname, /* I - Host to connect to */ /* - * End of "$Id: lpd.c,v 1.14 2000/01/04 13:45:32 mike Exp $". + * End of "$Id: lpd.c,v 1.15 2000/01/25 03:50:47 mike Exp $". */ diff --git a/backend/parallel.c b/backend/parallel.c index dbe3b2e15..2790c83a9 100644 --- a/backend/parallel.c +++ b/backend/parallel.c @@ -1,5 +1,5 @@ /* - * "$Id: parallel.c,v 1.8 2000/01/04 13:45:32 mike Exp $" + * "$Id: parallel.c,v 1.9 2000/01/25 03:50:47 mike Exp $" * * Parallel port backend for the Common UNIX Printing System (CUPS). * @@ -23,7 +23,8 @@ * * Contents: * - * main() - Send a file to the specified parallel port. + * main() - Send a file to the specified parallel port. + * list_devices() - List all parallel devices. */ /* @@ -44,6 +45,13 @@ #endif /* WIN32 || __EMX__ */ +/* + * Local functions... + */ + +void list_devices(void); + + /* * 'main()' - Send a file to the specified parallel port. * @@ -72,7 +80,12 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ struct termios opts; /* Parallel port options */ - if (argc < 6 || argc > 7) + if (argc == 1) + { + list_devices(); + return (0); + } + else if (argc < 6 || argc > 7) { fputs("Usage: parallel job-id user title copies options [file]\n", stderr); return (1); @@ -192,5 +205,33 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ /* - * End of "$Id: parallel.c,v 1.8 2000/01/04 13:45:32 mike Exp $". + * 'list_devices()' - List all parallel devices. + */ + +void +list_devices(void) +{ +#ifdef __linux + int i; /* Looping var */ + char device[255]; /* Device filename */ + + + for (i = 0; i < 4; i ++) + { + sprintf(device, "/dev/lp%d", i); + if (access(device, F_OK) == 0) + fprintf(stderr, "parallel parallel:/dev/lp%d \"\" \"Parallel Port #%d\"\n", + i, i + 1); + } +#elif defined(__sgi) +#elif defined(__sun) +#elif defined(__hpux) +#elif defined(__osf) +#elif defined(FreeBSD) || defined(OpenBSD) || defined(NetBSD) +#endif +} + + +/* + * End of "$Id: parallel.c,v 1.9 2000/01/25 03:50:47 mike Exp $". */ diff --git a/backend/serial.c b/backend/serial.c index 7ac42b5c4..9dad48412 100644 --- a/backend/serial.c +++ b/backend/serial.c @@ -1,5 +1,5 @@ /* - * "$Id: serial.c,v 1.8 2000/01/04 13:45:32 mike Exp $" + * "$Id: serial.c,v 1.9 2000/01/25 03:50:47 mike Exp $" * * Serial port backend for the Common UNIX Printing System (CUPS). * @@ -44,6 +44,13 @@ #endif /* WIN32 || __EMX__ */ +/* + * Local functions... + */ + +void list_devices(void); + + /* * 'main()' - Send a file to the printer or server. * @@ -75,7 +82,12 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ struct termios opts; /* Parallel port options */ - if (argc < 6 || argc > 7) + if (argc == 1) + { + list_devices(); + return (0); + } + else if (argc < 6 || argc > 7) { fputs("Usage: serial job-id user title copies options [file]\n", stderr); return (1); @@ -310,5 +322,33 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ /* - * End of "$Id: serial.c,v 1.8 2000/01/04 13:45:32 mike Exp $". + * 'list_devices()' - List all serial devices. + */ + +void +list_devices(void) +{ +#ifdef __linux + int i; /* Looping var */ + char device[255]; /* Device filename */ + + + for (i = 0; i < 4; i ++) + { + sprintf(device, "/dev/ttyS%d", i); + if (access(device, F_OK) == 0) + fprintf(stderr, "serial serial:/dev/ttyS%d \"\" \"Serial Port #%d\"\n", i, + i + 1); + } +#elif defined(__sgi) +#elif defined(__sun) +#elif defined(__hpux) +#elif defined(__osf) +#elif defined(FreeBSD) || defined(OpenBSD) || defined(NetBSD) +#endif +} + + +/* + * End of "$Id: serial.c,v 1.9 2000/01/25 03:50:47 mike Exp $". */ diff --git a/backend/socket.c b/backend/socket.c index bb544e169..a19283c88 100644 --- a/backend/socket.c +++ b/backend/socket.c @@ -1,5 +1,5 @@ /* - * "$Id: socket.c,v 1.9 2000/01/04 13:45:33 mike Exp $" + * "$Id: socket.c,v 1.10 2000/01/25 03:50:47 mike Exp $" * * AppSocket backend for the Common UNIX Printing System (CUPS). * @@ -81,7 +81,12 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ fd_set input; /* Input set for select() */ - if (argc < 6 || argc > 7) + if (argc == 1) + { + fputs("network socket \"\" \"AppSocket/HP JetDirect\"\n", stderr); + return (0); + } + else if (argc < 6 || argc > 7) { fprintf(stderr, "Usage: %s job-id user title copies options [file]\n", argv[0]); @@ -250,5 +255,5 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ /* - * End of "$Id: socket.c,v 1.9 2000/01/04 13:45:33 mike Exp $". + * End of "$Id: socket.c,v 1.10 2000/01/25 03:50:47 mike Exp $". */ diff --git a/cups/Makefile b/cups/Makefile index c48066817..b8b947920 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile,v 1.27 2000/01/21 20:33:16 mike Exp $" +# "$Id: Makefile,v 1.28 2000/01/25 03:50:47 mike Exp $" # # Support library Makefile for the Common UNIX Printing System (CUPS). # @@ -28,22 +28,21 @@ include ../Makedefs # Object files... # -LIBOBJS = emit.o filter.o http.o ipp.o language.o mark.o mime.o \ - options.o page.o ppd.o snprintf.o string.o type.o \ - usersys.o util.o -OBJS = $(LIBOBJS) testhttp.o testmime.o testppd.o +LIBOBJS = emit.o http.o ipp.o language.o mark.o options.o page.o ppd.o \ + snprintf.o string.o usersys.o util.o +OBJS = $(LIBOBJS) testhttp.o testppd.o # # Header files to install... # -HEADERS = cups.h http.h ipp.h language.h mime.h ppd.h +HEADERS = cups.h http.h ipp.h language.h ppd.h # # Targets in this directory... # -TARGETS = $(LIBCUPS) testhttp testmime testppd +TARGETS = $(LIBCUPS) testhttp testppd # # Make all targets... @@ -100,21 +99,18 @@ cups_C.h: ../locale/C/cups_C $(RM) cups_C.h $(AWK) '{print "\"" $$0 "\","}' < ../locale/C/cups_C > cups_C.h -emit.o: ppd.h ../config.h ../Makedefs -filter.o: mime.h ../config.h ../Makedefs -http.o: http.h ipp.h string.h ../config.h ../Makedefs -ipp.o: http.h ipp.h string.h language.h ../config.h ../Makedefs -language.o: cups_C.h language.h string.h ../config.h ../Makedefs -mark.o: ppd.h ../config.h ../Makedefs -mime.o: mime.h ../config.h ../Makedefs -options.o: cups.h ../config.h ../Makedefs -page.o: ppd.h ../config.h ../Makedefs -ppd.o: language.h ppd.h ../config.h ../Makedefs -snprintf.o: string.h ../config.h ../Makedefs -string.o: string.h ../config.h ../Makedefs -type.o: mime.h ../config.h ../Makedefs -usersys.o: cups.h ../config.h ../Makedefs -util.o: cups.h http.h ipp.h ../config.h ../Makedefs +emit.o: ppd.h +http.o: http.h ipp.h string.h +ipp.o: http.h ipp.h string.h language.h +language.o: cups_C.h language.h string.h +mark.o: ppd.h +options.o: cups.h +page.o: ppd.h +ppd.o: language.h ppd.h +snprintf.o: string.h +string.o: string.h +usersys.o: cups.h +util.o: cups.h http.h ipp.h # # testhttp (dependency on static CUPS library is intentional) @@ -124,17 +120,7 @@ testhttp: testhttp.o libcups.a echo Linking $@... $(CC) $(LDFLAGS) -o $@ testhttp.o libcups.a $(NETLIBS) -testhttp.o: http.h ../Makedefs - -# -# testmime (dependency on static CUPS library is intentional) -# - -testmime: testmime.o libcups.a - echo Linking $@... - $(CC) $(LDFLAGS) -o $@ testmime.o libcups.a - -testmime.o: mime.h ../Makedefs +testhttp.o: http.h # # testppd (dependency on static CUPS library is intentional) @@ -144,8 +130,10 @@ testppd: testppd.o libcups.a echo Linking $@... $(CC) $(LDFLAGS) -o $@ testppd.o libcups.a $(NETLIBS) -testppd.o: ppd.h ../Makedefs +testppd.o: ppd.h + +$(OBJS): ../Makedefs ../config.h # -# End of "$Id: Makefile,v 1.27 2000/01/21 20:33:16 mike Exp $". +# End of "$Id: Makefile,v 1.28 2000/01/25 03:50:47 mike Exp $". # diff --git a/scheduler/Makefile b/scheduler/Makefile index a7fbcd25d..9a25d7d9a 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -1,9 +1,9 @@ # -# "$Id: Makefile,v 1.17 2000/01/20 13:05:41 mike Exp $" +# "$Id: Makefile,v 1.18 2000/01/25 03:50:48 mike Exp $" # # Scheduler Makefile for the Common UNIX Printing System (CUPS). # -# Copyright 1997-1999 by Easy Software Products, all rights reserved. +# Copyright 1997-2000 by Easy Software Products, all rights reserved. # # These coded instructions, statements, and computer programs are the # property of Easy Software Products and are protected by Federal @@ -26,20 +26,23 @@ include ../Makedefs CUPSDOBJS = auth.o cert.o classes.o client.o conf.o dirsvc.o main.o ipp.o \ listen.o job.o log.o printers.o -OBJS = $(CUPSDOBJS) testspeed.o +MIMEOBJS = filter.o mime.o type.o +OBJS = $(CUPSDOBJS) $(MIMEOBJS) testmime.o testspeed.o # # Make everything... # -all: cupsd testspeed +all: cupsd libmime.a testmime testspeed + # # Clean all object files... # clean: - rm -f $(OBJS) cupsd testspeed + rm -f $(OBJS) cupsd libmime.a testmime testspeed + # # Install the scheduler... @@ -53,17 +56,42 @@ install: -$(MKDIR) $(SERVERROOT)/ppd -$(MKDIR) $(SERVERROOT)/requests + # # Make the scheduler executable, "cupsd". # -cupsd: $(CUPSDOBJS) ../cups/$(LIBCUPS) +cupsd: $(CUPSDOBJS) libmime.a ../cups/$(LIBCUPS) echo Linking $@... - $(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) $(LIBS) + $(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) libmime.a $(LIBS) $(CUPSDOBJS): auth.h cert.h classes.h client.h conf.h cupsd.h dirsvc.h job.h \ - printers.h ../cups/cups.h ../cups/http.h ../cups/ipp.h \ - ../cups/language.h ../cups/mime.h ../cups/string.h + mime.h printers.h ../cups/cups.h ../cups/http.h ../cups/ipp.h \ + ../cups/language.h ../cups/string.h + + +# +# libmime.a +# + +libmime.a: $(MIMEOBJS) + echo Archiving $@... + $(RM) $@ + $(AR) $(ARFLAGS) $@ $(MIMEOBJS) + $(RANLIB) $@ + +$(MIMEOBJS): mime.h + + +# +# testmime +# + +testmime: testmime.o libmime.a + echo Linking $@... + $(CC) $(LDFLAGS) -o $@ testmime.o libmime.a + +testmime.o: mime.h # # Make the test program, "testspeed". @@ -78,5 +106,5 @@ testspeed.o: ../cups/cups.h ../cups/http.h ../cups/ipp.h ../cups/language.h $(OBJS): ../config.h ../Makedefs # -# End of "$Id: Makefile,v 1.17 2000/01/20 13:05:41 mike Exp $". +# End of "$Id: Makefile,v 1.18 2000/01/25 03:50:48 mike Exp $". # diff --git a/cups/filter.c b/scheduler/filter.c similarity index 98% rename from cups/filter.c rename to scheduler/filter.c index c7f9ea4b1..9f085f6c5 100644 --- a/cups/filter.c +++ b/scheduler/filter.c @@ -1,5 +1,5 @@ /* - * "$Id: filter.c,v 1.11 2000/01/04 13:45:34 mike Exp $" + * "$Id: filter.c,v 1.1 2000/01/25 03:50:48 mike Exp $" * * File type conversion routines for the Common UNIX Printing System (CUPS). * @@ -37,7 +37,7 @@ #include #include -#include "string.h" +#include #include "mime.h" @@ -295,5 +295,5 @@ lookup(mime_t *mime, /* I - MIME database */ /* - * End of "$Id: filter.c,v 1.11 2000/01/04 13:45:34 mike Exp $". + * End of "$Id: filter.c,v 1.1 2000/01/25 03:50:48 mike Exp $". */ diff --git a/cups/mime.c b/scheduler/mime.c similarity index 82% rename from cups/mime.c rename to scheduler/mime.c index 3b71d1bc3..45613306f 100644 --- a/cups/mime.c +++ b/scheduler/mime.c @@ -1,5 +1,5 @@ /* - * "$Id: mime.c,v 1.16 2000/01/04 13:45:35 mike Exp $" + * "$Id: mime.c,v 1.1 2000/01/25 03:50:48 mike Exp $" * * MIME database file routines for the Common UNIX Printing System (CUPS). * @@ -29,82 +29,6 @@ * load_types() - Load a xyz.types file... * delete_rules() - Free all memory for the given rule tree. * load_convs() - Load a xyz.convs file... - * - * Revision History: - * - * $Log: mime.c,v $ - * Revision 1.16 2000/01/04 13:45:35 mike - * Y2k copyright changes. - * - * Revision 1.15 1999/10/10 15:40:23 mike - * Scanf, strcpy, and sprintf security changes. - * - * Revision 1.14 1999/07/12 16:09:38 mike - * Fixed all constant arrays to use "const" modifier. - * - * Revision 1.13 1999/06/18 18:36:10 mike - * Fixed address to 44141 Airport View Drive... - * - * Revision 1.12 1999/04/21 21:19:33 mike - * Changes for HP-UX. - * - * Revision 1.11 1999/04/21 19:31:29 mike - * Changed the directory header stuff to use the autoconf-recommended - * sequence of #ifdef's. - * - * Changed the language routines to look for the LOCALEDIR environment - * variable, and if it is not defined to use the LOCALEDIR string defined - * in config.h. - * - * Revision 1.10 1999/03/01 20:51:53 mike - * Code cleanup - removed extraneous semi-colons... - * - * Revision 1.9 1999/02/26 22:00:51 mike - * Added more debug statements. - * - * Fixed bugs in cupsPrintFile() - wasn't setting the IPP_TAG_MIMETYPE - * value tag for the file type. - * - * Updated conversion filter code to handle wildcards for super-type. - * - * Revision 1.8 1999/02/20 16:04:38 mike - * Updated mime.c to scan directories under WIN32. - * - * Fixed some compiler warnings under WIN32. - * - * Updated VC++ project files. - * - * Updated mime.types and mime.convs files for actual registered - * MIME type names. - * - * Revision 1.7 1999/02/05 17:40:53 mike - * Added IPP client read/write code. - * - * Added string functions missing from some UNIXs. - * - * Added option parsing functions. - * - * Added IPP convenience functions (not implemented yet). - * - * Updated source files to use local string.h as needed (for - * missing string functions) - * - * Revision 1.6 1999/02/01 22:08:39 mike - * Restored original directory-scanning functionality of mimeLoad(). - * - * Revision 1.4 1999/01/27 18:31:56 mike - * Updated PPD routines to handle emulations and patch files. - * - * Added DSC comments to emit output as appropriate. - * - * Revision 1.3 1999/01/24 14:18:43 mike - * Check-in prior to CVS use. - * - * Revision 1.2 1998/08/06 14:38:38 mike - * Finished coding and testing for CUPS 1.0. - * - * Revision 1.1 1998/06/11 20:50:53 mike - * Initial revision */ /* @@ -115,7 +39,7 @@ #include #include -#include "string.h" +#include #include "mime.h" #if defined(WIN32) || defined(__EMX__) @@ -621,5 +545,5 @@ delete_rules(mime_magic_t *rules) /* I - Rules to free */ /* - * End of "$Id: mime.c,v 1.16 2000/01/04 13:45:35 mike Exp $". + * End of "$Id: mime.c,v 1.1 2000/01/25 03:50:48 mike Exp $". */ diff --git a/cups/mime.h b/scheduler/mime.h similarity index 97% rename from cups/mime.h rename to scheduler/mime.h index 3d5023fc7..b17e3b2d6 100644 --- a/cups/mime.h +++ b/scheduler/mime.h @@ -1,5 +1,5 @@ /* - * "$Id: mime.h,v 1.7 2000/01/04 13:45:35 mike Exp $" + * "$Id: mime.h,v 1.1 2000/01/25 03:50:48 mike Exp $" * * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS). * @@ -133,5 +133,5 @@ extern mime_filter_t *mimeFilter(mime_t *mime, mime_type_t *src, mime_type_t *ds #endif /* !_MIME_H_ */ /* - * End of "$Id: mime.h,v 1.7 2000/01/04 13:45:35 mike Exp $". + * End of "$Id: mime.h,v 1.1 2000/01/25 03:50:48 mike Exp $". */ diff --git a/cups/testmime.c b/scheduler/testmime.c similarity index 97% rename from cups/testmime.c rename to scheduler/testmime.c index 948c4e7da..b24beee68 100644 --- a/cups/testmime.c +++ b/scheduler/testmime.c @@ -1,5 +1,5 @@ /* - * "$Id: testmime.c,v 1.8 2000/01/04 13:45:37 mike Exp $" + * "$Id: testmime.c,v 1.1 2000/01/25 03:50:49 mike Exp $" * * MIME test program for the Common UNIX Printing System (CUPS). * @@ -195,5 +195,5 @@ print_rules(mime_magic_t *rules) /* I - Rules to print */ /* - * End of "$Id: testmime.c,v 1.8 2000/01/04 13:45:37 mike Exp $". + * End of "$Id: testmime.c,v 1.1 2000/01/25 03:50:49 mike Exp $". */ diff --git a/cups/type.c b/scheduler/type.c similarity index 99% rename from cups/type.c rename to scheduler/type.c index 8e2d323d7..a909d60a3 100644 --- a/cups/type.c +++ b/scheduler/type.c @@ -1,5 +1,5 @@ /* - * "$Id: type.c,v 1.12 2000/01/04 13:45:37 mike Exp $" + * "$Id: type.c,v 1.1 2000/01/25 03:50:49 mike Exp $" * * MIME typing routines for the Common UNIX Printing System (CUPS). * @@ -41,7 +41,7 @@ #include #include -#include "string.h" +#include #include "mime.h" @@ -1010,5 +1010,5 @@ patmatch(const char *s, /* I - String to match against */ /* - * End of "$Id: type.c,v 1.12 2000/01/04 13:45:37 mike Exp $". + * End of "$Id: type.c,v 1.1 2000/01/25 03:50:49 mike Exp $". */ -- 2.39.5