diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2008-06-27 20:26:20 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2008-06-27 20:26:20 +0000 |
commit | 75bd9771f6e44fdd887ee90faac46f403aefc0fc (patch) | |
tree | 354e3067522df9490e905772f73b72bfed8733ae /scheduler | |
parent | dd1abb6b5f145c5e5f279d8848b5f3ec161fd227 (diff) |
Merge changes from CUPS 1.4svn-r7696.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@818 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'scheduler')
47 files changed, 987 insertions, 887 deletions
diff --git a/scheduler/Makefile b/scheduler/Makefile index 256a93a0f..abcd07269 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 6801 2007-08-16 18:42:49Z mike $" +# "$Id: Makefile 7558 2008-05-12 23:46:44Z mike $" # # Scheduler Makefile for the Common UNIX Printing System (CUPS). # @@ -525,5 +525,5 @@ include Dependencies # -# End of "$Id: Makefile 6801 2007-08-16 18:42:49Z mike $". +# End of "$Id: Makefile 7558 2008-05-12 23:46:44Z mike $". # diff --git a/scheduler/auth.c b/scheduler/auth.c index f065a1f51..d0d5641bc 100644 --- a/scheduler/auth.c +++ b/scheduler/auth.c @@ -1,5 +1,5 @@ /* - * "$Id: auth.c 6947 2007-09-12 21:09:49Z mike $" + * "$Id: auth.c 7673 2008-06-18 22:31:26Z mike $" * * Authorization routines for the Common UNIX Printing System (CUPS). * @@ -666,7 +666,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */ if (pamerr != PAM_SUCCESS) { cupsdLogMessage(CUPSD_LOG_ERROR, - "cupsdAuthorize: pam_start() returned %d (%s)!\n", + "cupsdAuthorize: pam_start() returned %d (%s)!", pamerr, pam_strerror(pamh, pamerr)); return; } @@ -676,7 +676,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */ if (pamerr != PAM_SUCCESS) cupsdLogMessage(CUPSD_LOG_WARN, "cupsdAuthorize: pam_set_item() returned %d " - "(%s)!\n", pamerr, pam_strerror(pamh, pamerr)); + "(%s)!", pamerr, pam_strerror(pamh, pamerr)); # endif /* HAVE_PAM_SET_ITEM && PAM_RHOST */ pamerr = pam_authenticate(pamh, PAM_SILENT); @@ -684,7 +684,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */ { cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdAuthorize: pam_authenticate() returned %d " - "(%s)!\n", + "(%s)!", pamerr, pam_strerror(pamh, pamerr)); pam_end(pamh, 0); return; @@ -695,7 +695,7 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */ { cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdAuthorize: pam_acct_mgmt() returned %d " - "(%s)!\n", + "(%s)!", pamerr, pam_strerror(pamh, pamerr)); pam_end(pamh, 0); return; @@ -713,8 +713,8 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */ cupsdLogMessage(CUPSD_LOG_DEBUG, - "cupsdAuthorize: AIX authenticate of username \"%s\"", - username); + "cupsdAuthorize: AIX authenticate of username " + "\"%s\"", username); reenter = 1; if (authenticate(username, password, &reenter, &authmsg) != 0) @@ -2743,5 +2743,5 @@ to64(char *s, /* O - Output string */ /* - * End of "$Id: auth.c 6947 2007-09-12 21:09:49Z mike $". + * End of "$Id: auth.c 7673 2008-06-18 22:31:26Z mike $". */ diff --git a/scheduler/auth.h b/scheduler/auth.h index 2679420f0..b5bb65362 100644 --- a/scheduler/auth.h +++ b/scheduler/auth.h @@ -1,5 +1,5 @@ /* - * "$Id: auth.h 6780 2007-08-08 20:50:42Z mike $" + * "$Id: auth.h 7317 2008-02-15 22:29:27Z mike $" * * Authorization definitions for the Common UNIX Printing System (CUPS) * scheduler. @@ -155,5 +155,5 @@ extern http_status_t cupsdIsAuthorized(cupsd_client_t *con, const char *owner); /* - * End of "$Id: auth.h 6780 2007-08-08 20:50:42Z mike $". + * End of "$Id: auth.h 7317 2008-02-15 22:29:27Z mike $". */ diff --git a/scheduler/banners.c b/scheduler/banners.c index 66305fb08..ef73d2e7c 100644 --- a/scheduler/banners.c +++ b/scheduler/banners.c @@ -1,5 +1,5 @@ /* - * "$Id: banners.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: banners.c 7221 2008-01-16 22:20:08Z mike $" * * Banner routines for the Common UNIX Printing System (CUPS). * @@ -220,5 +220,5 @@ free_banners(void) /* - * End of "$Id: banners.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: banners.c 7221 2008-01-16 22:20:08Z mike $". */ diff --git a/scheduler/cert.c b/scheduler/cert.c index 35f07c647..650363401 100644 --- a/scheduler/cert.c +++ b/scheduler/cert.c @@ -1,5 +1,5 @@ /* - * "$Id: cert.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: cert.c 7673 2008-06-18 22:31:26Z mike $" * * Authentication certificate routines for the Common UNIX * Printing System (CUPS). @@ -311,7 +311,7 @@ cupsdDeleteCert(int pid) /* I - Process ID */ snprintf(filename, sizeof(filename), "%s/certs/%d", StateDir, pid); if (unlink(filename)) cupsdLogMessage(CUPSD_LOG_ERROR, - "cupsdDeleteCert: Unable to remove %s!\n", filename); + "cupsdDeleteCert: Unable to remove %s!", filename); return; } @@ -343,7 +343,7 @@ cupsdDeleteAllCerts(void) snprintf(filename, sizeof(filename), "%s/certs/%d", StateDir, cert->pid); if (unlink(filename)) cupsdLogMessage(CUPSD_LOG_ERROR, - "cupsdDeleteAllCerts: Unable to remove %s!\n", filename); + "cupsdDeleteAllCerts: Unable to remove %s!", filename); /* * Free memory... @@ -437,5 +437,5 @@ cupsdInitCerts(void) /* - * End of "$Id: cert.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: cert.c 7673 2008-06-18 22:31:26Z mike $". */ diff --git a/scheduler/cert.h b/scheduler/cert.h index d1158802b..976600146 100644 --- a/scheduler/cert.h +++ b/scheduler/cert.h @@ -1,5 +1,5 @@ /* - * "$Id: cert.h 6649 2007-07-11 21:46:42Z mike $" + * "$Id: cert.h 7383 2008-03-20 20:58:07Z mike $" * * Authentication certificate definitions for the Common UNIX * Printing System (CUPS). @@ -53,5 +53,5 @@ extern void cupsdInitCerts(void); /* - * End of "$Id: cert.h 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: cert.h 7383 2008-03-20 20:58:07Z mike $". */ diff --git a/scheduler/classes.c b/scheduler/classes.c index 3e905b448..7fa3c4c5e 100644 --- a/scheduler/classes.c +++ b/scheduler/classes.c @@ -1,5 +1,5 @@ /* - * "$Id: classes.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: classes.c 7608 2008-05-21 01:37:21Z mike $" * * Printer class routines for the Common UNIX Printing System (CUPS). * @@ -956,5 +956,5 @@ cupsdUpdateImplicitClasses(void) /* - * End of "$Id: classes.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: classes.c 7608 2008-05-21 01:37:21Z mike $". */ diff --git a/scheduler/client.c b/scheduler/client.c index f56ed64a2..cf8365673 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -1,5 +1,5 @@ /* - * "$Id: client.c 6999 2007-09-28 19:46:53Z mike $" + * "$Id: client.c 7673 2008-06-18 22:31:26Z mike $" * * Client routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -1214,7 +1214,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ if ((status = cupsdIsAuthorized(con, NULL)) != HTTP_OK) { cupsdLogMessage(CUPSD_LOG_DEBUG2, - "cupsdReadClient: Unauthorized request for %s...\n", + "cupsdReadClient: Unauthorized request for %s...", con->uri); cupsdSendError(con, status, CUPSD_AUTH_NONE); cupsdCloseClient(con); @@ -3695,7 +3695,7 @@ is_cgi(cupsd_client_t *con, /* I - Client connection */ cupsdLogMessage(CUPSD_LOG_DEBUG2, - "is_cgi(con=%p, filename=\"%s\", filestats=%p, type=%s/%s)\n", + "is_cgi(con=%p, filename=\"%s\", filestats=%p, type=%s/%s)", con, filename, filestats, type ? type->super : "unknown", type ? type->type : "unknown"); @@ -4893,5 +4893,5 @@ write_pipe(cupsd_client_t *con) /* I - Client connection */ /* - * End of "$Id: client.c 6999 2007-09-28 19:46:53Z mike $". + * End of "$Id: client.c 7673 2008-06-18 22:31:26Z mike $". */ diff --git a/scheduler/client.h b/scheduler/client.h index e6d946d47..c817e7cce 100644 --- a/scheduler/client.h +++ b/scheduler/client.h @@ -1,5 +1,5 @@ /* - * "$Id: client.h 6947 2007-09-12 21:09:49Z mike $" + * "$Id: client.h 7470 2008-04-18 23:24:24Z mike $" * * Client definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -134,5 +134,5 @@ extern void cupsdWriteClient(cupsd_client_t *con); /* - * End of "$Id: client.h 6947 2007-09-12 21:09:49Z mike $". + * End of "$Id: client.h 7470 2008-04-18 23:24:24Z mike $". */ diff --git a/scheduler/conf.c b/scheduler/conf.c index c9eb950fa..955dc2df1 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -1,5 +1,5 @@ /* - * "$Id: conf.c 6930 2007-09-08 00:28:06Z mike $" + * "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $" * * Configuration routines for the Common UNIX Printing System (CUPS). * @@ -1116,22 +1116,23 @@ cupsdReadConfiguration(void) snprintf(temp, sizeof(temp), "%s/filter", ServerBin); snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir); - MimeDatabase = mimeLoad(ServerRoot, temp); + MimeDatabase = mimeLoadTypes(NULL, mimedir); + MimeDatabase = mimeLoadTypes(MimeDatabase, ServerRoot); + MimeDatabase = mimeLoadFilters(MimeDatabase, mimedir, temp); + MimeDatabase = mimeLoadFilters(MimeDatabase, ServerRoot, temp); if (!MimeDatabase) { cupsdLogMessage(CUPSD_LOG_EMERG, - "Unable to load MIME database from \'%s\'!", ServerRoot); + "Unable to load MIME database from \"%s\" or \"%s\"!", + mimedir, ServerRoot); exit(errno); } - if (!access(mimedir, 0)) - MimeDatabase = mimeMerge(MimeDatabase, mimedir, temp); - cupsdLogMessage(CUPSD_LOG_INFO, - "Loaded MIME database from \'%s\': %d types, %d filters...", - ServerRoot, mimeNumTypes(MimeDatabase), - mimeNumFilters(MimeDatabase)); + "Loaded MIME database from \"%s\" and \"%s\": %d types, " + "%d filters...", mimedir, ServerRoot, + mimeNumTypes(MimeDatabase), mimeNumFilters(MimeDatabase)); /* * Create a list of MIME types for the document-format-supported @@ -3400,5 +3401,5 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ /* - * End of "$Id: conf.c 6930 2007-09-08 00:28:06Z mike $". + * End of "$Id: conf.c 7694 2008-06-26 00:23:20Z mike $". */ diff --git a/scheduler/conf.h b/scheduler/conf.h index 2a91e5ceb..d5c483cc4 100644 --- a/scheduler/conf.h +++ b/scheduler/conf.h @@ -1,5 +1,5 @@ /* - * "$Id: conf.h 6649 2007-07-11 21:46:42Z mike $" + * "$Id: conf.h 7674 2008-06-18 23:18:32Z mike $" * * Configuration file definitions for the Common UNIX Printing System (CUPS) * scheduler. @@ -225,6 +225,11 @@ extern int cupsdLogGSSMessage(int level, int major_status, int minor_status, const char *message, ...); #endif /* HAVE_GSSAPI */ +extern int cupsdLogJob(cupsd_job_t *job, int level, const char *message, ...) +#ifdef __GNUC__ +__attribute__ ((__format__ (__printf__, 3, 4))) +#endif /* __GNUC__ */ +; extern int cupsdLogMessage(int level, const char *message, ...) #ifdef __GNUC__ __attribute__ ((__format__ (__printf__, 2, 3))) @@ -233,8 +238,9 @@ __attribute__ ((__format__ (__printf__, 2, 3))) extern int cupsdLogPage(cupsd_job_t *job, const char *page); extern int cupsdLogRequest(cupsd_client_t *con, http_status_t code); extern int cupsdReadConfiguration(void); +extern int cupsdWriteErrorLog(int level, const char *message); /* - * End of "$Id: conf.h 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: conf.h 7674 2008-06-18 23:18:32Z mike $". */ diff --git a/scheduler/cups-deviced.c b/scheduler/cups-deviced.c index a912358f1..4d05b53c0 100644 --- a/scheduler/cups-deviced.c +++ b/scheduler/cups-deviced.c @@ -1,5 +1,5 @@ /* - * "$Id: cups-deviced.c 7011 2007-10-10 21:13:35Z mike $" + * "$Id: cups-deviced.c 7624 2008-06-09 15:55:04Z mike $" * * Device scanning mini-daemon for the Common UNIX Printing System (CUPS). * @@ -719,5 +719,5 @@ start_backend(const char *name, /* I - Backend to run */ /* - * End of "$Id: cups-deviced.c 7011 2007-10-10 21:13:35Z mike $". + * End of "$Id: cups-deviced.c 7624 2008-06-09 15:55:04Z mike $". */ diff --git a/scheduler/cups-driverd.c b/scheduler/cups-driverd.c index 013f1de89..ed364c721 100644 --- a/scheduler/cups-driverd.c +++ b/scheduler/cups-driverd.c @@ -1,5 +1,5 @@ /* - * "$Id: cups-driverd.c 6762 2007-08-02 18:05:03Z mike $" + * "$Id: cups-driverd.c 7652 2008-06-16 17:56:27Z mike $" * * PPD/driver support for the Common UNIX Printing System (CUPS). * @@ -1704,5 +1704,5 @@ load_drivers(void) /* - * End of "$Id: cups-driverd.c 6762 2007-08-02 18:05:03Z mike $". + * End of "$Id: cups-driverd.c 7652 2008-06-16 17:56:27Z mike $". */ diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c index 7e810f4ca..ca918c462 100644 --- a/scheduler/cups-lpd.c +++ b/scheduler/cups-lpd.c @@ -1,5 +1,5 @@ /* - * "$Id: cups-lpd.c 6781 2007-08-08 21:09:31Z mike $" + * "$Id: cups-lpd.c 7221 2008-01-16 22:20:08Z mike $" * * Line Printer Daemon interface for the Common UNIX Printing System (CUPS). * @@ -1702,5 +1702,5 @@ smart_gets(char *s, /* I - Pointer to line buffer */ /* - * End of "$Id: cups-lpd.c 6781 2007-08-08 21:09:31Z mike $". + * End of "$Id: cups-lpd.c 7221 2008-01-16 22:20:08Z mike $". */ diff --git a/scheduler/cups-polld.c b/scheduler/cups-polld.c index 9ffc46d2c..b7165b5c9 100644 --- a/scheduler/cups-polld.c +++ b/scheduler/cups-polld.c @@ -1,5 +1,5 @@ /* - * "$Id: cups-polld.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: cups-polld.c 7198 2008-01-08 00:12:17Z mike $" * * Polling daemon for the Common UNIX Printing System (CUPS). * @@ -471,5 +471,5 @@ sighup_handler(int sig) /* I - Signal number */ /* - * End of "$Id: cups-polld.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: cups-polld.c 7198 2008-01-08 00:12:17Z mike $". */ diff --git a/scheduler/cupsd.h b/scheduler/cupsd.h index 0b68f781a..b4304ce83 100644 --- a/scheduler/cupsd.h +++ b/scheduler/cupsd.h @@ -1,5 +1,5 @@ /* - * "$Id: cupsd.h 6875 2007-08-27 23:25:06Z mike $" + * "$Id: cupsd.h 7317 2008-02-15 22:29:27Z mike $" * * Main header file for the Common UNIX Printing System (CUPS) scheduler. * @@ -234,5 +234,5 @@ extern void cupsdStopSelect(void); extern int cupsdRemoveFile(const char *filename); /* - * End of "$Id: cupsd.h 6875 2007-08-27 23:25:06Z mike $". + * End of "$Id: cupsd.h 7317 2008-02-15 22:29:27Z mike $". */ diff --git a/scheduler/cupsfilter.c b/scheduler/cupsfilter.c index 3ece2f4b2..f60c284fa 100644 --- a/scheduler/cupsfilter.c +++ b/scheduler/cupsfilter.c @@ -1,5 +1,5 @@ /* - * "$Id: cupsfilter.c 6879 2007-08-29 20:26:50Z mike $" + * "$Id: cupsfilter.c 7694 2008-06-26 00:23:20Z mike $" * * CUPS filtering program for the Common UNIX Printing System (CUPS). * @@ -353,18 +353,22 @@ main(int argc, /* I - Number of command-line args */ if (read_cupsd_conf(cupsdconf)) return (1); - if ((mime = mimeLoad(ServerRoot, Path)) == NULL) + snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir); + + mime = mimeLoadTypes(NULL, mimedir); + mime = mimeLoadTypes(mime, ServerRoot); + mime = mimeLoadFilters(mime, mimedir, Path); + mime = mimeLoadFilters(mime, ServerRoot, Path); + + if (!mime) { _cupsLangPrintf(stderr, - _("%s: Unable to read MIME database from \"%s\"!\n"), - command, ServerRoot); + _("%s: Unable to read MIME database from \"%s\" or " + "\"%s\"!\n"), + command, mimedir, ServerRoot); return (1); } - snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir); - if (!access(mimedir, 0)) - mime = mimeMerge(mime, mimedir, Path); - /* * Get the source and destination types... */ @@ -1140,5 +1144,5 @@ usage(const char *command, /* I - Command name */ /* - * End of "$Id: cupsfilter.c 6879 2007-08-29 20:26:50Z mike $". + * End of "$Id: cupsfilter.c 7694 2008-06-26 00:23:20Z mike $". */ diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index 9b7b285c4..51509b850 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -1,5 +1,5 @@ /* - * "$Id: dirsvc.c 7003 2007-10-01 23:10:13Z mike $" + * "$Id: dirsvc.c 7676 2008-06-18 23:42:37Z mike $" * * Directory services routines for the Common UNIX Printing System (CUPS). * @@ -29,7 +29,6 @@ * cupsdStopBrowsing() - Stop sending and receiving broadcast * information. * cupsdStopPolling() - Stop polling servers as needed. - * cupsdUpdateDNSSDBrowse() - Handle DNS-SD queries. * cupsdUpdateDNSSDName() - Update the computer name we use for * browsing... * cupsdUpdateLDAPBrowse() - Scan for new printers via LDAP... @@ -44,6 +43,7 @@ * dnssdRegisterCallback() - DNSServiceRegister callback. * dnssdRegisterPrinter() - Start sending broadcast information for a * printer or update the broadcast contents. + * dnssdUpdate() - Handle DNS-SD queries. * get_hostconfig() - Get an /etc/hostconfig service setting. * is_local_queue() - Determine whether the URI points at a local * queue. @@ -128,6 +128,7 @@ static void dnssdRegisterCallback(DNSServiceRef sdRef, const char *name, const char *regtype, const char *domain, void *context); static void dnssdRegisterPrinter(cupsd_printer_t *p); +static void dnssdUpdate(void); #endif /* HAVE_DNSSD */ #ifdef HAVE_OPENLDAP @@ -1058,7 +1059,7 @@ cupsdStartBrowsing(void) */ cupsdAddSelect(DNSServiceRefSockFD(DNSSDRef), - (cupsd_selfunc_t)cupsdUpdateDNSSDBrowse, NULL, NULL); + (cupsd_selfunc_t)dnssdUpdate, NULL, NULL); /* * Then get the port we use for registrations. If we are not listening @@ -1476,23 +1477,6 @@ cupsdStopPolling(void) #ifdef HAVE_DNSSD /* - * 'cupsdUpdateDNSSDBrowse()' - Handle DNS-SD queries. - */ - -void -cupsdUpdateDNSSDBrowse(void) -{ - DNSServiceErrorType sdErr; /* Service discovery error */ - - - if ((sdErr = DNSServiceProcessResult(DNSSDRef)) != kDNSServiceErr_NoError) - cupsdLogMessage(CUPSD_LOG_ERROR, - "DNS Service Discovery registration error %d!", - sdErr); -} - - -/* * 'cupsdUpdateDNSSDName()' - Update the computer name we use for browsing... */ @@ -2308,6 +2292,23 @@ dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ free(printer_txt); } } + + +/* + * 'dnssdUpdate()' - Handle DNS-SD queries. + */ + +static void +dnssdUpdate(void) +{ + DNSServiceErrorType sdErr; /* Service discovery error */ + + + if ((sdErr = DNSServiceProcessResult(DNSSDRef)) != kDNSServiceErr_NoError) + cupsdLogMessage(CUPSD_LOG_ERROR, + "DNS Service Discovery registration error %d!", + sdErr); +} #endif /* HAVE_DNSSD */ @@ -3324,7 +3325,7 @@ send_ldap_browse(cupsd_printer_t *p) /* I - Printer to register */ NULL }; - cupsdLogMessage(CUPSD_LOG_DEBUG2, "send_ldap_browse: %s\n", p->name); + cupsdLogMessage(CUPSD_LOG_DEBUG2, "send_ldap_browse: %s", p->name); /* * Everything in ldap is ** so we fudge around it... @@ -4278,5 +4279,5 @@ update_smb(int onoff) /* I - 1 = turn on, 0 = turn off */ /* - * End of "$Id: dirsvc.c 7003 2007-10-01 23:10:13Z mike $". + * End of "$Id: dirsvc.c 7676 2008-06-18 23:42:37Z mike $". */ diff --git a/scheduler/dirsvc.h b/scheduler/dirsvc.h index 16693c293..60c22c3bd 100644 --- a/scheduler/dirsvc.h +++ b/scheduler/dirsvc.h @@ -1,5 +1,5 @@ /* - * "$Id: dirsvc.h 6930 2007-09-08 00:28:06Z mike $" + * "$Id: dirsvc.h 7676 2008-06-18 23:42:37Z mike $" * * Directory services definitions for the Common UNIX Printing System * (CUPS) scheduler. @@ -188,7 +188,6 @@ extern void cupsdStartPolling(void); extern void cupsdStopBrowsing(void); extern void cupsdStopPolling(void); #ifdef HAVE_DNSSD -extern void cupsdUpdateDNSSDBrowse(void); extern void cupsdUpdateDNSSDName(void); #endif /* HAVE_DNSSD */ #ifdef HAVE_LDAP @@ -198,5 +197,5 @@ extern void cupsdUpdateSLPBrowse(void); /* - * End of "$Id: dirsvc.h 6930 2007-09-08 00:28:06Z mike $". + * End of "$Id: dirsvc.h 7676 2008-06-18 23:42:37Z mike $". */ diff --git a/scheduler/env.c b/scheduler/env.c index a7813f9f1..3eb9213a5 100644 --- a/scheduler/env.c +++ b/scheduler/env.c @@ -1,5 +1,5 @@ /* - * "$Id: env.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: env.c 7673 2008-06-18 22:31:26Z mike $" * * Environment management routines for the Common UNIX Printing System (CUPS). * @@ -185,7 +185,7 @@ cupsdSetEnv(const char *name, /* I - Name of variable */ cupsdSetStringf(common_env + i, "%s=%s", name, value); - cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSetEnv: %s\n", common_env[i]); + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSetEnv: %s", common_env[i]); } @@ -236,5 +236,5 @@ clear_env(void) /* - * End of "$Id: env.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: env.c 7673 2008-06-18 22:31:26Z mike $". */ diff --git a/scheduler/filter.c b/scheduler/filter.c index 73344b6ae..6df0483f9 100644 --- a/scheduler/filter.c +++ b/scheduler/filter.c @@ -1,9 +1,9 @@ /* - * "$Id: filter.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: filter.c 7694 2008-06-26 00:23:20Z mike $" * * File type conversion routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -403,5 +403,5 @@ find_filters(mime_t *mime, /* I - MIME database */ /* - * End of "$Id: filter.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: filter.c 7694 2008-06-26 00:23:20Z mike $". */ diff --git a/scheduler/ipp.c b/scheduler/ipp.c index ac80acb7f..7562cd9e2 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c 7014 2007-10-10 21:57:43Z mike $" + * "$Id: ipp.c 7682 2008-06-21 00:06:02Z mike $" * * IPP routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -796,8 +796,8 @@ cupsdTimeoutJob(cupsd_job_t *job) /* I - Job to timeout */ * Yes... */ - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Adding end banner page \"%s\".", - job->id, attr->values[1].string.text); + cupsdLogJob(job, CUPSD_LOG_INFO, "Adding end banner page \"%s\".", + attr->values[1].string.text); if ((kbytes = copy_banner(NULL, job, attr->values[1].string.text)) < 0) return (-1); @@ -1754,10 +1754,10 @@ add_job(cupsd_client_t *con, /* I - Client connection */ cupsdSetString(&attr->values[0].string.text, Classification); - cupsdLogMessage(CUPSD_LOG_NOTICE, "[Job %d] CLASSIFICATION FORCED " - "job-sheets=\"%s,none\", " - "job-originating-user-name=\"%s\"", - job->id, Classification, job->username); + cupsdLogJob(job, CUPSD_LOG_NOTICE, "CLASSIFICATION FORCED " + "job-sheets=\"%s,none\", " + "job-originating-user-name=\"%s\"", + Classification, job->username); } else if (attr->num_values == 2 && strcmp(attr->values[0].string.text, @@ -1771,11 +1771,11 @@ add_job(cupsd_client_t *con, /* I - Client connection */ cupsdSetString(&attr->values[1].string.text, attr->values[0].string.text); - cupsdLogMessage(CUPSD_LOG_NOTICE, "[Job %d] CLASSIFICATION FORCED " - "job-sheets=\"%s,%s\", " - "job-originating-user-name=\"%s\"", - job->id, attr->values[0].string.text, - attr->values[1].string.text, job->username); + cupsdLogJob(job, CUPSD_LOG_NOTICE, "CLASSIFICATION FORCED " + "job-sheets=\"%s,%s\", " + "job-originating-user-name=\"%s\"", + attr->values[0].string.text, + attr->values[1].string.text, job->username); } else if (strcmp(attr->values[0].string.text, Classification) && strcmp(attr->values[0].string.text, "none") && @@ -1784,18 +1784,18 @@ add_job(cupsd_client_t *con, /* I - Client connection */ strcmp(attr->values[1].string.text, "none")))) { if (attr->num_values == 1) - cupsdLogMessage(CUPSD_LOG_NOTICE, - "[Job %d] CLASSIFICATION OVERRIDDEN " - "job-sheets=\"%s\", " - "job-originating-user-name=\"%s\"", - job->id, attr->values[0].string.text, job->username); + cupsdLogJob(job, CUPSD_LOG_NOTICE, + "CLASSIFICATION OVERRIDDEN " + "job-sheets=\"%s\", " + "job-originating-user-name=\"%s\"", + attr->values[0].string.text, job->username); else - cupsdLogMessage(CUPSD_LOG_NOTICE, - "[Job %d] CLASSIFICATION OVERRIDDEN " - "job-sheets=\"%s,%s\",fffff " - "job-originating-user-name=\"%s\"", - job->id, attr->values[0].string.text, - attr->values[1].string.text, job->username); + cupsdLogJob(job, CUPSD_LOG_NOTICE, + "CLASSIFICATION OVERRIDDEN " + "job-sheets=\"%s,%s\",fffff " + "job-originating-user-name=\"%s\"", + attr->values[0].string.text, + attr->values[1].string.text, job->username); } } else if (strcmp(attr->values[0].string.text, Classification) && @@ -1824,18 +1824,18 @@ add_job(cupsd_client_t *con, /* I - Client connection */ } if (attr->num_values > 1) - cupsdLogMessage(CUPSD_LOG_NOTICE, - "[Job %d] CLASSIFICATION FORCED " - "job-sheets=\"%s,%s\", " - "job-originating-user-name=\"%s\"", - job->id, attr->values[0].string.text, - attr->values[1].string.text, job->username); + cupsdLogJob(job, CUPSD_LOG_NOTICE, + "CLASSIFICATION FORCED " + "job-sheets=\"%s,%s\", " + "job-originating-user-name=\"%s\"", + attr->values[0].string.text, + attr->values[1].string.text, job->username); else - cupsdLogMessage(CUPSD_LOG_NOTICE, - "[Job %d] CLASSIFICATION FORCED " - "job-sheets=\"%s\", " - "job-originating-user-name=\"%s\"", - job->id, Classification, job->username); + cupsdLogJob(job, CUPSD_LOG_NOTICE, + "CLASSIFICATION FORCED " + "job-sheets=\"%s\", " + "job-originating-user-name=\"%s\"", + Classification, job->username); } } @@ -1845,9 +1845,8 @@ add_job(cupsd_client_t *con, /* I - Client connection */ if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT))) { - cupsdLogMessage(CUPSD_LOG_INFO, - "[Job %d] Adding start banner page \"%s\".", - job->id, attr->values[0].string.text); + cupsdLogJob(job, CUPSD_LOG_INFO, "Adding start banner page \"%s\".", + attr->values[0].string.text); if ((kbytes = copy_banner(con, job, attr->values[0].string.text)) < 0) { @@ -3669,8 +3668,7 @@ authenticate_job(cupsd_client_t *con, /* I - Client connection */ cupsdReleaseJob(job); - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Authenticated by \"%s\".", jobid, - con->username); + cupsdLogJob(job, CUPSD_LOG_INFO, "Authenticated by \"%s\".", con->username); } @@ -4011,10 +4009,10 @@ cancel_job(cupsd_client_t *con, /* I - Client connection */ if (purge) cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Purged by \"%s\".", jobid, - username); + username); else cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Canceled by \"%s\".", jobid, - username); + username); con->response->request.status.status_code = IPP_OK; } @@ -5690,8 +5688,8 @@ create_job(cupsd_client_t *con, /* I - Client connection */ * Save and log the job... */ - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Queued on \"%s\" by \"%s\".", - job->id, job->dest, job->username); + cupsdLogJob(job, CUPSD_LOG_INFO, "Queued on \"%s\" by \"%s\".", + job->dest, job->username); } @@ -7945,8 +7943,7 @@ hold_job(cupsd_client_t *con, /* I - Client connection */ "Job job-hold-until value changed by user."); } - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Held by \"%s\".", jobid, - username); + cupsdLogJob(job, CUPSD_LOG_INFO, "Held by \"%s\".", username); con->response->request.status.status_code = IPP_OK; } @@ -8519,11 +8516,10 @@ print_job(cupsd_client_t *con, /* I - Client connection */ * Log and save the job... */ - cupsdLogMessage(CUPSD_LOG_INFO, - "[Job %d] File of type %s/%s queued by \"%s\".", job->id, - filetype->super, filetype->type, job->username); - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] hold_until=%d", job->id, - (int)job->hold_until); + cupsdLogJob(job, CUPSD_LOG_INFO, + "File of type %s/%s queued by \"%s\".", + filetype->super, filetype->type, job->username); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "hold_until=%d", (int)job->hold_until); /* * Start the job if possible... @@ -8930,8 +8926,7 @@ release_job(cupsd_client_t *con, /* I - Client connection */ cupsdAddEvent(CUPSD_EVENT_JOB_STATE, cupsdFindDest(job->dest), job, "Job released by user."); - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Released by \"%s\".", jobid, - username); + cupsdLogJob(job, CUPSD_LOG_INFO, "Released by \"%s\".", username); con->response->request.status.status_code = IPP_OK; } @@ -9150,8 +9145,7 @@ restart_job(cupsd_client_t *con, /* I - Client connection */ cupsdRestartJob(job); - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Restarted by \"%s\".", jobid, - username); + cupsdLogJob(job, CUPSD_LOG_INFO, "Restarted by \"%s\".", username); con->response->request.status.status_code = IPP_OK; } @@ -9395,8 +9389,7 @@ save_krb5_creds(cupsd_client_t *con, /* I - Client connection */ cupsdSetStringf(&(job->ccname), "KRB5CCNAME=FILE:%s", krb5_cc_get_name(KerberosContext, job->ccache)); - cupsdLogMessage(CUPSD_LOG_DEBUG2, "[Job %d] save_krb5_creds: %s", job->id, - job->ccname); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "save_krb5_creds: %s", job->ccname); # endif /* HAVE_KRB5_CC_NEW_UNIQUE || HAVE_HEIMDAL */ } #endif /* HAVE_GSSAPI && HAVE_KRB5_H */ @@ -9439,6 +9432,7 @@ send_document(cupsd_client_t *con, /* I - Client connection */ struct stat fileinfo; /* File information */ int kbytes; /* Size of file */ int compression; /* Type of compression */ + int start_job; /* Start the job? */ cupsdLogMessage(CUPSD_LOG_DEBUG2, "send_document(%p[%d], %s)", con, @@ -9608,7 +9602,7 @@ send_document(cupsd_client_t *con, /* I - Client connection */ ipp_attribute_t *doc_name; /* document-name attribute */ - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] Auto-typing file...", job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Auto-typing file..."); doc_name = ippFindAttribute(con->request, "document-name", IPP_TAG_NAME); filetype = mimeFileType(MimeDatabase, con->filename, @@ -9618,9 +9612,8 @@ send_document(cupsd_client_t *con, /* I - Client connection */ if (!filetype) filetype = mimeType(MimeDatabase, super, type); - cupsdLogMessage(CUPSD_LOG_DEBUG, - "[Job %d] Request file type is %s/%s.", job->id, - filetype->super, filetype->type); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.", + filetype->super, filetype->type); } else filetype = mimeType(MimeDatabase, super, type); @@ -9703,9 +9696,8 @@ send_document(cupsd_client_t *con, /* I - Client connection */ cupsdClearString(&con->filename); - cupsdLogMessage(CUPSD_LOG_INFO, - "[Job %d] File of type %s/%s queued by \"%s\".", job->id, - filetype->super, filetype->type, job->username); + cupsdLogJob(job, CUPSD_LOG_INFO, "File of type %s/%s queued by \"%s\".", + filetype->super, filetype->type, job->username); /* * Start the job if this is the last document... @@ -9743,16 +9735,7 @@ send_document(cupsd_client_t *con, /* I - Client connection */ job->dirty = 1; cupsdMarkDirty(CUPSD_DIRTY_JOBS); - /* - * Start the job if possible... Since cupsdCheckJobs() can cancel a - * job if it doesn't print, we need to re-find the job afterwards... - */ - - jobid = job->id; - - cupsdCheckJobs(); - - job = cupsdFindJob(jobid); + start_job = 1; } else { @@ -9769,6 +9752,8 @@ send_document(cupsd_client_t *con, /* I - Client connection */ cupsdMarkDirty(CUPSD_DIRTY_JOBS); } + + start_job = 0; } /* @@ -9784,10 +9769,17 @@ send_document(cupsd_client_t *con, /* I - Client connection */ ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", jobid); ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", - job ? job->state_value : IPP_JOB_CANCELED); + job->state_value); add_job_state_reasons(con, job); con->response->request.status.status_code = IPP_OK; + + /* + * Start the job if necessary... + */ + + if (start_job) + cupsdCheckJobs(); } @@ -11035,5 +11027,5 @@ validate_user(cupsd_job_t *job, /* I - Job */ /* - * End of "$Id: ipp.c 7014 2007-10-10 21:57:43Z mike $". + * End of "$Id: ipp.c 7682 2008-06-21 00:06:02Z mike $". */ diff --git a/scheduler/job.c b/scheduler/job.c index 68c68651f..890da3541 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1,5 +1,5 @@ /* - * "$Id: job.c 7005 2007-10-01 23:45:48Z mike $" + * "$Id: job.c 7682 2008-06-21 00:06:02Z mike $" * * Job management routines for the Common UNIX Printing System (CUPS). * @@ -436,9 +436,9 @@ cupsdCheckJobs(void) * cancel the job... */ - cupsdLogMessage(CUPSD_LOG_WARN, - "[Job %d] Printer/class %s has gone away; canceling job!", - job->id, job->dest); + cupsdLogJob(job, CUPSD_LOG_WARN, + "Printer/class %s has gone away; canceling job!", + job->dest); cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job canceled because the destination printer/class has " @@ -567,12 +567,12 @@ cupsdFinishJob(cupsd_job_t *job) /* I - Job */ ipp_attribute_t *attr; /* job-hold-until attribute */ - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] File %d is complete.", - job->id, job->current_file - 1); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "File %d is complete.", + job->current_file - 1); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] cupsdFinishJob: job->status is %d", - job->id, job->status); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "cupsdFinishJob: job->status is %d", + job->status); if (job->status_buffer && (job->status < 0 || job->current_file >= job->num_files)) @@ -583,9 +583,9 @@ cupsdFinishJob(cupsd_job_t *job) /* I - Job */ cupsdRemoveSelect(job->status_buffer->fd); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] cupsdFinishJob: Closing status pipes [ %d %d ]...", - job->id, job->status_pipes[0], job->status_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "cupsdFinishJob: Closing status pipes [ %d %d ]...", + job->status_pipes[0], job->status_pipes[1]); cupsdClosePipe(job->status_pipes); cupsdStatBufDelete(job->status_buffer); @@ -618,15 +618,15 @@ cupsdFinishJob(cupsd_job_t *job) /* I - Job */ else exit_code = job->status; - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Backend returned status %d (%s)", - job->id, exit_code, - exit_code == CUPS_BACKEND_FAILED ? "failed" : - exit_code == CUPS_BACKEND_AUTH_REQUIRED ? - "authentication required" : - exit_code == CUPS_BACKEND_HOLD ? "hold job" : - exit_code == CUPS_BACKEND_STOP ? "stop printer" : - exit_code == CUPS_BACKEND_CANCEL ? "cancel job" : - exit_code < 0 ? "crashed" : "unknown"); + cupsdLogJob(job, CUPSD_LOG_INFO, "Backend returned status %d (%s)", + exit_code, + exit_code == CUPS_BACKEND_FAILED ? "failed" : + exit_code == CUPS_BACKEND_AUTH_REQUIRED ? + "authentication required" : + exit_code == CUPS_BACKEND_HOLD ? "hold job" : + exit_code == CUPS_BACKEND_STOP ? "stop printer" : + exit_code == CUPS_BACKEND_CANCEL ? "cancel job" : + exit_code < 0 ? "crashed" : "unknown"); /* * Do what needs to be done... @@ -680,10 +680,10 @@ cupsdFinishJob(cupsd_job_t *job) /* I - Job */ * Too many tries... */ - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Canceling job since it could not be " - "sent after %d tries.", - job->id, JobRetryLimit); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Canceling job since it could not be " + "sent after %d tries.", + JobRetryLimit); cupsdCancelJob(job, 0, IPP_JOB_ABORTED); } @@ -800,8 +800,7 @@ cupsdFinishJob(cupsd_job_t *job) /* I - Job */ * Filter had errors; stop job... */ - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Job stopped due to filter errors.", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, "Job stopped due to filter errors."); cupsdStopJob(job, 1); job->dirty = 1; cupsdMarkDirty(CUPSD_DIRTY_JOBS); @@ -831,8 +830,7 @@ cupsdFinishJob(cupsd_job_t *job) /* I - Job */ * Close out this job... */ - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Completed successfully.", - job->id); + cupsdLogJob(job, CUPSD_LOG_INFO, "Completed successfully."); cupsdCancelJob(job, 0, IPP_JOB_COMPLETED); cupsdCheckJobs(); } @@ -1063,8 +1061,7 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if ((job->attrs = ippNew()) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Ran out of memory for job attributes!", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, "Ran out of memory for job attributes!"); return; } @@ -1072,14 +1069,14 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ * Load job attributes... */ - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] Loading attributes...", job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Loading attributes..."); snprintf(jobfile, sizeof(jobfile), "%s/c%05d", RequestRoot, job->id); if ((fp = cupsFileOpen(jobfile, "r")) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to open job control file \"%s\" - %s!", - job->id, jobfile, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to open job control file \"%s\" - %s!", + jobfile, strerror(errno)); ippDelete(job->attrs); job->attrs = NULL; return; @@ -1087,9 +1084,9 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if (ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL, job->attrs) != IPP_DATA) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to read job control file \"%s\"!", - job->id, jobfile); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to read job control file \"%s\"!", + jobfile); cupsFileClose(fp); ippDelete(job->attrs); job->attrs = NULL; @@ -1106,10 +1103,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if ((job->state = ippFindAttribute(job->attrs, "job-state", IPP_TAG_ENUM)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Missing or bad job-state attribute in " - "control file!", - job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Missing or bad job-state attribute in control file!"); ippDelete(job->attrs); job->attrs = NULL; unlink(jobfile); @@ -1123,9 +1118,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if ((attr = ippFindAttribute(job->attrs, "job-printer-uri", IPP_TAG_URI)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] No job-printer-uri attribute in control file!", - job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "No job-printer-uri attribute in control file!"); ippDelete(job->attrs); job->attrs = NULL; unlink(jobfile); @@ -1135,9 +1129,9 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if ((dest = cupsdValidateDest(attr->values[0].string.text, &(job->dtype), &destptr)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to queue job for destination \"%s\"!", - job->id, attr->values[0].string.text); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to queue job for destination \"%s\"!", + attr->values[0].string.text); ippDelete(job->attrs); job->attrs = NULL; unlink(jobfile); @@ -1148,9 +1142,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ } else if ((destptr = cupsdFindDest(job->dest)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to queue job for destination \"%s\"!", - job->id, job->dest); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to queue job for destination \"%s\"!", job->dest); ippDelete(job->attrs); job->attrs = NULL; unlink(jobfile); @@ -1166,9 +1159,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if ((attr = ippFindAttribute(job->attrs, "job-priority", IPP_TAG_INTEGER)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Missing or bad job-priority attribute in " - "control file!", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Missing or bad job-priority attribute in control file!"); ippDelete(job->attrs); job->attrs = NULL; unlink(jobfile); @@ -1183,9 +1175,9 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if ((attr = ippFindAttribute(job->attrs, "job-originating-user-name", IPP_TAG_NAME)) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Missing or bad job-originating-user-name " - "attribute in control file!", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Missing or bad job-originating-user-name attribute in " + "control file!"); ippDelete(job->attrs); job->attrs = NULL; unlink(jobfile); @@ -1233,9 +1225,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if (access(jobfile, 0)) break; - cupsdLogMessage(CUPSD_LOG_DEBUG, - "[Job %d] Auto-typing document file \"%s\"...", - job->id, jobfile); + cupsdLogJob(job, CUPSD_LOG_DEBUG, + "Auto-typing document file \"%s\"...", jobfile); if (fileid > job->num_files) { @@ -1255,9 +1246,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ if (!compressions || !filetypes) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Ran out of memory for job file types!", - job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Ran out of memory for job file types!"); return; } @@ -1522,9 +1512,9 @@ cupsdSaveJob(cupsd_job_t *job) /* I - Job */ if ((fp = cupsFileOpen(filename, "w")) == NULL) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to create job control file \"%s\" - %s.", - job->id, filename, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to create job control file \"%s\" - %s.", + filename, strerror(errno)); return; } @@ -1535,8 +1525,7 @@ cupsdSaveJob(cupsd_job_t *job) /* I - Job */ if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL, job->attrs) != IPP_DATA) - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to write job control file!", job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to write job control file!"); cupsFileClose(fp); @@ -1756,8 +1745,7 @@ cupsdStopJob(cupsd_job_t *job, /* I - Job */ int i; /* Looping var */ - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] cupsdStopJob: force = %d", job->id, force); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "cupsdStopJob: force = %d", force); if (job->state_value != IPP_JOB_PROCESSING) return; @@ -1790,18 +1778,18 @@ cupsdStopJob(cupsd_job_t *job, /* I - Job */ cupsdDestroyProfile(job->profile); job->profile = NULL; - cupsdLogMessage(CUPSD_LOG_DEBUG2, "[Job %d] Closing print pipes [ %d %d ]...", - job->id, job->print_pipes[0], job->print_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "Closing print pipes [ %d %d ]...", + job->print_pipes[0], job->print_pipes[1]); cupsdClosePipe(job->print_pipes); - cupsdLogMessage(CUPSD_LOG_DEBUG2, "[Job %d] Closing back pipes [ %d %d ]...", - job->id, job->back_pipes[0], job->back_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "Closing back pipes [ %d %d ]...", + job->back_pipes[0], job->back_pipes[1]); cupsdClosePipe(job->back_pipes); - cupsdLogMessage(CUPSD_LOG_DEBUG2, "[Job %d] Closing side pipes [ %d %d ]...", - job->id, job->side_pipes[0], job->side_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "Closing side pipes [ %d %d ]...", + job->side_pipes[0], job->side_pipes[1]); cupsdClosePipe(job->side_pipes); @@ -1813,9 +1801,8 @@ cupsdStopJob(cupsd_job_t *job, /* I - Job */ cupsdRemoveSelect(job->status_buffer->fd); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] Closing status pipes [ %d %d ]...", job->id, - job->status_pipes[0], job->status_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "Closing status pipes [ %d %d ]...", + job->status_pipes[0], job->status_pipes[1]); cupsdClosePipe(job->status_pipes); cupsdStatBufDelete(job->status_buffer); @@ -2093,7 +2080,7 @@ load_job_cache(const char *filename) /* I - job.cache filename */ if (!job) { cupsdLogMessage(CUPSD_LOG_EMERG, - "[Job %d] Unable to allocate memory for job!", jobid); + "[Job %d] Unable to allocate memory for job!", jobid); break; } @@ -2107,7 +2094,7 @@ load_job_cache(const char *filename) /* I - job.cache filename */ job->status_pipes[0] = -1; job->status_pipes[1] = -1; - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] Loading from cache...", job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Loading from cache..."); } else if (!job) { @@ -2175,8 +2162,7 @@ load_job_cache(const char *filename) /* I - job.cache filename */ job->id); if (access(jobfile, 0)) { - cupsdLogMessage(CUPSD_LOG_INFO, - "[Job %d] Data files have gone away!", job->id); + cupsdLogJob(job, CUPSD_LOG_INFO, "Data files have gone away!"); job->num_files = 0; continue; } @@ -2186,9 +2172,9 @@ load_job_cache(const char *filename) /* I - job.cache filename */ if (!job->filetypes || !job->compressions) { - cupsdLogMessage(CUPSD_LOG_EMERG, - "[Job %d] Unable to allocate memory for %d files!", - job->id, job->num_files); + cupsdLogJob(job, CUPSD_LOG_EMERG, + "Unable to allocate memory for %d files!", + job->num_files); break; } } @@ -2226,9 +2212,9 @@ load_job_cache(const char *filename) /* I - job.cache filename */ * If the original MIME type is unknown, auto-type it! */ - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unknown MIME type %s/%s for file %d!", - job->id, super, type, number + 1); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unknown MIME type %s/%s for file %d!", + super, type, number + 1); snprintf(jobfile, sizeof(jobfile), "%s/d%05d-%03d", RequestRoot, job->id, number + 1); @@ -2519,14 +2505,12 @@ start_job(cupsd_job_t *job, /* I - Job ID */ static int optlength = 0; /* Length of option buffer */ - cupsdLogMessage(CUPSD_LOG_DEBUG2, "[Job %d] start_job: file = %d/%d", - job->id, job->current_file, job->num_files); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "start_job: file = %d/%d", + job->current_file, job->num_files); if (job->num_files == 0) { - cupsdLogMessage(CUPSD_LOG_ERROR, "[Job %d] No files, canceling job!", - job->id); - + cupsdLogJob(job, CUPSD_LOG_ERROR, "No files, canceling job!"); cupsdCancelJob(job, 0, IPP_JOB_ABORTED); return; } @@ -2546,8 +2530,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ * filtering... */ - cupsdLogMessage(CUPSD_LOG_DEBUG, - "[Job %d] Sending job to queue tagged as raw...", job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Sending job to queue tagged as raw..."); filters = NULL; } @@ -2562,9 +2545,9 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (!filters) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to convert file %d to printable format!", - job->current_file, job->id); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to convert file %d to printable format!", + job->current_file); cupsdLogMessage(CUPSD_LOG_INFO, "Hint: Do you have Ghostscript installed?"); @@ -2645,13 +2628,12 @@ start_job(cupsd_job_t *job, /* I - Job ID */ cupsArrayDelete(filters); - cupsdLogMessage(CUPSD_LOG_INFO, - "[Job %d] Holding because filter limit has been reached.", - job->id); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: file=%d, cost=%d, level=%d, limit=%d", - job->id, job->current_file, job->cost, FilterLevel, - FilterLimit); + cupsdLogJob(job, CUPSD_LOG_INFO, + "Holding because filter limit has been reached."); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: file=%d, cost=%d, level=%d, limit=%d", + job->current_file, job->cost, FilterLevel, + FilterLimit); return; } @@ -2674,9 +2656,8 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (!cupsArrayInsert(filters, &gziptoany_filter)) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to add decompression filter - %s", - job->id, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to add decompression filter - %s", strerror(errno)); cupsArrayDelete(filters); @@ -2711,9 +2692,8 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (!cupsArrayAdd(filters, &port_monitor)) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to add port monitor - %s", - job->id, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to add port monitor - %s", strerror(errno)); cupsArrayDelete(filters); @@ -2732,9 +2712,9 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (cupsArrayCount(filters) > MAX_FILTERS) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Too many filters (%d > %d), unable to print!", - job->id, cupsArrayCount(filters), MAX_FILTERS); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Too many filters (%d > %d), unable to print!", + cupsArrayCount(filters), MAX_FILTERS); cupsArrayDelete(filters); cupsdCancelJob(job, 0, IPP_JOB_STOPPED); @@ -2801,21 +2781,19 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (job->job_sheets == NULL) { - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] No job-sheets attribute.", - job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "No job-sheets attribute."); if ((job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_ZERO)) != NULL) - cupsdLogMessage(CUPSD_LOG_DEBUG, - "[Job %d] ... but someone added one without setting " - "job_sheets!", job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, + "... but someone added one without setting job_sheets!"); } else if (job->job_sheets->num_values == 1) - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] job-sheets=%s", job->id, - job->job_sheets->values[0].string.text); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "job-sheets=%s", + job->job_sheets->values[0].string.text); else - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] job-sheets=%s,%s", job->id, - job->job_sheets->values[0].string.text, - job->job_sheets->values[1].string.text); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "job-sheets=%s,%s", + job->job_sheets->values[0].string.text, + job->job_sheets->values[1].string.text); if (printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) banner_page = 0; @@ -2831,8 +2809,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ else banner_page = 0; - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] banner_page = %d", job->id, - banner_page); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "banner_page = %d", banner_page); /* * Building the options string is harder than it needs to be, but @@ -2853,9 +2830,8 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (optptr == NULL) { - cupsdLogMessage(CUPSD_LOG_CRIT, - "[Job %d] Unable to allocate %d bytes for option buffer!", - job->id, i); + cupsdLogJob(job, CUPSD_LOG_CRIT, + "Unable to allocate %d bytes for option buffer!", i); cupsArrayDelete(filters); @@ -3080,8 +3056,8 @@ start_job(cupsd_job_t *job, /* I - Job ID */ } for (i = 0; argv[i]; i ++) - cupsdLogMessage(CUPSD_LOG_DEBUG, - "[Job %d] argv[%d]=\"%s\"", job->id, i, argv[i]); + cupsdLogJob(job, CUPSD_LOG_DEBUG, + "argv[%d]=\"%s\"", i, argv[i]); /* * Create environment variable strings for the filters... @@ -3220,14 +3196,13 @@ start_job(cupsd_job_t *job, /* I - Job ID */ for (i = 0; i < envc; i ++) if (!strncmp(envp[i], "AUTH_", 5)) - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] envp[%d]=\"AUTH_%c****\"", - job->id, i, envp[i][5]); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "envp[%d]=\"AUTH_%c****\"", i, + envp[i][5]); else if (strncmp(envp[i], "DEVICE_URI=", 11)) - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] envp[%d]=\"%s\"", - job->id, i, envp[i]); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "envp[%d]=\"%s\"", i, envp[i]); else - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] envp[%d]=\"DEVICE_URI=%s\"", - job->id, i, sani_uri); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "envp[%d]=\"DEVICE_URI=%s\"", i, + sani_uri); if (printer->remote) job->current_file = job->num_files; @@ -3247,9 +3222,8 @@ start_job(cupsd_job_t *job, /* I - Job ID */ { if (cupsdOpenPipe(job->status_pipes)) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to create job status pipes - %s.", - job->id, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to create job status pipes - %s.", strerror(errno)); snprintf(printer->state_message, sizeof(printer->state_message), "Unable to create status pipes - %s.", strerror(errno)); @@ -3262,12 +3236,11 @@ start_job(cupsd_job_t *job, /* I - Job ID */ goto abort_job; } - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: status_pipes = [ %d %d ]", - job->id, job->status_pipes[0], job->status_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: status_pipes = [ %d %d ]", + job->status_pipes[0], job->status_pipes[1]); - job->status_buffer = cupsdStatBufNew(job->status_pipes[0], "[Job %d]", - job->id); + job->status_buffer = cupsdStatBufNew(job->status_pipes[0], NULL); job->status_level = CUPSD_LOG_INFO; } @@ -3291,9 +3264,8 @@ start_job(cupsd_job_t *job, /* I - Job ID */ { if (cupsdOpenPipe(filterfds[slot])) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to create job filter pipes - %s.", - job->id, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to create job filter pipes - %s.", strerror(errno)); snprintf(printer->state_message, sizeof(printer->state_message), "Unable to create filter pipes - %s.", strerror(errno)); cupsdAddPrinterHistory(printer); @@ -3313,9 +3285,9 @@ start_job(cupsd_job_t *job, /* I - Job ID */ { if (cupsdOpenPipe(job->print_pipes)) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to create job backend pipes - %s.", - job->id, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to create job backend pipes - %s.", + strerror(errno)); snprintf(printer->state_message, sizeof(printer->state_message), "Unable to create backend pipes - %s.", strerror(errno)); cupsdAddPrinterHistory(printer); @@ -3350,9 +3322,9 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (job->print_pipes[1] < 0) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to open output file \"%s\" - %s.", - job->id, printer->device_uri, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, + "Unable to open output file \"%s\" - %s.", + printer->device_uri, strerror(errno)); snprintf(printer->state_message, sizeof(printer->state_message), "Unable to open output file \"%s\" - %s.", printer->device_uri, strerror(errno)); @@ -3369,38 +3341,34 @@ start_job(cupsd_job_t *job, /* I - Job ID */ } } - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: print_pipes = [ %d %d ]", - job->id, job->print_pipes[0], job->print_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: print_pipes = [ %d %d ]", + job->print_pipes[0], job->print_pipes[1]); } filterfds[slot][0] = job->print_pipes[0]; filterfds[slot][1] = job->print_pipes[1]; } - cupsdLogMessage(CUPSD_LOG_DEBUG2, "[Job %d] start_job: filter=\"%s\"", - job->id, command); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: filterfds[%d]=[ %d %d ]", - job->id, slot, filterfds[slot][0], filterfds[slot][1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "start_job: filter=\"%s\"", command); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "start_job: filterfds[%d]=[ %d %d ]", + slot, filterfds[slot][0], filterfds[slot][1]); pid = cupsdStartProcess(command, argv, envp, filterfds[!slot][0], filterfds[slot][1], job->status_pipes[1], job->back_pipes[0], job->side_pipes[0], 0, job->profile, job->filters + i); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing filter pipes for slot %d " - "[ %d %d ]...", - job->id, !slot, filterfds[!slot][0], filterfds[!slot][1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing filter pipes for slot %d [ %d %d ]...", + !slot, filterfds[!slot][0], filterfds[!slot][1]); cupsdClosePipe(filterfds[!slot]); if (pid == 0) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to start filter \"%s\" - %s.", - job->id, filter->filter, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to start filter \"%s\" - %s.", + filter->filter, strerror(errno)); snprintf(printer->state_message, sizeof(printer->state_message), "Unable to start filter \"%s\" - %s.", filter->filter, strerror(errno)); @@ -3414,14 +3382,15 @@ start_job(cupsd_job_t *job, /* I - Job ID */ goto abort_job; } - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Started filter %s (PID %d)", - job->id, command, pid); + cupsdLogJob(job, CUPSD_LOG_INFO, "Started filter %s (PID %d)", command, + pid); argv[6] = NULL; slot = !slot; } cupsArrayDelete(filters); + filters = NULL; /* * Finally, pipe the final output into a backend process if needed... @@ -3450,11 +3419,9 @@ start_job(cupsd_job_t *job, /* I - Job ID */ filterfds[slot][0] = -1; filterfds[slot][1] = -1; - cupsdLogMessage(CUPSD_LOG_DEBUG2, "[Job %d] start_job: backend=\"%s\"", - job->id, command); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: filterfds[%d] = [ %d %d ]", job->id, - slot, filterfds[slot][0], filterfds[slot][1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "start_job: backend=\"%s\"", command); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, "start_job: filterfds[%d] = [ %d %d ]", + slot, filterfds[slot][0], filterfds[slot][1]); pid = cupsdStartProcess(command, argv, envp, filterfds[!slot][0], filterfds[slot][1], job->status_pipes[1], @@ -3463,9 +3430,8 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (pid == 0) { - cupsdLogMessage(CUPSD_LOG_ERROR, - "[Job %d] Unable to start backend \"%s\" - %s.", - job->id, method, strerror(errno)); + cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to start backend \"%s\" - %s.", + method, strerror(errno)); snprintf(printer->state_message, sizeof(printer->state_message), "Unable to start backend \"%s\" - %s.", method, strerror(errno)); @@ -3478,34 +3444,34 @@ start_job(cupsd_job_t *job, /* I - Job ID */ } else { - cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Started backend %s (PID %d)", - job->id, command, pid); + cupsdLogJob(job, CUPSD_LOG_INFO, "Started backend %s (PID %d)", + command, pid); } } if (job->current_file == job->num_files) { - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing print pipes [ %d %d ]...", - job->id, job->print_pipes[0], job->print_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing print pipes [ %d %d ]...", + job->print_pipes[0], job->print_pipes[1]); cupsdClosePipe(job->print_pipes); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing back pipes [ %d %d ]...", - job->id, job->back_pipes[0], job->back_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing back pipes [ %d %d ]...", + job->back_pipes[0], job->back_pipes[1]); cupsdClosePipe(job->back_pipes); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing side pipes [ %d %d ]...", - job->id, job->side_pipes[0], job->side_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing side pipes [ %d %d ]...", + job->side_pipes[0], job->side_pipes[1]); cupsdClosePipe(job->side_pipes); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing status output pipe %d...", - job->id, job->status_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing status output pipe %d...", + job->status_pipes[1]); close(job->status_pipes[1]); job->status_pipes[1] = -1; @@ -3518,25 +3484,24 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (job->current_file == job->num_files) { - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing print pipes [ %d %d ]...", - job->id, job->print_pipes[0], job->print_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing print pipes [ %d %d ]...", + job->print_pipes[0], job->print_pipes[1]); cupsdClosePipe(job->print_pipes); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing status output pipe %d...", - job->id, job->status_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing status output pipe %d...", + job->status_pipes[1]); close(job->status_pipes[1]); job->status_pipes[1] = -1; } } - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing filter pipes for slot %d " - "[ %d %d ]...", - job->id, slot, filterfds[slot][0], filterfds[slot][1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing filter pipes for slot %d [ %d %d ]...", + slot, filterfds[slot][0], filterfds[slot][1]); cupsdClosePipe(filterfds[slot]); if (printer->remote && job->num_files > 1) @@ -3565,16 +3530,15 @@ start_job(cupsd_job_t *job, /* I - Job ID */ for (slot = 0; slot < 2; slot ++) { - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing filter pipes for slot %d " - "[ %d %d ]...", - job->id, slot, filterfds[slot][0], filterfds[slot][1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing filter pipes for slot %d [ %d %d ]...", + slot, filterfds[slot][0], filterfds[slot][1]); cupsdClosePipe(filterfds[slot]); } - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "[Job %d] start_job: Closing status pipes [ %d %d ]...", - job->id, job->status_pipes[0], job->status_pipes[1]); + cupsdLogJob(job, CUPSD_LOG_DEBUG2, + "start_job: Closing status pipes [ %d %d ]...", + job->status_pipes[0], job->status_pipes[1]); cupsdClosePipe(job->status_pipes); cupsdStatBufDelete(job->status_buffer); @@ -3604,7 +3568,7 @@ unload_job(cupsd_job_t *job) /* I - Job */ if (!job->attrs) return; - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] Unloading...", job->id); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Unloading..."); ippDelete(job->attrs); @@ -3646,8 +3610,7 @@ update_job(cupsd_job_t *job) /* I - Job to check */ * job sheet count... */ - if (LogLevel >= CUPSD_LOG_DEBUG) - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] PAGE: %s", job->id, message); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "PAGE: %s", message); if (job->sheets) { @@ -3677,11 +3640,11 @@ update_job(cupsd_job_t *job) /* I - Job to check */ * Quota limit exceeded, cancel job in progress immediately... */ - cupsdLogMessage(CUPSD_LOG_INFO, - "[Job %d] Canceled because pages exceed user %s " - "quota limit on printer %s (%s).", - job->id, job->username, job->printer->name, - job->printer->info); + cupsdLogJob(job, CUPSD_LOG_INFO, + "Canceled because pages exceed user %s " + "quota limit on printer %s (%s).", + job->username, job->printer->name, + job->printer->info); cupsdCancelJob(job, 1, IPP_JOB_CANCELED); return; @@ -3700,9 +3663,7 @@ update_job(cupsd_job_t *job) /* I - Job to check */ } else if (loglevel == CUPSD_LOG_STATE) { - if (LogLevel >= CUPSD_LOG_DEBUG) - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] STATE: %s", job->id, - message); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "STATE: %s", message); if (!strcmp(message, "paused")) { @@ -3729,8 +3690,7 @@ update_job(cupsd_job_t *job) /* I - Job to check */ const char *attr; /* Attribute */ - if (LogLevel >= CUPSD_LOG_DEBUG) - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] ATTR: %s", job->id, message); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "ATTR: %s", message); num_attrs = cupsParseOptions(message, 0, &attrs); @@ -3773,6 +3733,13 @@ update_job(cupsd_job_t *job) /* I - Job to check */ event |= CUPSD_EVENT_PRINTER_STATE; } + if ((attr = cupsGetOption("marker-message", num_attrs, attrs)) != NULL) + { + cupsdSetPrinterAttr(job->printer, "marker-message", (char *)attr); + job->printer->marker_time = time(NULL); + event |= CUPSD_EVENT_PRINTER_STATE; + } + if ((attr = cupsGetOption("marker-names", num_attrs, attrs)) != NULL) { cupsdSetPrinterAttr(job->printer, "marker-names", (char *)attr); @@ -3799,8 +3766,7 @@ update_job(cupsd_job_t *job) /* I - Job to check */ cups_option_t *keywords; /* Keywords */ - if (LogLevel >= CUPSD_LOG_DEBUG) - cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] PPD: %s", job->id, message); + cupsdLogJob(job, CUPSD_LOG_DEBUG, "PPD: %s", message); num_keywords = cupsParseOptions(message, 0, &keywords); @@ -3837,23 +3803,28 @@ update_job(cupsd_job_t *job) /* I - Job to check */ event |= CUPSD_EVENT_PRINTER_STATE; } #endif /* __APPLE__ */ - else if (loglevel <= job->status_level) + else { - /* - * Some message to show in the printer-state-message attribute... - */ + cupsdLogJob(job, loglevel, "%s", message); - if (loglevel != CUPSD_LOG_NOTICE) - job->status_level = loglevel; + if (loglevel <= job->status_level) + { + /* + * Some messages show in the printer-state-message attribute... + */ - strlcpy(job->printer->state_message, message, - sizeof(job->printer->state_message)); - cupsdAddPrinterHistory(job->printer); + if (loglevel != CUPSD_LOG_NOTICE) + job->status_level = loglevel; - if (loglevel <= CUPSD_LOG_INFO) - event |= CUPSD_EVENT_PRINTER_STATE; + strlcpy(job->printer->state_message, message, + sizeof(job->printer->state_message)); + cupsdAddPrinterHistory(job->printer); - update_job_attrs(job); + if (loglevel <= CUPSD_LOG_INFO) + event |= CUPSD_EVENT_PRINTER_STATE; + + update_job_attrs(job); + } } if (!strchr(job->status_buffer->buffer, '\n')) @@ -3971,5 +3942,5 @@ update_job_attrs(cupsd_job_t *job) /* I - Job to update */ /* - * End of "$Id: job.c 7005 2007-10-01 23:45:48Z mike $". + * End of "$Id: job.c 7682 2008-06-21 00:06:02Z mike $". */ diff --git a/scheduler/job.h b/scheduler/job.h index 09bf75ce0..e1e304324 100644 --- a/scheduler/job.h +++ b/scheduler/job.h @@ -1,5 +1,5 @@ /* - * "$Id: job.h 6755 2007-08-01 19:02:47Z mike $" + * "$Id: job.h 7468 2008-04-18 18:31:59Z mike $" * * Print job definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -131,5 +131,5 @@ extern void cupsdUnloadCompletedJobs(void); /* - * End of "$Id: job.h 6755 2007-08-01 19:02:47Z mike $". + * End of "$Id: job.h 7468 2008-04-18 18:31:59Z mike $". */ diff --git a/scheduler/libcupsmime.exp b/scheduler/libcupsmime.exp index bf2fa4c02..dfe99c290 100644 --- a/scheduler/libcupsmime.exp +++ b/scheduler/libcupsmime.exp @@ -10,8 +10,8 @@ _mimeFilterLookup _mimeFirstFilter _mimeFirstType _mimeLoad -_mimeMerge -_mimeNew +_mimeLoadFilters +_mimeLoadTypes _mimeNextFilter _mimeNextType _mimeNumFilters diff --git a/scheduler/listen.c b/scheduler/listen.c index 931bc9de1..361ff677c 100644 --- a/scheduler/listen.c +++ b/scheduler/listen.c @@ -1,5 +1,5 @@ /* - * "$Id: listen.c 6788 2007-08-13 17:20:14Z mike $" + * "$Id: listen.c 7673 2008-06-18 22:31:26Z mike $" * * Server listening routines for the Common UNIX Printing System (CUPS) * scheduler. @@ -151,7 +151,7 @@ cupsdStartListening(void) if ((ServerAddrs = httpAddrGetList(ServerName, AF_UNSPEC, NULL)) == NULL) cupsdLogMessage(CUPSD_LOG_ERROR, - "Unable to find IP address for server name \"%s\"!\n", + "Unable to find IP address for server name \"%s\"!", ServerName); /* @@ -428,5 +428,5 @@ cupsdStopListening(void) /* - * End of "$Id: listen.c 6788 2007-08-13 17:20:14Z mike $". + * End of "$Id: listen.c 7673 2008-06-18 22:31:26Z mike $". */ diff --git a/scheduler/log.c b/scheduler/log.c index 4a21b0856..fde21215e 100644 --- a/scheduler/log.c +++ b/scheduler/log.c @@ -1,5 +1,5 @@ /* - * "$Id: log.c 6875 2007-08-27 23:25:06Z mike $" + * "$Id: log.c 7697 2008-06-27 15:56:00Z mike $" * * Log file routines for the Common UNIX Printing System (CUPS). * @@ -16,10 +16,13 @@ * * cupsdGetDateTime() - Returns a pointer to a date/time string. * cupsdLogGSSMessage() - Log a GSSAPI error... + * cupsdLogJob() - Log a job message. * cupsdLogMessage() - Log a message to the error log file. * cupsdLogPage() - Log a page to the page log file. * cupsdLogRequest() - Log an HTTP request in Common Log Format. + * cupsdWriteErrorLog() - Write a line to the ErrorLog. * check_log_file() - Open/rotate a log file if it needs it. + * format_log_line() - Format a line for a log file. */ /* @@ -32,10 +35,19 @@ /* + * Local globals... + */ + +static int log_linesize = 0; /* Size of line for output file */ +static char *log_line = NULL; /* Line for output file */ + + +/* * Local functions... */ -static int check_log_file(cups_file_t **, const char *); +static int check_log_file(cups_file_t **lf, const char *logname); +static char *format_log_line(const char *message, va_list ap); /* @@ -157,176 +169,94 @@ cupsdLogGSSMessage( /* - * 'cupsdLogMessage()' - Log a message to the error log file. + * 'cupsdLogJob()' - Log a job message. */ int /* O - 1 on success, 0 on error */ -cupsdLogMessage(int level, /* I - Log level */ - const char *message, /* I - printf-style message string */ - ...) /* I - Additional args as needed */ +cupsdLogJob(cupsd_job_t *job, /* I - Job */ + int level, /* I - Log level */ + const char *message, /* I - Printf-style message string */ + ...) /* I - Additional arguments as needed */ { - int len; /* Length of message */ va_list ap; /* Argument pointer */ - static const char levels[] = /* Log levels... */ - { - ' ', - 'X', - 'A', - 'C', - 'E', - 'W', - 'N', - 'I', - 'D', - 'd' - }; -#ifdef HAVE_VSYSLOG - static const int syslevels[] = /* SYSLOG levels... */ - { - 0, - LOG_EMERG, - LOG_ALERT, - LOG_CRIT, - LOG_ERR, - LOG_WARNING, - LOG_NOTICE, - LOG_INFO, - LOG_DEBUG, - LOG_DEBUG - }; -#endif /* HAVE_VSYSLOG */ - static int linesize = 0; /* Size of line for output file */ - static char *line = NULL; /* Line for output file */ + char jobmsg[1024], /* Format string for job message */ + *line; /* Message line */ /* * See if we want to log this message... */ - if (TestConfigFile) - { - if (level <= CUPSD_LOG_WARN) - { - va_start(ap, message); - vfprintf(stderr, message, ap); - putc('\n', stderr); - va_end(ap); - } - + if (TestConfigFile || level > LogLevel || !ErrorLog) return (1); - } if (level > LogLevel || !ErrorLog) return (1); -#ifdef HAVE_VSYSLOG - /* - * See if we are logging errors via syslog... - */ - - if (!strcmp(ErrorLog, "syslog")) - { - va_start(ap, message); - vsyslog(syslevels[level], message, ap); - va_end(ap); - - return (1); - } -#endif /* HAVE_VSYSLOG */ - - /* - * Not using syslog; check the log file... - */ - - if (!check_log_file(&ErrorFile, ErrorLog)) - return (0); - /* - * Print the log level and date/time... + * Format and write the log message... */ - cupsFilePrintf(ErrorFile, "%c %s ", levels[level], cupsdGetDateTime(time(NULL))); + snprintf(jobmsg, sizeof(jobmsg), "[Job %d] %s", job->id, message); - /* - * Allocate the line buffer as needed... - */ + va_start(ap, message); + line = format_log_line(jobmsg, ap); + va_end(ap); - if (!linesize) - { - linesize = 8192; - line = malloc(linesize); + if (line) + return (cupsdWriteErrorLog(level, line)); + else + return (cupsdWriteErrorLog(CUPSD_LOG_ERROR, + "Unable to allocate memory for log line!")); +} - if (!line) - { - cupsFilePrintf(ErrorFile, - "ERROR: Unable to allocate memory for line - %s\n", - strerror(errno)); - cupsFileFlush(ErrorFile); - return (0); - } - } +/* + * 'cupsdLogMessage()' - Log a message to the error log file. + */ - /* - * Format the log message... - */ +int /* O - 1 on success, 0 on error */ +cupsdLogMessage(int level, /* I - Log level */ + const char *message, /* I - printf-style message string */ + ...) /* I - Additional args as needed */ +{ + va_list ap; /* Argument pointer */ + char *line; /* Message line */ - va_start(ap, message); - len = vsnprintf(line, linesize, message, ap); - va_end(ap); /* - * Resize the buffer as needed... + * See if we want to log this message... */ - if (len >= linesize) + if (TestConfigFile) { - char *temp; /* Temporary string pointer */ - - - len ++; - - if (len < 8192) - len = 8192; - else if (len > 65536) - len = 65536; - - temp = realloc(line, len); - - if (temp) + if (level <= CUPSD_LOG_WARN) { - line = temp; - linesize = len; + va_start(ap, message); + vfprintf(stderr, message, ap); + putc('\n', stderr); + va_end(ap); } - va_start(ap, message); - len = vsnprintf(line, linesize, message, ap); - va_end(ap); + return (1); } - if (len >= linesize) - len = linesize - 1; - - /* - * Then the log message... - */ - - cupsFilePuts(ErrorFile, line); - - /* - * Then a newline... - */ - - if (len > 0 && line[len - 1] != '\n') - cupsFilePutChar(ErrorFile, '\n'); + if (level > LogLevel || !ErrorLog) + return (1); /* - * Flush the line to the file and return... + * Format and write the log message... */ - cupsFileFlush(ErrorFile); + va_start(ap, message); + line = format_log_line(message, ap); + va_end(ap); - return (1); + if (line) + return (cupsdWriteErrorLog(level, line)); + else + return (cupsdWriteErrorLog(CUPSD_LOG_ERROR, + "Unable to allocate memory for log line!")); } @@ -414,8 +344,10 @@ cupsdLogPage(cupsd_job_t *job, /* I - Job being printed */ * Pull the name from inside the brackets... */ - memcpy(name, format + 1, nameend - format - 2); - name[nameend - format - 2] = '\0'; + memcpy(name, format + 1, nameend - format - 1); + name[nameend - format - 1] = '\0'; + + format = nameend; if ((attr = ippFindAttribute(job->attrs, name, IPP_TAG_ZERO)) != NULL) @@ -424,8 +356,6 @@ cupsdLogPage(cupsd_job_t *job, /* I - Job being printed */ * Add the attribute value... */ - format = nameend; - for (i = 0; i < attr->num_values && bufptr < (buffer + sizeof(buffer) - 1); @@ -607,6 +537,75 @@ cupsdLogRequest(cupsd_client_t *con, /* I - Request to log */ /* + * 'cupsdWriteErrorLog()' - Write a line to the ErrorLog. + */ + +int /* O - 1 on success, 0 on failure */ +cupsdWriteErrorLog(int level, /* I - Log level */ + const char *message) /* I - Message string */ +{ + static const char levels[] = /* Log levels... */ + { + ' ', + 'X', + 'A', + 'C', + 'E', + 'W', + 'N', + 'I', + 'D', + 'd' + }; +#ifdef HAVE_VSYSLOG + static const int syslevels[] = /* SYSLOG levels... */ + { + 0, + LOG_EMERG, + LOG_ALERT, + LOG_CRIT, + LOG_ERR, + LOG_WARNING, + LOG_NOTICE, + LOG_INFO, + LOG_DEBUG, + LOG_DEBUG + }; +#endif /* HAVE_VSYSLOG */ + + +#ifdef HAVE_VSYSLOG + /* + * See if we are logging errors via syslog... + */ + + if (!strcmp(ErrorLog, "syslog")) + { + syslog(syslevels[level], "%s", message); + return (1); + } +#endif /* HAVE_VSYSLOG */ + + /* + * Not using syslog; check the log file... + */ + + if (!check_log_file(&ErrorFile, ErrorLog)) + return (0); + + /* + * Write the log message... + */ + + cupsFilePrintf(ErrorFile, "%c %s %s\n", levels[level], + cupsdGetDateTime(time(NULL)), message); + cupsFileFlush(ErrorFile); + + return (1); +} + + +/* * 'check_log_file()' - Open/rotate a log file if it needs it. */ @@ -765,5 +764,70 @@ check_log_file(cups_file_t **lf, /* IO - Log file */ /* - * End of "$Id: log.c 6875 2007-08-27 23:25:06Z mike $". + * 'format_log_line()' - Format a line for a log file. + * + * This function resizes a global string buffer as needed. Each call returns + * a pointer to this buffer, so the contents are only good until the next call + * to format_log_line()... + */ + +static char * /* O - Text or NULL on error */ +format_log_line(const char *message, /* I - Printf-style format string */ + va_list ap) /* I - Argument list */ +{ + int len; /* Length of formatted line */ + + + /* + * Allocate the line buffer as needed... + */ + + if (!log_linesize) + { + log_linesize = 8192; + log_line = malloc(log_linesize); + + if (!log_line) + return (NULL); + } + + /* + * Format the log message... + */ + + len = vsnprintf(log_line, log_linesize, message, ap); + + /* + * Resize the buffer as needed... + */ + + if (len >= log_linesize) + { + char *temp; /* Temporary string pointer */ + + + len ++; + + if (len < 8192) + len = 8192; + else if (len > 65536) + len = 65536; + + temp = realloc(log_line, len); + + if (temp) + { + log_line = temp; + log_linesize = len; + } + + len = vsnprintf(log_line, log_linesize, message, ap); + } + + return (log_line); +} + + +/* + * End of "$Id: log.c 7697 2008-06-27 15:56:00Z mike $". */ diff --git a/scheduler/main.c b/scheduler/main.c index 54334523b..e3319467a 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -1,5 +1,5 @@ /* - * "$Id: main.c 6914 2007-09-05 21:05:04Z mike $" + * "$Id: main.c 7681 2008-06-20 21:06:02Z mike $" * * Scheduler main loop for the Common UNIX Printing System (CUPS). * @@ -489,7 +489,7 @@ main(int argc, /* I - Number of command-line args */ { snprintf(tempfile, sizeof(tempfile), "%s/%s", TempDir, dent->filename); - if (cupsdRemoveFile(tempfile)) + if (unlink(tempfile)) cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to remove temporary file \"%s\" - %s", tempfile, strerror(errno)); @@ -2019,5 +2019,5 @@ usage(int status) /* O - Exit status */ /* - * End of "$Id: main.c 6914 2007-09-05 21:05:04Z mike $". + * End of "$Id: main.c 7681 2008-06-20 21:06:02Z mike $". */ diff --git a/scheduler/mime.c b/scheduler/mime.c index cee81209e..890f2ea06 100644 --- a/scheduler/mime.c +++ b/scheduler/mime.c @@ -1,5 +1,5 @@ /* - * "$Id: mime.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: mime.c 7694 2008-06-26 00:23:20Z mike $" * * MIME database file routines for the Common UNIX Printing System (CUPS). * @@ -72,6 +72,7 @@ static void load_convs(mime_t *mime, const char *filename, const char *filterpath, cups_array_t *filtercache); static void load_types(mime_t *mime, const char *filename); +static mime_t *mime_new(void); /* @@ -192,73 +193,50 @@ mimeFirstType(mime_t *mime) /* I - MIME database */ /* * 'mimeLoad()' - Create a new MIME database from disk. + * + * This function uses @link mimeLoadFilters@ and @link mimeLoadTypes@ to + * create a MIME database from a single directory. */ mime_t * /* O - New MIME database */ mimeLoad(const char *pathname, /* I - Directory to load */ const char *filterpath) /* I - Directory to load */ { - return (mimeMerge(NULL, pathname, filterpath)); + return (mimeLoadFilters(mimeLoadTypes(NULL, pathname), pathname, filterpath)); } /* - * 'mimeMerge()' - Merge a MIME database from disk with the current one. + * 'mimeLoadFilters()' - Load filter definitions from disk. + * + * This function loads all of the .convs files from the specified directory. + * Use @link mimeLoadTypes@ to load all types before you load the filters. */ -mime_t * /* O - Updated MIME database */ -mimeMerge(mime_t *mime, /* I - MIME database to add to */ - const char *pathname, /* I - Directory to load */ - const char *filterpath) /* I - Directory to load */ +mime_t * /* O - MIME database */ +mimeLoadFilters(mime_t *mime, /* I - MIME database */ + const char *pathname, /* I - Directory to load from */ + const char *filterpath) /* I - Default filter program directory */ { cups_dir_t *dir; /* Directory */ cups_dentry_t *dent; /* Directory entry */ - char filename[1024]; /* Full filename of types/converts file */ + char filename[1024]; /* Full filename of .convs file */ cups_array_t *filtercache; /* Filter cache */ /* - * First open the directory specified by pathname... Return NULL if nothing - * was read or if the pathname is NULL... + * Range check input... */ - if (!pathname) - return (NULL); - - if ((dir = cupsDirOpen(pathname)) == NULL) - return (NULL); + if (!mime || !pathname || !filterpath) + return (mime); /* - * If "mime" is NULL, make a new, blank database... + * Then open the directory specified by pathname... */ - if (!mime) - mime = mimeNew(); - if (!mime) - { - cupsDirClose(dir); - return (NULL); - } - - /* - * Read all the .types files... - */ - - while ((dent = cupsDirRead(dir)) != NULL) - { - if (strlen(dent->filename) > 6 && - !strcmp(dent->filename + strlen(dent->filename) - 6, ".types")) - { - /* - * Load a mime.types file... - */ - - snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename); - load_types(mime, filename); - } - } - - cupsDirRewind(dir); + if ((dir = cupsDirOpen(pathname)) == NULL) + return (mime); /* * Read all the .convs files... @@ -289,13 +267,62 @@ mimeMerge(mime_t *mime, /* I - MIME database to add to */ /* - * 'mimeNew()' - Create a new, empty MIME database. + * 'mimeLoadTypes()' - Load type definitions from disk. + * + * This function loads all of the .types files from the specified directory. + * Use @link mimeLoadFilters@ to load all filters after you load the types. */ mime_t * /* O - MIME database */ -mimeNew(void) +mimeLoadTypes(mime_t *mime, /* I - MIME database or @code NULL@ to create a new one */ + const char *pathname) /* I - Directory to load from */ { - return ((mime_t *)calloc(1, sizeof(mime_t))); + cups_dir_t *dir; /* Directory */ + cups_dentry_t *dent; /* Directory entry */ + char filename[1024]; /* Full filename of .types file */ + + + /* + * First open the directory specified by pathname... + */ + + if ((dir = cupsDirOpen(pathname)) == NULL) + return (mime); + + /* + * If "mime" is NULL, make a new, empty database... + */ + + if (!mime) + mime = mime_new(); + + if (!mime) + { + cupsDirClose(dir); + return (NULL); + } + + /* + * Read all the .types files... + */ + + while ((dent = cupsDirRead(dir)) != NULL) + { + if (strlen(dent->filename) > 6 && + !strcmp(dent->filename + strlen(dent->filename) - 6, ".types")) + { + /* + * Load a mime.types file... + */ + + snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename); + load_types(mime, filename); + } + } + + cupsDirClose(dir); + + return (mime); } @@ -474,6 +501,10 @@ load_convs(mime_t *mime, /* I - MIME database */ int cost; /* Cost of filter */ + DEBUG_printf(("load_convs(mime=%p, filename=\"%s\", filterpath=\"%s\", " + "filtercache=%p)\n", mime, filename, filterpath, filtercache)); + + /* * First try to open the file... */ @@ -481,8 +512,6 @@ load_convs(mime_t *mime, /* I - MIME database */ if ((fp = cupsFileOpen(filename, "r")) == NULL) return; - DEBUG_printf(("\"%s\":\n", filename)); - /* * Then read each line from the file, skipping any comments in the file... */ @@ -493,8 +522,6 @@ load_convs(mime_t *mime, /* I - MIME database */ * Skip blank lines and lines starting with a #... */ - DEBUG_puts(line); - if (!line[0] || line[0] == '#') continue; @@ -544,7 +571,8 @@ load_convs(mime_t *mime, /* I - MIME database */ if ((dsttype = mimeType(mime, super, type)) == NULL) { - DEBUG_printf((" Destination type %s/%s not found!\n", super, type)); + DEBUG_printf(("load_convs: Destination type %s/%s not found!\n", + super, type)); continue; } @@ -578,7 +606,8 @@ load_convs(mime_t *mime, /* I - MIME database */ if (!add_fcache(filtercache, filter, filterpath)) { - DEBUG_printf((" Filter %s not found in %s!\n", filter, filterpath)); + DEBUG_printf(("load_convs: Filter %s not found in %s!\n", filter, + filterpath)); continue; } } @@ -653,6 +682,8 @@ load_types(mime_t *mime, /* I - MIME database */ mime_type_t *typeptr; /* New MIME type */ + DEBUG_printf(("load_types(mime=%p, filename=\"%s\")\n", mime, filename)); + /* * First try to open the file... */ @@ -660,8 +691,6 @@ load_types(mime_t *mime, /* I - MIME database */ if ((fp = cupsFileOpen(filename, "r")) == NULL) return; - DEBUG_printf(("\"%s\":\n", filename)); - /* * Then read each line from the file, skipping any comments in the file... */ @@ -672,8 +701,6 @@ load_types(mime_t *mime, /* I - MIME database */ * Skip blank lines and lines starting with a #... */ - DEBUG_puts(line); - if (!line[0] || line[0] == '#') continue; @@ -732,5 +759,16 @@ load_types(mime_t *mime, /* I - MIME database */ /* - * End of "$Id: mime.c 6649 2007-07-11 21:46:42Z mike $". + * 'mime_new()' - Create a new, empty MIME database. + */ + +static mime_t * /* O - MIME database */ +mime_new(void) +{ + return ((mime_t *)calloc(1, sizeof(mime_t))); +} + + +/* + * End of "$Id: mime.c 7694 2008-06-26 00:23:20Z mike $". */ diff --git a/scheduler/mime.h b/scheduler/mime.h index 975ab79f4..019496495 100644 --- a/scheduler/mime.h +++ b/scheduler/mime.h @@ -1,5 +1,5 @@ /* - * "$Id: mime.h 6649 2007-07-11 21:46:42Z mike $" + * "$Id: mime.h 7694 2008-06-26 00:23:20Z mike $" * * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS). * @@ -113,9 +113,9 @@ typedef struct _mime_s /**** MIME Database ****/ extern void mimeDelete(mime_t *mime); extern mime_t *mimeLoad(const char *pathname, const char *filterpath); -extern mime_t *mimeMerge(mime_t *mime, const char *pathname, - const char *filterpath); -extern mime_t *mimeNew(void); +extern mime_t *mimeLoadFilters(mime_t *mime, const char *pathname, + const char *filterpath); +extern mime_t *mimeLoadTypes(mime_t *mime, const char *pathname); extern mime_type_t *mimeAddType(mime_t *mime, const char *super, const char *type); @@ -147,5 +147,5 @@ extern int mimeNumFilters(mime_t *mime); #endif /* !_CUPS_MIME_H_ */ /* - * End of "$Id: mime.h 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: mime.h 7694 2008-06-26 00:23:20Z mike $". */ diff --git a/scheduler/policy.c b/scheduler/policy.c index d550af4c8..4fefbd16a 100644 --- a/scheduler/policy.c +++ b/scheduler/policy.c @@ -1,5 +1,5 @@ /* - * "$Id: policy.c 6895 2007-08-30 00:09:27Z mike $" + * "$Id: policy.c 7673 2008-06-18 22:31:26Z mike $" * * Policy routines for the Common UNIX Printing System (CUPS). * @@ -276,7 +276,7 @@ cupsdFindPolicyOp(cupsd_policy_t *p, /* I - Policy */ *po; /* Current policy operation */ - cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindPolicyOp(p=%p, op=%x(%s))\n", + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindPolicyOp(p=%p, op=%x(%s))", p, op, ippOpString(op)); /* @@ -348,5 +348,5 @@ hash_op(cupsd_location_t *op) /* I - Operation */ /* - * End of "$Id: policy.c 6895 2007-08-30 00:09:27Z mike $". + * End of "$Id: policy.c 7673 2008-06-18 22:31:26Z mike $". */ diff --git a/scheduler/printers.c b/scheduler/printers.c index c2ae13f2c..c5f4a91a9 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -1,5 +1,5 @@ /* - * "$Id: printers.c 7608 2008-05-21 01:37:21Z mike $" + * "$Id: printers.c 7677 2008-06-19 23:22:19Z mike $" * * Printer routines for the Common UNIX Printing System (CUPS). * @@ -1569,6 +1569,24 @@ cupsdSaveAllPrinters(void) cupsFilePuts(fp, "\n"); } + if ((marker = ippFindAttribute(printer->attrs, "marker-message", + IPP_TAG_TEXT)) != NULL) + { + cupsFilePrintf(fp, "Attribute %s ", marker->name); + + if (!ptr && (ptr = strchr(marker->values[0].string.text, '#')) != NULL) + { + cupsFileWrite(fp, marker->values[0].string.text, + ptr - marker->values[0].string.text); + cupsFilePutChar(fp, '\\'); + cupsFilePuts(fp, ptr); + } + else + cupsFilePuts(fp, marker->values[0].string.text); + + cupsFilePuts(fp, "\n"); + } + if ((marker = ippFindAttribute(printer->attrs, "marker-names", IPP_TAG_NAME)) != NULL) { @@ -1860,6 +1878,8 @@ cupsdSetPrinterAttr( if (!strcmp(name, "marker-types")) value_tag = IPP_TAG_KEYWORD; + else if (!strcmp(name, "marker-message")) + value_tag = IPP_TAG_TEXT; else value_tag = IPP_TAG_NAME; @@ -1871,7 +1891,12 @@ cupsdSetPrinterAttr( } if (attr) + { + for (i = 0; i < attr->num_values; i ++) + _cupsStrFree(attr->values[i].string.text); + attr->num_values = count; + } else attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, value_tag, name, count, NULL, NULL); @@ -1889,7 +1914,6 @@ cupsdSetPrinterAttr( if ((ptr = strchr(value, ',')) != NULL) *ptr++ = '\0'; - _cupsStrFree(attr->values[i].string.text); attr->values[i].string.text = _cupsStrAlloc(value); if (ptr) @@ -4311,5 +4335,5 @@ write_irix_state(cupsd_printer_t *p) /* I - Printer to update */ /* - * End of "$Id: printers.c 7608 2008-05-21 01:37:21Z mike $". + * End of "$Id: printers.c 7677 2008-06-19 23:22:19Z mike $". */ diff --git a/scheduler/printers.h b/scheduler/printers.h index b14b1b196..0853b2eda 100644 --- a/scheduler/printers.h +++ b/scheduler/printers.h @@ -1,5 +1,5 @@ /* - * "$Id: printers.h 6649 2007-07-11 21:46:42Z mike $" + * "$Id: printers.h 7564 2008-05-15 00:57:43Z mike $" * * Printer definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -176,5 +176,5 @@ extern void cupsdWritePrintcap(void); /* - * End of "$Id: printers.h 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: printers.h 7564 2008-05-15 00:57:43Z mike $". */ diff --git a/scheduler/process.c b/scheduler/process.c index d37b07915..b0481296c 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -1,5 +1,5 @@ /* - * "$Id: process.c 6987 2007-09-25 15:43:44Z mike $" + * "$Id: process.c 7256 2008-01-25 00:48:54Z mike $" * * Process management routines for the Common UNIX Printing System (CUPS). * @@ -494,5 +494,5 @@ cupsd_requote(char *dst, /* I - Destination buffer */ /* - * End of "$Id: process.c 6987 2007-09-25 15:43:44Z mike $". + * End of "$Id: process.c 7256 2008-01-25 00:48:54Z mike $". */ diff --git a/scheduler/select.c b/scheduler/select.c index a2e1925d1..6f6843685 100644 --- a/scheduler/select.c +++ b/scheduler/select.c @@ -1,5 +1,5 @@ /* - * "$Id: select.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: select.c 7093 2007-11-30 19:09:36Z mike $" * * Select abstraction functions for the Common UNIX Printing System (CUPS). * @@ -1018,5 +1018,5 @@ find_fd(int fd) /* I - File descriptor */ /* - * End of "$Id: select.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: select.c 7093 2007-11-30 19:09:36Z mike $". */ diff --git a/scheduler/server.c b/scheduler/server.c index 9483ae658..d44e4ee73 100644 --- a/scheduler/server.c +++ b/scheduler/server.c @@ -1,5 +1,5 @@ /* - * "$Id: server.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: server.c 7468 2008-04-18 18:31:59Z mike $" * * Server start/stop routines for the Common UNIX Printing System (CUPS). * @@ -214,5 +214,5 @@ cupsdStopServer(void) /* - * End of "$Id: server.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: server.c 7468 2008-04-18 18:31:59Z mike $". */ diff --git a/scheduler/statbuf.c b/scheduler/statbuf.c index a650f867b..c4959cfbe 100644 --- a/scheduler/statbuf.c +++ b/scheduler/statbuf.c @@ -1,10 +1,10 @@ /* - * "$Id: statbuf.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: statbuf.c 7674 2008-06-18 23:18:32Z mike $" * * Status buffer routines for the Common UNIX Printing System (CUPS) * scheduler. * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -15,8 +15,8 @@ * * Contents: * - * cupsdStatBufNew() - Create a new status buffer. * cupsdStatBufDelete() - Destroy a status buffer. + * cupsdStatBufNew() - Create a new status buffer. * cupsdStatBufUpdate() - Update the status buffer. */ @@ -29,6 +29,30 @@ /* + * 'cupsdStatBufDelete()' - Destroy a status buffer. + */ + +void +cupsdStatBufDelete(cupsd_statbuf_t *sb) /* I - Status buffer */ +{ + /* + * Range check input... + */ + + if (!sb) + return; + + /* + * Close the status pipe and free memory used... + */ + + close(sb->fd); + + free(sb); +} + + +/* * 'cupsdStatBufNew()' - Create a new status buffer. */ @@ -90,30 +114,6 @@ cupsdStatBufNew(int fd, /* I - File descriptor of pipe */ /* - * 'cupsdStatBufDelete()' - Destroy a status buffer. - */ - -void -cupsdStatBufDelete(cupsd_statbuf_t *sb) /* I - Status buffer */ -{ - /* - * Range check input... - */ - - if (!sb) - return; - - /* - * Close the status pipe and free memory used... - */ - - close(sb->fd); - - free(sb); -} - - -/* * 'cupsdStatBufUpdate()' - Update the status buffer. */ @@ -288,20 +288,23 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb, /* I - Status buffer */ * Send it to the log file as needed... */ - if (*loglevel > CUPSD_LOG_NONE && - (*loglevel != CUPSD_LOG_INFO || LogLevel == CUPSD_LOG_DEBUG2)) + if (sb->prefix[0]) { - /* - * General status message; send it to the error_log file... - */ + if (*loglevel > CUPSD_LOG_NONE && + (*loglevel != CUPSD_LOG_INFO || LogLevel == CUPSD_LOG_DEBUG2)) + { + /* + * General status message; send it to the error_log file... + */ - if (message[0] == '[') - cupsdLogMessage(*loglevel, "%s", message); - else - cupsdLogMessage(*loglevel, "%s %s", sb->prefix, message); + if (message[0] == '[') + cupsdLogMessage(*loglevel, "%s", message); + else + cupsdLogMessage(*loglevel, "%s %s", sb->prefix, message); + } + else if (*loglevel < CUPSD_LOG_NONE && LogLevel == CUPSD_LOG_DEBUG2) + cupsdLogMessage(CUPSD_LOG_DEBUG2, "%s %s", sb->prefix, sb->buffer); } - else if (*loglevel < CUPSD_LOG_NONE && LogLevel == CUPSD_LOG_DEBUG2) - cupsdLogMessage(CUPSD_LOG_DEBUG2, "%s %s", sb->prefix, sb->buffer); /* * Copy the message to the line buffer... @@ -326,5 +329,5 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb, /* I - Status buffer */ /* - * End of "$Id: statbuf.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: statbuf.c 7674 2008-06-18 23:18:32Z mike $". */ diff --git a/scheduler/statbuf.h b/scheduler/statbuf.h index 385e68c9b..c42c6fdb7 100644 --- a/scheduler/statbuf.h +++ b/scheduler/statbuf.h @@ -1,10 +1,10 @@ /* - * "$Id: statbuf.h 6649 2007-07-11 21:46:42Z mike $" + * "$Id: statbuf.h 7674 2008-06-18 23:18:32Z mike $" * * Status buffer definitions for the Common UNIX Printing System (CUPS) * scheduler. * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2008 by Apple Inc. * Copyright 1997-2005 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -39,12 +39,12 @@ typedef struct /**** Status buffer */ * Prototypes... */ -extern cupsd_statbuf_t *cupsdStatBufNew(int fd, const char *prefix, ...); extern void cupsdStatBufDelete(cupsd_statbuf_t *sb); +extern cupsd_statbuf_t *cupsdStatBufNew(int fd, const char *prefix, ...); extern char *cupsdStatBufUpdate(cupsd_statbuf_t *sb, int *loglevel, char *line, int linelen); /* - * End of "$Id: statbuf.h 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: statbuf.h 7674 2008-06-18 23:18:32Z mike $". */ diff --git a/scheduler/subscriptions.c b/scheduler/subscriptions.c index cea357fd3..4f92f873b 100644 --- a/scheduler/subscriptions.c +++ b/scheduler/subscriptions.c @@ -1,5 +1,5 @@ /* - * "$Id: subscriptions.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: subscriptions.c 7673 2008-06-18 22:31:26Z mike $" * * Subscription routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -1363,7 +1363,7 @@ cupsd_send_notification( cupsdLogMessage(CUPSD_LOG_DEBUG2, - "cupsd_send_notification(sub=%p(%d), event=%p(%s))\n", + "cupsd_send_notification(sub=%p(%d), event=%p(%s))", sub, sub->id, event, cupsdEventName(event->event)); /* @@ -1616,5 +1616,5 @@ cupsd_update_notifier(void) /* - * End of "$Id: subscriptions.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: subscriptions.c 7673 2008-06-18 22:31:26Z mike $". */ diff --git a/scheduler/subscriptions.h b/scheduler/subscriptions.h index 7f112fa0c..ab0154b71 100644 --- a/scheduler/subscriptions.h +++ b/scheduler/subscriptions.h @@ -1,5 +1,5 @@ /* - * "$Id: subscriptions.h 6649 2007-07-11 21:46:42Z mike $" + * "$Id: subscriptions.h 7253 2008-01-23 22:18:15Z mike $" * * Subscription definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -163,5 +163,5 @@ extern void cupsdStopAllNotifiers(void); /* - * End of "$Id: subscriptions.h 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: subscriptions.h 7253 2008-01-23 22:18:15Z mike $". */ diff --git a/scheduler/sysman.c b/scheduler/sysman.c index b6d175142..cffb285a7 100644 --- a/scheduler/sysman.c +++ b/scheduler/sysman.c @@ -1,5 +1,5 @@ /* - * "$Id: sysman.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: sysman.c 7676 2008-06-18 23:42:37Z mike $" * * System management definitions for the Common UNIX Printing System (CUPS). * @@ -21,13 +21,13 @@ * doing something. * cupsdStartSystemMonitor() - Start monitoring for system change. * cupsdStopSystemMonitor() - Stop monitoring for system change. - * cupsdUpdateSystemMonitor() - Update the current system state. * sysEventThreadEntry() - A thread to receive power and computer * name change notifications. * sysEventPowerNotifier() - Handle power notification events. * sysEventConfigurationNotifier() - Computer name changed notification * callback. * sysEventTimerNotifier() - Handle delayed event notifications. + * sysUpdate() - Update the current system state. */ @@ -230,6 +230,7 @@ static void sysEventConfigurationNotifier(SCDynamicStoreRef store, CFArrayRef changedKeys, void *context); static void sysEventTimerNotifier(CFRunLoopTimerRef timer, void *context); +static void sysUpdate(void); /* @@ -249,8 +250,7 @@ cupsdStartSystemMonitor(void) return; } - cupsdAddSelect(SysEventPipes[0], (cupsd_selfunc_t)cupsdUpdateSystemMonitor, - NULL, NULL); + cupsdAddSelect(SysEventPipes[0], (cupsd_selfunc_t)sysUpdate, NULL, NULL); /* * Set non-blocking mode on the descriptor we will be receiving notification @@ -314,174 +314,6 @@ cupsdStopSystemMonitor(void) /* - * 'cupsdUpdateSystemMonitor()' - Update the current system state. - */ - -void -cupsdUpdateSystemMonitor(void) -{ - int i; /* Looping var */ - cupsd_sysevent_t sysevent; /* The system event */ - cupsd_printer_t *p; /* Printer information */ - - - /* - * Drain the event pipe... - */ - - while (read((int)SysEventPipes[0], &sysevent, sizeof(sysevent)) - == sizeof(sysevent)) - { - if (sysevent.event & SYSEVENT_CANSLEEP) - { - /* - * If there are active printers that don't have the connecting-to-device - * printer-state-reason then cancel the sleep request (i.e. this reason - * indicates a job that is not yet connected to the printer)... - */ - - for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); - p; - p = (cupsd_printer_t *)cupsArrayNext(Printers)) - { - if (p->job) - { - for (i = 0; i < p->num_reasons; i ++) - if (!strcmp(p->reasons[i], "connecting-to-device")) - break; - - if (!p->num_reasons || i >= p->num_reasons) - break; - } - } - - if (p) - { - cupsdLogMessage(CUPSD_LOG_INFO, - "System sleep canceled because printer %s is active", - p->name); - IOCancelPowerChange(sysevent.powerKernelPort, - sysevent.powerNotificationID); - } - else - { - cupsdLogMessage(CUPSD_LOG_DEBUG, "System wants to sleep"); - IOAllowPowerChange(sysevent.powerKernelPort, - sysevent.powerNotificationID); - } - } - - if (sysevent.event & SYSEVENT_WILLSLEEP) - { - cupsdLogMessage(CUPSD_LOG_DEBUG, "System going to sleep"); - - Sleeping = 1; - - cupsdStopAllJobs(0); - - for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); - p; - p = (cupsd_printer_t *)cupsArrayNext(Printers)) - { - if (p->type & CUPS_PRINTER_DISCOVERED) - { - cupsdLogMessage(CUPSD_LOG_DEBUG, - "Deleting remote destination \"%s\"", p->name); - cupsArraySave(Printers); - cupsdDeletePrinter(p, 0); - cupsArrayRestore(Printers); - } - else - { - cupsdLogMessage(CUPSD_LOG_DEBUG, - "Deregistering local printer \"%s\"", p->name); - cupsdDeregisterPrinter(p, 0); - } - } - - cupsdCleanDirty(); - - IOAllowPowerChange(sysevent.powerKernelPort, - sysevent.powerNotificationID); - } - - if (sysevent.event & SYSEVENT_WOKE) - { - cupsdLogMessage(CUPSD_LOG_DEBUG, "System woke from sleep"); - IOAllowPowerChange(sysevent.powerKernelPort, - sysevent.powerNotificationID); - Sleeping = 0; - cupsdCheckJobs(); - } - - if (sysevent.event & SYSEVENT_NETCHANGED) - { - if (!Sleeping) - { - cupsdLogMessage(CUPSD_LOG_DEBUG, - "System network configuration changed"); - - /* - * Resetting browse_time before calling cupsdSendBrowseList causes - * browse packets to be sent for local shared printers. - */ - - for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); - p; - p = (cupsd_printer_t *)cupsArrayNext(Printers)) - p->browse_time = 0; - - cupsdSendBrowseList(); - cupsdRestartPolling(); - } - else - cupsdLogMessage(CUPSD_LOG_DEBUG, - "System network configuration changed; " - "ignored while sleeping"); - } - - if (sysevent.event & SYSEVENT_NAMECHANGED) - { - if (!Sleeping) - { - cupsdLogMessage(CUPSD_LOG_DEBUG, "Computer name changed"); - - /* - * De-register the individual printers... - */ - - for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); - p; - p = (cupsd_printer_t *)cupsArrayNext(Printers)) - cupsdDeregisterPrinter(p, 1); - - /* - * Update the computer name... - */ - - cupsdUpdateDNSSDName(); - - /* - * Now re-register them... - */ - - for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); - p; - p = (cupsd_printer_t *)cupsArrayNext(Printers)) - { - p->browse_time = 0; - cupsdRegisterPrinter(p); - } - } - else - cupsdLogMessage(CUPSD_LOG_DEBUG, - "Computer name changed; ignored while sleeping"); - } - } -} - - -/* * 'sysEventThreadEntry()' - A thread to receive power and computer name * change notifications. */ @@ -843,9 +675,177 @@ sysEventTimerNotifier( threadData->sysevent.event = 0; } } + + +/* + * 'sysUpdate()' - Update the current system state. + */ + +static void +sysUpdate(void) +{ + int i; /* Looping var */ + cupsd_sysevent_t sysevent; /* The system event */ + cupsd_printer_t *p; /* Printer information */ + + + /* + * Drain the event pipe... + */ + + while (read((int)SysEventPipes[0], &sysevent, sizeof(sysevent)) + == sizeof(sysevent)) + { + if (sysevent.event & SYSEVENT_CANSLEEP) + { + /* + * If there are active printers that don't have the connecting-to-device + * printer-state-reason then cancel the sleep request (i.e. this reason + * indicates a job that is not yet connected to the printer)... + */ + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + { + if (p->job) + { + for (i = 0; i < p->num_reasons; i ++) + if (!strcmp(p->reasons[i], "connecting-to-device")) + break; + + if (!p->num_reasons || i >= p->num_reasons) + break; + } + } + + if (p) + { + cupsdLogMessage(CUPSD_LOG_INFO, + "System sleep canceled because printer %s is active", + p->name); + IOCancelPowerChange(sysevent.powerKernelPort, + sysevent.powerNotificationID); + } + else + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "System wants to sleep"); + IOAllowPowerChange(sysevent.powerKernelPort, + sysevent.powerNotificationID); + } + } + + if (sysevent.event & SYSEVENT_WILLSLEEP) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "System going to sleep"); + + Sleeping = 1; + + cupsdStopAllJobs(0); + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + { + if (p->type & CUPS_PRINTER_DISCOVERED) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + "Deleting remote destination \"%s\"", p->name); + cupsArraySave(Printers); + cupsdDeletePrinter(p, 0); + cupsArrayRestore(Printers); + } + else + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + "Deregistering local printer \"%s\"", p->name); + cupsdDeregisterPrinter(p, 0); + } + } + + cupsdCleanDirty(); + + IOAllowPowerChange(sysevent.powerKernelPort, + sysevent.powerNotificationID); + } + + if (sysevent.event & SYSEVENT_WOKE) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "System woke from sleep"); + IOAllowPowerChange(sysevent.powerKernelPort, + sysevent.powerNotificationID); + Sleeping = 0; + cupsdCheckJobs(); + } + + if (sysevent.event & SYSEVENT_NETCHANGED) + { + if (!Sleeping) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + "System network configuration changed"); + + /* + * Resetting browse_time before calling cupsdSendBrowseList causes + * browse packets to be sent for local shared printers. + */ + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + p->browse_time = 0; + + cupsdSendBrowseList(); + cupsdRestartPolling(); + } + else + cupsdLogMessage(CUPSD_LOG_DEBUG, + "System network configuration changed; " + "ignored while sleeping"); + } + + if (sysevent.event & SYSEVENT_NAMECHANGED) + { + if (!Sleeping) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "Computer name changed"); + + /* + * De-register the individual printers... + */ + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + cupsdDeregisterPrinter(p, 1); + + /* + * Update the computer name... + */ + + cupsdUpdateDNSSDName(); + + /* + * Now re-register them... + */ + + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); + p; + p = (cupsd_printer_t *)cupsArrayNext(Printers)) + { + p->browse_time = 0; + cupsdRegisterPrinter(p); + } + } + else + cupsdLogMessage(CUPSD_LOG_DEBUG, + "Computer name changed; ignored while sleeping"); + } + } +} #endif /* __APPLE__ */ /* - * End of "$Id: sysman.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: sysman.c 7676 2008-06-18 23:42:37Z mike $". */ diff --git a/scheduler/sysman.h b/scheduler/sysman.h index 50ef17f96..282f7b5bc 100644 --- a/scheduler/sysman.h +++ b/scheduler/sysman.h @@ -1,5 +1,5 @@ /* - * "$Id: sysman.h 6649 2007-07-11 21:46:42Z mike $" + * "$Id: sysman.h 7676 2008-06-18 23:42:37Z mike $" * * System management definitions for the Common UNIX Printing System (CUPS). * @@ -53,9 +53,8 @@ extern void cupsdMarkDirty(int what); extern void cupsdSetBusyState(void); extern void cupsdStartSystemMonitor(void); extern void cupsdStopSystemMonitor(void); -extern void cupsdUpdateSystemMonitor(void); /* - * End of "$Id: sysman.h 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: sysman.h 7676 2008-06-18 23:42:37Z mike $". */ diff --git a/scheduler/testmime.c b/scheduler/testmime.c index 130aaaaa2..3eface432 100644 --- a/scheduler/testmime.c +++ b/scheduler/testmime.c @@ -1,5 +1,5 @@ /* - * "$Id: testmime.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: testmime.c 7670 2008-06-17 22:42:08Z mike $" * * MIME test program for the Common UNIX Printing System (CUPS). * @@ -322,5 +322,5 @@ type_dir(mime_t *mime, /* I - MIME database */ /* - * End of "$Id: testmime.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: testmime.c 7670 2008-06-17 22:42:08Z mike $". */ diff --git a/scheduler/testspeed.c b/scheduler/testspeed.c index 4b740675e..11cdfcae6 100644 --- a/scheduler/testspeed.c +++ b/scheduler/testspeed.c @@ -1,5 +1,5 @@ /* - * "$Id: testspeed.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: testspeed.c 7688 2008-06-24 04:34:52Z mike $" * * Scheduler speed test for the Common UNIX Printing System (CUPS). * @@ -24,15 +24,13 @@ * Include necessary headers... */ -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/wait.h> +#include <cups/string.h> #include <cups/cups.h> #include <cups/language.h> #include <cups/debug.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/wait.h> #include <errno.h> @@ -366,5 +364,5 @@ usage(void) /* - * End of "$Id: testspeed.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: testspeed.c 7688 2008-06-24 04:34:52Z mike $". */ diff --git a/scheduler/type.c b/scheduler/type.c index f40d10b2b..6532b9c08 100644 --- a/scheduler/type.c +++ b/scheduler/type.c @@ -1,5 +1,5 @@ /* - * "$Id: type.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: type.c 7694 2008-06-26 00:23:20Z mike $" * * MIME typing routines for the Common UNIX Printing System (CUPS). * @@ -157,7 +157,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ logic = MIME_MAGIC_NOP; invert = 0; - DEBUG_printf(("%s/%s: %s\n", mt->super, mt->type, rule)); + DEBUG_printf(("mimeAddTypeRule: %s/%s: %s\n", mt->super, mt->type, rule)); while (*rule != '\0') { @@ -166,13 +166,13 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ if (*rule == '(') { - DEBUG_puts("new parenthesis group"); + DEBUG_puts("mimeAddTypeRule: New parenthesis group"); logic = MIME_MAGIC_NOP; rule ++; } else if (*rule == ')') { - DEBUG_puts("close paren..."); + DEBUG_puts("mimeAddTypeRule: Close paren..."); if (current == NULL || current->parent == NULL) return (-1); @@ -208,11 +208,12 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ current->prev = NULL; current->parent = temp; - DEBUG_printf(("creating new AND group %p...\n", temp)); + DEBUG_printf(("mimeAddTypeRule: Creating new AND group %p...\n", temp)); } else { - DEBUG_printf(("setting group %p op to AND...\n", current->parent)); + DEBUG_printf(("mimeAddTypeRule: Setting group %p op to AND...\n", + current->parent)); current->parent->op = MIME_MAGIC_AND; } @@ -238,7 +239,8 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ if ((temp = calloc(1, sizeof(mime_magic_t))) == NULL) return (-1); - DEBUG_printf(("creating new AND group %p inside OR group\n", temp)); + DEBUG_printf(("mimeAddTypeRule: Creating new AND group %p inside OR " + "group\n", temp)); while (current->prev != NULL) { @@ -258,7 +260,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ * This isn't the top rule, so go up one level... */ - DEBUG_puts("going up one level"); + DEBUG_puts("mimeAddTypeRule: Going up one level"); current = current->parent; } } @@ -268,7 +270,7 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ } else if (*rule == '!') { - DEBUG_puts("NOT"); + DEBUG_puts("mimeAddTypeRule: NOT"); invert = 1; rule ++; } @@ -441,7 +443,8 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ * Add parenthetical grouping... */ - DEBUG_printf(("making new OR group %p for parenthesis...\n", temp)); + DEBUG_printf(("mimeAddTypeRule: Making new OR group %p for " + "parenthesis...\n", temp)); temp->op = MIME_MAGIC_OR; @@ -454,8 +457,8 @@ mimeAddTypeRule(mime_type_t *mt, /* I - Type to add to */ logic = MIME_MAGIC_OR; } - DEBUG_printf(("adding %p: %s, op = %d, logic = %d, invert = %d\n", - temp, name, op, logic, invert)); + DEBUG_printf(("mimeAddTypeRule: adding %p: %s, op=%d, logic=%d, " + "invert=%d\n", temp, name, op, logic, invert)); /* * Fill in data for the rule... @@ -543,10 +546,7 @@ mimeFileType(mime_t *mime, /* I - MIME database */ DEBUG_printf(("mimeFileType(mime=%p, pathname=\"%s\", filename=\"%s\", " - "compression=%p)\n", - mime, pathname ? pathname : "(nil)", - filename ? filename : "(nil)", - compression)); + "compression=%p)\n", mime, pathname, filename, compression)); /* * Range check input parameters... @@ -803,7 +803,7 @@ checkrules(const char *filename, /* I - Filename */ break; case MIME_MAGIC_STRING : - DEBUG_printf((" string(%d, \"%s\")\n", rules->offset, + DEBUG_printf(("checkrules: string(%d, \"%s\")\n", rules->offset, rules->value.stringv)); /* @@ -822,7 +822,7 @@ checkrules(const char *filename, /* I - Filename */ sizeof(fb->buffer)); fb->offset = rules->offset; - DEBUG_printf((" loaded %d byte fb->buffer at %d, starts " + DEBUG_printf(("checkrules: loaded %d byte fb->buffer at %d, starts " "with \"%c%c%c%c\"...\n", fb->length, fb->offset, fb->buffer[0], fb->buffer[1], fb->buffer[2], fb->buffer[3])); @@ -838,7 +838,7 @@ checkrules(const char *filename, /* I - Filename */ else result = (memcmp(fb->buffer + rules->offset - fb->offset, rules->value.stringv, rules->length) == 0); - DEBUG_printf((" result=%d\n", result)); + DEBUG_printf(("checkrules: result=%d\n", result)); break; case MIME_MAGIC_ISTRING : @@ -1039,8 +1039,8 @@ checkrules(const char *filename, /* I - Filename */ * the the rule set is false... */ - DEBUG_printf((" result of test %p (MIME_MAGIC_%s) is %d\n", rules, - debug_tests[rules->op], result)); + DEBUG_printf(("checkrules: result of test %p (MIME_MAGIC_%s) is %d\n", + rules, debug_tests[rules->op], result)); if ((result && logic == MIME_MAGIC_OR) || (!result && logic == MIME_MAGIC_AND)) @@ -1162,5 +1162,5 @@ patmatch(const char *s, /* I - String to match against */ /* - * End of "$Id: type.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: type.c 7694 2008-06-26 00:23:20Z mike $". */ diff --git a/scheduler/util.c b/scheduler/util.c index 115bbf8b3..c876c9a04 100644 --- a/scheduler/util.c +++ b/scheduler/util.c @@ -1,5 +1,5 @@ /* - * "$Id: util.c 6649 2007-07-11 21:46:42Z mike $" + * "$Id: util.c 7621 2008-06-06 18:55:35Z mike $" * * Mini-daemon utility functions for the Common UNIX Printing System (CUPS). * @@ -446,5 +446,5 @@ cupsdSendIPPTrailer(void) /* - * End of "$Id: util.c 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: util.c 7621 2008-06-06 18:55:35Z mike $". */ diff --git a/scheduler/util.h b/scheduler/util.h index 420030771..05642f3a9 100644 --- a/scheduler/util.h +++ b/scheduler/util.h @@ -1,5 +1,5 @@ /* - * "$Id: util.h 6649 2007-07-11 21:46:42Z mike $" + * "$Id: util.h 7621 2008-06-06 18:55:35Z mike $" * * Mini-daemon utility definitions for the Common UNIX Printing System (CUPS). * @@ -50,5 +50,5 @@ extern void cupsdSendIPPTrailer(void); #endif /* !_CUPSD_UTIL_H_ */ /* - * End of "$Id: util.h 6649 2007-07-11 21:46:42Z mike $". + * End of "$Id: util.h 7621 2008-06-06 18:55:35Z mike $". */ |