*/
# define cupsLangDefault() cupsLangGet(NULL)
-extern const char *cupsEncodingName(cups_encoding_t encoding);
extern const char *cupsLangEncoding(cups_lang_t *lang);
extern void cupsLangFlush(void);
extern void cupsLangFree(cups_lang_t *lang);
extern cups_lang_t *cupsLangGet(const char *language);
-extern int cupsLangPrintf(FILE *fp, cups_lang_t *lang,
- cups_msg_t msg, ...);
-extern int cupsLangPuts(FILE *fp, cups_lang_t *lang,
- cups_msg_t msg);
# define cupsLangString(lang,msg) (lang)->messages[(msg)]
/**** New in CUPS 1.1.20 ****/
extern void _cupsRestoreLocale(int category, char *oldlocale);
extern char *_cupsSaveLocale(int category, const char *locale);
+/**** New in CUPS 1.2 ****/
+extern const char *cupsEncodingName(cups_encoding_t encoding);
+extern int cupsLangPrintf(FILE *fp, cups_lang_t *lang,
+ cups_msg_t msg, ...);
+extern int cupsLangPuts(FILE *fp, cups_lang_t *lang,
+ cups_msg_t msg);
+
# ifdef __cplusplus
}
# endif /* __cplusplus */
*
* Contents:
*
- * cupsdAddLocation() - Add a location for authorization.
- * cupsdAddName() - Add a name to a location...
- * cupsdAllowHost() - Add a host name that is allowed to access the
- * location.
- * cupsdAllowIP() - Add an IP address or network that is allowed to
- * access the location.
- * cupsdCheckAuth() - Check authorization masks.
- * cupsdCheckGroup() - Check for a user's group membership.
- * cupsdCopyLocation() - Make a copy of a location...
- * cupsdDeleteAllLocations() - Free all memory used for location authorization.
- * cupsdDeleteLocation() - Free all memory used by a location.
- * cupsdDenyHost() - Add a host name that is not allowed to access the
- * location.
- * cupsdDenyIP() - Add an IP address or network that is not allowed
- * to access the location.
- * cupsdFindBest() - Find the location entry that best matches the
- * resource.
- * cupsdFindLocation() - Find the named location.
- * cupsdGetMD5Passwd() - Get an MD5 password.
- * cupsdIsAuthorized() - Check to see if the user is authorized...
- * add_allow() - Add an allow mask to the location.
- * add_deny() - Add a deny mask to the location.
- * cups_crypt() - Encrypt the password using the DES or MD5
- * algorithms, as needed.
- * pam_func() - PAM conversation function.
- * to64() - Base64-encode an integer value...
+ * cupsdAddLocation() - Add a location for authorization.
+ * cupsdAddName() - Add a name to a location...
+ * cupsdAllowHost() - Add a host name that is allowed to access the
+ * location.
+ * cupsdAllowIP() - Add an IP address or network that is allowed to
+ * access the location.
+ * cupsdCheckAuth() - Check authorization masks.
+ * cupsdCheckGroup() - Check for a user's group membership.
+ * cupsdCopyLocation() - Make a copy of a location...
+ * cupsdDeleteAllLocations() - Free all memory used for location authorization.
+ * cupsdDeleteLocation() - Free all memory used by a location.
+ * cupsdDenyHost() - Add a host name that is not allowed to access the
+ * location.
+ * cupsdDenyIP() - Add an IP address or network that is not allowed
+ * to access the location.
+ * cupsdFindBest() - Find the location entry that best matches the
+ * resource.
+ * cupsdFindLocation() - Find the named location.
+ * cupsdGetMD5Passwd() - Get an MD5 password.
+ * cupsdIsAuthorized() - Check to see if the user is authorized...
+ * add_allow() - Add an allow mask to the location.
+ * add_deny() - Add a deny mask to the location.
+ * cups_crypt() - Encrypt the password using the DES or MD5
+ * algorithms, as needed.
+ * pam_func() - PAM conversation function.
+ * to64() - Base64-encode an integer value...
*/
/*
*/
#if defined(__hpux) && defined(HAVE_LIBPAM)
-static cupsd_client_t *auth_client; /* Current client being authenticated */
+static cupsd_client_t *auth_client; /* Current client being authenticated */
#endif /* __hpux && HAVE_LIBPAM */
* 'cupsdAddLocation()' - Add a location for authorization.
*/
-cupsd_location_t * /* O - Pointer to new location record */
+cupsd_location_t * /* O - Pointer to new location record */
cupsdAddLocation(const char *location) /* I - Location path */
{
- cupsd_location_t *temp; /* New location */
+ cupsd_location_t *temp; /* New location */
/*
strlcpy(temp->location, location, sizeof(temp->location));
temp->length = strlen(temp->location);
- cupsdLogMessage(L_DEBUG, "cupsdAddLocation: added location \'%s\'", location);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdAddLocation: added location \'%s\'",
+ location);
/*
* Return the new record...
void
cupsdAddName(cupsd_location_t *loc, /* I - Location to add to */
- char *name) /* I - Name to add */
+ char *name) /* I - Name to add */
{
- char **temp; /* Pointer to names array */
+ char **temp; /* Pointer to names array */
- cupsdLogMessage(L_DEBUG2, "cupsdAddName(loc=%p, name=\"%s\")", loc, name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddName(loc=%p, name=\"%s\")",
+ loc, name);
if (loc->num_names == 0)
temp = malloc(sizeof(char *));
if (temp == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to add name to location %s: %s", loc->location,
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to add name to location %s: %s",
+ loc->location, strerror(errno));
return;
}
if ((temp[loc->num_names] = strdup(name)) == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to duplicate name for location %s: %s",
- loc->location, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to duplicate name for location %s: %s",
+ loc->location, strerror(errno));
return;
}
void
cupsdAllowHost(cupsd_location_t *loc, /* I - Location to add to */
- char *name) /* I - Name of host or domain to add */
+ char *name) /* I - Name of host or domain to add */
{
cupsd_authmask_t *temp; /* New host/domain mask */
- char ifname[32], /* Interface name */
- *ifptr; /* Pointer to end of name */
+ char ifname[32], /* Interface name */
+ *ifptr; /* Pointer to end of name */
- cupsdLogMessage(L_DEBUG2, "cupsdAllowHost(loc=%p(%s), name=\"%s\")", loc,
- loc->location, name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAllowHost(loc=%p(%s), name=\"%s\")",
+ loc, loc->location, name);
if ((temp = add_allow(loc)) == NULL)
return;
/*
- * 'cupsdAllowIP()' - Add an IP address or network that is allowed to access the
- * location.
+ * 'cupsdAllowIP()' - Add an IP address or network that is allowed to access
+ * the location.
*/
void
cupsdAllowIP(cupsd_location_t *loc, /* I - Location to add to */
- unsigned address[4], /* I - IP address to add */
- unsigned netmask[4]) /* I - Netmask of address */
+ unsigned address[4], /* I - IP address to add */
+ unsigned netmask[4]) /* I - Netmask of address */
{
cupsd_authmask_t *temp; /* New host/domain mask */
- cupsdLogMessage(L_DEBUG2, "cupsdAllowIP(loc=%p(%s), address=%x:%x:%x:%x, netmask=%x:%x:%x:%x)",
- loc, loc->location, address[0], address[1], address[2],
- address[3], netmask[0], netmask[1], netmask[2],
- netmask[3]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdAllowIP(loc=%p(%s), address=%x:%x:%x:%x, netmask=%x:%x:%x:%x)",
+ loc, loc->location, address[0], address[1], address[2],
+ address[3], netmask[0], netmask[1], netmask[2],
+ netmask[3]);
if ((temp = add_allow(loc)) == NULL)
return;
* 'cupsdCheckAuth()' - Check authorization masks.
*/
-int /* O - 1 if mask matches, 0 otherwise */
-cupsdCheckAuth(unsigned ip[4], /* I - Client address */
- char *name, /* I - Client hostname */
- int name_len, /* I - Length of hostname */
- int num_masks, /* I - Number of masks */
- cupsd_authmask_t *masks) /* I - Masks */
+int /* O - 1 if mask matches, 0 otherwise */
+cupsdCheckAuth(
+ unsigned ip[4], /* I - Client address */
+ char *name, /* I - Client hostname */
+ int name_len, /* I - Length of hostname */
+ int num_masks, /* I - Number of masks */
+ cupsd_authmask_t *masks) /* I - Masks */
{
- int i; /* Looping var */
- cupsd_netif_t *iface; /* Network interface */
- unsigned netip4; /* IPv4 network address */
+ int i; /* Looping var */
+ cupsd_netif_t *iface; /* Network interface */
+ unsigned netip4; /* IPv4 network address */
#ifdef AF_INET6
- unsigned netip6[4]; /* IPv6 network address */
+ unsigned netip6[4]; /* IPv6 network address */
#endif /* AF_INET6 */
while (num_masks > 0)
* Check the named interface...
*/
- if ((iface = NetIFFind(masks->mask.name.name)) != NULL)
+ if ((iface = cupsdNetIFFind(masks->mask.name.name)) != NULL)
{
if (iface->address.addr.sa_family == AF_INET)
{
* Check for exact name match...
*/
- if (strcasecmp(name, masks->mask.name.name) == 0)
+ if (!strcasecmp(name, masks->mask.name.name))
return (1);
/*
*/
for (i = 0; i < 4; i ++)
- if ((ip[i] & masks->mask.ip.netmask[i]) != masks->mask.ip.address[i])
+ if ((ip[i] & masks->mask.ip.netmask[i]) !=
+ masks->mask.ip.address[i])
break;
if (i == 4)
char junk[33]; /* MD5 password (not used) */
- cupsdLogMessage(L_DEBUG2, "cupsdCheckGroup(username=\"%s\", user=%p, groupname=\"%s\")\n",
- username, user, groupname);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdCheckGroup(username=\"%s\", user=%p, groupname=\"%s\")",
+ username, user, groupname);
/*
* Validate input...
*/
cupsd_location_t * /* O - New location */
-cupsdCopyLocation(cupsd_location_t **loc) /* IO - Original location */
+cupsdCopyLocation(
+ cupsd_location_t **loc) /* IO - Original location */
{
- int i; /* Looping var */
- int locindex; /* Index into Locations array */
+ int i; /* Looping var */
+ int locindex; /* Index into Locations array */
cupsd_location_t *temp; /* New location */
- char location[HTTP_MAX_URI]; /* Location of resource */
+ char location[HTTP_MAX_URI];
+ /* Location of resource */
/*
if ((temp->names = calloc(temp->num_names, sizeof(char *))) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to allocate memory for %d names: %s",
- temp->num_names, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdCopyLocation: Unable to allocate memory for %d names: %s",
+ temp->num_names, strerror(errno));
NumLocations --;
return (NULL);
}
for (i = 0; i < temp->num_names; i ++)
if ((temp->names[i] = strdup((*loc)->names[i])) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to copy name \"%s\": %s",
- (*loc)->names[i], strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdCopyLocation: Unable to copy name \"%s\": %s",
+ (*loc)->names[i], strerror(errno));
NumLocations --;
return (NULL);
if ((temp->allow = calloc(temp->num_allow, sizeof(cupsd_authmask_t))) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to allocate memory for %d allow rules: %s",
- temp->num_allow, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdCopyLocation: Unable to allocate memory for %d allow rules: %s",
+ temp->num_allow, strerror(errno));
NumLocations --;
return (NULL);
}
if (temp->allow[i].mask.name.name == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to copy allow name \"%s\": %s",
- (*loc)->allow[i].mask.name.name, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdCopyLocation: Unable to copy allow name \"%s\": %s",
+ (*loc)->allow[i].mask.name.name, strerror(errno));
NumLocations --;
return (NULL);
}
if ((temp->deny = calloc(temp->num_deny, sizeof(cupsd_authmask_t))) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to allocate memory for %d deny rules: %s",
- temp->num_deny, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdCopyLocation: Unable to allocate memory for %d deny rules: %s",
+ temp->num_deny, strerror(errno));
NumLocations --;
return (NULL);
}
if (temp->deny[i].mask.name.name == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to copy deny name \"%s\": %s",
- (*loc)->deny[i].mask.name.name, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdCopyLocation: Unable to copy deny name \"%s\": %s",
+ (*loc)->deny[i].mask.name.name, strerror(errno));
NumLocations --;
return (NULL);
}
void
cupsdDeleteAllLocations(void)
{
- int i; /* Looping var */
- cupsd_location_t *loc; /* Current location */
+ int i; /* Looping var */
+ cupsd_location_t *loc; /* Current location */
/*
*/
void
-cupsdDeleteLocation(cupsd_location_t *loc) /* I - Location to delete */
+cupsdDeleteLocation(
+ cupsd_location_t *loc) /* I - Location to delete */
{
- int i; /* Looping var */
- cupsd_authmask_t *mask; /* Current mask */
+ int i; /* Looping var */
+ cupsd_authmask_t *mask; /* Current mask */
for (i = loc->num_names - 1; i >= 0; i --)
/*
- * 'cupsdDenyHost()' - Add a host name that is not allowed to access the location.
+ * 'cupsdDenyHost()' - Add a host name that is not allowed to access the
+ * location.
*/
void
cupsdDenyHost(cupsd_location_t *loc, /* I - Location to add to */
- char *name) /* I - Name of host or domain to add */
+ char *name) /* I - Name of host or domain to add */
{
cupsd_authmask_t *temp; /* New host/domain mask */
- char ifname[32], /* Interface name */
- *ifptr; /* Pointer to end of name */
+ char ifname[32], /* Interface name */
+ *ifptr; /* Pointer to end of name */
- cupsdLogMessage(L_DEBUG2, "cupsdDenyHost(loc=%p(%s), name=\"%s\")", loc,
- loc->location, name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdDenyHost(loc=%p(%s), name=\"%s\")",
+ loc, loc->location, name);
if ((temp = add_deny(loc)) == NULL)
return;
/*
- * 'cupsdDenyIP()' - Add an IP address or network that is not allowed to access
- * the location.
+ * 'cupsdDenyIP()' - Add an IP address or network that is not allowed to
+ * access the location.
*/
void
-cupsdDenyIP(cupsd_location_t *loc, /* I - Location to add to */
- unsigned address[4], /* I - IP address to add */
- unsigned netmask[4]) /* I - Netmask of address */
+cupsdDenyIP(cupsd_location_t *loc, /* I - Location to add to */
+ unsigned address[4],/* I - IP address to add */
+ unsigned netmask[4])/* I - Netmask of address */
{
cupsd_authmask_t *temp; /* New host/domain mask */
- cupsdLogMessage(L_DEBUG, "cupsdDenyIP(loc=%p(%s), address=%x:%x:%x:%x, netmask=%x:%x:%x:%x)",
- loc, loc->location, address[0], address[1], address[2],
- address[3], netmask[0], netmask[1], netmask[2],
- netmask[3]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdDenyIP(loc=%p(%s), address=%x:%x:%x:%x, netmask=%x:%x:%x:%x)",
+ loc, loc->location, address[0], address[1], address[2],
+ address[3], netmask[0], netmask[1], netmask[2],
+ netmask[3]);
if ((temp = add_deny(loc)) == NULL)
return;
* 'cupsdFindBest()' - Find the location entry that best matches the resource.
*/
-cupsd_location_t * /* O - Location that matches */
-cupsdFindBest(const char *path, /* I - Resource path */
- http_state_t state) /* I - HTTP state/request */
+cupsd_location_t * /* O - Location that matches */
+cupsdFindBest(const char *path, /* I - Resource path */
+ http_state_t state) /* I - HTTP state/request */
{
- int i; /* Looping var */
- char uri[HTTP_MAX_URI], /* URI in request... */
- *uriptr; /* Pointer into URI */
- cupsd_location_t *loc, /* Current location */
- *best; /* Best match for location so far */
- int bestlen; /* Length of best match */
- int limit; /* Limit field */
- static const int limits[] = /* Map http_status_t to AUTH_LIMIT_xyz */
+ int i; /* Looping var */
+ char uri[HTTP_MAX_URI],
+ /* URI in request... */
+ *uriptr; /* Pointer into URI */
+ cupsd_location_t *loc, /* Current location */
+ *best; /* Best match for location so far */
+ int bestlen; /* Length of best match */
+ int limit; /* Limit field */
+ static const int limits[] = /* Map http_status_t to AUTH_LIMIT_xyz */
{
AUTH_LIMIT_ALL,
AUTH_LIMIT_OPTIONS,
*uriptr = '\0';
}
- cupsdLogMessage(L_DEBUG2, "cupsdFindBest: uri = \"%s\"...", uri);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindBest: uri = \"%s\"...", uri);
/*
* Loop through the list of locations to find a match...
for (i = NumLocations, loc = Locations; i > 0; i --, loc ++)
{
- cupsdLogMessage(L_DEBUG2, "cupsdFindBest: Location %s Limit %x",
- loc->location, loc->limit);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindBest: Location %s Limit %x",
+ loc->location, loc->limit);
if (!strncmp(uri, "/printers/", 10) || !strncmp(uri, "/classes/", 9))
{
* Return the match, if any...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdFindBest: best = %s", best ? best->location : "NONE");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindBest: best = %s",
+ best ? best->location : "NONE");
return (best);
}
* 'cupsdFindLocation()' - Find the named location.
*/
-cupsd_location_t * /* O - Location that matches */
+cupsd_location_t * /* O - Location that matches */
cupsdFindLocation(const char *location) /* I - Connection */
{
int i; /* Looping var */
*/
for (i = 0; i < NumLocations; i ++)
- if (strcasecmp(Locations[i].location, location) == 0)
+ if (!strcasecmp(Locations[i].location, location))
return (Locations + i);
return (NULL);
char * /* O - MD5 password string */
cupsdGetMD5Passwd(const char *username, /* I - Username */
- const char *group, /* I - Group */
- char passwd[33]) /* O - MD5 password string */
+ const char *group, /* I - Group */
+ char passwd[33])/* O - MD5 password string */
{
cups_file_t *fp; /* passwd.md5 file */
char filename[1024], /* passwd.md5 filename */
tempgroup[33]; /* Group from file */
- cupsdLogMessage(L_DEBUG2, "cupsdGetMD5Passwd(username=\"%s\", group=\"%s\", passwd=%p)",
- username, group ? group : "(null)", passwd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdGetMD5Passwd(username=\"%s\", group=\"%s\", passwd=%p)",
+ username, group ? group : "(null)", passwd);
snprintf(filename, sizeof(filename), "%s/passwd.md5", ServerRoot);
if ((fp = cupsFileOpen(filename, "r")) == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to open %s - %s", filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open %s - %s", filename,
+ strerror(errno));
return (NULL);
}
{
if (sscanf(line, "%32[^:]:%32[^:]:%32s", tempuser, tempgroup, passwd) != 3)
{
- cupsdLogMessage(L_ERROR, "Bad MD5 password line: %s", line);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad MD5 password line: %s", line);
continue;
}
* Found the password entry!
*/
- cupsdLogMessage(L_DEBUG2, "Found MD5 user %s, group %s...", username,
- tempgroup);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "Found MD5 user %s, group %s...",
+ username, tempgroup);
cupsFileClose(fp);
return (passwd);
*/
http_status_t /* O - HTTP_OK if authorized or error code */
-cupsdIsAuthorized(cupsd_client_t *con, /* I - Connection */
- const char *owner) /* I - Owner of object */
+cupsdIsAuthorized(cupsd_client_t *con, /* I - Connection */
+ const char *owner)/* I - Owner of object */
{
- int i, j, /* Looping vars */
- auth; /* Authorization status */
- unsigned address[4]; /* Authorization address */
- cupsd_location_t *best; /* Best match for location so far */
- int hostlen; /* Length of hostname */
- struct passwd *pw; /* User password data */
- char nonce[HTTP_MAX_VALUE], /* Nonce value from client */
- md5[33], /* MD5 password */
- basicmd5[33]; /* MD5 of Basic password */
+ int i, j, /* Looping vars */
+ auth; /* Authorization status */
+ unsigned address[4]; /* Authorization address */
+ cupsd_location_t *best; /* Best match for location so far */
+ int hostlen; /* Length of hostname */
+ struct passwd *pw; /* User password data */
+ char nonce[HTTP_MAX_VALUE],
+ /* Nonce value from client */
+ md5[33], /* MD5 password */
+ basicmd5[33]; /* MD5 of Basic password */
#if HAVE_LIBPAM
- pam_handle_t *pamh; /* PAM authentication handle */
- int pamerr; /* PAM error code */
- struct pam_conv pamdata; /* PAM conversation data */
+ pam_handle_t *pamh; /* PAM authentication handle */
+ int pamerr; /* PAM error code */
+ struct pam_conv pamdata; /* PAM conversation data */
#elif defined(HAVE_USERSEC_H)
- char *authmsg; /* Authentication message */
- char *loginmsg; /* Login message */
- int reenter; /* ??? */
+ char *authmsg; /* Authentication message */
+ char *loginmsg; /* Login message */
+ int reenter; /* ??? */
#else
- char *pass; /* Encrypted password */
+ char *pass; /* Encrypted password */
# ifdef HAVE_SHADOW_H
- struct spwd *spw; /* Shadow password data */
+ struct spwd *spw; /* Shadow password data */
# endif /* HAVE_SHADOW_H */
#endif /* HAVE_LIBPAM */
static const char * const states[] = /* HTTP client states... */
};
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: con->uri=\"%s\", con->best=%p(%s)",
- con->uri, con->best, con->best ? con->best->location : "");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: con->uri=\"%s\", con->best=%p(%s)",
+ con->uri, con->best, con->best ? con->best->location : "");
/*
* If there is no "best" authentication rule for this request, then
best = con->best;
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: level=AUTH_%s, type=AUTH_%s, satisfy=AUTH_SATISFY_%s, num_names=%d",
- levels[best->level], types[best->type],
- best->satisfy ? "ANY" : "ALL", best->num_names);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: level=AUTH_%s, type=AUTH_%s, satisfy=AUTH_SATISFY_%s, num_names=%d",
+ levels[best->level], types[best->type],
+ best->satisfy ? "ANY" : "ALL", best->num_names);
if (best->limit == AUTH_LIMIT_IPP)
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: op=%x(%s)", best->op,
- ippOpString(best->op));
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsAuthorized: op=%x(%s)",
+ best->op, ippOpString(best->op));
/*
* Check host/ip-based accesses...
}
}
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: auth=AUTH_%s...",
- auth ? "DENY" : "ALLOW");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsAuthorized: auth=AUTH_%s...",
+ auth ? "DENY" : "ALLOW");
if (auth == AUTH_DENY && best->satisfy == AUTH_SATISFY_ALL)
return (HTTP_FORBIDDEN);
if (best->encryption >= HTTP_ENCRYPT_REQUIRED && !con->http.tls)
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: Need upgrade to TLS...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: Need upgrade to TLS...");
return (HTTP_UPGRADE_REQUIRED);
}
#endif /* HAVE_SSL */
attr = ippFindAttribute(con->request, "requesting-user-name", IPP_TAG_NAME);
if (attr)
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: requesting-user-name=\"%s\"",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: requesting-user-name=\"%s\"",
+ attr->values[0].string.text);
return (HTTP_OK);
}
}
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: username=\"%s\" password=%d chars",
- con->username, (int)strlen(con->password));
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: username=\"%s\" password=%d chars",
+ con->username, (int)strlen(con->password));
DEBUG_printf(("cupsdIsAuthorized: username=\"%s\", password=\"%s\"\n",
con->username, con->password));
* Check the user's password...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking \"%s\", address = %x:%x:%x:%x, hostname = \"%s\"",
- con->username, address[0], address[1], address[2],
- address[3], con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: Checking \"%s\", address = %x:%x:%x:%x, hostname = \"%s\"",
+ con->username, address[0], address[1], address[2],
+ address[3], con->http.hostname);
pw = NULL;
pamerr = pam_start("cups", con->username, &pamdata, &pamh);
if (pamerr != PAM_SUCCESS)
{
- cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: pam_start() returned %d (%s)!\n",
- pamerr, pam_strerror(pamh, pamerr));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdIsAuthorized: pam_start() returned %d (%s)!\n",
+ pamerr, pam_strerror(pamh, pamerr));
pam_end(pamh, 0);
return (HTTP_UNAUTHORIZED);
}
pamerr = pam_authenticate(pamh, PAM_SILENT);
if (pamerr != PAM_SUCCESS)
{
- cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: pam_authenticate() returned %d (%s)!\n",
- pamerr, pam_strerror(pamh, pamerr));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdIsAuthorized: pam_authenticate() returned %d (%s)!\n",
+ pamerr, pam_strerror(pamh, pamerr));
pam_end(pamh, 0);
return (HTTP_UNAUTHORIZED);
}
pamerr = pam_acct_mgmt(pamh, PAM_SILENT);
if (pamerr != PAM_SUCCESS)
{
- cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: pam_acct_mgmt() returned %d (%s)!\n",
- pamerr, pam_strerror(pamh, pamerr));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdIsAuthorized: pam_acct_mgmt() returned %d (%s)!\n",
+ pamerr, pam_strerror(pamh, pamerr));
pam_end(pamh, 0);
return (HTTP_UNAUTHORIZED);
}
* Use AIX authentication interface...
*/
- cupsdLogMessage(L_DEBUG, "cupsdIsAuthorized: AIX authenticate of username \"%s\"",
- con->username);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdIsAuthorized: AIX authenticate of username \"%s\"",
+ con->username);
reenter = 1;
if (authenticate(con->username, con->password, &reenter, &authmsg) != 0)
{
- cupsdLogMessage(L_DEBUG, "cupsdIsAuthorized: Unable to authenticate username \"%s\": %s",
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdIsAuthorized: Unable to authenticate username \"%s\": %s",
con->username, strerror(errno));
return (HTTP_UNAUTHORIZED);
}
if (pw == NULL) /* No such user... */
{
- cupsdLogMessage(L_WARN, "cupsdIsAuthorized: Unknown username \"%s\"; access denied.",
- con->username);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "cupsdIsAuthorized: Unknown username \"%s\"; access denied.",
+ con->username);
return (HTTP_UNAUTHORIZED);
}
if (spw == NULL && strcmp(pw->pw_passwd, "x") == 0)
{ /* Don't allow blank passwords! */
- cupsdLogMessage(L_WARN, "cupsdIsAuthorized: Username \"%s\" has no shadow password; access denied.",
- con->username);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "cupsdIsAuthorized: Username \"%s\" has no shadow password; access denied.",
+ con->username);
return (HTTP_UNAUTHORIZED); /* No such user or bad shadow file */
}
if (pw->pw_passwd[0] == '\0')
# endif /* HAVE_SHADOW_H */
{ /* Don't allow blank passwords! */
- cupsdLogMessage(L_WARN, "cupsdIsAuthorized: Username \"%s\" has no password; access denied.",
- con->username);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "cupsdIsAuthorized: Username \"%s\" has no password; access denied.",
+ con->username);
return (HTTP_UNAUTHORIZED);
}
pass = cups_crypt(con->password, pw->pw_passwd);
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: pw_passwd = %s, crypt = %s",
- pw->pw_passwd, pass);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: pw_passwd = %s, crypt = %s",
+ pw->pw_passwd, pass);
if (pass == NULL || strcmp(pw->pw_passwd, pass) != 0)
{
{
pass = cups_crypt(con->password, spw->sp_pwdp);
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: sp_pwdp = %s, crypt = %s",
- spw->sp_pwdp, pass);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: sp_pwdp = %s, crypt = %s",
+ spw->sp_pwdp, pass);
if (pass == NULL || strcmp(spw->sp_pwdp, pass) != 0)
return (HTTP_UNAUTHORIZED);
if (!httpGetSubField(&(con->http), HTTP_FIELD_AUTHORIZATION, "nonce",
nonce))
{
- cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: No nonce value for Digest authentication!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdIsAuthorized: No nonce value for Digest authentication!");
return (HTTP_UNAUTHORIZED);
}
if (strcmp(con->http.hostname, nonce) != 0)
{
- cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: Nonce value error!");
- cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: Expected \"%s\",",
- con->http.hostname);
- cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: Got \"%s\"!", nonce);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdIsAuthorized: Nonce value error!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdIsAuthorized: Expected \"%s\",",
+ con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdIsAuthorized: Got \"%s\"!", nonce);
return (HTTP_UNAUTHORIZED);
}
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: nonce = \"%s\"", nonce);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsAuthorized: nonce = \"%s\"",
+ nonce);
if (best->num_names && best->level == AUTH_GROUP)
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: num_names = %d", best->num_names);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: num_names = %d",
+ best->num_names);
for (i = 0; i < best->num_names; i ++)
{
if (!md5[0])
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: No matching user:group for \"%s\" in passwd.md5!",
- con->username);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: No matching user:group for \"%s\" in passwd.md5!",
+ con->username);
return (HTTP_UNAUTHORIZED);
}
if (strcmp(md5, con->password) != 0)
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: MD5s \"%s\" and \"%s\" don't match!",
- md5, con->password);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: MD5s \"%s\" and \"%s\" don't match!",
+ md5, con->password);
return (HTTP_UNAUTHORIZED);
}
break;
if (best->num_names && best->level == AUTH_GROUP)
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: num_names = %d", best->num_names);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: num_names = %d",
+ best->num_names);
for (i = 0; i < best->num_names; i ++)
{
if (!md5[0])
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: No matching user:group for \"%s\" in passwd.md5!",
- con->username);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: No matching user:group for \"%s\" in passwd.md5!",
+ con->username);
return (HTTP_UNAUTHORIZED);
}
if (strcmp(md5, basicmd5) != 0)
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: MD5s \"%s\" and \"%s\" don't match!",
- md5, basicmd5);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: MD5s \"%s\" and \"%s\" don't match!",
+ md5, basicmd5);
return (HTTP_UNAUTHORIZED);
}
break;
* any valid user is OK...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking user membership...");
-
if (best->num_names == 0)
return (HTTP_OK);
* allowed...
*/
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: Checking user membership...");
+
for (i = 0; i < best->num_names; i ++)
{
if (!strcasecmp(best->names[i], "@OWNER") && owner &&
* Check to see if this user is in any of the named groups...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking group membership...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: Checking group membership...");
if (best->type == AUTH_BASIC)
{
for (i = 0; i < best->num_names; i ++)
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking group \"%s\" membership...",
- best->names[i]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: Checking group \"%s\" membership...",
+ best->names[i]);
if (!strcasecmp(best->names[i], "@SYSTEM"))
{
* The user isn't part of the specified group, so deny access...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: User not in group(s)!");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsAuthorized: User not in group(s)!");
return (HTTP_UNAUTHORIZED);
}
*/
static cupsd_authmask_t * /* O - New mask record */
-add_deny(cupsd_location_t *loc) /* I - Location to add to */
+add_deny(cupsd_location_t *loc) /* I - Location to add to */
{
cupsd_authmask_t *temp; /* New mask record */
* 'pam_func()' - PAM conversation function.
*/
-static int /* O - Success or failure */
-pam_func(int num_msg, /* I - Number of messages */
- const struct pam_message **msg, /* I - Messages */
- struct pam_response **resp, /* O - Responses */
- void *appdata_ptr) /* I - Pointer to connection */
+static int /* O - Success or failure */
+pam_func(
+ int num_msg, /* I - Number of messages */
+ const struct pam_message **msg, /* I - Messages */
+ struct pam_response **resp, /* O - Responses */
+ void *appdata_ptr)
+ /* I - Pointer to connection */
{
- int i; /* Looping var */
- struct pam_response *replies; /* Replies */
- cupsd_client_t *client; /* Pointer client connection */
+ int i; /* Looping var */
+ struct pam_response *replies; /* Replies */
+ cupsd_client_t *client; /* Pointer client connection */
/*
*/
static void
-to64(char *s, /* O - Output string */
- unsigned long v, /* I - Value to encode */
- int n) /* I - Number of digits */
+to64(char *s, /* O - Output string */
+ unsigned long v, /* I - Value to encode */
+ int n) /* I - Number of digits */
{
const char *itoa64 = "./0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
int type; /* Mask type */
union
{
- cupsd_namemask_t name; /* Host/Domain name */
- cupsd_ipmask_t ip; /* IP address/network */
+ cupsd_namemask_t name; /* Host/Domain name */
+ cupsd_ipmask_t ip; /* IP address/network */
} mask; /* Mask data */
} cupsd_authmask_t;
typedef struct
{
- char location[HTTP_MAX_URI]; /* Location of resource */
- ipp_op_t op; /* IPP operation */
- int limit, /* Limit for these types of requests */
- length, /* Length of location string */
- order_type, /* Allow or Deny */
- type, /* Type of authentication */
- level, /* Access level required */
- satisfy; /* Satisfy any or all limits? */
- int num_names; /* Number of names */
- char **names; /* User or group names */
- int num_allow; /* Number of Allow lines */
- cupsd_authmask_t *allow; /* Allow lines */
- int num_deny; /* Number of Deny lines */
- cupsd_authmask_t *deny; /* Deny lines */
- http_encryption_t encryption; /* To encrypt or not to encrypt... */
+ char location[HTTP_MAX_URI];
+ /* Location of resource */
+ ipp_op_t op; /* IPP operation */
+ int limit, /* Limit for these types of requests */
+ length, /* Length of location string */
+ order_type, /* Allow or Deny */
+ type, /* Type of authentication */
+ level, /* Access level required */
+ satisfy; /* Satisfy any or all limits? */
+ int num_names; /* Number of names */
+ char **names; /* User or group names */
+ int num_allow; /* Number of Allow lines */
+ cupsd_authmask_t *allow; /* Allow lines */
+ int num_deny; /* Number of Deny lines */
+ cupsd_authmask_t *deny; /* Deny lines */
+ http_encryption_t encryption; /* To encrypt or not to encrypt... */
} cupsd_location_t;
typedef struct cupsd_client_s cupsd_client_t;
VAR int NumLocations VALUE(0);
/* Number of authorization locations */
-VAR cupsd_location_t *Locations VALUE(NULL);
+VAR cupsd_location_t *Locations VALUE(NULL);
/* Authorization locations */
VAR int DefaultAuthType VALUE(AUTH_BASIC);
/* Default AuthType, if not specified */
extern void cupsdAddName(cupsd_location_t *loc, char *name);
extern void cupsdAllowHost(cupsd_location_t *loc, char *name);
extern void cupsdAllowIP(cupsd_location_t *loc, unsigned address[4],
- unsigned netmask[4]);
+ unsigned netmask[4]);
extern int cupsdCheckAuth(unsigned ip[4], char *name, int namelen,
- int num_masks, cupsd_authmask_t *masks);
+ int num_masks, cupsd_authmask_t *masks);
extern int cupsdCheckGroup(const char *username,
struct passwd *user,
const char *groupname);
extern void cupsdDeleteLocation(cupsd_location_t *loc);
extern void cupsdDenyHost(cupsd_location_t *loc, char *name);
extern void cupsdDenyIP(cupsd_location_t *loc, unsigned address[4],
- unsigned netmask[4]);
+ unsigned netmask[4]);
extern cupsd_location_t *cupsdFindBest(const char *path, http_state_t state);
extern cupsd_location_t *cupsdFindLocation(const char *location);
extern char *cupsdGetMD5Passwd(const char *username, const char *group,
- char passwd[33]);
+ char passwd[33]);
extern http_status_t cupsdIsAuthorized(cupsd_client_t *con, const char *owner);
* cupsdAddBanner() - Add a banner to the array.
* cupsdFindBanner() - Find a named banner.
* cupsdLoadBanners() - Load all available banner files...
- * compare() - Compare two banners.
+ * compare() - Compare two banners.
*/
/*
void
cupsdAddBanner(const char *name, /* I - Name of banner */
- const char *filename) /* I - Filename for banner */
+ const char *filename) /* I - Filename for banner */
{
- mime_type_t *filetype; /* Filetype */
+ mime_type_t *filetype; /* Filetype */
cupsd_banner_t *temp; /* New banner data */
if ((filetype = mimeFileType(MimeDatabase, filename, NULL)) == NULL)
{
- cupsdLogMessage(L_WARN, "cupsdAddBanner: Banner \"%s\" (\"%s\") is of an unknown file type - skipping!",
- name, filename);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "cupsdAddBanner: Banner \"%s\" (\"%s\") is of an unknown file type - skipping!",
+ name, filename);
return;
}
if (temp == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdAddBanner: Ran out of memory adding a banner!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdAddBanner: Ran out of memory adding a banner!");
return;
}
if ((dir = cupsDirOpen(d)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadBanners: Unable to open banner directory \"%s\": %s",
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdLoadBanners: Unable to open banner directory \"%s\": %s",
d, strerror(errno));
return;
}
* 'compare()' - Compare two banners.
*/
-static int /* O - -1 if name0 < name1, etc. */
+static int /* O - -1 if name0 < name1, etc. */
compare(const cupsd_banner_t *b0, /* I - First banner */
const cupsd_banner_t *b1) /* I - Second banner */
{
typedef struct
{
- char name[256]; /* Name of banner */
- mime_type_t *filetype; /* Filetype for banner */
+ char name[256]; /* Name of banner */
+ mime_type_t *filetype; /* Filetype for banner */
} cupsd_banner_t;
* Globals...
*/
-VAR int NumBanners VALUE(0);
- /* Number of banner files available */
+VAR int NumBanners VALUE(0);
+ /* Number of banner files available */
VAR cupsd_banner_t *Banners VALUE(NULL);
- /* Available banner files */
+ /* Available banner files */
/*
* Prototypes...
*/
-extern void cupsdAddBanner(const char *name, const char *filename);
+extern void cupsdAddBanner(const char *name, const char *filename);
extern cupsd_banner_t *cupsdFindBanner(const char *name);
-extern void cupsdLoadBanners(const char *d);
+extern void cupsdLoadBanners(const char *d);
/*
* cupsdDeleteAllCerts() - Delete all certificates...
* cupsdFindCert() - Find a certificate.
* cupsdInitCerts() - Initialize the certificate "system" and root
- * certificate.
+ * certificate.
*/
/*
*/
void
-cupsdAddCert(int pid, /* I - Process ID */
- const char *username) /* I - Username */
+cupsdAddCert(int pid, /* I - Process ID */
+ const char *username) /* I - Username */
{
int i; /* Looping var */
cupsd_cert_t *cert; /* Current certificate */
/* Hex constants... */
- cupsdLogMessage(L_DEBUG2, "cupsdAddCert: adding certificate for pid %d", pid);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdAddCert: adding certificate for pid %d", pid);
/*
* Allocate memory for the certificate...
if ((fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0400)) < 0)
{
- cupsdLogMessage(L_ERROR, "cupsdAddCert: Unable to create certificate file %s - %s",
- filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdAddCert: Unable to create certificate file %s - %s",
+ filename, strerror(errno));
free(cert);
return;
}
*/
void
-cupsdDeleteCert(int pid) /* I - Process ID */
+cupsdDeleteCert(int pid) /* I - Process ID */
{
cupsd_cert_t *cert, /* Current certificate */
*prev; /* Previous certificate */
* Remove this certificate from the list...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdDeleteCert: removing certificate for pid %d", pid);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdDeleteCert: removing certificate for pid %d", pid);
DEBUG_printf(("DELETE pid=%d, username=%s, cert=%s\n", cert->pid,
cert->username, cert->certificate));
snprintf(filename, sizeof(filename), "%s/certs/%d", StateDir, pid);
if (unlink(filename))
- cupsdLogMessage(L_ERROR, "cupsdDeleteCert: Unable to remove %s!\n", filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdDeleteCert: Unable to remove %s!\n", filename);
return;
}
snprintf(filename, sizeof(filename), "%s/certs/%d", StateDir, cert->pid);
if (unlink(filename))
- cupsdLogMessage(L_ERROR, "cupsdDeleteAllCerts: Unable to remove %s!\n", filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdDeleteAllCerts: Unable to remove %s!\n", filename);
/*
* Free memory...
DEBUG_printf(("cupsdFindCert(certificate=%s)\n", certificate));
for (cert = Certs; cert != NULL; cert = cert->next)
- if (strcasecmp(certificate, cert->certificate) == 0)
+ if (!strcasecmp(certificate, cert->certificate))
{
DEBUG_printf((" returning %s...\n", cert->username));
return (cert->username);
/*
- * 'cupsdInitCerts()' - Initialize the certificate "system" and root certificate.
+ * 'cupsdInitCerts()' - Initialize the certificate "system" and root
+ * certificate.
*/
void
typedef struct cupsd_cert_s
{
struct cupsd_cert_s *next; /* Next certificate in list */
- int pid; /* Process ID (0 for root certificate) */
- char certificate[33];/* 32 hex characters, or 128 bits */
- char username[33]; /* Authenticated username */
+ int pid; /* Process ID (0 for root certificate) */
+ char certificate[33]; /* 32 hex characters, or 128 bits */
+ char username[33]; /* Authenticated username */
} cupsd_cert_t;
*/
VAR cupsd_cert_t *Certs; /* List of certificates */
-VAR time_t RootCertTime; /* Root certificate update time */
+VAR time_t RootCertTime; /* Root certificate update time */
/*
* cupsdLoadAllClasses() - Load classes from the classes.conf file.
* cupsdSaveAllClasses() - Save classes to the classes.conf file.
* cupsdUpdateImplicitClasses() - Update the accepting state of implicit
- * classes.
+ * classes.
*/
/*
*/
cupsd_printer_t * /* O - New class */
-cupsdAddClass(const char *name) /* I - Name of class */
+cupsdAddClass(const char *name) /* I - Name of class */
{
cupsd_printer_t *c; /* New class */
c->type = CUPS_PRINTER_CLASS;
- cupsdSetStringf(&c->uri, "ipp://%s:%d/classes/%s", ServerName, LocalPort, name);
+ cupsdSetStringf(&c->uri, "ipp://%s:%d/classes/%s", ServerName, LocalPort,
+ name);
cupsdSetString(&c->error_policy, "retry-job");
}
*/
void
-cupsdAddPrinterToClass(cupsd_printer_t *c, /* I - Class to add to */
- cupsd_printer_t *p) /* I - Printer to add */
+cupsdAddPrinterToClass(
+ cupsd_printer_t *c, /* I - Class to add to */
+ cupsd_printer_t *p) /* I - Printer to add */
{
- int i; /* Looping var */
+ int i; /* Looping var */
cupsd_printer_t **temp; /* Pointer to printer array */
if (temp == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to add printer %s to class %s!",
- p->name, c->name);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to add printer %s to class %s!",
+ p->name, c->name);
return;
}
*/
void
-cupsdDeletePrinterFromClass(cupsd_printer_t *c, /* I - Class to delete from */
- cupsd_printer_t *p) /* I - Printer to delete */
+cupsdDeletePrinterFromClass(
+ cupsd_printer_t *c, /* I - Class to delete from */
+ cupsd_printer_t *p) /* I - Printer to delete */
{
int i; /* Looping var */
cups_ptype_t type; /* Class type */
*/
void
-cupsdDeletePrinterFromClasses(cupsd_printer_t *p) /* I - Printer to delete */
+cupsdDeletePrinterFromClasses(
+ cupsd_printer_t *p) /* I - Printer to delete */
{
- cupsd_printer_t *c; /* Pointer to current class */
+ cupsd_printer_t *c; /* Pointer to current class */
/*
void
cupsdDeleteAllClasses(void)
{
- cupsd_printer_t *c; /* Pointer to current printer/class */
+ cupsd_printer_t *c; /* Pointer to current printer/class */
for (c = (cupsd_printer_t *)cupsArrayFirst(Printers);
* 'cupsdFindAvailablePrinter()' - Find an available printer in a class.
*/
-cupsd_printer_t * /* O - Available printer or NULL */
-cupsdFindAvailablePrinter(const char *name) /* I - Class to check */
+cupsd_printer_t * /* O - Available printer or NULL */
+cupsdFindAvailablePrinter(
+ const char *name) /* I - Class to check */
{
- int i; /* Looping var */
- cupsd_printer_t *c; /* Printer class */
+ int i; /* Looping var */
+ cupsd_printer_t *c; /* Printer class */
/*
if ((c = cupsdFindClass(name)) == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to find class \"%s\"!", name);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to find class \"%s\"!", name);
return (NULL);
}
void
cupsdLoadAllClasses(void)
{
- cups_file_t *fp; /* classes.conf file */
- int linenum; /* Current line number */
- char line[1024], /* Line from file */
- *value, /* Pointer to value */
- *valueptr; /* Pointer into value */
- cupsd_printer_t *p, /* Current printer class */
- *temp; /* Temporary pointer to printer */
+ cups_file_t *fp; /* classes.conf file */
+ int linenum; /* Current line number */
+ char line[1024], /* Line from file */
+ *value, /* Pointer to value */
+ *valueptr; /* Pointer into value */
+ cupsd_printer_t *p, /* Current printer class */
+ *temp; /* Temporary pointer to printer */
/*
snprintf(line, sizeof(line), "%s/classes.conf", ServerRoot);
if ((fp = cupsFileOpen(line, "r")) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllClasses: Unable to open %s - %s", line,
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllClasses: Unable to open %s - %s", line,
+ strerror(errno));
return;
}
if (p == NULL && value)
{
- cupsdLogMessage(L_DEBUG, "cupsdLoadAllClasses: Loading class %s...", value);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdLoadAllClasses: Loading class %s...", value);
p = cupsdAddClass(value);
p->accepting = 1;
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
else if (!p)
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
else if (!strcasecmp(line, "Info"))
{
if (!value)
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
else if ((temp = cupsdFindPrinter(value)) == NULL)
{
- cupsdLogMessage(L_WARN, "Unknown printer %s on line %d of classes.conf.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Unknown printer %s on line %d of classes.conf.",
+ value, linenum);
/*
* Add the missing remote printer...
p->state = IPP_PRINTER_STOPPED;
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.",
+ linenum);
return;
}
}
p->accepting = 0;
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.",
+ linenum);
return;
}
}
p->shared = 0;
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.",
+ linenum);
return;
}
}
if (value)
{
- for (valueptr = value; *valueptr && !isspace(*valueptr & 255); valueptr ++);
+ for (valueptr = value;
+ *valueptr && !isspace(*valueptr & 255);
+ valueptr ++);
if (*valueptr)
*valueptr++ = '\0';
- cupsdSetString(&p->cupsd_job_sheets[0], value);
+ cupsdSetString(&p->job_sheets[0], value);
while (isspace(*valueptr & 255))
valueptr ++;
if (*valueptr)
{
- for (value = valueptr; *valueptr && !isspace(*valueptr & 255); valueptr ++);
+ for (value = valueptr;
+ *valueptr && !isspace(*valueptr & 255);
+ valueptr ++);
if (*valueptr)
*valueptr++ = '\0';
- cupsdSetString(&p->cupsd_job_sheets[1], value);
+ cupsdSetString(&p->job_sheets[1], value);
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
p->quota_period = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
p->page_limit = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
p->k_limit = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
cupsdSetString(&p->op_policy, value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
cupsdSetString(&p->error_policy, value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of classes.conf.", linenum);
return;
}
}
* Something else we don't understand...
*/
- cupsdLogMessage(L_ERROR, "Unknown configuration directive %s on line %d of classes.conf.",
- line, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown configuration directive %s on line %d of classes.conf.",
+ line, linenum);
}
}
void
cupsdSaveAllClasses(void)
{
- cups_file_t *fp; /* classes.conf file */
- char temp[1024]; /* Temporary string */
- char backup[1024]; /* classes.conf.O file */
- cupsd_printer_t *pclass; /* Current printer class */
- int i; /* Looping var */
- time_t curtime; /* Current time */
- struct tm *curdate; /* Current date */
+ cups_file_t *fp; /* classes.conf file */
+ char temp[1024]; /* Temporary string */
+ char backup[1024]; /* classes.conf.O file */
+ cupsd_printer_t *pclass; /* Current printer class */
+ int i; /* Looping var */
+ time_t curtime; /* Current time */
+ struct tm *curdate; /* Current date */
/*
snprintf(backup, sizeof(backup), "%s/classes.conf.O", ServerRoot);
if (rename(temp, backup))
- cupsdLogMessage(L_ERROR, "Unable to backup classes.conf - %s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to backup classes.conf - %s",
+ strerror(errno));
if ((fp = cupsFileOpen(temp, "w")) == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to save classes.conf - %s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to save classes.conf - %s",
+ strerror(errno));
if (rename(backup, temp))
- cupsdLogMessage(L_ERROR, "Unable to restore classes.conf - %s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to restore classes.conf - %s",
+ strerror(errno));
return;
}
else
- cupsdLogMessage(L_INFO, "Saving classes.conf...");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Saving classes.conf...");
/*
* Restrict access to the file...
else
cupsFilePuts(fp, "Shared No\n");
- cupsFilePrintf(fp, "JobSheets %s %s\n", pclass->cupsd_job_sheets[0],
- pclass->cupsd_job_sheets[1]);
+ cupsFilePrintf(fp, "JobSheets %s %s\n", pclass->job_sheets[0],
+ pclass->job_sheets[1]);
for (i = 0; i < pclass->num_printers; i ++)
cupsFilePrintf(fp, "Printer %s\n", pclass->printers[i]->name);
/*
- * 'cupsdUpdateImplicitClasses()' - Update the accepting state of implicit classes.
+ * 'cupsdUpdateImplicitClasses()' - Update the accepting state of implicit
+ * classes.
*/
void
cupsdUpdateImplicitClasses(void)
{
- int i; /* Looping var */
- cupsd_printer_t *pclass; /* Current class */
- int accepting; /* printer-is-accepting-jobs value */
+ int i; /* Looping var */
+ cupsd_printer_t *pclass; /* Current class */
+ int accepting; /* printer-is-accepting-jobs value */
for (pclass = (cupsd_printer_t *)cupsArrayFirst(Printers);
*/
extern cupsd_printer_t *cupsdAddClass(const char *name);
-extern void cupsdAddPrinterToClass(cupsd_printer_t *c, cupsd_printer_t *p);
-extern void cupsdDeletePrinterFromClass(cupsd_printer_t *c, cupsd_printer_t *p);
+extern void cupsdAddPrinterToClass(cupsd_printer_t *c,
+ cupsd_printer_t *p);
+extern void cupsdDeletePrinterFromClass(cupsd_printer_t *c,
+ cupsd_printer_t *p);
extern void cupsdDeletePrinterFromClasses(cupsd_printer_t *p);
extern void cupsdDeleteAllClasses(void);
extern cupsd_printer_t *cupsdFindAvailablePrinter(const char *name);
*
* Contents:
*
- * cupsdAcceptClient() - Accept a new client.
- * cupsdCloseAllClients() - Close all remote clients immediately.
- * cupsdCloseClient() - Close a remote client.
- * cupsdEncryptClient() - Enable encryption for the client...
- * cupsdIsCGI() - Is the resource a CGI script/program?
- * cupsdReadClient() - Read data from a client.
- * cupsdSendCommand() - Send output from a command via HTTP.
- * cupsdSendError() - Send an error message via HTTP.
- * cupsdSendFile() - Send a file via HTTP.
- * cupsdSendHeader() - Send an HTTP request.
- * cupsdUpdateCGI() - Read status messages from CGI scripts and programs.
- * cupsdWriteClient() - Write data to a client as needed.
- * check_if_modified() - Decode an "If-Modified-Since" line.
- * decode_auth() - Decode an authorization string.
- * get_file() - Get a filename and state info.
- * install_conf_file() - Install a configuration file.
- * is_path_absolute() - Is a path absolute and free of relative elements.
- * pipe_command() - Pipe the output of a command to the remote client.
- * CDSAReadFunc() - Read function for CDSA decryption code.
- * CDSAWriteFunc() - Write function for CDSA encryption code.
+ * cupsdAcceptClient() - Accept a new client.
+ * cupsdCloseAllClients() - Close all remote clients immediately.
+ * cupsdCloseClient() - Close a remote client.
+ * cupsdEncryptClient() - Enable encryption for the client...
+ * cupsdIsCGI() - Is the resource a CGI script/program?
+ * cupsdReadClient() - Read data from a client.
+ * cupsdSendCommand() - Send output from a command via HTTP.
+ * cupsdSendError() - Send an error message via HTTP.
+ * cupsdSendFile() - Send a file via HTTP.
+ * cupsdSendHeader() - Send an HTTP request.
+ * cupsdUpdateCGI() - Read status messages from CGI scripts and programs.
+ * cupsdWriteClient() - Write data to a client as needed.
+ * check_if_modified() - Decode an "If-Modified-Since" line.
+ * decode_auth() - Decode an authorization string.
+ * get_file() - Get a filename and state info.
+ * install_conf_file() - Install a configuration file.
+ * is_path_absolute() - Is a path absolute and free of relative elements.
+ * pipe_command() - Pipe the output of a command to the remote client.
+ * CDSAReadFunc() - Read function for CDSA decryption code.
+ * CDSAWriteFunc() - Write function for CDSA encryption code.
*/
/*
*/
void
-cupsdAcceptClient(cupsd_listener_t *lis) /* I - Listener socket */
+cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
{
- int i; /* Looping var */
- int count; /* Count of connections on a host */
- int val; /* Parameter value */
- cupsd_client_t *con; /* New client pointer */
- const struct hostent *host; /* Host entry for address */
- char *hostname;/* Hostname for address */
- http_addr_t temp; /* Temporary address variable */
- static time_t last_dos = 0;
- /* Time of last DoS attack */
+ int i; /* Looping var */
+ int count; /* Count of connections on a host */
+ int val; /* Parameter value */
+ cupsd_client_t *con; /* New client pointer */
+ const struct hostent *host; /* Host entry for address */
+ char *hostname; /* Hostname for address */
+ http_addr_t temp; /* Temporary address variable */
+ static time_t last_dos = 0; /* Time of last DoS attack */
- cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient(lis=%p) %d NumClients = %d",
- lis, lis->fd, NumClients);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdAcceptClient(lis=%p) %d NumClients = %d",
+ lis, lis->fd, NumClients);
/*
* Make sure we don't have a full set of clients already...
if ((con->http.fd = accept(lis->fd, (struct sockaddr *)&(con->http.hostaddr),
&val)) < 0)
{
- cupsdLogMessage(L_ERROR, "Unable to accept client connection - %s.",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to accept client connection - %s.",
+ strerror(errno));
return;
}
con->http.hostaddr.ipv6.sin6_port = lis->address.ipv6.sin6_port;
else
#endif /* AF_INET6 */
- con->http.hostaddr.ipv4.sin_port = lis->address.ipv4.sin_port;
+ if (lis->address.addr.sa_family == AF_INET)
+ con->http.hostaddr.ipv4.sin_port = lis->address.ipv4.sin_port;
/*
* Check the number of clients on the same address...
if ((time(NULL) - last_dos) >= 60)
{
last_dos = time(NULL);
- cupsdLogMessage(L_WARN, "Possible DoS attack - more than %d clients connecting from %s!",
- MaxClientsPerHost, Clients[i].http.hostname);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Possible DoS attack - more than %d clients connecting from %s!",
+ MaxClientsPerHost, Clients[i].http.hostname);
}
#ifdef WIN32
* Can't have an unresolved IP address with double-lookups enabled...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient: Closing connection %d...",
- con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdAcceptClient: Closing connection %d...",
+ con->http.fd);
#ifdef WIN32
closesocket(con->http.fd);
close(con->http.fd);
#endif /* WIN32 */
- cupsdLogMessage(L_WARN, "Name lookup failed - connection from %s closed!",
- con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Name lookup failed - connection from %s closed!",
+ con->http.hostname);
return;
}
* with double-lookups enabled...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient: Closing connection %d...",
- con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdAcceptClient: Closing connection %d...",
+ con->http.fd);
#ifdef WIN32
closesocket(con->http.fd);
close(con->http.fd);
#endif /* WIN32 */
- cupsdLogMessage(L_WARN, "IP lookup failed - connection from %s closed!",
- con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "IP lookup failed - connection from %s closed!",
+ con->http.hostname);
return;
}
}
#ifdef AF_INET6
if (con->http.hostaddr.addr.sa_family == AF_INET6)
- cupsdLogMessage(L_DEBUG, "cupsdAcceptClient: %d from %s:%d.", con->http.fd,
- con->http.hostname, ntohs(con->http.hostaddr.ipv6.sin6_port));
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdAcceptClient: %d from %s:%d (IPv6)",
+ con->http.fd, con->http.hostname,
+ ntohs(con->http.hostaddr.ipv6.sin6_port));
else
#endif /* AF_INET6 */
- cupsdLogMessage(L_DEBUG, "cupsdAcceptClient: %d from %s:%d.", con->http.fd,
- con->http.hostname, ntohs(con->http.hostaddr.ipv4.sin_port));
+#ifdef AF_LOCAL
+ if (con->http.hostaddr.addr.sa_family == AF_LOCAL)
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdAcceptClient: %d from %s (Domain)",
+ con->http.fd, con->http.hostname);
+ else
+#endif /* AF_LOCAL */
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdAcceptClient: %d from %s:%d (IPv4)",
+ con->http.fd, con->http.hostname,
+ ntohs(con->http.hostaddr.ipv4.sin_port));
/*
* Get the local address the client connected to...
i = sizeof(temp);
if (getsockname(con->http.fd, (struct sockaddr *)&temp, &i))
{
- cupsdLogMessage(L_ERROR, "Unable to get local address - %s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get local address - %s",
+ strerror(errno));
strcpy(con->servername, "localhost");
con->serverport = LocalPort;
}
}
- cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient: %d connected to server on %s:%d",
- con->http.fd, con->servername, con->serverport);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdAcceptClient: %d connected to server on %s:%d",
+ con->http.fd, con->servername, con->serverport);
+
/*
* Using TCP_NODELAY improves responsiveness, especially on systems
* with a slow loopback interface... Since we write large buffers
* Add the socket to the select() input mask.
*/
- cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient: Adding fd %d to InputSet...",
- con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdAcceptClient: Adding fd %d to InputSet...",
+ con->http.fd);
FD_SET(con->http.fd, InputSet);
NumClients ++;
* 'cupsdCloseClient()' - Close a remote client.
*/
-int /* O - 1 if partial close, 0 if fully closed */
+int /* O - 1 if partial close, 0 if fully closed */
cupsdCloseClient(cupsd_client_t *con) /* I - Client to close */
{
- int partial; /* Do partial close for SSL? */
+ int partial; /* Do partial close for SSL? */
#if defined(HAVE_LIBSSL)
- SSL_CTX *context; /* Context for encryption */
- SSL *conn; /* Connection for encryption */
- unsigned long error; /* Error code */
+ SSL_CTX *context; /* Context for encryption */
+ SSL *conn; /* Connection for encryption */
+ unsigned long error; /* Error code */
#elif defined(HAVE_GNUTLS)
- http_tls_t *conn; /* TLS connection information */
- int error; /* Error code */
+ http_tls_t *conn; /* TLS connection information */
+ int error; /* Error code */
gnutls_certificate_server_credentials *credentials;
- /* TLS credentials */
+ /* TLS credentials */
#elif defined(HAVE_CDSASSL)
- int status; /* Error status */
+ int status; /* Error status */
#endif /* HAVE_LIBSSL */
- cupsdLogMessage(L_DEBUG, "cupsdCloseClient: %d", con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdCloseClient: %d", con->http.fd);
/*
* Flush pending writes before closing...
switch (SSL_shutdown(conn))
{
case 1 :
- cupsdLogMessage(L_INFO, "cupsdCloseClient: SSL shutdown successful!");
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "cupsdCloseClient: SSL shutdown successful!");
break;
case -1 :
- cupsdLogMessage(L_ERROR, "cupsdCloseClient: Fatal error during SSL shutdown!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdCloseClient: Fatal error during SSL shutdown!");
default :
while ((error = ERR_get_error()) != 0)
- cupsdLogMessage(L_ERROR, "cupsdCloseClient: %s", ERR_error_string(error, NULL));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdCloseClient: %s",
+ ERR_error_string(error, NULL));
break;
}
switch (error)
{
case GNUTLS_E_SUCCESS:
- cupsdLogMessage(L_INFO, "cupsdCloseClient: SSL shutdown successful!");
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "cupsdCloseClient: SSL shutdown successful!");
break;
default:
- cupsdLogMessage(L_ERROR, "cupsdCloseClient: %s", gnutls_strerror(error));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdCloseClient: %s", gnutls_strerror(error));
break;
}
* Stop any CGI process...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: %d Killing process ID %d...",
- con->http.fd, con->pipe_pid);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdCloseClient: %d Killing process ID %d...",
+ con->http.fd, con->pipe_pid);
cupsdEndProcess(con->pipe_pid, 1);
}
{
if (FD_ISSET(con->file, InputSet))
{
- cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: %d Removing fd %d from InputSet...",
- con->http.fd, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdCloseClient: %d Removing fd %d from InputSet...",
+ con->http.fd, con->file);
FD_CLR(con->file, InputSet);
}
- cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: %d Closing data file %d.",
- con->http.fd, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdCloseClient: %d Closing data file %d.",
+ con->http.fd, con->file);
close(con->file);
con->file = -1;
* Only do a partial close so that the encrypted client gets everything.
*/
- cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: Removing fd %d from OutputSet...",
- con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdCloseClient: Removing fd %d from OutputSet...",
+ con->http.fd);
shutdown(con->http.fd, 0);
FD_CLR(con->http.fd, OutputSet);
}
* Shut the socket down fully...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: Removing fd %d from InputSet and OutputSet...",
- con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdCloseClient: Removing fd %d from InputSet and OutputSet...",
+ con->http.fd);
close(con->http.fd);
FD_CLR(con->http.fd, InputSet);
FD_CLR(con->http.fd, OutputSet);
* 'cupsdEncryptClient()' - Enable encryption for the client...
*/
-int /* O - 1 on success, 0 on error */
+int /* O - 1 on success, 0 on error */
cupsdEncryptClient(cupsd_client_t *con) /* I - Client to encrypt */
{
#if defined HAVE_LIBSSL
- SSL_CTX *context; /* Context for encryption */
- SSL *conn; /* Connection for encryption */
- unsigned long error; /* Error code */
+ SSL_CTX *context; /* Context for encryption */
+ SSL *conn; /* Connection for encryption */
+ unsigned long error; /* Error code */
/*
SSL_set_fd(conn, con->http.fd);
if (SSL_accept(conn) != 1)
{
- cupsdLogMessage(L_ERROR, "cupsdEncryptClient: Unable to encrypt connection from %s!",
- con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdEncryptClient: Unable to encrypt connection from %s!",
+ con->http.hostname);
while ((error = ERR_get_error()) != 0)
- cupsdLogMessage(L_ERROR, "cupsdEncryptClient: %s", ERR_error_string(error, NULL));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdEncryptClient: %s",
+ ERR_error_string(error, NULL));
SSL_CTX_free(context);
SSL_free(conn);
return (0);
}
- cupsdLogMessage(L_DEBUG, "cupsdEncryptClient: %d Connection from %s now encrypted.",
- con->http.fd, con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdEncryptClient: %d Connection from %s now encrypted.",
+ con->http.fd, con->http.hostname);
con->http.tls = conn;
return (1);
#elif defined(HAVE_GNUTLS)
- http_tls_t *conn; /* TLS session object */
- int error; /* Error code */
+ http_tls_t *conn; /* TLS session object */
+ int error; /* Error code */
gnutls_certificate_server_credentials *credentials;
- /* TLS credentials */
+ /* TLS credentials */
/*
* Create the SSL object and perform the SSL handshake...
malloc(sizeof(gnutls_certificate_server_credentials));
if (credentials == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdEncryptClient: Unable to encrypt connection from %s!",
- con->http.hostname);
- cupsdLogMessage(L_ERROR, "cupsdEncryptClient: %s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdEncryptClient: Unable to encrypt connection from %s!",
+ con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdEncryptClient: %s", strerror(errno));
free(conn);
return (0);
if (error != GNUTLS_E_SUCCESS)
{
- cupsdLogMessage(L_ERROR, "cupsdEncryptClient: Unable to encrypt connection from %s!",
- con->http.hostname);
- cupsdLogMessage(L_ERROR, "cupsdEncryptClient: %s", gnutls_strerror(error));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdEncryptClient: Unable to encrypt connection from %s!",
+ con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdEncryptClient: %s",
+ gnutls_strerror(error));
gnutls_deinit(conn->session);
gnutls_certificate_free_credentials(*credentials);
return (0);
}
- cupsdLogMessage(L_DEBUG, "cupsdEncryptClient: %d Connection from %s now encrypted.",
- con->http.fd, con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdEncryptClient: %d Connection from %s now encrypted.",
+ con->http.fd, con->http.hostname);
conn->credentials = credentials;
con->http.tls = conn;
if (error)
{
- cupsdLogMessage(L_ERROR, "cupsdEncryptClient: Unable to encrypt connection from %s!",
- con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdEncryptClient: Unable to encrypt connection from %s!",
+ con->http.hostname);
- cupsdLogMessage(L_ERROR, "cupsdEncryptClient: CDSA error code is %d", error);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdEncryptClient: CDSA error code is %d", error);
con->http.error = error;
con->http.status = HTTP_ERROR;
return (0);
}
- cupsdLogMessage(L_DEBUG, "cupsdEncryptClient: %d Connection from %s now encrypted.",
- con->http.fd, con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdEncryptClient: %d Connection from %s now encrypted.",
+ con->http.fd, con->http.hostname);
con->http.tls = conn;
return (1);
* 'cupsdIsCGI()' - Is the resource a CGI script/program?
*/
-int /* O - 1 = CGI, 0 = file */
-cupsdIsCGI(cupsd_client_t *con, /* I - Client connection */
- const char *filename, /* I - Real filename */
- struct stat *filestats, /* I - File information */
- mime_type_t *type) /* I - MIME type */
+int /* O - 1 = CGI, 0 = file */
+cupsdIsCGI(cupsd_client_t *con, /* I - Client connection */
+ const char *filename, /* I - Real filename */
+ struct stat *filestats, /* I - File information */
+ mime_type_t *type) /* I - MIME type */
{
- const char *options; /* Options on URL */
+ const char *options; /* Options on URL */
- cupsdLogMessage(L_DEBUG2, "cupsdIsCGI(con=%p, filename=\"%s\", filestats=%p, type=%s/%s)\n",
- con, filename, filestats, type ? type->super : "unknown",
- type ? type->type : "unknown");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsCGI(con=%p, filename=\"%s\", filestats=%p, type=%s/%s)\n",
+ con, filename, filestats, type ? type->super : "unknown",
+ type ? type->type : "unknown");
/*
* Get the options, if any...
if (!type || strcasecmp(type->super, "application"))
{
- cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 0...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsCGI: Returning 0...");
return (0);
}
else
cupsdSetStringf(&con->options, "%s", filename);
- cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
- con->command, con->options);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
+ con->command, con->options);
return (1);
}
else
cupsdSetStringf(&con->options, "java %s", filename);
- cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
- con->command, con->options);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
+ con->command, con->options);
return (1);
}
else
cupsdSetStringf(&con->options, "perl %s", filename);
- cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
- con->command, con->options);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
+ con->command, con->options);
return (1);
}
else
cupsdSetStringf(&con->options, "php %s", filename);
- cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
- con->command, con->options);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
+ con->command, con->options);
return (1);
}
else
cupsdSetStringf(&con->options, "python %s", filename);
- cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
- con->command, con->options);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"",
+ con->command, con->options);
return (1);
}
#endif /* HAVE_PYTHON */
- cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 0...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsCGI: Returning 0...");
return (0);
}
*/
int /* O - 1 on success, 0 on error */
-cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
+cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
{
- char line[32768], /* Line from client... */
- operation[64], /* Operation code from socket */
- version[64], /* HTTP version number string */
- locale[64], /* Locale */
- *ptr; /* Pointer into strings */
- int major, minor; /* HTTP version numbers */
- http_status_t status; /* Transfer status */
- ipp_state_t ipp_state; /* State of IPP transfer */
- int bytes; /* Number of bytes to POST */
- char *filename; /* Name of file for GET/HEAD */
- char buf[1024]; /* Buffer for real filename */
- struct stat filestats; /* File information */
- mime_type_t *type; /* MIME type of file */
- cupsd_printer_t *p; /* Printer */
- static unsigned request_id = 0; /* Request ID for temp files */
+ char line[32768], /* Line from client... */
+ operation[64], /* Operation code from socket */
+ version[64], /* HTTP version number string */
+ locale[64], /* Locale */
+ *ptr; /* Pointer into strings */
+ int major, minor; /* HTTP version numbers */
+ http_status_t status; /* Transfer status */
+ ipp_state_t ipp_state; /* State of IPP transfer */
+ int bytes; /* Number of bytes to POST */
+ char *filename; /* Name of file for GET/HEAD */
+ char buf[1024]; /* Buffer for real filename */
+ struct stat filestats; /* File information */
+ mime_type_t *type; /* MIME type of file */
+ cupsd_printer_t *p; /* Printer */
+ static unsigned request_id = 0; /* Request ID for temp files */
status = HTTP_CONTINUE;
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d, used=%d, file=%d", con->http.fd,
- con->http.used, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadClient: %d, used=%d, file=%d",
+ con->http.fd, con->http.used, con->file);
if (con->http.error)
{
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: http error seen...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadClient: http error seen...");
return (cupsdCloseClient(con));
}
* Encrypt this connection...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: Saw first byte %02X, auto-negotiating SSL/TLS session...",
- buf[0] & 255);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: Saw first byte %02X, auto-negotiating SSL/TLS session...",
+ buf[0] & 255);
cupsdEncryptClient(con);
return (1);
if (httpGets(line, sizeof(line) - 1, HTTP(con)) == NULL)
{
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: httpGets returned EOF...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: httpGets returned EOF...");
return (cupsdCloseClient(con));
}
switch (sscanf(line, "%63s%1023s%63s", operation, con->uri, version))
{
case 1 :
- cupsdLogMessage(L_ERROR, "Bad request line \"%s\" from %s!", line,
- con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad request line \"%s\" from %s!", line,
+ con->http.hostname);
cupsdSendError(con, HTTP_BAD_REQUEST);
return (cupsdCloseClient(con));
case 2 :
case 3 :
if (sscanf(version, "HTTP/%d.%d", &major, &minor) != 2)
{
- cupsdLogMessage(L_ERROR, "Bad request line \"%s\" from %s!", line,
- con->http.hostname);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad request line \"%s\" from %s!", line,
+ con->http.hostname);
cupsdSendError(con, HTTP_BAD_REQUEST);
return (cupsdCloseClient(con));
}
if (con->uri[0] != '/' && strcmp(con->uri, "*"))
{
- char method[HTTP_MAX_URI], /* Method/scheme */
- userpass[HTTP_MAX_URI], /* Username:password */
- hostname[HTTP_MAX_URI], /* Hostname */
- resource[HTTP_MAX_URI]; /* Resource path */
- int port; /* Port number */
+ char method[HTTP_MAX_URI], /* Method/scheme */
+ userpass[HTTP_MAX_URI], /* Username:password */
+ hostname[HTTP_MAX_URI], /* Hostname */
+ resource[HTTP_MAX_URI]; /* Resource path */
+ int port; /* Port number */
/*
* Nope, we don't do proxies...
*/
- cupsdLogMessage(L_ERROR, "Bad URI \"%s\" in request!", con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad URI \"%s\" in request!",
+ con->uri);
cupsdSendError(con, HTTP_METHOD_NOT_ALLOWED);
return (cupsdCloseClient(con));
}
* Process the request...
*/
- if (strcmp(operation, "GET") == 0)
+ if (!strcmp(operation, "GET"))
con->http.state = HTTP_GET;
- else if (strcmp(operation, "PUT") == 0)
+ else if (!strcmp(operation, "PUT"))
con->http.state = HTTP_PUT;
- else if (strcmp(operation, "POST") == 0)
+ else if (!strcmp(operation, "POST"))
con->http.state = HTTP_POST;
- else if (strcmp(operation, "DELETE") == 0)
+ else if (!strcmp(operation, "DELETE"))
con->http.state = HTTP_DELETE;
- else if (strcmp(operation, "TRACE") == 0)
+ else if (!strcmp(operation, "TRACE"))
con->http.state = HTTP_TRACE;
- else if (strcmp(operation, "OPTIONS") == 0)
+ else if (!strcmp(operation, "OPTIONS"))
con->http.state = HTTP_OPTIONS;
- else if (strcmp(operation, "HEAD") == 0)
+ else if (!strcmp(operation, "HEAD"))
con->http.state = HTTP_HEAD;
else
{
- cupsdLogMessage(L_ERROR, "Bad operation \"%s\"!", operation);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad operation \"%s\"!", operation);
cupsdSendError(con, HTTP_BAD_REQUEST);
return (cupsdCloseClient(con));
}
con->start = time(NULL);
con->operation = con->http.state;
- cupsdLogMessage(L_DEBUG, "cupsdReadClient: %d %s %s HTTP/%d.%d", con->http.fd,
- operation, con->uri,
- con->http.version / 100, con->http.version % 100);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdReadClient: %d %s %s HTTP/%d.%d", con->http.fd,
+ operation, con->uri,
+ con->http.version / 100, con->http.version % 100);
con->http.status = HTTP_OK;
decode_auth(con);
- if (strncmp(con->http.fields[HTTP_FIELD_CONNECTION], "Keep-Alive", 10) == 0 &&
+ if (!strncmp(con->http.fields[HTTP_FIELD_CONNECTION], "Keep-Alive", 10) &&
KeepAlive)
con->http.keep_alive = HTTP_KEEPALIVE_ON;
- if (con->http.fields[HTTP_FIELD_HOST][0] == '\0' &&
+ if (!con->http.fields[HTTP_FIELD_HOST][0] &&
con->http.version >= HTTP_1_1)
{
/*
if ((status = cupsdIsAuthorized(con, NULL)) != HTTP_OK)
{
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: Unauthorized request for %s...\n",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: Unauthorized request for %s...\n",
+ con->uri);
cupsdSendError(con, status);
return (cupsdCloseClient(con));
}
switch (con->http.state)
{
case HTTP_GET_SEND :
- if (strncmp(con->uri, "/printers/", 10) == 0 &&
- strcmp(con->uri + strlen(con->uri) - 4, ".ppd") == 0)
+ if (!strncmp(con->uri, "/printers/", 10) &&
+ !strcmp(con->uri + strlen(con->uri) - 4, ".ppd"))
{
/*
* Send PPD file - get the real printer name since printer
if (!strncmp(con->uri, "/admin", 6))
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/admin.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/admin.cgi",
+ ServerBin);
if ((ptr = strchr(con->uri + 6, '?')) != NULL)
cupsdSetStringf(&con->options, "admin%s", ptr);
}
else if (!strncmp(con->uri, "/printers", 9))
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi",
+ ServerBin);
cupsdSetString(&con->options, con->uri + 9);
}
else if (!strncmp(con->uri, "/classes", 8))
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi",
+ ServerBin);
cupsdSetString(&con->options, con->uri + 8);
}
else if (!strncmp(con->uri, "/jobs", 5))
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/jobs.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/jobs.cgi",
+ ServerBin);
cupsdSetString(&con->options, con->uri + 5);
}
else
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/help.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/help.cgi",
+ ServerBin);
cupsdSetString(&con->options, con->uri + 5);
}
* so check the length against any limits that are set...
*/
- cupsdLogMessage(L_DEBUG2, "POST %s", con->uri);
- cupsdLogMessage(L_DEBUG2, "CONTENT_TYPE = %s", con->http.fields[HTTP_FIELD_CONTENT_TYPE]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "POST %s", con->uri);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "CONTENT_TYPE = %s",
+ con->http.fields[HTTP_FIELD_CONTENT_TYPE]);
if (con->http.fields[HTTP_FIELD_CONTENT_LENGTH][0] &&
- atoi(con->http.fields[HTTP_FIELD_CONTENT_LENGTH]) > MaxRequestSize &&
+ atoi(con->http.fields[HTTP_FIELD_CONTENT_LENGTH]) >
+ MaxRequestSize &&
MaxRequestSize > 0)
{
/*
* content-type field will be "application/ipp"...
*/
- if (strcmp(con->http.fields[HTTP_FIELD_CONTENT_TYPE], "application/ipp") == 0)
+ if (!strcmp(con->http.fields[HTTP_FIELD_CONTENT_TYPE],
+ "application/ipp"))
con->request = ippNew();
else if ((!strncmp(con->uri, "/admin", 6) &&
strncmp(con->uri, "/admin/conf/", 12) &&
if (!strncmp(con->uri, "/admin", 6))
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/admin.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/admin.cgi",
+ ServerBin);
if ((ptr = strchr(con->uri + 6, '?')) != NULL)
cupsdSetStringf(&con->options, "admin%s", ptr);
}
else if (!strncmp(con->uri, "/printers", 9))
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi",
+ ServerBin);
cupsdSetString(&con->options, con->uri + 9);
}
else if (!strncmp(con->uri, "/classes", 8))
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi",
+ ServerBin);
cupsdSetString(&con->options, con->uri + 8);
}
else if (!strncmp(con->uri, "/jobs", 5))
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/jobs.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/jobs.cgi",
+ ServerBin);
cupsdSetString(&con->options, con->uri + 5);
}
else
{
- cupsdSetStringf(&con->command, "%s/cgi-bin/help.cgi", ServerBin);
+ cupsdSetStringf(&con->command, "%s/cgi-bin/help.cgi",
+ ServerBin);
cupsdSetString(&con->options, con->uri + 5);
}
if (con->options[0] == '/')
_cups_strcpy(con->options, con->options + 1);
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d command=\"%s\", options = \"%s\"",
- con->http.fd, con->command, con->options);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d command=\"%s\", options = \"%s\"",
+ con->http.fd, con->command, con->options);
if (con->http.version <= HTTP_1_0)
con->http.keep_alive = HTTP_KEEPALIVE_OFF;
* so check the length against any limits that are set...
*/
- cupsdLogMessage(L_DEBUG2, "PUT %s", con->uri);
- cupsdLogMessage(L_DEBUG2, "CONTENT_TYPE = %s", con->http.fields[HTTP_FIELD_CONTENT_TYPE]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "PUT %s", con->uri);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "CONTENT_TYPE = %s",
+ con->http.fields[HTTP_FIELD_CONTENT_TYPE]);
if (con->http.fields[HTTP_FIELD_CONTENT_LENGTH][0] &&
- atoi(con->http.fields[HTTP_FIELD_CONTENT_LENGTH]) > MaxRequestSize &&
+ atoi(con->http.fields[HTTP_FIELD_CONTENT_LENGTH]) >
+ MaxRequestSize &&
MaxRequestSize > 0)
{
/*
* Open a temporary file to hold the request...
*/
- cupsdSetStringf(&con->filename, "%s/%08x", RequestRoot, request_id ++);
+ cupsdSetStringf(&con->filename, "%s/%08x", RequestRoot,
+ request_id ++);
con->file = open(con->filename, O_WRONLY | O_CREAT | O_TRUNC, 0640);
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d REQUEST %s=%d", con->http.fd,
- con->filename, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d REQUEST %s=%d", con->http.fd,
+ con->filename, con->file);
if (con->file < 0)
{
switch (con->http.state)
{
case HTTP_PUT_RECV :
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d con->data_encoding = %s, con->data_remaining = %d, con->file = %d",
- con->http.fd,
- con->http.data_encoding == HTTP_ENCODE_CHUNKED ? "chunked" : "length",
- con->http.data_remaining, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d con->data_encoding = %s, con->data_remaining = %d, con->file = %d",
+ con->http.fd,
+ con->http.data_encoding == HTTP_ENCODE_CHUNKED ?
+ "chunked" : "length",
+ con->http.data_remaining, con->file);
if ((bytes = httpRead(HTTP(con), line, sizeof(line))) < 0)
return (cupsdCloseClient(con));
{
con->bytes += bytes;
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d writing %d bytes to %d",
- con->http.fd, bytes, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d writing %d bytes to %d",
+ con->http.fd, bytes, con->file);
if (write(con->file, line, bytes) < bytes)
{
- cupsdLogMessage(L_ERROR, "cupsdReadClient: Unable to write %d bytes to %s: %s",
- bytes, con->filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdReadClient: Unable to write %d bytes to %s: %s",
+ bytes, con->filename, strerror(errno));
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: Closing data file %d...",
- con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: Closing data file %d...",
+ con->file);
close(con->file);
con->file = -1;
fstat(con->file, &filestats);
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d Closing data file %d, size = %d.",
- con->http.fd, con->file, (int)filestats.st_size);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d Closing data file %d, size = %d.",
+ con->http.fd, con->file, (int)filestats.st_size);
close(con->file);
con->file = -1;
* Request is too big; remove it and send an error...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d Removing temp file %s",
- con->http.fd, con->filename);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d Removing temp file %s",
+ con->http.fd, con->filename);
unlink(con->filename);
cupsdClearString(&con->filename);
break;
case HTTP_POST_RECV :
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d con->data_encoding = %s, con->data_remaining = %d, con->file = %d",
- con->http.fd,
- con->http.data_encoding == HTTP_ENCODE_CHUNKED ? "chunked" : "length",
- con->http.data_remaining, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d con->data_encoding = %s, con->data_remaining = %d, con->file = %d",
+ con->http.fd,
+ con->http.data_encoding == HTTP_ENCODE_CHUNKED ?
+ "chunked" : "length",
+ con->http.data_remaining, con->file);
if (con->request != NULL)
{
if ((ipp_state = ippRead(&(con->http), con->request)) == IPP_ERROR)
{
- cupsdLogMessage(L_ERROR, "cupsdReadClient: %d IPP Read Error!",
- con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdReadClient: %d IPP Read Error!",
+ con->http.fd);
cupsdSendError(con, HTTP_BAD_REQUEST);
return (cupsdCloseClient(con));
cupsdSetStringf(&con->filename, "%s/%08x", RequestRoot, request_id ++);
con->file = open(con->filename, O_WRONLY | O_CREAT | O_TRUNC, 0640);
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d REQUEST %s=%d", con->http.fd,
- con->filename, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReadClient: %d REQUEST %s=%d", con->http.fd,
+ con->filename, con->file);
if (con->file < 0)
{
{
con->bytes += bytes;
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d writing %d bytes to %d",
- con->http.fd, bytes, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d writing %d bytes to %d",
+ con->http.fd, bytes, con->file);
if (write(con->file, line, bytes) < bytes)
{
- cupsdLogMessage(L_ERROR, "cupsdReadClient: Unable to write %d bytes to %s: %s",
- bytes, con->filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdReadClient: Unable to write %d bytes to %s: %s",
+ bytes, con->filename, strerror(errno));
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: Closing file %d...",
- con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: Closing file %d...",
+ con->file);
close(con->file);
con->file = -1;
{
fstat(con->file, &filestats);
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d Closing data file %d, size = %d.",
- con->http.fd, con->file, (int)filestats.st_size);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d Closing data file %d, size = %d.",
+ con->http.fd, con->file, (int)filestats.st_size);
close(con->file);
con->file = -1;
* Request is too big; remove it and send an error...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d Removing temp file %s",
- con->http.fd, con->filename);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdReadClient: %d Removing temp file %s",
+ con->http.fd, con->filename);
unlink(con->filename);
cupsdClearString(&con->filename);
*/
int /* O - 1 on success, 0 on failure */
-cupsdSendCommand(cupsd_client_t *con, /* I - Client connection */
- char *command, /* I - Command to run */
- char *options, /* I - Command-line options */
- int root) /* I - Run as root? */
+cupsdSendCommand(
+ cupsd_client_t *con, /* I - Client connection */
+ char *command, /* I - Command to run */
+ char *options, /* I - Command-line options */
+ int root) /* I - Run as root? */
{
int fd; /* Standard input file descriptor */
if (fd < 0)
{
- cupsdLogMessage(L_ERROR, "cupsdSendCommand: %d Unable to open \"%s\" for reading: %s",
- con->http.fd, con->filename ? con->filename : "/dev/null",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdSendCommand: %d Unable to open \"%s\" for reading: %s",
+ con->http.fd, con->filename ? con->filename : "/dev/null",
+ strerror(errno));
return (0);
}
close(fd);
- cupsdLogMessage(L_INFO, "Started \"%s\" (pid=%d)", command, con->pipe_pid);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Started \"%s\" (pid=%d)", command,
+ con->pipe_pid);
- cupsdLogMessage(L_DEBUG, "cupsdSendCommand: %d file=%d", con->http.fd, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdSendCommand: %d file=%d",
+ con->http.fd, con->file);
if (con->pipe_pid == 0)
return (0);
fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC);
- cupsdLogMessage(L_DEBUG2, "cupsdSendCommand: Adding fd %d to InputSet...", con->file);
- cupsdLogMessage(L_DEBUG2, "cupsdSendCommand: Adding fd %d to OutputSet...",
- con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSendCommand: Adding fd %d to InputSet...", con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSendCommand: Adding fd %d to OutputSet...",
+ con->http.fd);
FD_SET(con->file, InputSet);
FD_SET(con->http.fd, OutputSet);
* 'cupsdSendError()' - Send an error message via HTTP.
*/
-int /* O - 1 if successful, 0 otherwise */
-cupsdSendError(cupsd_client_t *con, /* I - Connection */
- http_status_t code) /* I - Error code */
+int /* O - 1 if successful, 0 otherwise */
+cupsdSendError(cupsd_client_t *con, /* I - Connection */
+ http_status_t code) /* I - Error code */
{
- char message[1024]; /* Message for user */
+ char message[1024]; /* Message for user */
/*
cupsdLogRequest(con, code);
- cupsdLogMessage(L_DEBUG, "cupsdSendError: %d code=%d (%s)", con->http.fd, code,
- httpStatus(code));
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdSendError: %d code=%d (%s)",
+ con->http.fd, code, httpStatus(code));
/*
* To work around bugs in some proxies, don't use Keep-Alive for some
* 'cupsdSendFile()' - Send a file via HTTP.
*/
-int
-cupsdSendFile(cupsd_client_t *con,
- http_status_t code,
- char *filename,
- char *type,
- struct stat *filestats)
+int /* O - 0 on failure, 1 on success */
+cupsdSendFile(cupsd_client_t *con, /* I - Client connection */
+ http_status_t code, /* I - HTTP status */
+ char *filename, /* I - Filename */
+ char *type, /* I - File type */
+ struct stat *filestats)/* O - File information */
{
con->file = open(filename, O_RDONLY);
- cupsdLogMessage(L_DEBUG, "cupsdSendFile: %d file=%d", con->http.fd, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdSendFile: %d file=%d", con->http.fd,
+ con->file);
if (con->file < 0)
return (0);
if (!cupsdSendHeader(con, code, type))
return (0);
- if (httpPrintf(HTTP(con), "Last-Modified: %s\r\n", httpGetDateString(filestats->st_mtime)) < 0)
+ if (httpPrintf(HTTP(con), "Last-Modified: %s\r\n",
+ httpGetDateString(filestats->st_mtime)) < 0)
return (0);
if (httpPrintf(HTTP(con), "Content-Length: %lu\r\n",
(unsigned long)filestats->st_size) < 0)
if (httpPrintf(HTTP(con), "\r\n") < 0)
return (0);
- cupsdLogMessage(L_DEBUG2, "cupsdSendFile: Adding fd %d to OutputSet...", con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSendFile: Adding fd %d to OutputSet...", con->http.fd);
FD_SET(con->http.fd, OutputSet);
* 'cupsdSendHeader()' - Send an HTTP request.
*/
-int /* O - 1 on success, 0 on failure */
-cupsdSendHeader(cupsd_client_t *con, /* I - Client to send to */
- http_status_t code, /* I - HTTP status code */
- char *type) /* I - MIME type of document */
+int /* O - 1 on success, 0 on failure */
+cupsdSendHeader(cupsd_client_t *con, /* I - Client to send to */
+ http_status_t code, /* I - HTTP status code */
+ char *type) /* I - MIME type of document */
{
if (httpPrintf(HTTP(con), "HTTP/%d.%d %d %s\r\n", con->http.version / 100,
con->http.version % 100, code, httpStatus(code)) < 0)
{
if (httpPrintf(HTTP(con), "Connection: Keep-Alive\r\n") < 0)
return (0);
- if (httpPrintf(HTTP(con), "Keep-Alive: timeout=%d\r\n", KeepAliveTimeout) < 0)
+ if (httpPrintf(HTTP(con), "Keep-Alive: timeout=%d\r\n",
+ KeepAliveTimeout) < 0)
return (0);
}
if (code == HTTP_METHOD_NOT_ALLOWED)
if (auth_type != AUTH_DIGEST)
{
- if (httpPrintf(HTTP(con), "WWW-Authenticate: Basic realm=\"CUPS\"\r\n") < 0)
+ if (httpPrintf(HTTP(con),
+ "WWW-Authenticate: Basic realm=\"CUPS\"\r\n") < 0)
return (0);
}
else
{
- if (httpPrintf(HTTP(con), "WWW-Authenticate: Digest realm=\"CUPS\", "
- "nonce=\"%s\"\r\n", con->http.hostname) < 0)
+ if (httpPrintf(HTTP(con),
+ "WWW-Authenticate: Digest realm=\"CUPS\", nonce=\"%s\"\r\n",
+ con->http.hostname) < 0)
return (0);
}
}
{
if (!strcmp(type, "text/html"))
{
- if (httpPrintf(HTTP(con), "Content-Type: text/html; charset=utf-8\r\n") < 0)
+ if (httpPrintf(HTTP(con),
+ "Content-Type: text/html; charset=utf-8\r\n") < 0)
return (0);
}
else if (httpPrintf(HTTP(con), "Content-Type: %s\r\n", type) < 0)
* Fatal error on pipe - should never happen!
*/
- cupsdLogMessage(L_CRIT, "cupsdUpdateCGI: error reading from CGI error pipe - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_CRIT,
+ "cupsdUpdateCGI: error reading from CGI error pipe - %s",
+ strerror(errno));
}
}
*/
int /* O - 1 if success, 0 if fail */
-cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */
+cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */
{
int bytes; /* Number of bytes written */
char buf[16385]; /* Data buffer */
#ifdef DEBUG
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient(con=%p) %d response=%p, file=%d pipe_pid=%d",
- con, con->http.fd, con->response, con->file, con->pipe_pid);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdWriteClient(con=%p) %d response=%p, file=%d pipe_pid=%d",
+ con, con->http.fd, con->response, con->file, con->pipe_pid);
#endif /* DEBUG */
if (con->http.state != HTTP_GET_SEND &&
}
else if ((bytes = read(con->file, buf, sizeof(buf) - 1)) > 0)
{
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: Read %d bytes from file %d...",
- bytes, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdWriteClient: Read %d bytes from file %d...",
+ bytes, con->file);
if (con->pipe_pid && !con->got_fields)
{
bufptr[-1] = '\0';
*bufptr++ = '\0';
- cupsdLogMessage(L_DEBUG2, "Script header: %s", buf);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "Script header: %s", buf);
if (!con->sent_header)
{
if (strncasecmp(buf, "Status:", 7))
httpPrintf(HTTP(con), "%s\r\n", buf);
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d %s", con->http.fd, buf);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdWriteClient: %d %s",
+ con->http.fd, buf);
/*
* Update buffer...
else if (*bufptr != '\r')
con->field_col ++;
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d bytes=%d, got_fields=%d",
- con->http.fd, bytes, con->got_fields);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdWriteClient: %d bytes=%d, got_fields=%d",
+ con->http.fd, bytes, con->got_fields);
if (bytes > 0 && !con->got_fields)
{
if (httpWrite(HTTP(con), buf, bytes) < 0)
{
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d Write of %d bytes failed!",
- con->http.fd, bytes);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdWriteClient: %d Write of %d bytes failed!",
+ con->http.fd, bytes);
cupsdCloseClient(con);
return (0);
if (bytes <= 0)
{
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d bytes < 0", con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdWriteClient: %d bytes < 0",
+ con->http.fd);
cupsdLogRequest(con, HTTP_OK);
con->http.state = HTTP_WAITING;
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: Removing fd %d from OutputSet...",
- con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdWriteClient: Removing fd %d from OutputSet...",
+ con->http.fd);
FD_CLR(con->http.fd, OutputSet);
{
if (FD_ISSET(con->file, InputSet))
{
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: Removing fd %d from InputSet...",
- con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdWriteClient: Removing fd %d from InputSet...",
+ con->file);
FD_CLR(con->file, InputSet);
}
if (con->pipe_pid)
cupsdEndProcess(con->pipe_pid, 0);
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d Closing data file %d.",
- con->http.fd, con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdWriteClient: %d Closing data file %d.",
+ con->http.fd, con->file);
close(con->file);
con->file = -1;
if (con->filename)
{
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d Removing temp file %s",
- con->http.fd, con->filename);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdWriteClient: %d Removing temp file %s",
+ con->http.fd, con->filename);
unlink(con->filename);
cupsdClearString(&con->filename);
}
if (con->pipe_pid && !FD_ISSET(con->file, InputSet))
{
- cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: Adding fd %d to InputSet...", con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdWriteClient: Adding fd %d to InputSet...",
+ con->file);
FD_SET(con->file, InputSet);
}
}
* 'check_if_modified()' - Decode an "If-Modified-Since" line.
*/
-static int /* O - 1 if modified since */
-check_if_modified(cupsd_client_t *con, /* I - Client connection */
- struct stat *filestats) /* I - File information */
+static int /* O - 1 if modified since */
+check_if_modified(
+ cupsd_client_t *con, /* I - Client connection */
+ struct stat *filestats) /* I - File information */
{
- char *ptr; /* Pointer into field */
- time_t date; /* Time/date value */
- int size; /* Size/length value */
+ char *ptr; /* Pointer into field */
+ time_t date; /* Time/date value */
+ int size; /* Size/length value */
size = 0;
if (*ptr == '\0')
return (1);
- cupsdLogMessage(L_DEBUG2, "check_if_modified: %d If-Modified-Since=\"%s\"",
- con->http.fd, ptr);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "check_if_modified: %d If-Modified-Since=\"%s\"",
+ con->http.fd, ptr);
while (*ptr != '\0')
{
}
}
- cupsdLogMessage(L_DEBUG2, "check_if_modified: %d sizes=%d,%d dates=%d,%d",
- con->http.fd, size, (int)filestats->st_size, (int)date,
- (int)filestats->st_mtime);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "check_if_modified: %d sizes=%d,%d dates=%d,%d",
+ con->http.fd, size, (int)filestats->st_size, (int)date,
+ (int)filestats->st_mtime);
return ((size != filestats->st_size && size != 0) ||
(date < filestats->st_mtime && date != 0) ||
*/
static void
-decode_auth(cupsd_client_t *con) /* I - Client to decode to */
+decode_auth(cupsd_client_t *con) /* I - Client to decode to */
{
char *s, /* Authorization string */
value[1024]; /* Value string */
s = con->http.fields[HTTP_FIELD_AUTHORIZATION];
- cupsdLogMessage(L_DEBUG2, "decode_auth(%p): Authorization string = \"%s\"",
- con, s);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "decode_auth(%p): Authorization string = \"%s\"", con, s);
- if (strncmp(s, "Basic", 5) == 0)
+ if (!strncmp(s, "Basic", 5))
{
s += 5;
while (isspace(*s))
if ((s = strchr(value, ':')) == NULL)
{
- cupsdLogMessage(L_DEBUG, "decode_auth: %d no colon in auth string \"%s\"",
- con->http.fd, value);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "decode_auth: %d no colon in auth string \"%s\"",
+ con->http.fd, value);
return;
}
strlcpy(con->username, value, sizeof(con->username));
strlcpy(con->password, s, sizeof(con->password));
}
- else if (strncmp(s, "Local", 5) == 0)
+ else if (!strncmp(s, "Local", 5))
{
s += 5;
while (isspace(*s))
if ((username = cupsdFindCert(s)) != NULL)
strlcpy(con->username, username, sizeof(con->username));
}
- else if (strncmp(s, "Digest", 5) == 0)
+ else if (!strncmp(s, "Digest", 6))
{
/*
* Get the username and password from the Digest attributes...
strlcpy(con->password, value, sizeof(con->password));
}
- cupsdLogMessage(L_DEBUG2, "decode_auth: %d username=\"%s\"",
- con->http.fd, con->username);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "decode_auth: %d username=\"%s\"",
+ con->http.fd, con->username);
}
*/
static char * /* O - Real filename */
-get_file(cupsd_client_t *con, /* I - Client connection */
- struct stat *filestats, /* O - File information */
- char *filename, /* IO - Filename buffer */
- int len) /* I - Buffer length */
+get_file(cupsd_client_t *con, /* I - Client connection */
+ struct stat *filestats, /* O - File information */
+ char *filename, /* IO - Filename buffer */
+ int len) /* I - Buffer length */
{
int status; /* Status of filesystem calls */
char *ptr; /* Pointer info filename */
#endif /* HAVE_PYTHON */
}
- cupsdLogMessage(L_DEBUG2, "get_file: %d filename=%s size=%d",
- con->http.fd, filename, status ? -1 : (int)filestats->st_size);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_file: %d filename=%s size=%d",
+ con->http.fd, filename,
+ status ? -1 : (int)filestats->st_size);
if (!status)
con->http.data_remaining = (int)filestats->st_size;
snprintf(newfile, sizeof(newfile), "%s%s.N", ServerRoot, con->uri + 11);
snprintf(oldfile, sizeof(oldfile), "%s%s.O", ServerRoot, con->uri + 11);
- cupsdLogMessage(L_INFO, "Installing config file \"%s\"...", conffile);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Installing config file \"%s\"...", conffile);
/*
* Get the owner, group, and permissions of the configuration file.
if ((in = cupsFileOpen(con->filename, "rb")) == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to open request file \"%s\" - %s",
- con->filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open request file \"%s\" - %s",
+ con->filename, strerror(errno));
return (HTTP_SERVER_ERROR);
}
if ((out = cupsFileOpen(newfile, "wb")) == NULL)
{
cupsFileClose(in);
- cupsdLogMessage(L_ERROR, "Unable to open config file \"%s\" - %s",
- newfile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open config file \"%s\" - %s",
+ newfile, strerror(errno));
return (HTTP_SERVER_ERROR);
}
while ((bytes = cupsFileRead(in, buffer, sizeof(buffer))) > 0)
if (cupsFileWrite(out, buffer, bytes) < bytes)
{
- cupsdLogMessage(L_ERROR, "Unable to copy to config file \"%s\" - %s",
- newfile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to copy to config file \"%s\" - %s",
+ newfile, strerror(errno));
cupsFileClose(in);
cupsFileClose(out);
cupsFileClose(in);
if (cupsFileClose(out))
{
- cupsdLogMessage(L_ERROR, "Error file closing config file \"%s\" - %s",
- newfile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Error file closing config file \"%s\" - %s",
+ newfile, strerror(errno));
unlink(newfile);
if (unlink(oldfile))
if (errno != ENOENT)
{
- cupsdLogMessage(L_ERROR, "Unable to remove backup config file \"%s\" - %s",
- oldfile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to remove backup config file \"%s\" - %s",
+ oldfile, strerror(errno));
unlink(newfile);
if (rename(conffile, oldfile))
if (errno != ENOENT)
{
- cupsdLogMessage(L_ERROR, "Unable to rename old config file \"%s\" - %s",
- conffile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to rename old config file \"%s\" - %s",
+ conffile, strerror(errno));
unlink(newfile);
if (rename(newfile, conffile))
{
- cupsdLogMessage(L_ERROR, "Unable to rename new config file \"%s\" - %s",
- newfile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to rename new config file \"%s\" - %s",
+ newfile, strerror(errno));
rename(oldfile, conffile);
unlink(newfile);
*/
static int /* O - Process ID */
-pipe_command(cupsd_client_t *con, /* I - Client connection */
- int infile, /* I - Standard input for command */
- int *outfile, /* O - Standard output for command */
- char *command, /* I - Command to run */
- char *options, /* I - Options for command */
- int root) /* I - Run as root? */
+pipe_command(cupsd_client_t *con, /* I - Client connection */
+ int infile, /* I - Standard input for command */
+ int *outfile, /* O - Standard output for command */
+ char *command, /* I - Command to run */
+ char *options, /* I - Options for command */
+ int root) /* I - Run as root? */
{
int i; /* Looping var */
int pid; /* Process ID */
script_name[1024], /* SCRIPT_NAME environment variable */
server_name[1024], /* SERVER_NAME environment variable */
server_port[1024]; /* SERVER_PORT environment variable */
- static const char * const locale_encodings[] =
- { /* Locale charset names */
- "ASCII", "ISO8859-1", "ISO8859-2", "ISO8859-3",
- "ISO8859-4", "ISO8859-5", "ISO8859-6", "ISO8859-7",
- "ISO8859-8", "ISO8859-9", "ISO8859-10", "UTF-8",
- "ISO8859-13", "ISO8859-14", "ISO8859-15", "CP874",
- "CP1250", "CP1251", "CP1252", "CP1253",
- "CP1254", "CP1255", "CP1256", "CP1257",
- "CP1258", "KOI8R", "KOI8U", "ISO8859-11",
- "ISO8859-16", "", "", "",
-
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
-
- "CP932", "CP936", "CP949", "CP950",
- "CP1361", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
-
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
- "", "", "", "",
-
- "EUC-CN", "EUC-JP", "EUC-KR", "EUC-TW"
- };
/*
* be consistent with Apache...
*/
- cupsdLogMessage(L_DEBUG2, "pipe_command: command=\"%s\", options=\"%s\"",
- command, options);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "pipe_command: command=\"%s\", options=\"%s\"",
+ command, options);
strlcpy(argbuf, options, sizeof(argbuf));
*/
if (con->language)
- snprintf(lang, sizeof(lang), "LANG=%s.%s", con->language->language,
- locale_encodings[con->language->encoding]);
+ snprintf(lang, sizeof(lang), "LANG=%s.UTF-8", con->language->language);
else
strcpy(lang, "LANG=C");
if (con->operation == HTTP_GET)
{
for (i = 0; i < argc; i ++)
- cupsdLogMessage(L_DEBUG2, "argv[%d] = \"%s\"", i, argv[i]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "argv[%d] = \"%s\"", i, argv[i]);
envp[envc ++] = "REQUEST_METHOD=GET";
envp[envc] = NULL;
- if (LogLevel == L_DEBUG2)
+ if (LogLevel == CUPSD_LOG_DEBUG2)
{
for (i = 0; i < argc; i ++)
- cupsdLogMessage(L_DEBUG2, "pipe_command: argv[%d] = \"%s\"", i, argv[i]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "pipe_command: argv[%d] = \"%s\"", i, argv[i]);
for (i = 0; i < envc; i ++)
- cupsdLogMessage(L_DEBUG2, "pipe_command: envp[%d] = \"%s\"", i, envp[i]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "pipe_command: envp[%d] = \"%s\"", i, envp[i]);
}
/*
{
cupsdClearString(&query_string);
- cupsdLogMessage(L_ERROR, "Unable to create pipes for CGI %s - %s",
- argv[0], strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create pipes for CGI %s - %s",
+ argv[0], strerror(errno));
return (0);
}
* Error - can't fork!
*/
- cupsdLogMessage(L_ERROR, "Unable to fork for CGI %s - %s", argv[0],
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to fork for CGI %s - %s", argv[0],
+ strerror(errno));
cupsdClosePipe(fds);
pid = 0;
if (con->username[0])
cupsdAddCert(pid, con->username);
- cupsdLogMessage(L_DEBUG, "CGI %s started - PID = %d", command, pid);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "CGI %s started - PID = %d", command, pid);
*outfile = fds[0];
close(fds[1]);
* 'CDSAReadFunc()' - Read function for CDSA decryption code.
*/
-static OSStatus /* O - -1 on error, 0 on success */
-CDSAReadFunc(SSLConnectionRef connection, /* I - SSL/TLS connection */
- void *data, /* I - Data buffer */
- size_t *dataLength) /* IO - Number of bytes */
+static OSStatus /* O - -1 on error, 0 on success */
+CDSAReadFunc(
+ SSLConnectionRef connection, /* I - SSL/TLS connection */
+ void *data, /* I - Data buffer */
+ size_t *dataLength) /* IO - Number of bytes */
{
- ssize_t bytes; /* Number of bytes read */
+ ssize_t bytes; /* Number of bytes read */
bytes = recv((int)connection, data, *dataLength, 0);
* 'CDSAWriteFunc()' - Write function for CDSA encryption code.
*/
-static OSStatus /* O - -1 on error, 0 on success */
-CDSAWriteFunc(SSLConnectionRef connection, /* I - SSL/TLS connection */
- const void *data, /* I - Data buffer */
- size_t *dataLength) /* IO - Number of bytes */
+static OSStatus /* O - -1 on error, 0 on success */
+CDSAWriteFunc(
+ SSLConnectionRef connection, /* I - SSL/TLS connection */
+ const void *data, /* I - Data buffer */
+ size_t *dataLength) /* IO - Number of bytes */
{
ssize_t bytes;
struct cupsd_client_s
{
- http_t http; /* HTTP client connection */
- ipp_t *request, /* IPP request information */
- *response; /* IPP response information */
- cupsd_location_t *best; /* Best match for AAA */
- time_t start; /* Request start time */
- http_state_t operation; /* Request operation */
- int bytes; /* Bytes transferred for this request */
- char username[33], /* Username from Authorization: line */
- password[33], /* Password from Authorization: line */
- uri[HTTP_MAX_URI], /* Localized URL/URI for GET/PUT */
- *filename, /* Filename of output file */
- *command, /* Command to run */
- *options; /* Options for command */
- int file; /* Input/output file */
- int file_ready; /* Input ready on file/pipe? */
- int pipe_pid; /* Pipe process ID (or 0 if not a pipe) */
- int sent_header, /* Non-zero if sent HTTP header */
- got_fields, /* Non-zero if all fields seen */
- field_col; /* Column within line */
- cups_lang_t *language; /* Language to use */
+ http_t http; /* HTTP client connection */
+ ipp_t *request, /* IPP request information */
+ *response; /* IPP response information */
+ cupsd_location_t *best; /* Best match for AAA */
+ time_t start; /* Request start time */
+ http_state_t operation; /* Request operation */
+ int bytes; /* Bytes transferred for this request */
+ char username[33], /* Username from Authorization: line */
+ password[33], /* Password from Authorization: line */
+ uri[HTTP_MAX_URI],
+ /* Localized URL/URI for GET/PUT */
+ *filename, /* Filename of output file */
+ *command, /* Command to run */
+ *options; /* Options for command */
+ int file; /* Input/output file */
+ int file_ready; /* Input ready on file/pipe? */
+ int pipe_pid; /* Pipe process ID (or 0 if not a pipe) */
+ int sent_header, /* Non-zero if sent HTTP header */
+ got_fields, /* Non-zero if all fields seen */
+ field_col; /* Column within line */
+ cups_lang_t *language; /* Language to use */
#ifdef HAVE_SSL
- int auto_ssl; /* Automatic test for SSL/TLS */
+ int auto_ssl; /* Automatic test for SSL/TLS */
#endif /* HAVE_SSL */
- char servername[256]; /* Server name for connection */
- int serverport; /* Server port for connection */
+ char servername[256];/* Server name for connection */
+ int serverport; /* Server port for connection */
};
#define HTTP(con) &((con)->http)
extern int cupsdCloseClient(cupsd_client_t *con);
extern int cupsdEncryptClient(cupsd_client_t *con);
extern int cupsdIsCGI(cupsd_client_t *con, const char *filename,
- struct stat *filestats, mime_type_t *type);
+ struct stat *filestats, mime_type_t *type);
extern void cupsdPauseListening(void);
extern int cupsdProcessIPPRequest(cupsd_client_t *con);
extern int cupsdReadClient(cupsd_client_t *con);
extern void cupsdResumeListening(void);
-extern int cupsdSendCommand(cupsd_client_t *con, char *command, char *options,
- int root);
+extern int cupsdSendCommand(cupsd_client_t *con, char *command,
+ char *options, int root);
extern int cupsdSendError(cupsd_client_t *con, http_status_t code);
-extern int cupsdSendFile(cupsd_client_t *con, http_status_t code, char *filename,
- char *type, struct stat *filestats);
-extern int cupsdSendHeader(cupsd_client_t *con, http_status_t code, char *type);
+extern int cupsdSendFile(cupsd_client_t *con, http_status_t code,
+ char *filename, char *type,
+ struct stat *filestats);
+extern int cupsdSendHeader(cupsd_client_t *con, http_status_t code,
+ char *type);
extern void cupsdShutdownClient(cupsd_client_t *con);
extern void cupsdStartListening(void);
extern void cupsdStopListening(void);
*
* Contents:
*
- * cupsdReadConfiguration() - Read the cupsd.conf file.
- * get_address() - Get an address + port number from a line.
- * get_addr_and_mask() - Get an IP address and netmask.
- * parse_aaa() - Parse authentication, authorization, and
- * access control lines.
- * read_configuration() - Read a configuration file.
- * read_location() - Read a <Location path> definition.
- * read_policy() - Read a <Policy name> definition.
- * CDSAGetServerCerts() - Convert a keychain name into the CFArrayRef
- * required by SSLSetCertificate.
+ * cupsdReadConfiguration() - Read the cupsd.conf file.
+ * get_address() - Get an address + port number from a line.
+ * get_addr_and_mask() - Get an IP address and netmask.
+ * parse_aaa() - Parse authentication, authorization, and
+ * access control lines.
+ * read_configuration() - Read a configuration file.
+ * read_location() - Read a <Location path> definition.
+ * read_policy() - Read a <Policy name> definition.
+ * CDSAGetServerCerts() - Convert a keychain name into the CFArrayRef
+ * required by SSLSetCertificate.
*/
/*
#include <sys/utsname.h>
#include <cups/dir.h>
-#ifdef HAVE_DOMAINSOCKETS
-# include <sys/un.h>
-#endif /* HAVE_DOMAINSOCKETS */
-
#ifdef HAVE_CDSASSL
# include <Security/SecureTransport.h>
# include <Security/SecIdentitySearch.h>
* Configuration variable structure...
*/
-typedef struct
+typedef enum
{
- char *name; /* Name of variable */
- void *ptr; /* Pointer to variable */
- int type; /* Type (int, string, address) */
-} var_t;
+ CUPSD_VARTYPE_INTEGER, /* Integer option */
+ CUPSD_VARTYPE_STRING, /* String option */
+ CUPSD_VARTYPE_BOOLEAN /* Boolean option */
+} cupsd_vartype_t;
-#define VAR_INTEGER 0
-#define VAR_STRING 1
-#define VAR_BOOLEAN 2
+typedef struct
+{
+ char *name; /* Name of variable */
+ void *ptr; /* Pointer to variable */
+ cupsd_vartype_t type; /* Type (int, string, address) */
+} cupsd_var_t;
/*
* Local globals...
*/
-static var_t variables[] =
+static cupsd_var_t variables[] =
{
- { "AccessLog", &AccessLog, VAR_STRING },
- { "AutoPurgeJobs", &JobAutoPurge, VAR_BOOLEAN },
- { "BrowseInterval", &BrowseInterval, VAR_INTEGER },
- { "BrowseLocalOptions", &BrowseLocalOptions, VAR_STRING },
- { "BrowsePort", &BrowsePort, VAR_INTEGER },
- { "BrowseRemoteOptions", &BrowseRemoteOptions, VAR_STRING },
- { "BrowseShortNames", &BrowseShortNames, VAR_BOOLEAN },
- { "BrowseTimeout", &BrowseTimeout, VAR_INTEGER },
- { "Browsing", &Browsing, VAR_BOOLEAN },
- { "CacheDir", &CacheDir, VAR_STRING },
- { "Classification", &Classification, VAR_STRING },
- { "ClassifyOverride", &ClassifyOverride, VAR_BOOLEAN },
- { "ConfigFilePerm", &ConfigFilePerm, VAR_INTEGER },
- { "DataDir", &DataDir, VAR_STRING },
- { "DefaultCharset", &DefaultCharset, VAR_STRING },
- { "DefaultLanguage", &DefaultLanguage, VAR_STRING },
- { "DefaultPolicy", &DefaultPolicy, VAR_STRING },
- { "DocumentRoot", &DocumentRoot, VAR_STRING },
- { "ErrorLog", &ErrorLog, VAR_STRING },
- { "FaxRetryLimit", &FaxRetryLimit, VAR_INTEGER },
- { "FaxRetryInterval", &FaxRetryInterval, VAR_INTEGER },
- { "FileDevice", &FileDevice, VAR_BOOLEAN },
- { "FilterLimit", &FilterLimit, VAR_INTEGER },
- { "FilterNice", &FilterNice, VAR_INTEGER },
- { "FontPath", &FontPath, VAR_STRING },
- { "HideImplicitMembers", &HideImplicitMembers, VAR_BOOLEAN },
- { "ImplicitClasses", &ImplicitClasses, VAR_BOOLEAN },
- { "ImplicitAnyClasses", &ImplicitAnyClasses, VAR_BOOLEAN },
- { "KeepAliveTimeout", &KeepAliveTimeout, VAR_INTEGER },
- { "KeepAlive", &KeepAlive, VAR_BOOLEAN },
- { "LimitRequestBody", &MaxRequestSize, VAR_INTEGER },
- { "ListenBackLog", &ListenBackLog, VAR_INTEGER },
- { "LogFilePerm", &LogFilePerm, VAR_INTEGER },
- { "MaxActiveJobs", &MaxActiveJobs, VAR_INTEGER },
- { "MaxClients", &MaxClients, VAR_INTEGER },
- { "MaxClientsPerHost", &MaxClientsPerHost, VAR_INTEGER },
- { "MaxCopies", &MaxCopies, VAR_INTEGER },
- { "MaxJobs", &MaxJobs, VAR_INTEGER },
- { "MaxJobsPerPrinter", &MaxJobsPerPrinter, VAR_INTEGER },
- { "MaxJobsPerUser", &MaxJobsPerUser, VAR_INTEGER },
- { "MaxLogSize", &MaxLogSize, VAR_INTEGER },
- { "MaxPrinterHistory", &MaxPrinterHistory, VAR_INTEGER },
- { "MaxRequestSize", &MaxRequestSize, VAR_INTEGER },
- { "PageLog", &PageLog, VAR_STRING },
- { "PreserveJobFiles", &JobFiles, VAR_BOOLEAN },
- { "PreserveJobHistory", &JobHistory, VAR_BOOLEAN },
- { "Printcap", &Printcap, VAR_STRING },
- { "PrintcapGUI", &PrintcapGUI, VAR_STRING },
- { "ReloadTimeout", &ReloadTimeout, VAR_INTEGER },
- { "RemoteRoot", &RemoteRoot, VAR_STRING },
- { "RequestRoot", &RequestRoot, VAR_STRING },
- { "RIPCache", &RIPCache, VAR_STRING },
- { "RunAsUser", &RunAsUser, VAR_BOOLEAN },
- { "RootCertDuration", &RootCertDuration, VAR_INTEGER },
- { "ServerAdmin", &ServerAdmin, VAR_STRING },
- { "ServerBin", &ServerBin, VAR_STRING },
+ { "AccessLog", &AccessLog, CUPSD_VARTYPE_STRING },
+ { "AutoPurgeJobs", &JobAutoPurge, CUPSD_VARTYPE_BOOLEAN },
+ { "BrowseInterval", &BrowseInterval, CUPSD_VARTYPE_INTEGER },
+ { "BrowseLocalOptions", &BrowseLocalOptions, CUPSD_VARTYPE_STRING },
+ { "BrowsePort", &BrowsePort, CUPSD_VARTYPE_INTEGER },
+ { "BrowseRemoteOptions", &BrowseRemoteOptions, CUPSD_VARTYPE_STRING },
+ { "BrowseShortNames", &BrowseShortNames, CUPSD_VARTYPE_BOOLEAN },
+ { "BrowseTimeout", &BrowseTimeout, CUPSD_VARTYPE_INTEGER },
+ { "Browsing", &Browsing, CUPSD_VARTYPE_BOOLEAN },
+ { "CacheDir", &CacheDir, CUPSD_VARTYPE_STRING },
+ { "Classification", &Classification, CUPSD_VARTYPE_STRING },
+ { "ClassifyOverride", &ClassifyOverride, CUPSD_VARTYPE_BOOLEAN },
+ { "ConfigFilePerm", &ConfigFilePerm, CUPSD_VARTYPE_INTEGER },
+ { "DataDir", &DataDir, CUPSD_VARTYPE_STRING },
+ { "DefaultCharset", &DefaultCharset, CUPSD_VARTYPE_STRING },
+ { "DefaultLanguage", &DefaultLanguage, CUPSD_VARTYPE_STRING },
+ { "DefaultPolicy", &DefaultPolicy, CUPSD_VARTYPE_STRING },
+ { "DocumentRoot", &DocumentRoot, CUPSD_VARTYPE_STRING },
+ { "ErrorLog", &ErrorLog, CUPSD_VARTYPE_STRING },
+ { "FaxRetryLimit", &FaxRetryLimit, CUPSD_VARTYPE_INTEGER },
+ { "FaxRetryInterval", &FaxRetryInterval, CUPSD_VARTYPE_INTEGER },
+ { "FileDevice", &FileDevice, CUPSD_VARTYPE_BOOLEAN },
+ { "FilterLimit", &FilterLimit, CUPSD_VARTYPE_INTEGER },
+ { "FilterNice", &FilterNice, CUPSD_VARTYPE_INTEGER },
+ { "FontPath", &FontPath, CUPSD_VARTYPE_STRING },
+ { "HideImplicitMembers", &HideImplicitMembers, CUPSD_VARTYPE_BOOLEAN },
+ { "ImplicitClasses", &ImplicitClasses, CUPSD_VARTYPE_BOOLEAN },
+ { "ImplicitAnyClasses", &ImplicitAnyClasses, CUPSD_VARTYPE_BOOLEAN },
+ { "KeepAliveTimeout", &KeepAliveTimeout, CUPSD_VARTYPE_INTEGER },
+ { "KeepAlive", &KeepAlive, CUPSD_VARTYPE_BOOLEAN },
+ { "LimitRequestBody", &MaxRequestSize, CUPSD_VARTYPE_INTEGER },
+ { "ListenBackLog", &ListenBackLog, CUPSD_VARTYPE_INTEGER },
+ { "LogFilePerm", &LogFilePerm, CUPSD_VARTYPE_INTEGER },
+ { "MaxActiveJobs", &MaxActiveJobs, CUPSD_VARTYPE_INTEGER },
+ { "MaxClients", &MaxClients, CUPSD_VARTYPE_INTEGER },
+ { "MaxClientsPerHost", &MaxClientsPerHost, CUPSD_VARTYPE_INTEGER },
+ { "MaxCopies", &MaxCopies, CUPSD_VARTYPE_INTEGER },
+ { "MaxJobs", &MaxJobs, CUPSD_VARTYPE_INTEGER },
+ { "MaxJobsPerPrinter", &MaxJobsPerPrinter, CUPSD_VARTYPE_INTEGER },
+ { "MaxJobsPerUser", &MaxJobsPerUser, CUPSD_VARTYPE_INTEGER },
+ { "MaxLogSize", &MaxLogSize, CUPSD_VARTYPE_INTEGER },
+ { "MaxPrinterHistory", &MaxPrinterHistory, CUPSD_VARTYPE_INTEGER },
+ { "MaxRequestSize", &MaxRequestSize, CUPSD_VARTYPE_INTEGER },
+ { "PageLog", &PageLog, CUPSD_VARTYPE_STRING },
+ { "PreserveJobFiles", &JobFiles, CUPSD_VARTYPE_BOOLEAN },
+ { "PreserveJobHistory", &JobHistory, CUPSD_VARTYPE_BOOLEAN },
+ { "Printcap", &Printcap, CUPSD_VARTYPE_STRING },
+ { "PrintcapGUI", &PrintcapGUI, CUPSD_VARTYPE_STRING },
+ { "ReloadTimeout", &ReloadTimeout, CUPSD_VARTYPE_INTEGER },
+ { "RemoteRoot", &RemoteRoot, CUPSD_VARTYPE_STRING },
+ { "RequestRoot", &RequestRoot, CUPSD_VARTYPE_STRING },
+ { "RIPCache", &RIPCache, CUPSD_VARTYPE_STRING },
+ { "RunAsUser", &RunAsUser, CUPSD_VARTYPE_BOOLEAN },
+ { "RootCertDuration", &RootCertDuration, CUPSD_VARTYPE_INTEGER },
+ { "ServerAdmin", &ServerAdmin, CUPSD_VARTYPE_STRING },
+ { "ServerBin", &ServerBin, CUPSD_VARTYPE_STRING },
#ifdef HAVE_SSL
- { "ServerCertificate", &ServerCertificate, VAR_STRING },
+ { "ServerCertificate", &ServerCertificate, CUPSD_VARTYPE_STRING },
# if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)
- { "ServerKey", &ServerKey, VAR_STRING },
+ { "ServerKey", &ServerKey, CUPSD_VARTYPE_STRING },
# endif /* HAVE_LIBSSL || HAVE_GNUTLS */
#endif /* HAVE_SSL */
- { "ServerName", &ServerName, VAR_STRING },
- { "ServerRoot", &ServerRoot, VAR_STRING },
- { "StateDir", &StateDir, VAR_STRING },
- { "TempDir", &TempDir, VAR_STRING },
- { "Timeout", &Timeout, VAR_INTEGER }
+ { "ServerName", &ServerName, CUPSD_VARTYPE_STRING },
+ { "ServerRoot", &ServerRoot, CUPSD_VARTYPE_STRING },
+ { "StateDir", &StateDir, CUPSD_VARTYPE_STRING },
+ { "TempDir", &TempDir, CUPSD_VARTYPE_STRING },
+ { "Timeout", &Timeout, CUPSD_VARTYPE_INTEGER }
};
#define NUM_VARS (sizeof(variables) / sizeof(variables[0]))
*slash; /* Directory separator */
char type[MIME_MAX_SUPER + MIME_MAX_TYPE];
/* MIME type name */
- char *language; /* Language string */
+ cups_lang_t *language; /* Language */
struct passwd *user; /* Default user */
struct group *group; /* Default group */
char *old_serverroot, /* Old ServerRoot */
*old_requestroot; /* Old RequestRoot */
-
/*
* Shutdown the server...
*/
if (NumListeners > 0)
{
#ifdef HAVE_DOMAINSOCKETS
- int i; /* Looping var */
- cupsd_listener_t *lis; /* Current listening socket */
+ int i; /* Looping var */
+ cupsd_listener_t *lis; /* Current listening socket */
for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)
if (lis->address.sin_family == AF_LOCAL)
# endif /* HAVE_CDSASSL */
#endif /* HAVE_SSL */
- if ((language = DEFAULT_LANGUAGE) == NULL)
- language = "en";
- else if (!strcmp(language, "C") || !strcmp(language, "POSIX"))
- language = "en";
+ language = cupsLangDefault();
+
+ if (!strcmp(language->language, "C") || !strcmp(language->language, "POSIX"))
+ cupsdSetString(&DefaultLanguage, "en");
+ else
+ cupsdSetString(&DefaultLanguage, language->language);
- cupsdSetString(&DefaultLanguage, language);
- cupsdSetString(&DefaultCharset, DEFAULT_CHARSET);
+ cupsdSetString(&DefaultCharset, cupsEncodingName(language->encoding));
cupsdSetString(&RIPCache, "8m");
KeepAliveTimeout = DEFAULT_KEEPALIVE;
ListenBackLog = SOMAXCONN;
LogFilePerm = 0644;
- LogLevel = L_ERROR;
+ LogLevel = CUPSD_LOG_ERROR;
MaxClients = 100;
MaxClientsPerHost = 0;
MaxLogSize = 1024 * 1024;
* Log the configuration file that was used...
*/
- cupsdLogMessage(L_INFO, "Loaded configuration file \"%s\"", ConfigurationFile);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Loaded configuration file \"%s\"",
+ ConfigurationFile);
/*
* Validate the Group and SystemGroup settings - they cannot be the same,
* Log the error and reset the group to a safe value...
*/
- cupsdLogMessage(L_NOTICE, "Group and SystemGroup cannot use the same groups!");
- cupsdLogMessage(L_INFO, "Resetting Group to \"nobody\"...");
+ cupsdLogMessage(CUPSD_LOG_NOTICE,
+ "Group and SystemGroup cannot use the same groups!");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Resetting Group to \"nobody\"...");
group = getgrnam("nobody");
endgrent();
* No listeners!
*/
- cupsdLogMessage(L_EMERG, "No valid Listen or Port lines were found in the configuration file!");
+ cupsdLogMessage(CUPSD_LOG_EMERG,
+ "No valid Listen or Port lines were found in the configuration file!");
/*
* Commit suicide...
if ((dir = cupsDirOpen(TempDir)) != NULL)
{
- cupsdLogMessage(L_INFO, "Cleaning out old temporary files in \"%s\"...",
- TempDir);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Cleaning out old temporary files in \"%s\"...", TempDir);
while ((dent = cupsDirRead(dir)) != NULL)
{
snprintf(tempfile, sizeof(tempfile), "%s/%s", TempDir, dent->filename);
if (unlink(tempfile))
- cupsdLogMessage(L_ERROR, "Unable to remove temporary file \"%s\" - %s",
- tempfile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to remove temporary file \"%s\" - %s",
+ tempfile, strerror(errno));
else
- cupsdLogMessage(L_DEBUG, "Removed temporary file \"%s\"...", tempfile);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Removed temporary file \"%s\"...",
+ tempfile);
}
cupsDirClose(dir);
}
else
- cupsdLogMessage(L_ERROR, "Unable to open temporary directory \"%s\" - %s",
- TempDir, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to open temporary directory \"%s\" - %s",
+ TempDir, strerror(errno));
}
/*
if (MaxClients > (MaxFDs / 3) || MaxClients <= 0)
{
if (MaxClients > 0)
- cupsdLogMessage(L_INFO, "MaxClients limited to 1/3 (%d) of the file descriptor limit (%d)...",
+ cupsdLogMessage(CUPSD_LOG_INFO, "MaxClients limited to 1/3 (%d) of the file descriptor limit (%d)...",
MaxFDs / 3, MaxFDs);
MaxClients = MaxFDs / 3;
if ((Clients = calloc(sizeof(cupsd_client_t), MaxClients)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdReadConfiguration: Unable to allocate memory for %d clients: %s",
- MaxClients, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdReadConfiguration: Unable to allocate memory for %d clients: %s",
+ MaxClients, strerror(errno));
exit(1);
}
else
- cupsdLogMessage(L_INFO, "Configured for up to %d clients.", MaxClients);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Configured for up to %d clients.",
+ MaxClients);
/*
* Check the MaxActiveJobs setting; limit to 1/3 the available
cupsdClearString(&Classification);
if (Classification)
- cupsdLogMessage(L_INFO, "Security set to \"%s\"", Classification);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Security set to \"%s\"", Classification);
/*
* Update the MaxClientsPerHost value, as needed...
if (MaxClientsPerHost > MaxClients)
MaxClientsPerHost = MaxClients;
- cupsdLogMessage(L_INFO, "Allowing up to %d client connections per host.",
- MaxClientsPerHost);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Allowing up to %d client connections per host.",
+ MaxClientsPerHost);
/*
* Update the default policy, as needed...
if (!DefaultPolicyPtr)
{
cupsd_policy_t *p; /* New policy */
- cupsd_location_t *po; /* New policy operation */
+ cupsd_location_t *po; /* New policy operation */
if (DefaultPolicy)
- cupsdLogMessage(L_ERROR, "Default policy \"%s\" not found!", DefaultPolicy);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Default policy \"%s\" not found!",
+ DefaultPolicy);
if ((DefaultPolicyPtr = cupsdFindPolicy("default")) != NULL)
- cupsdLogMessage(L_INFO, "Using policy \"default\" as the default!");
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Using policy \"default\" as the default!");
else
{
- cupsdLogMessage(L_INFO, "Creating CUPS default administrative policy:");
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Creating CUPS default administrative policy:");
DefaultPolicyPtr = p = cupsdAddPolicy("default");
- cupsdLogMessage(L_INFO, "<Policy default>");
- cupsdLogMessage(L_INFO, "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
- "Release-Job Restart-Job Purge-Jobs "
- "Set-Job-Attributes Create-Job-Subscription "
- "Renew-Subscription Cancel-Subscription "
- "Get-Notifications Reprocess-Job Cancel-Current-Job "
- "Suspend-Current-Job Resume-Job CUPS-Move-Job "
- "CUPS-Authenticate-Job>");
- cupsdLogMessage(L_INFO, "Order Deny,Allow");
+ cupsdLogMessage(CUPSD_LOG_INFO, "<Policy default>");
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
+ "Release-Job Restart-Job Purge-Jobs "
+ "Set-Job-Attributes Create-Job-Subscription "
+ "Renew-Subscription Cancel-Subscription "
+ "Get-Notifications Reprocess-Job Cancel-Current-Job "
+ "Suspend-Current-Job Resume-Job CUPS-Move-Job "
+ "CUPS-Authenticate-Job>");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
po = cupsdAddPolicyOp(p, NULL, IPP_SEND_DOCUMENT);
po->order_type = AUTH_ALLOW;
cupsdAddName(po, "@OWNER");
cupsdAddName(po, "@SYSTEM");
- cupsdLogMessage(L_INFO, "Require user @OWNER @SYSTEM");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Require user @OWNER @SYSTEM");
cupsdAddPolicyOp(p, po, IPP_SEND_URI);
cupsdAddPolicyOp(p, po, IPP_CANCEL_JOB);
cupsdAddPolicyOp(p, po, CUPS_MOVE_JOB);
cupsdAddPolicyOp(p, po, CUPS_AUTHENTICATE_JOB);
- cupsdLogMessage(L_INFO, "</Limit>");
-
- cupsdLogMessage(L_INFO, "<Limit Pause-Printer Resume-Printer "
- "Set-Printer-Attributes Enable-Printer "
- "Disable-Printer Pause-Printer-After-Current-Job "
- "Hold-New-Jobs Release-Held-New-Jobs "
- "Deactivate-Printer Activate-Printer Restart-Printer "
- "Shutdown-Printer Startup-Printer Promote-Job "
- "Schedule-Job-After CUPS-Add-Printer "
- "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
- "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
- cupsdLogMessage(L_INFO, "Order Deny,Allow");
- cupsdLogMessage(L_INFO, "AuthType Basic");
+ cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
+
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "<Limit Pause-Printer Resume-Printer "
+ "Set-Printer-Attributes Enable-Printer "
+ "Disable-Printer Pause-Printer-After-Current-Job "
+ "Hold-New-Jobs Release-Held-New-Jobs "
+ "Deactivate-Printer Activate-Printer Restart-Printer "
+ "Shutdown-Printer Startup-Printer Promote-Job "
+ "Schedule-Job-After CUPS-Add-Printer "
+ "CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
+ "CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
+ cupsdLogMessage(CUPSD_LOG_INFO, "AuthType Basic");
po = cupsdAddPolicyOp(p, NULL, IPP_PAUSE_PRINTER);
po->order_type = AUTH_ALLOW;
po->level = AUTH_USER;
cupsdAddName(po, "@SYSTEM");
- cupsdLogMessage(L_INFO, "Require user @SYSTEM");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Require user @SYSTEM");
cupsdAddPolicyOp(p, po, IPP_RESUME_PRINTER);
cupsdAddPolicyOp(p, po, IPP_SET_PRINTER_ATTRIBUTES);
cupsdAddPolicyOp(p, po, CUPS_REJECT_JOBS);
cupsdAddPolicyOp(p, po, CUPS_SET_DEFAULT);
- cupsdLogMessage(L_INFO, "</Limit>");
+ cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
- cupsdLogMessage(L_INFO, "<Limit All>");
- cupsdLogMessage(L_INFO, "Order Deny,Allow");
+ cupsdLogMessage(CUPSD_LOG_INFO, "<Limit All>");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
po = cupsdAddPolicyOp(p, NULL, IPP_ANY_OPERATION);
po->order_type = AUTH_ALLOW;
- cupsdLogMessage(L_INFO, "</Limit>");
- cupsdLogMessage(L_INFO, "</Policy>");
+ cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
+ cupsdLogMessage(CUPSD_LOG_INFO, "</Policy>");
}
}
!old_serverroot || !ServerRoot || strcmp(old_serverroot, ServerRoot) ||
!old_requestroot || !RequestRoot || strcmp(old_requestroot, RequestRoot))
{
- cupsdLogMessage(L_INFO, "Full reload is required.");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Full reload is required.");
/*
* Free all memory...
if (!MimeDatabase)
{
- cupsdLogMessage(L_EMERG, "Unable to load MIME database from \'%s\'!",
- ServerRoot);
+ cupsdLogMessage(CUPSD_LOG_EMERG,
+ "Unable to load MIME database from \'%s\'!", ServerRoot);
exit(errno);
}
- cupsdLogMessage(L_INFO, "Loaded MIME database from \'%s\': %d types, %d filters...",
- ServerRoot, MimeDatabase->num_types, MimeDatabase->num_filters);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Loaded MIME database from \'%s\': %d types, %d filters...",
+ ServerRoot, MimeDatabase->num_types, MimeDatabase->num_filters);
/*
* Create a list of MIME types for the document-format-supported
cupsdLoadAllJobs();
- cupsdLogMessage(L_INFO, "Full reload complete.");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Full reload complete.");
}
else
{
cupsdCreateCommonData();
- cupsdLogMessage(L_INFO, "Partial reload complete.");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Partial reload complete.");
}
/*
if (!*value)
{
- cupsdLogMessage(L_ERROR, "Bad (empty) address!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad (empty) address!");
return (0);
}
{
if (strlen(value) >= sizeof(address->un.sun_path))
{
- cupsdLogMessage(L_ERROR, "Domain socket name \"%s\" too long!", value);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Domain socket name \"%s\" too long!",
+ value);
return (0);
}
{
if ((host = httpGetHostByName(hostname)) == NULL)
{
- cupsdLogMessage(L_ERROR, "httpGetHostByName(\"%s\") failed - %s!", hostname,
- hstrerror(h_errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "httpGetHostByName(\"%s\") failed - %s!",
+ hostname, hstrerror(h_errno));
return (0);
}
{
if ((port = getservbyname(portname, NULL)) == NULL)
{
- cupsdLogMessage(L_ERROR, "getservbyname(\"%s\") failed - %s!", portname,
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "getservbyname(\"%s\") failed - %s!",
+ portname, strerror(errno));
return (0);
}
else
else
memcpy(mask, netmasks[ipcount - 1], sizeof(unsigned) * 4);
- cupsdLogMessage(L_DEBUG2, "get_addr_and_mask(value=\"%s\", "
- "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x]",
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "get_addr_and_mask(value=\"%s\", "
+ "ip=[%08x:%08x:%08x:%08x], mask=[%08x:%08x:%08x:%08x]",
value, ip[0], ip[1], ip[2], ip[3], mask[0], mask[1], mask[2],
mask[3]);
*/
static int /* O - 1 on success, 0 on failure */
-parse_aaa(cupsd_location_t *loc, /* I - Location */
- char *line, /* I - Line from file */
- char *value, /* I - Start of value data */
- int linenum) /* I - Current line number */
+parse_aaa(cupsd_location_t *loc, /* I - Location */
+ char *line, /* I - Line from file */
+ char *value, /* I - Start of value data */
+ int linenum) /* I - Current line number */
{
char *valptr; /* Pointer into value */
unsigned ip[4], /* IP address components */
loc->encryption = HTTP_ENCRYPT_NEVER;
else if (!strcasecmp(value, "always"))
{
- cupsdLogMessage(L_ERROR, "Encryption value \"%s\" on line %d is invalid in this context. "
- "Using \"required\" instead.", value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Encryption value \"%s\" on line %d is invalid in this "
+ "context. Using \"required\" instead.", value, linenum);
loc->encryption = HTTP_ENCRYPT_REQUIRED;
}
loc->encryption = HTTP_ENCRYPT_IF_REQUESTED;
else
{
- cupsdLogMessage(L_ERROR, "Unknown Encryption value %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown Encryption value %s on line %d.", value, linenum);
return (0);
}
}
loc->order_type = AUTH_DENY;
else
{
- cupsdLogMessage(L_ERROR, "Unknown Order value %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown Order value %s on line %d.",
+ value, linenum);
return (0);
}
}
if (!get_addr_and_mask(value, ip, mask))
{
- cupsdLogMessage(L_ERROR, "Bad netmask value %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
+ value, linenum);
return (0);
}
}
else
{
- cupsdLogMessage(L_WARN, "Unknown authorization type %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Unknown authorization type %s on line %d.",
+ value, linenum);
return (0);
}
}
}
else
{
- cupsdLogMessage(L_WARN, "Unknown authorization class %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Unknown authorization class %s on line %d.",
+ value, linenum);
return (0);
}
}
loc->level = AUTH_GROUP;
else
{
- cupsdLogMessage(L_WARN, "Unknown Require type %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown Require type %s on line %d.",
+ value, linenum);
return (0);
}
loc->satisfy = AUTH_SATISFY_ANY;
else
{
- cupsdLogMessage(L_WARN, "Unknown Satisfy value %s on line %d.", value,
- linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown Satisfy value %s on line %d.",
+ value, linenum);
return (0);
}
}
static int /* O - 1 on success, 0 on failure */
read_configuration(cups_file_t *fp) /* I - File to read from */
{
- int i; /* Looping var */
- int linenum; /* Current line number */
- char line[HTTP_MAX_BUFFER], /* Line from file */
- temp[HTTP_MAX_BUFFER], /* Temporary buffer for value */
- temp2[HTTP_MAX_BUFFER], /* Temporary buffer 2 for value */
- *ptr, /* Pointer into line/temp */
- *value; /* Pointer to value */
- int valuelen; /* Length of value */
- var_t *var; /* Current variable */
- unsigned ip[4], /* Address value */
- mask[4]; /* Netmask value */
- cupsd_dirsvc_relay_t *relay; /* Relay data */
- cupsd_dirsvc_poll_t *poll; /* Polling data */
- http_addr_t polladdr; /* Polling address */
- cupsd_location_t *location; /* Browse location */
- cups_file_t *incfile; /* Include file */
- char incname[1024]; /* Include filename */
- struct group *group; /* Group */
+ int i; /* Looping var */
+ int linenum; /* Current line number */
+ char line[HTTP_MAX_BUFFER],
+ /* Line from file */
+ temp[HTTP_MAX_BUFFER],
+ /* Temporary buffer for value */
+ temp2[HTTP_MAX_BUFFER],
+ /* Temporary buffer 2 for value */
+ *ptr, /* Pointer into line/temp */
+ *value; /* Pointer to value */
+ int valuelen; /* Length of value */
+ cupsd_var_t *var; /* Current variable */
+ unsigned ip[4], /* Address value */
+ mask[4]; /* Netmask value */
+ cupsd_dirsvc_relay_t *relay; /* Relay data */
+ cupsd_dirsvc_poll_t *poll; /* Polling data */
+ http_addr_t polladdr; /* Polling address */
+ cupsd_location_t *location; /* Browse location */
+ cups_file_t *incfile; /* Include file */
+ char incname[1024]; /* Include filename */
+ struct group *group; /* Group */
/*
snprintf(incname, sizeof(incname), "%s/%s", ServerRoot, value);
if ((incfile = cupsFileOpen(incname, "rb")) == NULL)
- cupsdLogMessage(L_ERROR, "Unable to include config file \"%s\" - %s",
- incname, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to include config file \"%s\" - %s",
+ incname, strerror(errno));
else
{
read_configuration(incfile);
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d.",
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.",
linenum);
return (0);
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
return (0);
}
}
if (!lis)
{
- cupsdLogMessage(L_ERROR, "Unable to allocate %s at line %d - %s.",
- line, linenum, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to allocate %s at line %d - %s.",
+ line, linenum, strerror(errno));
continue;
}
#ifdef AF_INET6
if (lis->address.addr.sa_family == AF_INET6)
- cupsdLogMessage(L_INFO, "Listening to %s:%d (IPv6)", temp,
- ntohs(lis->address.ipv6.sin6_port));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv6)", temp,
+ ntohs(lis->address.ipv6.sin6_port));
else
#endif /* AF_INET6 */
#ifdef AF_LOCAL
if (lis->address.addr.sa_family == AF_LOCAL)
- cupsdLogMessage(L_INFO, "Listening to %s (Domain)", temp);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s (Domain)", temp);
else
#endif /* AF_LOCAL */
- cupsdLogMessage(L_INFO, "Listening to %s:%d", temp,
- ntohs(lis->address.ipv4.sin_port));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp,
+ ntohs(lis->address.ipv4.sin_port));
NumListeners ++;
}
else
- cupsdLogMessage(L_ERROR, "Bad %s address %s at line %d.", line,
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad %s address %s at line %d.", line,
+ value, linenum);
}
#ifdef HAVE_SSL
else if (!strcasecmp(line, "SSLPort") || !strcasecmp(line, "SSLListen"))
if (!lis)
{
- cupsdLogMessage(L_ERROR, "Unable to allocate %s at line %d - %s.",
- line, linenum, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to allocate %s at line %d - %s.",
+ line, linenum, strerror(errno));
continue;
}
#ifdef AF_INET6
if (lis->address.addr.sa_family == AF_INET6)
- cupsdLogMessage(L_INFO, "Listening to %s:%d (IPv6)", temp,
- ntohs(lis->address.ipv6.sin6_port));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv6)", temp,
+ ntohs(lis->address.ipv6.sin6_port));
else
#endif /* AF_INET6 */
- cupsdLogMessage(L_INFO, "Listening to %s:%d", temp,
- ntohs(lis->address.ipv4.sin_port));
+#ifdef AF_LOCAL
+ if (lis->address.addr.sa_family == AF_LOCAL)
+ cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s (Domain)", temp);
+ else
+#endif /* AF_LOCAL */
+ cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp,
+ ntohs(lis->address.ipv4.sin_port));
lis->encryption = HTTP_ENCRYPT_ALWAYS;
NumListeners ++;
}
else
- cupsdLogMessage(L_ERROR, "Bad %s address %s at line %d.", line,
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad %s address %s at line %d.", line,
+ value, linenum);
}
#endif /* HAVE_SSL */
else if (!strcasecmp(line, "BrowseAddress"))
* Add a browse address to the list...
*/
- cupsd_dirsvc_addr_t *dira; /* New browse address array */
+ cupsd_dirsvc_addr_t *dira; /* New browse address array */
if (NumBrowsers == 0)
if (!dira)
{
- cupsdLogMessage(L_ERROR, "Unable to allocate BrowseAddress at line %d - %s.",
- linenum, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to allocate BrowseAddress at line %d - %s.",
+ linenum, strerror(errno));
continue;
}
#ifdef AF_INET6
if (dira->to.addr.sa_family == AF_INET6)
- cupsdLogMessage(L_INFO, "Sending browsing info to %s:%d (IPv6)", temp,
- ntohs(dira->to.ipv6.sin6_port));
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Sending browsing info to %s:%d (IPv6)", temp,
+ ntohs(dira->to.ipv6.sin6_port));
else
#endif /* AF_INET6 */
- cupsdLogMessage(L_INFO, "Sending browsing info to %s:%d", temp,
- ntohs(dira->to.ipv4.sin_port));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Sending browsing info to %s:%d (IPv4)",
+ temp, ntohs(dira->to.ipv4.sin_port));
NumBrowsers ++;
}
else
- cupsdLogMessage(L_ERROR, "Bad BrowseAddress %s at line %d.", value,
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad BrowseAddress %s at line %d.",
+ value, linenum);
}
else if (!strcasecmp(line, "BrowseOrder"))
{
location = cupsdAddLocation("CUPS_INTERNAL_BROWSE_ACL");
if (location == NULL)
- cupsdLogMessage(L_ERROR, "Unable to initialize browse access control list!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to initialize browse access control list!");
else if (!strncasecmp(value, "deny", 4))
location->order_type = AUTH_ALLOW;
else if (!strncasecmp(value, "allow", 5))
location->order_type = AUTH_DENY;
else
- cupsdLogMessage(L_ERROR, "Unknown BrowseOrder value %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown BrowseOrder value %s on line %d.",
+ value, linenum);
}
else if (!strcasecmp(line, "BrowseProtocols") ||
!strcasecmp(line, "BrowseLocalProtocols") ||
}
else
{
- cupsdLogMessage(L_ERROR, "Unknown browse protocol \"%s\" on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown browse protocol \"%s\" on line %d.",
+ value, linenum);
break;
}
location = cupsdAddLocation("CUPS_INTERNAL_BROWSE_ACL");
if (location == NULL)
- cupsdLogMessage(L_ERROR, "Unable to initialize browse access control list!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to initialize browse access control list!");
else
{
if (!strncasecmp(value, "from ", 5))
if (!get_addr_and_mask(value, ip, mask))
{
- cupsdLogMessage(L_ERROR, "Bad netmask value %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
+ value, linenum);
break;
}
if (!relay)
{
- cupsdLogMessage(L_ERROR, "Unable to allocate BrowseRelay at line %d - %s.",
- linenum, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to allocate BrowseRelay at line %d - %s.",
+ linenum, strerror(errno));
continue;
}
if (!get_addr_and_mask(value, ip, mask))
{
- cupsdLogMessage(L_ERROR, "Bad netmask value %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad netmask value %s on line %d.",
+ value, linenum);
break;
}
#ifdef AF_INET6
if (relay->to.addr.sa_family == AF_INET6)
- cupsdLogMessage(L_INFO, "Relaying from %s to %s:%d", temp, temp2,
- ntohs(relay->to.ipv6.sin6_port));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Relaying from %s to %s:%d (IPv6)",
+ temp, temp2, ntohs(relay->to.ipv6.sin6_port));
else
#endif /* AF_INET6 */
- cupsdLogMessage(L_INFO, "Relaying from %s to %s:%d", temp, temp2,
- ntohs(relay->to.ipv4.sin_port));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Relaying from %s to %s:%d (IPv4)",
+ temp, temp2, ntohs(relay->to.ipv4.sin_port));
NumRelays ++;
}
if (relay->from.type == AUTH_NAME)
free(relay->from.mask.name.name);
- cupsdLogMessage(L_ERROR, "Bad relay address %s at line %d.", value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad relay address %s at line %d.",
+ value, linenum);
}
}
else if (!strcasecmp(line, "BrowsePoll"))
if (!poll)
{
- cupsdLogMessage(L_ERROR, "Unable to allocate BrowsePoll at line %d - %s.",
- linenum, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to allocate BrowsePoll at line %d - %s.",
+ linenum, strerror(errno));
continue;
}
#endif /* AF_INET6 */
poll->port = ntohs(polladdr.ipv4.sin_port);
- cupsdLogMessage(L_INFO, "Polling %s:%d", poll->hostname, poll->port);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Polling %s:%d", poll->hostname,
+ poll->port);
}
else
- cupsdLogMessage(L_ERROR, "Bad poll address %s at line %d.", value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad poll address %s at line %d.",
+ value, linenum);
}
else if (!strcasecmp(line, "DefaultAuthType"))
{
DefaultAuthType = AUTH_BASICDIGEST;
else
{
- cupsdLogMessage(L_WARN, "Unknown default authorization type %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Unknown default authorization type %s on line %d.",
+ value, linenum);
return (0);
}
}
if (p != NULL)
User = p->pw_uid;
else
- cupsdLogMessage(L_ERROR, "Unknown User \"%s\" on line %d, ignoring!",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown User \"%s\" on line %d, ignoring!",
+ value, linenum);
}
}
else if (!strcasecmp(line, "Group"))
if (group != NULL)
Group = group->gr_gid;
else
- cupsdLogMessage(L_ERROR, "Unknown Group \"%s\" on line %d, ignoring!",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown Group \"%s\" on line %d, ignoring!",
+ value, linenum);
}
}
else if (!strcasecmp(line, "SystemGroup"))
* System (admin) group(s)...
*/
- char *valueptr, /* Pointer into value */
- quote; /* Quote character */
+ char *valueptr, /* Pointer into value */
+ quote; /* Quote character */
for (i = NumSystemGroups; *value && i < MAX_SYSTEM_GROUPS;)
i ++;
}
else
- cupsdLogMessage(L_ERROR, "Unknown SystemGroup \"%s\" on line %d, ignoring!",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown SystemGroup \"%s\" on line %d, ignoring!",
+ value, linenum);
endgrent();
else if (!strcasecmp(value, "double"))
HostNameLookups = 2;
else
- cupsdLogMessage(L_WARN, "Unknown HostNameLookups %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown HostNameLookups %s on line %d.",
+ value, linenum);
}
else if (!strcasecmp(line, "LogLevel"))
{
*/
if (!strcasecmp(value, "debug2"))
- LogLevel = L_DEBUG2;
+ LogLevel = CUPSD_LOG_DEBUG2;
else if (!strcasecmp(value, "debug"))
- LogLevel = L_DEBUG;
+ LogLevel = CUPSD_LOG_DEBUG;
else if (!strcasecmp(value, "info"))
- LogLevel = L_INFO;
+ LogLevel = CUPSD_LOG_INFO;
else if (!strcasecmp(value, "notice"))
- LogLevel = L_NOTICE;
+ LogLevel = CUPSD_LOG_NOTICE;
else if (!strcasecmp(value, "warn"))
- LogLevel = L_WARN;
+ LogLevel = CUPSD_LOG_WARN;
else if (!strcasecmp(value, "error"))
- LogLevel = L_ERROR;
+ LogLevel = CUPSD_LOG_ERROR;
else if (!strcasecmp(value, "crit"))
- LogLevel = L_CRIT;
+ LogLevel = CUPSD_LOG_CRIT;
else if (!strcasecmp(value, "alert"))
- LogLevel = L_ALERT;
+ LogLevel = CUPSD_LOG_ALERT;
else if (!strcasecmp(value, "emerg"))
- LogLevel = L_EMERG;
+ LogLevel = CUPSD_LOG_EMERG;
else if (!strcasecmp(value, "none"))
- LogLevel = L_NONE;
+ LogLevel = CUPSD_LOG_NONE;
else
- cupsdLogMessage(L_WARN, "Unknown LogLevel %s on line %d.", value, linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown LogLevel %s on line %d.",
+ value, linenum);
}
else if (!strcasecmp(line, "PrintcapFormat"))
{
else if (!strcasecmp(value, "solaris"))
PrintcapFormat = PRINTCAP_SOLARIS;
else
- cupsdLogMessage(L_WARN, "Unknown PrintcapFormat %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown PrintcapFormat %s on line %d.",
+ value, linenum);
}
else if (!strcasecmp(line, "ServerTokens"))
{
* Set the string used for the Server header...
*/
- struct utsname plat; /* Platform info */
+ struct utsname plat; /* Platform info */
uname(&plat);
else if (!strcasecmp(value, "OS"))
cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s)", plat.sysname);
else if (!strcasecmp(value, "Full"))
- cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s) IPP/1.1", plat.sysname);
+ cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s) IPP/1.1",
+ plat.sysname);
else if (!strcasecmp(value, "None"))
cupsdClearString(&ServerHeader);
else
- cupsdLogMessage(L_WARN, "Unknown ServerTokens %s on line %d.", value, linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown ServerTokens %s on line %d.",
+ value, linenum);
}
else
{
* Unknown directive! Output an error message and continue...
*/
- cupsdLogMessage(L_ERROR, "Unknown directive %s on line %d.", line,
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown directive %s on line %d.",
+ line, linenum);
continue;
}
switch (var->type)
{
- case VAR_INTEGER :
+ case CUPSD_VARTYPE_INTEGER :
{
- int n; /* Number */
- char *units; /* Units */
+ int n; /* Number */
+ char *units; /* Units */
n = strtol(value, &units, 0);
}
break;
- case VAR_BOOLEAN :
+ case CUPSD_VARTYPE_BOOLEAN :
if (!strcasecmp(value, "true") ||
!strcasecmp(value, "on") ||
!strcasecmp(value, "enabled") ||
!strcasecmp(value, "0"))
*((int *)var->ptr) = FALSE;
else
- cupsdLogMessage(L_ERROR, "Unknown boolean value %s on line %d.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown boolean value %s on line %d.",
+ value, linenum);
break;
- case VAR_STRING :
+ case CUPSD_VARTYPE_STRING :
cupsdSetString((char **)var->ptr, value);
break;
}
char *location, /* I - Location name/path */
int linenum) /* I - Current line number */
{
- cupsd_location_t *loc, /* New location */
- *parent; /* Parent location */
- char line[HTTP_MAX_BUFFER], /* Line buffer */
- *value, /* Value for directive */
- *valptr; /* Pointer into value */
+ cupsd_location_t *loc, /* New location */
+ *parent; /* Parent location */
+ char line[HTTP_MAX_BUFFER],
+ /* Line buffer */
+ *value, /* Value for directive */
+ *valptr; /* Pointer into value */
if ((parent = cupsdAddLocation(location)) == NULL)
{
if (!value)
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d.", linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
return (0);
}
else if (!strcmp(value, "TRACE"))
loc->limit |= AUTH_LIMIT_TRACE;
else
- cupsdLogMessage(L_WARN, "Unknown request type %s on line %d!", value,
- linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown request type %s on line %d!",
+ value, linenum);
for (value = valptr; isspace(*value & 255); value ++);
}
loc = parent;
else if (!parse_aaa(loc, line, value, linenum))
{
- cupsdLogMessage(L_ERROR, "Unknown Location directive %s on line %d.",
- line, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown Location directive %s on line %d.",
+ line, linenum);
return (0);
}
}
- cupsdLogMessage(L_ERROR, "Unexpected end-of-file at line %d while reading location!",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unexpected end-of-file at line %d while reading location!",
+ linenum);
return (0);
}
{
int i; /* Looping var */
cupsd_policy_t *pol; /* Policy */
- cupsd_location_t *op; /* Policy operation */
+ cupsd_location_t *op; /* Policy operation */
int num_ops; /* Number of IPP operations */
ipp_op_t ops[100]; /* Operations */
char line[HTTP_MAX_BUFFER],
if (!strcasecmp(line, "</Policy>"))
{
if (op)
- cupsdLogMessage(L_WARN, "Missing </Limit> before </Policy> on line %d!",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Missing </Limit> before </Policy> on line %d!",
+ linenum);
return (linenum);
}
{
if (!value)
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d.", linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d.", linenum);
return (0);
}
if (!strcasecmp(value, "All"))
ops[num_ops] = IPP_ANY_OPERATION;
else if ((ops[num_ops] = ippOpValue(value)) == IPP_BAD_OPERATION)
- cupsdLogMessage(L_ERROR, "Bad IPP operation name \"%s\" on line %d!",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad IPP operation name \"%s\" on line %d!",
+ value, linenum);
else
num_ops ++;
}
else
- cupsdLogMessage(L_ERROR, "Too many operations listed on line %d!",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Too many operations listed on line %d!",
+ linenum);
for (value = valptr; isspace(*value & 255); value ++);
}
}
else if (!op)
{
- cupsdLogMessage(L_ERROR, "Missing <Limit ops> directive before %s on line %d.",
- line, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Missing <Limit ops> directive before %s on line %d.",
+ line, linenum);
return (0);
}
else if (!parse_aaa(op, line, value, linenum))
{
if (op)
- cupsdLogMessage(L_ERROR, "Unknown Policy Limit directive %s on line %d.",
- line, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown Policy Limit directive %s on line %d.",
+ line, linenum);
else
- cupsdLogMessage(L_ERROR, "Unknown Policy directive %s on line %d.",
- line, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown Policy directive %s on line %d.",
+ line, linenum);
return (0);
}
}
- cupsdLogMessage(L_ERROR, "Unexpected end-of-file at line %d while reading policy \"%s\"!",
- linenum, policy);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unexpected end-of-file at line %d while reading policy \"%s\"!",
+ linenum, policy);
return (0);
}
err = SecKeychainOpen(ServerCertificate, &kcRef);
if (err)
- cupsdLogMessage(L_ERROR, "Cannot open keychain \"%s\", error %d.",
- ServerCertificate, err);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot open keychain \"%s\", error %d.",
+ ServerCertificate, err);
else
{
/*
err = SecIdentitySearchCreate(kcRef, CSSM_KEYUSE_SIGN, &srchRef);
if (err)
- cupsdLogMessage(L_ERROR,
- "Cannot find signing key in keychain \"%s\", error %d",
- ServerCertificate, err);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Cannot find signing key in keychain \"%s\", error %d",
+ ServerCertificate, err);
else
{
err = SecIdentitySearchCopyNext(srchRef, &identity);
if (err)
- cupsdLogMessage(L_ERROR,
- "Cannot find signing key in keychain \"%s\", error %d",
- ServerCertificate, err);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Cannot find signing key in keychain \"%s\", error %d",
+ ServerCertificate, err);
else
{
if (CFGetTypeID(identity) != SecIdentityGetTypeID())
- cupsdLogMessage(L_ERROR, "SecIdentitySearchCopyNext CFTypeID failure!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "SecIdentitySearchCopyNext CFTypeID failure!");
else
{
/*
ca = CFArrayCreate(NULL, (const void **)&identity, 1, NULL);
if (ca == nil)
- cupsdLogMessage(L_ERROR, "CFArrayCreate error");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "CFArrayCreate error");
}
/*CFRelease(identity);*/
* Log levels...
*/
-#define L_ATTR -3 /* Used internally for attributes */
-#define L_STATE -2 /* Used internally for state-reasons */
-#define L_PAGE -1 /* Used internally for page logging */
-#define L_NONE 0
-#define L_EMERG 1 /* Emergency issues */
-#define L_ALERT 2 /* Something bad happened that needs attention */
-#define L_CRIT 3 /* Critical error but server continues */
-#define L_ERROR 4 /* Error condition */
-#define L_WARN 5 /* Warning */
-#define L_NOTICE 6 /* Normal condition that needs logging */
-#define L_INFO 7 /* General information */
-#define L_DEBUG 8 /* General debugging */
-#define L_DEBUG2 9 /* Detailed debugging */
+typedef enum
+{
+ CUPSD_LOG_ATTR = -3, /* Used internally for attributes */
+ CUPSD_LOG_STATE, /* Used internally for state-reasons */
+ CUPSD_LOG_PAGE, /* Used internally for page logging */
+ CUPSD_LOG_NONE,
+ CUPSD_LOG_EMERG, /* Emergency issues */
+ CUPSD_LOG_ALERT, /* Something bad happened that needs attention */
+ CUPSD_LOG_CRIT, /* Critical error but server continues */
+ CUPSD_LOG_ERROR, /* Error condition */
+ CUPSD_LOG_WARN, /* Warning */
+ CUPSD_LOG_NOTICE, /* Normal condition that needs logging */
+ CUPSD_LOG_INFO, /* General information */
+ CUPSD_LOG_DEBUG, /* General debugging */
+ CUPSD_LOG_DEBUG2 /* Detailed debugging */
+} cupsd_loglevel_t;
/*
/* Permissions for config files */
LogFilePerm VALUE(0644),
/* Permissions for log files */
- LogLevel VALUE(L_ERROR),
+ LogLevel VALUE(CUPSD_LOG_ERROR),
/* Log level */
MaxClients VALUE(0),
/* Maximum number of clients */
#define DEFAULT_TIMEOUT 300 /* Timeout during requests/updates */
#define DEFAULT_KEEPALIVE 60 /* Timeout between requests */
#define DEFAULT_INTERVAL 30 /* Interval between browse updates */
-#define DEFAULT_LANGUAGE setlocale(LC_ALL,"")
- /* Default language encoding */
#define DEFAULT_CHARSET "utf-8" /* Default charset */
* cupsdStopPolling() - Stop polling servers as needed.
* cupsdUpdateCUPSBrowse() - Update the browse lists using the CUPS protocol.
* cupsdUpdatePolling() - Read status messages from the poll daemons.
- * RegReportCallback() - Empty SLPRegReport.
+ * slp_reg_callback() - Empty SLPRegReport.
* cupsdSendSLPBrowse() - Register the specified printer with SLP.
- * SLPDeregPrinter() - SLPDereg() the specified printer
- * GetSlpAttrVal() - Get an attribute from an SLP registration.
- * AttrCallback() - SLP attribute callback
- * SrvUrlCallback() - SLP service url callback
+ * slp_dereg_printer() - SLPDereg() the specified printer
+ * slp_get_attr() - Get an attribute from an SLP registration.
+ * slp_attr_callback() - SLP attribute callback
+ * slp_url_callback() - SLP service url callback
* cupsdUpdateSLPBrowse() - Get browsing information via SLP.
*/
#ifdef HAVE_LIBSLP
-void SLPDeregPrinter(cupsd_printer_t *p);
+static void slp_dereg_printer(cupsd_printer_t *p);
#endif /* HAVE_LIBSLP */
*/
void
-cupsdProcessBrowseData(const char *uri, /* I - URI of printer/class */
- cups_ptype_t type, /* I - Printer type */
- ipp_pstate_t state, /* I - Printer state */
- const char *location,/* I - Printer location */
- const char *info, /* I - Printer information */
- const char *make_model) /* I - Printer make and model */
+cupsdProcessBrowseData(
+ const char *uri, /* I - URI of printer/class */
+ cups_ptype_t type, /* I - Printer type */
+ ipp_pstate_t state, /* I - Printer state */
+ const char *location, /* I - Printer location */
+ const char *info, /* I - Printer information */
+ const char *make_model) /* I - Printer make and model */
{
int i; /* Looping var */
int update; /* Update printer attributes? */
*sptr; /* Pointer into ServerName */
char local_make_model[IPP_MAX_NAME];
/* Local make and model */
- cupsd_printer_t *p, /* Printer information */
+ cupsd_printer_t *p, /* Printer information */
*pclass, /* Printer class */
*first; /* First printer in class */
int offset, /* Offset of name */
(strncmp(resource, "/printers/", 10) &&
strncmp(resource, "/classes/", 9)))
{
- cupsdLogMessage(L_ERROR, "cupsdProcessBrowseData: Bad printer URI in browse data: %s",
- uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdProcessBrowseData: Bad printer URI in browse data: %s",
+ uri);
return;
}
(!strncmp(resource, "/printers/", 10) && strchr(resource + 10, '/')) ||
(!strncmp(resource, "/classes/", 9) && strchr(resource + 9, '/')))
{
- cupsdLogMessage(L_ERROR, "cupsdProcessBrowseData: Bad resource in browse data: %s",
- resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdProcessBrowseData: Bad resource in browse data: %s",
+ resource);
return;
}
if (p->type & CUPS_PRINTER_REMOTE)
{
- cupsdLogMessage(L_INFO, "Renamed remote class \"%s\" to \"%s@%s\"...",
- p->name, p->name, p->hostname);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Renamed remote class \"%s\" to \"%s@%s\"...",
+ p->name, p->name, p->hostname);
cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL,
"Class \'%s\' deleted by directory services.",
p->name);
p = cupsdAddClass(name);
- cupsdLogMessage(L_INFO, "Added remote class \"%s\"...", name);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Added remote class \"%s\"...", name);
cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
"Class \'%s\' added by directory services.", name);
if (p->type & CUPS_PRINTER_REMOTE)
{
- cupsdLogMessage(L_INFO, "Renamed remote printer \"%s\" to \"%s@%s\"...",
- p->name, p->name, p->hostname);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Renamed remote printer \"%s\" to \"%s@%s\"...",
+ p->name, p->name, p->hostname);
cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL,
"Printer \'%s\' deleted by directory services.",
p->name);
cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
"Printer \'%s\' added by directory services.", name);
- cupsdLogMessage(L_INFO, "Added remote printer \"%s\"...", name);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Added remote printer \"%s\"...", name);
/*
* Force the URI to point to the real server...
* Loop through all available printers and create classes as needed...
*/
- for (p = (cupsd_printer_t *)cupsArrayFirst(Printers), len = 0, offset = 0, update = 0,
- pclass = NULL, first = NULL;
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers), len = 0, offset = 0,
+ update = 0, pclass = NULL, first = NULL;
p != NULL;
p = (cupsd_printer_t *)cupsArrayNext(Printers))
{
update = 1;
- cupsdLogMessage(L_INFO, "Added implicit class \"%s\"...", name);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Added implicit class \"%s\"...",
+ name);
}
if (first != NULL)
*/
void
-cupsdSendBrowseDelete(cupsd_printer_t *p) /* I - Printer to delete */
+cupsdSendBrowseDelete(
+ cupsd_printer_t *p) /* I - Printer to delete */
{
/*
* Only announce if browsing is enabled...
cupsdSendCUPSBrowse(p);
#ifdef HAVE_LIBSLP
if (BrowseLocalProtocols & BROWSE_SLP)
- SLPDeregPrinter(p);
+ slp_dereg_printer(p);
#endif /* HAVE_LIBSLP */
}
cupsdSendBrowseList(void)
{
int count; /* Number of dests to update */
- cupsd_printer_t *p; /* Current printer */
+ cupsd_printer_t *p; /* Current printer */
time_t ut, /* Minimum update time */
to; /* Timeout time */
(p->type & CUPS_PRINTER_CLASS) ? "Class" : "Printer",
p->name);
- cupsdLogMessage(L_INFO, "Remote destination \"%s\" has timed out; deleting it...",
- p->name);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Remote destination \"%s\" has timed out; deleting it...",
+ p->name);
cupsdDeletePrinter(p, 1);
}
*/
void
-cupsdSendCUPSBrowse(cupsd_printer_t *p) /* I - Printer to send */
+cupsdSendCUPSBrowse(cupsd_printer_t *p) /* I - Printer to send */
{
int i; /* Looping var */
cups_ptype_t type; /* Printer type */
- cupsd_dirsvc_addr_t *b; /* Browse address */
+ cupsd_dirsvc_addr_t *b; /* Browse address */
int bytes; /* Length of packet */
char packet[1453]; /* Browse data packet */
char options[1024]; /* Browse local options */
bytes = strlen(packet);
- cupsdLogMessage(L_DEBUG2, "cupsdSendBrowseList: (%d bytes to \"%s\") %s", bytes,
- iface->name, packet);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSendBrowseList: (%d bytes to \"%s\") %s", bytes,
+ iface->name, packet);
if (iface->broadcast.addr.sa_family == AF_INET)
{
#endif /* AF_INET6 */
}
}
- else if ((iface = NetIFFind(b->iface)) != NULL)
+ else if ((iface = cupsdNetIFFind(b->iface)) != NULL)
{
/*
* Send to the named interface...
bytes = strlen(packet);
- cupsdLogMessage(L_DEBUG2, "cupsdSendBrowseList: (%d bytes to \"%s\") %s", bytes,
- iface->name, packet);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSendBrowseList: (%d bytes to \"%s\") %s", bytes,
+ iface->name, packet);
if (iface->broadcast.addr.sa_family == AF_INET)
{
p->make_model ? p->make_model : "Unknown");
bytes = strlen(packet);
- cupsdLogMessage(L_DEBUG2, "cupsdSendBrowseList: (%d bytes) %s", bytes, packet);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdSendBrowseList: (%d bytes) %s", bytes, packet);
#ifdef AF_INET6
if (sendto(BrowseSocket, packet, bytes, 0,
* list...
*/
- cupsdLogMessage(L_ERROR, "cupsdSendBrowseList: sendto failed for browser %d - %s.",
- b - Browsers + 1, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdSendBrowseList: sendto failed for browser %d - %s.",
+ b - Browsers + 1, strerror(errno));
if (i > 1)
memcpy(b, b + 1, (i - 1) * sizeof(cupsd_dirsvc_addr_t));
void
cupsdStartBrowsing(void)
{
- int val; /* Socket option value */
- struct sockaddr_in addr; /* Broadcast address */
+ int val; /* Socket option value */
+ struct sockaddr_in addr; /* Broadcast address */
if (!Browsing || !(BrowseLocalProtocols | BrowseRemoteProtocols))
if ((BrowseSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
- cupsdLogMessage(L_ERROR, "cupsdStartBrowsing: Unable to create broadcast socket - %s.",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartBrowsing: Unable to create broadcast socket - %s.",
+ strerror(errno));
BrowseLocalProtocols &= ~BROWSE_CUPS;
BrowseRemoteProtocols &= ~BROWSE_CUPS;
return;
val = 1;
if (setsockopt(BrowseSocket, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val)))
{
- cupsdLogMessage(L_ERROR, "cupsdStartBrowsing: Unable to set broadcast mode - %s.",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartBrowsing: Unable to set broadcast mode - %s.",
+ strerror(errno));
#ifdef WIN32
closesocket(BrowseSocket);
if (bind(BrowseSocket, (struct sockaddr *)&addr, sizeof(addr)))
{
- cupsdLogMessage(L_ERROR, "cupsdStartBrowsing: Unable to bind broadcast socket - %s.",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartBrowsing: Unable to bind broadcast socket - %s.",
+ strerror(errno));
#ifdef WIN32
closesocket(BrowseSocket);
* Finally, add the socket to the input selection set...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdStartBrowsing: Adding fd %d to InputSet...",
- BrowseSocket);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartBrowsing: Adding fd %d to InputSet...",
+ BrowseSocket);
FD_SET(BrowseSocket, InputSet);
}
if (SLPOpen("en", SLP_FALSE, &BrowseSLPHandle) != SLP_OK)
{
- cupsdLogMessage(L_ERROR, "Unable to open an SLP handle; disabling SLP browsing!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to open an SLP handle; disabling SLP browsing!");
BrowseLocalProtocols &= ~BROWSE_SLP;
BrowseRemoteProtocols &= ~BROWSE_SLP;
}
void
cupsdStartPolling(void)
{
- int i; /* Looping var */
- cupsd_dirsvc_poll_t *poll; /* Current polling server */
- char polld[1024]; /* Poll daemon path */
- char sport[10]; /* Server port */
- char bport[10]; /* Browser port */
- char interval[10]; /* Poll interval */
- int statusfds[2]; /* Status pipe */
- char *argv[6]; /* Arguments */
- char *envp[100]; /* Environment */
+ int i; /* Looping var */
+ cupsd_dirsvc_poll_t *poll; /* Current polling server */
+ char polld[1024]; /* Poll daemon path */
+ char sport[10]; /* Server port */
+ char bport[10]; /* Browser port */
+ char interval[10]; /* Poll interval */
+ int statusfds[2]; /* Status pipe */
+ char *argv[6]; /* Arguments */
+ char *envp[100]; /* Environment */
/*
if (cupsdOpenPipe(statusfds))
{
- cupsdLogMessage(L_ERROR, "Unable to create polling status pipes - %s.",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to create polling status pipes - %s.",
+ strerror(errno));
PollPipe = -1;
PollStatusBuffer = NULL;
return;
if (cupsdStartProcess(polld, argv, envp, -1, -1, statusfds[1], -1,
0, &(poll->pid)) < 0)
{
- cupsdLogMessage(L_ERROR, "cupsdStartPolling: Unable to fork polling daemon - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartPolling: Unable to fork polling daemon - %s",
+ strerror(errno));
poll->pid = 0;
break;
}
else
- cupsdLogMessage(L_DEBUG, "cupsdStartPolling: Started polling daemon for %s:%d, pid = %d",
- poll->hostname, poll->port, poll->pid);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdStartPolling: Started polling daemon for %s:%d, pid = %d",
+ poll->hostname, poll->port, poll->pid);
}
close(statusfds[1]);
* Finally, add the pipe to the input selection set...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdStartPolling: Adding fd %d to InputSet...",
- PollPipe);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartPolling: Adding fd %d to InputSet...", PollPipe);
FD_SET(PollPipe, InputSet);
}
close(BrowseSocket);
#endif /* WIN32 */
- cupsdLogMessage(L_DEBUG2, "cupsdStopBrowsing: Removing fd %d from InputSet...",
- BrowseSocket);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStopBrowsing: Removing fd %d from InputSet...",
+ BrowseSocket);
FD_CLR(BrowseSocket, InputSet);
BrowseSocket = -1;
void
cupsdStopPolling(void)
{
- int i; /* Looping var */
+ int i; /* Looping var */
cupsd_dirsvc_poll_t *poll; /* Current polling server */
cupsdStatBufDelete(PollStatusBuffer);
close(PollPipe);
- cupsdLogMessage(L_DEBUG2, "cupsdStopPolling: removing fd %d from InputSet.",
- PollPipe);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStopPolling: removing fd %d from InputSet.", PollPipe);
FD_CLR(PollPipe, InputSet);
PollPipe = -1;
*pptr; /* Pointer into packet */
http_addr_t srcaddr; /* Source address */
char srcname[1024]; /* Source hostname */
- unsigned address[4], /* Source address */
- temp; /* Temporary address var (host order) */
+ unsigned address[4]; /* Source address */
unsigned type; /* Printer type */
unsigned state; /* Printer state */
char uri[HTTP_MAX_URI], /* Printer URI */
if (errno != ECONNREFUSED && errno != EAGAIN)
{
- cupsdLogMessage(L_ERROR, "Browse recv failed - %s.", strerror(errno));
- cupsdLogMessage(L_ERROR, "Browsing turned off.");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Browse recv failed - %s.",
+ strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Browsing turned off.");
cupsdStopBrowsing();
Browsing = 0;
else
#endif /* AF_INET6 */
{
- temp = ntohl(srcaddr.ipv4.sin_addr.s_addr);
-
- address[3] = temp & 255;
- temp >>= 8;
- address[2] = temp & 255;
- temp >>= 8;
- address[1] = temp & 255;
- temp >>= 8;
- address[0] = temp & 255;
+ address[0] = 0;
+ address[1] = 0;
+ address[2] = 0;
+ address[3] = ntohl(srcaddr.ipv4.sin_addr.s_addr);
}
if (HostNameLookups)
if (auth == AUTH_DENY)
{
- cupsdLogMessage(L_DEBUG, "cupsdUpdateCUPSBrowse: Refused %d bytes from %s", bytes,
- srcname);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdUpdateCUPSBrowse: Refused %d bytes from %s", bytes,
+ srcname);
return;
}
- cupsdLogMessage(L_DEBUG2, "cupsdUpdateCUPSBrowse: (%d bytes from %s) %s", bytes, srcname,
- packet);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdUpdateCUPSBrowse: (%d bytes from %s) %s", bytes,
+ srcname, packet);
/*
* Parse packet...
if (sscanf(packet, "%x%x%1023s", &type, &state, uri) < 3)
{
- cupsdLogMessage(L_WARN, "cupsdUpdateCUPSBrowse: Garbled browse packet - %s",
- packet);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "cupsdUpdateCUPSBrowse: Garbled browse packet - %s", packet);
return;
}
(struct sockaddr *)&(Relays[i].to),
sizeof(http_addr_t)) <= 0)
{
- cupsdLogMessage(L_ERROR, "cupsdUpdateCUPSBrowse: sendto failed for relay %d - %s.",
- i + 1, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdUpdateCUPSBrowse: sendto failed for relay %d - %s.",
+ i + 1, strerror(errno));
return;
}
*/
cupsdProcessBrowseData(uri, (cups_ptype_t)type, (ipp_pstate_t)state, location,
- info, make_model);
+ info, make_model);
}
* All polling processes have died; stop polling...
*/
- cupsdLogMessage(L_ERROR, "cupsdUpdatePolling: all polling processes have exited!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdUpdatePolling: all polling processes have exited!");
cupsdStopPolling();
}
}
/*
- * 'RegReportCallback()' - Empty SLPRegReport.
+ * 'slp_reg_callback()' - Empty SLPRegReport.
*/
-void
-RegReportCallback(SLPHandle hslp,
+static void
+slp_reg_callback(SLPHandle hslp,
SLPError errcode,
void *cookie)
{
*/
void
-cupsdSendSLPBrowse(cupsd_printer_t *p) /* I - Printer to register */
+cupsdSendSLPBrowse(cupsd_printer_t *p) /* I - Printer to register */
{
char srvurl[HTTP_MAX_URI], /* Printer service URI */
attrs[8192], /* Printer attributes */
/* Make and model, quoted */
location[IPP_MAX_NAME * 2],
/* Location, quoted */
- info[IPP_MAX_NAME * 2],
- /* Info, quoted */
+ info[IPP_MAX_NAME * 2], /* Info, quoted */
*src, /* Pointer to original string */
*dst; /* Pointer to destination string */
ipp_attribute_t *authentication; /* uri-authentication-supported value */
SLPError error; /* SLP error, if any */
- cupsdLogMessage(L_DEBUG, "cupsdSendSLPBrowse(%p = \"%s\")", p, p->name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdSendSLPBrowse(%p = \"%s\")", p,
+ p->name);
/*
* Make the SLP service URL that conforms to the IANA
snprintf(srvurl, sizeof(srvurl), SLP_CUPS_SRVTYPE ":%s", p->uri);
- cupsdLogMessage(L_DEBUG2, "Service URL = \"%s\"", srvurl);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "Service URL = \"%s\"", srvurl);
/*
* Figure out the finishings string...
p->type & CUPS_PRINTER_DUPLEX ?
",two-sided-long-edge,two-sided-short-edge" : "");
- cupsdLogMessage(L_DEBUG2, "Attributes = \"%s\"", attrs);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "Attributes = \"%s\"", attrs);
/*
* Register the printer with the SLP server...
*/
error = SLPReg(BrowseSLPHandle, srvurl, BrowseTimeout,
- SLP_CUPS_SRVTYPE, attrs, SLP_TRUE, RegReportCallback, 0);
+ SLP_CUPS_SRVTYPE, attrs, SLP_TRUE, slp_reg_callback, 0);
if (error != SLP_OK)
- cupsdLogMessage(L_ERROR, "SLPReg of \"%s\" failed with status %d!", p->name,
- error);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "SLPReg of \"%s\" failed with status %d!", p->name,
+ error);
}
/*
- * 'SLPDeregPrinter()' - SLPDereg() the specified printer
+ * 'slp_dereg_printer()' - SLPDereg() the specified printer
*/
-void
-SLPDeregPrinter(cupsd_printer_t *p)
+static void
+slp_dereg_printer(cupsd_printer_t *p)
{
char srvurl[HTTP_MAX_URI]; /* Printer service URI */
- cupsdLogMessage(L_DEBUG, "SLPDeregPrinter: printer=\"%s\"", p->name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "slp_dereg_printer: printer=\"%s\"", p->name);
- if((p->type & CUPS_PRINTER_REMOTE) == 0)
+ if (!(p->type & CUPS_PRINTER_REMOTE))
{
/*
* Make the SLP service URL that conforms to the IANA
* Deregister the printer...
*/
- SLPDereg(BrowseSLPHandle, srvurl, RegReportCallback, 0);
+ SLPDereg(BrowseSLPHandle, srvurl, slp_reg_callback, 0);
}
}
/*
- * 'GetSlpAttrVal()' - Get an attribute from an SLP registration.
+ * 'slp_get_attr()' - Get an attribute from an SLP registration.
*/
-int /* O - 0 on success */
-GetSlpAttrVal(const char *attrlist, /* I - Attribute list string */
- const char *tag, /* I - Name of attribute */
- char **valbuf) /* O - Value */
+static int /* O - 0 on success */
+slp_get_attr(const char *attrlist, /* I - Attribute list string */
+ const char *tag, /* I - Name of attribute */
+ char **valbuf) /* O - Value */
{
char *ptr1, /* Pointer into string */
*ptr2; /* ... */
/*
- * 'AttrCallback()' - SLP attribute callback
+ * 'slp_attr_callback()' - SLP attribute callback
*/
-SLPBoolean /* O - SLP_TRUE for success */
-AttrCallback(SLPHandle hslp, /* I - SLP handle */
- const char *attrlist, /* I - Attribute list */
- SLPError errcode, /* I - Parsing status for this attr */
- void *cookie) /* I - Current printer */
+static SLPBoolean /* O - SLP_TRUE for success */
+slp_attr_callback(
+ SLPHandle hslp, /* I - SLP handle */
+ const char *attrlist, /* I - Attribute list */
+ SLPError errcode, /* I - Parsing status for this attr */
+ void *cookie) /* I - Current printer */
{
- char *tmp = 0;
- cupsd_printer_t *p = (cupsd_printer_t*)cookie;
+ char *tmp = 0;
+ cupsd_printer_t *p = (cupsd_printer_t*)cookie;
/*
p->type = CUPS_PRINTER_REMOTE;
- if (GetSlpAttrVal(attrlist, "(printer-location=", &(p->location)))
+ if (slp_get_attr(attrlist, "(printer-location=", &(p->location)))
return (SLP_FALSE);
- if (GetSlpAttrVal(attrlist, "(printer-info=", &(p->info)))
+ if (slp_get_attr(attrlist, "(printer-info=", &(p->info)))
return (SLP_FALSE);
- if (GetSlpAttrVal(attrlist, "(printer-make-and-model=", &(p->make_model)))
+ if (slp_get_attr(attrlist, "(printer-make-and-model=", &(p->make_model)))
return (SLP_FALSE);
- if (GetSlpAttrVal(attrlist, "(color-supported=", &tmp))
+ if (slp_get_attr(attrlist, "(color-supported=", &tmp))
return (SLP_FALSE);
if (strcasecmp(tmp, "true") == 0)
p->type |= CUPS_PRINTER_COLOR;
- if (GetSlpAttrVal(attrlist, "(finishings-supported=", &tmp))
+ if (slp_get_attr(attrlist, "(finishings-supported=", &tmp))
return (SLP_FALSE);
if (strstr(tmp, "staple"))
p->type |= CUPS_PRINTER_STAPLE;
if (strstr(tmp, "punch"))
p->type |= CUPS_PRINTER_PUNCH;
- if (GetSlpAttrVal(attrlist, "(sides-supported=", &tmp))
+ if (slp_get_attr(attrlist, "(sides-supported=", &tmp))
return (SLP_FALSE);
if (strstr(tmp,"two-sided"))
p->type |= CUPS_PRINTER_DUPLEX;
/*
- * 'SrvUrlCallback()' - SLP service url callback
+ * 'slp_url_callback()' - SLP service url callback
*/
-SLPBoolean /* O - TRUE = OK, FALSE = error */
-SrvUrlCallback(SLPHandle hslp, /* I - SLP handle */
- const char *srvurl, /* I - URL of service */
- unsigned short lifetime, /* I - Life of service */
- SLPError errcode, /* I - Existing error code */
- void *cookie) /* I - Pointer to service list */
+static SLPBoolean /* O - TRUE = OK, FALSE = error */
+slp_url_callback(
+ SLPHandle hslp, /* I - SLP handle */
+ const char *srvurl, /* I - URL of service */
+ unsigned short lifetime, /* I - Life of service */
+ SLPError errcode, /* I - Existing error code */
+ void *cookie) /* I - Pointer to service list */
{
slpsrvurl_t *s, /* New service entry */
**head; /* Pointer to head of entry */
int port; /* Port portion of URI */
- cupsdLogMessage(L_DEBUG, "cupsdUpdateSLPBrowse() Start...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdUpdateSLPBrowse() Start...");
/*
* Reset the refresh time...
s = NULL;
SLPFindSrvs(BrowseSLPHandle, SLP_CUPS_SRVTYPE, "", "",
- SrvUrlCallback, &s);
+ slp_url_callback, &s);
/*
* Loop through the list of available printers...
* Load a cupsd_printer_t structure with the SLP service attributes...
*/
- SLPFindAttrs(BrowseSLPHandle, s->url, "", "", AttrCallback, &p);
+ SLPFindAttrs(BrowseSLPHandle, s->url, "", "", slp_attr_callback, &p);
/*
* Process this printer entry...
free(s);
}
- cupsdLogMessage(L_DEBUG, "cupsdUpdateSLPBrowse() End...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdUpdateSLPBrowse() End...");
}
#endif /* HAVE_LIBSLP */
typedef struct
{
- cupsd_authmask_t from; /* Source address/name mask */
+ cupsd_authmask_t from; /* Source address/name mask */
http_addr_t to; /* Destination address */
} cupsd_dirsvc_relay_t;
/* Options to add to remote printer URIs */
VAR cupsd_dirsvc_addr_t *Browsers VALUE(NULL);
/* Broadcast addresses */
-VAR cupsd_location_t *BrowseACL VALUE(NULL);
+VAR cupsd_location_t *BrowseACL VALUE(NULL);
/* Browser access control list */
-VAR cupsd_printer_t *BrowseNext VALUE(NULL);
+VAR cupsd_printer_t *BrowseNext VALUE(NULL);
/* Next class/printer to broadcast */
VAR int NumRelays VALUE(0);
/* Number of broadcast relays */
-VAR cupsd_dirsvc_relay_t *Relays VALUE(NULL);
+VAR cupsd_dirsvc_relay_t *Relays VALUE(NULL);
/* Broadcast relays */
VAR int NumPolled VALUE(0);
/* Number of polled servers */
*/
extern void cupsdProcessBrowseData(const char *uri, cups_ptype_t type,
- ipp_pstate_t state, const char *location,
- const char *info, const char *make_model);
+ ipp_pstate_t state, const char *location,
+ const char *info, const char *make_model);
extern void cupsdSendBrowseDelete(cupsd_printer_t *p);
extern void cupsdSendBrowseList(void);
extern void cupsdSendCUPSBrowse(cupsd_printer_t *p);
if (num_common_env >= (int)(sizeof(common_env) / sizeof(common_env[0])))
{
- cupsdLogMessage(L_ERROR, "cupsdSetEnv: Too many environment variables set!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdSetEnv: Too many environment variables set!");
return;
}
cupsdSetStringf(common_env + num_common_env, "%s=%s", name, value);
- cupsdLogMessage(L_DEBUG, "cupsdSetEnv: %s\n", common_env[num_common_env]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdSetEnv: %s\n",
+ common_env[num_common_env]);
num_common_env ++;
}
*
* Contents:
*
- * cupsdProcessIPPRequest() - Process an incoming IPP request...
+ * cupsdProcessIPPRequest() - Process an incoming IPP request...
* accept_jobs() - Accept print jobs to a printer.
* add_class() - Add a class to the system.
* add_file() - Add a file to a job.
- * add_cupsd_job_state_reasons() - Add the "job-state-reasons" attribute based
+ * add_job_state_reasons() - Add the "job-state-reasons" attribute based
* upon the job and printer state...
- * add_cupsd_job_subscriptions() - Add any subcriptions for a job.
+ * add_job_subscriptions() - Add any subcriptions for a job.
* add_printer() - Add a printer to the system.
- * add_cupsd_printer_state_reasons() - Add the "printer-state-reasons" attribute
+ * add_printer_state_reasons() - Add the "printer-state-reasons" attribute
* based upon the printer state...
* add_queued_job_count() - Add the "queued-job-count" attribute for
* authenticate_job() - Set job authentication info.
* ppd_parse_line() - Parse a PPD default line.
* print_job() - Print a file to a printer or class.
* read_ps_line() - Read a line from a PS file...
- * read_ps_cupsd_job_ticket() - Reads a job ticket embedded in a PS file.
+ * read_ps_job_ticket() - Reads a job ticket embedded in a PS file.
* reject_jobs() - Reject print jobs to a printer.
* release_job() - Release a held print job.
* restart_job() - Restart an old print job.
static void add_class(cupsd_client_t *con, ipp_attribute_t *uri);
static int add_file(cupsd_client_t *con, cupsd_job_t *job, mime_type_t *filetype,
int compression);
-static void add_cupsd_job_state_reasons(cupsd_client_t *con, cupsd_job_t *job);
-static void add_cupsd_job_subscriptions(cupsd_client_t *con, cupsd_job_t *job);
+static void add_job_state_reasons(cupsd_client_t *con, cupsd_job_t *job);
+static void add_job_subscriptions(cupsd_client_t *con, cupsd_job_t *job);
static void add_printer(cupsd_client_t *con, ipp_attribute_t *uri);
-static void add_cupsd_printer_state_reasons(cupsd_client_t *con, cupsd_printer_t *p);
+static void add_printer_state_reasons(cupsd_client_t *con, cupsd_printer_t *p);
static void add_queued_job_count(cupsd_client_t *con, cupsd_printer_t *p);
static void authenticate_job(cupsd_client_t *con, ipp_attribute_t *uri);
static void cancel_all_jobs(cupsd_client_t *con, ipp_attribute_t *uri);
static int ppd_parse_line(const char *line, char *option, int olen,
char *choice, int clen);
static void print_job(cupsd_client_t *con, ipp_attribute_t *uri);
-static void read_ps_cupsd_job_ticket(cupsd_client_t *con);
+static void read_ps_job_ticket(cupsd_client_t *con);
static void reject_jobs(cupsd_client_t *con, ipp_attribute_t *uri);
static void release_job(cupsd_client_t *con, ipp_attribute_t *uri);
static void renew_subscription(cupsd_client_t *con, int sub_id);
*/
int /* O - 1 on success, 0 on failure */
-cupsdProcessIPPRequest(cupsd_client_t *con) /* I - Client connection */
+cupsdProcessIPPRequest(
+ cupsd_client_t *con) /* I - Client connection */
{
ipp_tag_t group; /* Current group tag */
ipp_attribute_t *attr; /* Current attribute */
int sub_id; /* Subscription ID */
- cupsdLogMessage(L_DEBUG2, "cupsdProcessIPPRequest(%p[%d]): operation_id = %04x",
- con, con->http.fd, con->request->request.op.operation_id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdProcessIPPRequest(%p[%d]): operation_id = %04x",
+ con, con->http.fd, con->request->request.op.operation_id);
/*
* First build an empty response message for this request...
* Return an error, since we only support IPP 1.x.
*/
- cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: bad request version (%d.%d)!",
- con->request->request.any.version[0],
- con->request->request.any.version[1]);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdProcessIPPRequest: bad request version (%d.%d)!",
+ con->request->request.any.version[0],
+ con->request->request.any.version[1]);
cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
"%04X %s Bad request version (%d.%d)",
}
else if (con->request->attrs == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: no attributes in request!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdProcessIPPRequest: no attributes in request!");
cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
"%04X %s No attributes in request",
* Out of order; return an error...
*/
- cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: attribute groups are out of order!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdProcessIPPRequest: attribute groups are out of order!");
cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
"%04X %s Attribute groups are out of order",
if (!charset)
{
- cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: missing attributes-charset attribute!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdProcessIPPRequest: missing attributes-charset attribute!");
cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
"%04X %s Missing attributes-charset attribute",
if (!language)
{
- cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: missing attributes-natural-language attribute!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdProcessIPPRequest: missing attributes-natural-language attribute!");
cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
"%04X %s Missing attributes-natural-language attribute",
if (!uri)
{
- cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: missing printer-uri or job-uri attribute!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdProcessIPPRequest: missing printer-uri or job-uri attribute!");
cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
"%04X %s Missing printer-uri or job-uri attribute",
IPP_BAD_REQUEST, con->http.hostname);
}
- cupsdLogMessage(L_DEBUG, "Request attributes follow...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Request attributes follow...");
for (attr = con->request->attrs; attr != NULL; attr = attr->next)
- cupsdLogMessage(L_DEBUG, "attr \"%s\": group_tag = %x, value_tag = %x",
- attr->name ? attr->name : "(null)", attr->group_tag,
- attr->value_tag);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "attr \"%s\": group_tag = %x, value_tag = %x",
+ attr->name ? attr->name : "(null)", attr->group_tag,
+ attr->value_tag);
- cupsdLogMessage(L_DEBUG, "End of attributes...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "End of attributes...");
send_ipp_error(con, IPP_BAD_REQUEST);
}
*/
if (uri)
- cupsdLogMessage(L_DEBUG2, "cupsdProcessIPPRequest: URI=\"%s\"",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdProcessIPPRequest: URI=\"%s\"",
+ uri->values[0].string.text);
switch (con->request->request.op.operation_id)
{
* Sending data from the scheduler...
*/
- cupsdLogMessage(L_DEBUG, "cupsdProcessIPPRequest: %d status_code=%x (%s)",
- con->http.fd, con->response->request.status.status_code,
- ippErrorString(con->response->request.status.status_code));
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdProcessIPPRequest: %d status_code=%x (%s)",
+ con->http.fd, con->response->request.status.status_code,
+ ippErrorString(con->response->request.status.status_code));
if (cupsdSendHeader(con, HTTP_OK, "application/ipp"))
{
con->http.data_remaining);
}
- cupsdLogMessage(L_DEBUG2, "cupsdProcessIPPRequest: Adding fd %d to OutputSet...",
- con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdProcessIPPRequest: Adding fd %d to OutputSet...",
+ con->http.fd);
FD_SET(con->http.fd, OutputSet);
*/
static void
-accept_jobs(cupsd_client_t *con, /* I - Client connection */
+accept_jobs(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer or class URI */
{
cups_ptype_t dtype; /* Destination type (printer or class) */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
const char *name; /* Printer name */
- cupsd_printer_t *printer; /* Printer data */
+ cupsd_printer_t *printer; /* Printer data */
- cupsdLogMessage(L_DEBUG2, "accept_jobs(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "accept_jobs(%p[%d], %s)\n", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Was this operation called from the correct URI?
if (strncmp(con->uri, "/admin/", 7) != 0)
{
- cupsdLogMessage(L_ERROR, "accept_jobs: admin request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "accept_jobs: admin request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "accept_jobs: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "accept_jobs: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "accept_jobs: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "accept_jobs: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
else
cupsdSaveAllPrinters();
- cupsdLogMessage(L_INFO, "Printer \'%s\' now accepting jobs (\'%s\').", name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \'%s\' now accepting jobs (\'%s\').", name,
+ con->username);
/*
* Everything was ok, so return OK status...
*/
static void
-add_class(cupsd_client_t *con, /* I - Client connection */
+add_class(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - URI of class */
{
int i; /* Looping var */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_printer_t *pclass, /* Class */
+ cupsd_printer_t *pclass, /* Class */
*member; /* Member printer/class */
cups_ptype_t dtype; /* Destination type */
const char *dest; /* Printer or class name */
int modify; /* Non-zero if we just modified */
- cupsdLogMessage(L_DEBUG2, "add_class(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_class(%p[%d], %s)\n", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Was this operation called from the correct URI?
if (strncmp(con->uri, "/admin/", 7) != 0)
{
- cupsdLogMessage(L_ERROR, "add_class: admin request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_class: admin request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "add_class: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "add_class: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if ((attr = ippFindAttribute(con->request, "printer-is-accepting-jobs", IPP_TAG_BOOLEAN)) != NULL)
{
- cupsdLogMessage(L_INFO, "Setting %s printer-is-accepting-jobs to %d (was %d.)",
+ cupsdLogMessage(CUPSD_LOG_INFO, "Setting %s printer-is-accepting-jobs to %d (was %d.)",
pclass->name, attr->values[0].boolean, pclass->accepting);
pclass->accepting = attr->values[0].boolean;
if ((attr = ippFindAttribute(con->request, "printer-is-shared", IPP_TAG_BOOLEAN)) != NULL)
{
- cupsdLogMessage(L_INFO, "Setting %s printer-is-shared to %d (was %d.)",
- pclass->name, attr->values[0].boolean, pclass->shared);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Setting %s printer-is-shared to %d (was %d.)",
+ pclass->name, attr->values[0].boolean, pclass->shared);
pclass->shared = attr->values[0].boolean;
}
if (attr->values[0].integer != IPP_PRINTER_IDLE &&
attr->values[0].integer == IPP_PRINTER_STOPPED)
{
- cupsdLogMessage(L_ERROR, "Attempt to set %s printer-state to bad value %d!",
- pclass->name, attr->values[0].integer);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Attempt to set %s printer-state to bad value %d!",
+ pclass->name, attr->values[0].integer);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
- cupsdLogMessage(L_INFO, "Setting %s printer-state to %d (was %d.)", pclass->name,
- attr->values[0].integer, pclass->state);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Setting %s printer-state to %d (was %d.)", pclass->name,
+ attr->values[0].integer, pclass->state);
cupsdSetPrinterState(pclass, (ipp_pstate_t)(attr->values[0].integer), 0);
}
if ((attr = ippFindAttribute(con->request, "job-sheets-default", IPP_TAG_ZERO)) != NULL &&
!Classification)
{
- cupsdSetString(&pclass->cupsd_job_sheets[0], attr->values[0].string.text);
+ cupsdSetString(&pclass->job_sheets[0], attr->values[0].string.text);
if (attr->num_values > 1)
- cupsdSetString(&pclass->cupsd_job_sheets[1], attr->values[1].string.text);
+ cupsdSetString(&pclass->job_sheets[1], attr->values[1].string.text);
else
- cupsdSetString(&pclass->cupsd_job_sheets[1], "none");
+ cupsdSetString(&pclass->job_sheets[1], "none");
}
if ((attr = ippFindAttribute(con->request, "requesting-user-name-allowed",
IPP_TAG_ZERO)) != NULL)
if ((attr = ippFindAttribute(con->request, "job-quota-period",
IPP_TAG_INTEGER)) != NULL)
{
- cupsdLogMessage(L_DEBUG, "add_class: Setting job-quota-period to %d...",
- attr->values[0].integer);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_class: Setting job-quota-period to %d...",
+ attr->values[0].integer);
cupsdFreeQuotas(pclass);
pclass->quota_period = attr->values[0].integer;
}
if ((attr = ippFindAttribute(con->request, "job-k-limit",
IPP_TAG_INTEGER)) != NULL)
{
- cupsdLogMessage(L_DEBUG, "add_class: Setting job-k-limit to %d...",
- attr->values[0].integer);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_class: Setting job-k-limit to %d...",
+ attr->values[0].integer);
cupsdFreeQuotas(pclass);
pclass->k_limit = attr->values[0].integer;
}
if ((attr = ippFindAttribute(con->request, "job-page-limit",
IPP_TAG_INTEGER)) != NULL)
{
- cupsdLogMessage(L_DEBUG, "add_class: Setting job-page-limit to %d...",
- attr->values[0].integer);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_class: Setting job-page-limit to %d...",
+ attr->values[0].integer);
cupsdFreeQuotas(pclass);
pclass->page_limit = attr->values[0].integer;
}
if ((p = cupsdFindPolicy(attr->values[0].string.text)) != NULL)
{
- cupsdLogMessage(L_DEBUG, "add_class: Setting printer-op-policy to \"%s\"...",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_class: Setting printer-op-policy to \"%s\"...",
+ attr->values[0].string.text);
cupsdSetString(&pclass->op_policy, attr->values[0].string.text);
pclass->op_policy_ptr = p;
}
else
{
- cupsdLogMessage(L_ERROR, "add_class: Unknown printer-op-policy \"%s\"...",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_class: Unknown printer-op-policy \"%s\"...",
+ attr->values[0].string.text);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
strcmp(attr->values[0].string.text, "retry-job") &&
strcmp(attr->values[0].string.text, "stop-printer"))
{
- cupsdLogMessage(L_ERROR, "add_class: Unknown printer-error-policy \"%s\"...",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_class: Unknown printer-error-policy \"%s\"...",
+ attr->values[0].string.text);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
- cupsdLogMessage(L_DEBUG, "add_class: Setting printer-error-policy to \"%s\"...",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_class: Setting printer-error-policy to \"%s\"...",
+ attr->values[0].string.text);
cupsdSetString(&pclass->error_policy, attr->values[0].string.text);
}
if ((attr = ippFindAttribute(con->request, "member-uris", IPP_TAG_URI)) != NULL)
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "add_class: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_class: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
"Class \'%s\' modified by \'%s\'.", pclass->name,
con->username);
- cupsdLogMessage(L_INFO, "Class \'%s\' modified by \'%s\'.", pclass->name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \'%s\' modified by \'%s\'.",
+ pclass->name, con->username);
}
else
{
"New class \'%s\' added by \'%s\'.", pclass->name,
con->username);
- cupsdLogMessage(L_INFO, "New class \'%s\' added by \'%s\'.", pclass->name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "New class \'%s\' added by \'%s\'.",
+ pclass->name, con->username);
}
con->response->request.status.status_code = IPP_OK;
*/
static int /* O - 0 on success, -1 on error */
-add_file(cupsd_client_t *con, /* I - Connection to client */
- cupsd_job_t *job, /* I - Job to add to */
- mime_type_t *filetype, /* I - Type of file */
- int compression) /* I - Compression */
+add_file(cupsd_client_t *con, /* I - Connection to client */
+ cupsd_job_t *job, /* I - Job to add to */
+ mime_type_t *filetype, /* I - Type of file */
+ int compression) /* I - Compression */
{
mime_type_t **filetypes; /* New filetypes array... */
int *compressions; /* New compressions array... */
- cupsdLogMessage(L_DEBUG2, "add_file(con=%p[%d], job=%d, filetype=%s/%s, compression=%d)\n",
- con, con->http.fd, job->id, filetype->super, filetype->type,
- compression);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "add_file(con=%p[%d], job=%d, filetype=%s/%s, compression=%d)",
+ con, con->http.fd, job->id, filetype->super, filetype->type,
+ compression);
/*
* Add the file to the job...
if (compressions == NULL || filetypes == NULL)
{
cupsdCancelJob(job->id, 1);
- cupsdLogMessage(L_ERROR, "add_file: unable to allocate memory for file types!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_file: unable to allocate memory for file types!");
send_ipp_error(con, IPP_INTERNAL_ERROR);
return (-1);
}
/*
- * 'add_cupsd_job_state_reasons()' - Add the "job-state-reasons" attribute based
+ * 'add_job_state_reasons()' - Add the "job-state-reasons" attribute based
* upon the job and printer state...
*/
static void
-add_cupsd_job_state_reasons(cupsd_client_t *con, /* I - Client connection */
- cupsd_job_t *job) /* I - Job info */
+add_job_state_reasons(
+ cupsd_client_t *con, /* I - Client connection */
+ cupsd_job_t *job) /* I - Job info */
{
- cupsd_printer_t *dest; /* Destination printer */
+ cupsd_printer_t *dest; /* Destination printer */
- cupsdLogMessage(L_DEBUG2, "add_cupsd_job_state_reasons(%p[%d], %d)\n", con, con->http.fd,
- job ? job->id : 0);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job_state_reasons(%p[%d], %d)\n",
+ con, con->http.fd, job ? job->id : 0);
switch (job ? job->state->values[0].integer : IPP_JOB_CANCELLED)
{
/*
- * 'add_cupsd_job_subscriptions()' - Add any subcriptions for a job.
+ * 'add_job_subscriptions()' - Add any subcriptions for a job.
*/
static void
-add_cupsd_job_subscriptions(cupsd_client_t *con, /* I - Client connection */
- cupsd_job_t *job) /* I - Newly created job */
+add_job_subscriptions(
+ cupsd_client_t *con, /* I - Client connection */
+ cupsd_job_t *job) /* I - Newly created job */
{
int i; /* Looping var */
ipp_attribute_t *prev, /* Previous attribute */
* none...
*/
- for (attr = job->attrs->attrs, prev = NULL; attr; prev = attr, attr = attr->next)
+ for (attr = job->attrs->attrs, prev = NULL;
+ attr;
+ prev = attr, attr = attr->next)
if (attr->group_tag == IPP_TAG_SUBSCRIPTION)
break;
*/
static void
-add_printer(cupsd_client_t *con, /* I - Client connection */
+add_printer(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - URI of printer */
{
int i; /* Looping var */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_printer_t *printer; /* Printer/class */
+ cupsd_printer_t *printer; /* Printer/class */
ipp_attribute_t *attr; /* Printer attribute */
cups_file_t *fp; /* Script/PPD file */
char line[1024]; /* Line from file... */
int modify; /* Non-zero if we are modifying */
- cupsdLogMessage(L_DEBUG2, "add_printer(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_printer(%p[%d], %s)\n", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Was this operation called from the correct URI?
if (strncmp(con->uri, "/admin/", 7) != 0)
{
- cupsdLogMessage(L_ERROR, "add_printer: admin request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: admin request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* No, return an error...
*/
- cupsdLogMessage(L_ERROR, "add_printer: bad printer URI \"%s\"!",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "add_printer: bad printer URI \"%s\"!",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "add_printer: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "add_printer: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* Yes, return an error...
*/
- cupsdLogMessage(L_ERROR, "add_printer: \"%s\" already exists as a class!",
- resource + 10);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: \"%s\" already exists as a class!",
+ resource + 10);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
* File devices are disabled and the URL is not file:/dev/null...
*/
- cupsdLogMessage(L_ERROR, "add_printer: File device URIs have been disabled! "
- "To enable, see the FileDevice directive in cupsd.conf.");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: File device URIs have been disabled! "
+ "To enable, see the FileDevice directive in cupsd.conf.");
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
* Could not find device in list!
*/
- cupsdLogMessage(L_ERROR, "add_printer: bad device-uri attribute \'%s\'!",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: bad device-uri attribute \'%s\'!",
+ attr->values[0].string.text);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
}
- cupsdLogMessage(L_INFO, "Setting %s device-uri to \"%s\" (was \"%s\".)",
- printer->name,
- cupsdSanitizeURI(attr->values[0].string.text, line, sizeof(line)),
- cupsdSanitizeURI(printer->device_uri, resource, sizeof(resource)));
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Setting %s device-uri to \"%s\" (was \"%s\".)",
+ printer->name,
+ cupsdSanitizeURI(attr->values[0].string.text, line,
+ sizeof(line)),
+ cupsdSanitizeURI(printer->device_uri, resource,
+ sizeof(resource)));
cupsdSetString(&printer->device_uri, attr->values[0].string.text);
}
if (i >= supported->num_values)
{
- cupsdLogMessage(L_ERROR, "add_printer: bad port-monitor attribute \'%s\'!",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: bad port-monitor attribute \'%s\'!",
+ attr->values[0].string.text);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
- cupsdLogMessage(L_INFO, "Setting %s port-monitor to \"%s\" (was \"%s\".)",
- printer->name, attr->values[0].string.text,
- printer->port_monitor);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Setting %s port-monitor to \"%s\" (was \"%s\".)",
+ printer->name, attr->values[0].string.text,
+ printer->port_monitor);
if (strcmp(attr->values[0].string.text, "none"))
cupsdSetString(&printer->port_monitor, attr->values[0].string.text);
if ((attr = ippFindAttribute(con->request, "printer-is-accepting-jobs", IPP_TAG_BOOLEAN)) != NULL)
{
- cupsdLogMessage(L_INFO, "Setting %s printer-is-accepting-jobs to %d (was %d.)",
- printer->name, attr->values[0].boolean, printer->accepting);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Setting %s printer-is-accepting-jobs to %d (was %d.)",
+ printer->name, attr->values[0].boolean, printer->accepting);
printer->accepting = attr->values[0].boolean;
cupsdAddPrinterHistory(printer);
if ((attr = ippFindAttribute(con->request, "printer-is-shared", IPP_TAG_BOOLEAN)) != NULL)
{
- cupsdLogMessage(L_INFO, "Setting %s printer-is-shared to %d (was %d.)",
- printer->name, attr->values[0].boolean, printer->shared);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Setting %s printer-is-shared to %d (was %d.)",
+ printer->name, attr->values[0].boolean, printer->shared);
printer->shared = attr->values[0].boolean;
}
if (attr->values[0].integer != IPP_PRINTER_IDLE &&
attr->values[0].integer == IPP_PRINTER_STOPPED)
{
- cupsdLogMessage(L_ERROR, "Attempt to set %s printer-state to bad value %d!",
- printer->name, attr->values[0].integer);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Attempt to set %s printer-state to bad value %d!",
+ printer->name, attr->values[0].integer);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
- cupsdLogMessage(L_INFO, "Setting %s printer-state to %d (was %d.)", printer->name,
+ cupsdLogMessage(CUPSD_LOG_INFO, "Setting %s printer-state to %d (was %d.)", printer->name,
attr->values[0].integer, printer->state);
cupsdSetPrinterState(printer, (ipp_pstate_t)(attr->values[0].integer), 0);
if ((attr = ippFindAttribute(con->request, "job-sheets-default", IPP_TAG_ZERO)) != NULL &&
!Classification)
{
- cupsdSetString(&printer->cupsd_job_sheets[0], attr->values[0].string.text);
+ cupsdSetString(&printer->job_sheets[0], attr->values[0].string.text);
if (attr->num_values > 1)
- cupsdSetString(&printer->cupsd_job_sheets[1], attr->values[1].string.text);
+ cupsdSetString(&printer->job_sheets[1], attr->values[1].string.text);
else
- cupsdSetString(&printer->cupsd_job_sheets[1], "none");
+ cupsdSetString(&printer->job_sheets[1], "none");
}
if ((attr = ippFindAttribute(con->request, "requesting-user-name-allowed",
IPP_TAG_ZERO)) != NULL)
if ((attr = ippFindAttribute(con->request, "job-quota-period",
IPP_TAG_INTEGER)) != NULL)
{
- cupsdLogMessage(L_DEBUG, "add_printer: Setting job-quota-period to %d...",
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "add_printer: Setting job-quota-period to %d...",
attr->values[0].integer);
cupsdFreeQuotas(printer);
printer->quota_period = attr->values[0].integer;
if ((attr = ippFindAttribute(con->request, "job-k-limit",
IPP_TAG_INTEGER)) != NULL)
{
- cupsdLogMessage(L_DEBUG, "add_printer: Setting job-k-limit to %d...",
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "add_printer: Setting job-k-limit to %d...",
attr->values[0].integer);
cupsdFreeQuotas(printer);
printer->k_limit = attr->values[0].integer;
if ((attr = ippFindAttribute(con->request, "job-page-limit",
IPP_TAG_INTEGER)) != NULL)
{
- cupsdLogMessage(L_DEBUG, "add_printer: Setting job-page-limit to %d...",
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "add_printer: Setting job-page-limit to %d...",
attr->values[0].integer);
cupsdFreeQuotas(printer);
printer->page_limit = attr->values[0].integer;
if ((p = cupsdFindPolicy(attr->values[0].string.text)) != NULL)
{
- cupsdLogMessage(L_DEBUG, "add_printer: Setting printer-op-policy to \"%s\"...",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_printer: Setting printer-op-policy to \"%s\"...",
+ attr->values[0].string.text);
cupsdSetString(&printer->op_policy, attr->values[0].string.text);
printer->op_policy_ptr = p;
}
else
{
- cupsdLogMessage(L_ERROR, "add_printer: Unknown printer-op-policy \"%s\"...",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: Unknown printer-op-policy \"%s\"...",
+ attr->values[0].string.text);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
strcmp(attr->values[0].string.text, "retry-job") &&
strcmp(attr->values[0].string.text, "stop-printer"))
{
- cupsdLogMessage(L_ERROR, "add_printer: Unknown printer-error-policy \"%s\"...",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: Unknown printer-error-policy \"%s\"...",
+ attr->values[0].string.text);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
- cupsdLogMessage(L_DEBUG, "add_printer: Setting printer-error-policy to \"%s\"...",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_printer: Setting printer-error-policy to \"%s\"...",
+ attr->values[0].string.text);
cupsdSetString(&printer->error_policy, attr->values[0].string.text);
}
if (copy_file(srcfile, dstfile))
{
- cupsdLogMessage(L_ERROR, "add_printer: Unable to copy interface script from %s to %s - %s!",
- srcfile, dstfile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: Unable to copy interface script from %s to %s - %s!",
+ srcfile, dstfile, strerror(errno));
send_ipp_error(con, IPP_INTERNAL_ERROR);
return;
}
else
{
- cupsdLogMessage(L_DEBUG, "add_printer: Copied interface script successfully!");
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_printer: Copied interface script successfully!");
chmod(dstfile, 0755);
}
}
if (copy_file(srcfile, dstfile))
{
- cupsdLogMessage(L_ERROR, "add_printer: Unable to copy PPD file from %s to %s - %s!",
- srcfile, dstfile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: Unable to copy PPD file from %s to %s - %s!",
+ srcfile, dstfile, strerror(errno));
send_ipp_error(con, IPP_INTERNAL_ERROR);
return;
}
else
{
- cupsdLogMessage(L_DEBUG, "add_printer: Copied PPD file successfully!");
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_printer: Copied PPD file successfully!");
chmod(dstfile, 0644);
}
}
if (copy_model(con, attr->values[0].string.text, dstfile))
{
- cupsdLogMessage(L_ERROR, "add_printer: Unable to copy PPD file from %s to %s - %s!",
- attr->values[0].string.text, dstfile, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "add_printer: Unable to copy PPD file from %s to %s!",
+ attr->values[0].string.text, dstfile);
send_ipp_error(con, IPP_INTERNAL_ERROR);
return;
}
else
{
- cupsdLogMessage(L_DEBUG, "add_printer: Copied PPD file successfully!");
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "add_printer: Copied PPD file successfully!");
chmod(dstfile, 0644);
}
}
"Printer \'%s\' modified by \'%s\'.", printer->name,
con->username);
- cupsdLogMessage(L_INFO, "Printer \'%s\' modified by \'%s\'.", printer->name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \'%s\' modified by \'%s\'.",
+ printer->name, con->username);
}
else
{
"New printer \'%s\' added by \'%s\'.", printer->name,
con->username);
- cupsdLogMessage(L_INFO, "New printer \'%s\' added by \'%s\'.", printer->name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "New printer \'%s\' added by \'%s\'.",
+ printer->name, con->username);
}
con->response->request.status.status_code = IPP_OK;
/*
- * 'add_cupsd_printer_state_reasons()' - Add the "printer-state-reasons" attribute
+ * 'add_printer_state_reasons()' - Add the "printer-state-reasons" attribute
* based upon the printer state...
*/
static void
-add_cupsd_printer_state_reasons(
- cupsd_client_t *con, /* I - Client connection */
+add_printer_state_reasons(
+ cupsd_client_t *con, /* I - Client connection */
cupsd_printer_t *p) /* I - Printer info */
{
- cupsdLogMessage(L_DEBUG2, "add_cupsd_printer_state_reasons(%p[%d], %p[%s])\n",
- con, con->http.fd, p, p->name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "add_printer_state_reasons(%p[%d], %p[%s])",
+ con, con->http.fd, p, p->name);
if (p->num_reasons == 0)
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
*/
static void
-add_queued_job_count(cupsd_client_t *con, /* I - Client connection */
- cupsd_printer_t *p) /* I - Printer or class */
+add_queued_job_count(
+ cupsd_client_t *con, /* I - Client connection */
+ cupsd_printer_t *p) /* I - Printer or class */
{
int count; /* Number of jobs on destination */
- cupsdLogMessage(L_DEBUG2, "add_queued_job_count(%p[%d], %p[%s])\n",
- con, con->http.fd, p, p->name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_queued_job_count(%p[%d], %p[%s])",
+ con, con->http.fd, p, p->name);
count = cupsdGetPrinterJobCount(p->name);
*/
static void
-authenticate_job(cupsd_client_t *con, /* I - Client connection */
+authenticate_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job URI */
{
ipp_attribute_t *attr; /* Job-id attribute */
int jobid; /* Job ID */
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
char method[HTTP_MAX_URI],
/* Method portion of URI */
username[HTTP_MAX_URI],
int port; /* Port portion of URI */
- cupsdLogMessage(L_DEBUG2, "authenticate_job(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "authenticate_job(%p[%d], %s)",
+ con, con->http.fd, uri->values[0].string.text);
/*
* Start with "everything is OK" status...
if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "authenticate_job: got a printer-uri attribute but no job-id!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "authenticate_job: got a printer-uri attribute but no job-id!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Not a valid URI!
*/
- cupsdLogMessage(L_ERROR, "authenticate_job: bad job-uri attribute \'%s\'!\n",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "authenticate_job: bad job-uri attribute \'%s\'!\n",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Nope - return a "not found" error...
*/
- cupsdLogMessage(L_ERROR, "authenticate_job: job #%d doesn't exist!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "authenticate_job: job #%d doesn't exist!", jobid);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
* Return a "not-possible" error...
*/
- cupsdLogMessage(L_ERROR, "authenticate_job: job #%d is not held for authentication!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "authenticate_job: job #%d is not held for authentication!",
+ jobid);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- cupsdLogMessage(L_ERROR, "authenticate_job: \"%s\" not authorized to authenticate job id %d owned by \"%s\"!",
- username, jobid, job->username);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "authenticate_job: \"%s\" not authorized to authenticate "
+ "job id %d owned by \"%s\"!",
+ username, jobid, job->username);
send_ipp_error(con, IPP_FORBIDDEN);
return;
}
cupsdReleaseJob(jobid);
- cupsdLogMessage(L_INFO, "Job %d was authenticated by \'%s\'.", jobid,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was authenticated by \'%s\'.", jobid,
+ con->username);
}
*/
static void
-cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */
+cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job or Printer URI */
{
const char *dest; /* Destination */
ipp_attribute_t *attr; /* Attribute in request */
const char *username; /* Username */
int purge; /* Purge? */
- cupsd_printer_t *printer; /* Printer */
+ cupsd_printer_t *printer; /* Printer */
- cupsdLogMessage(L_DEBUG2, "cancel_all_jobs(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_all_jobs(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Was this operation called from the correct URI?
if (strncmp(con->uri, "/admin/", 7) &&
strncmp(con->uri, "/jobs/", 7))
{
- cupsdLogMessage(L_ERROR, "cancel_all_jobs: admin request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_all_jobs: admin request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if (strcmp(uri->name, "printer-uri"))
{
- cupsdLogMessage(L_ERROR, "cancel_all_jobs: bad %s attribute \'%s\'!",
- uri->name, uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_all_jobs: bad %s attribute \'%s\'!",
+ uri->name, uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
username = attr->values[0].string.text;
else
{
- cupsdLogMessage(L_ERROR, "cancel_all_jobs: missing requesting-user-name attribute!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_all_jobs: missing requesting-user-name attribute!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
else
username = NULL;
- if ((!username ||
- (username && con->username[0] && strcmp(username, con->username))) &&
- strncmp(con->uri, "/admin/", 7))
- {
- cupsdLogMessage(L_ERROR, "cancel_all_jobs: only administrators can cancel "
- "other users\' jobs!");
- send_ipp_error(con, IPP_NOT_AUTHORIZED);
- return;
- }
-
/*
* Look for the "purge-jobs" attribute...
*/
if (strcmp(resource, "/printers/") != 0)
{
- cupsdLogMessage(L_ERROR, "cancel_all_jobs: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_all_jobs: resource name \'%s\' no good!",
+ resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "cancel_all_jobs: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cancel_all_jobs: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
cupsdCancelJobs(NULL, username, purge);
- cupsdLogMessage(L_INFO, "All jobs were %s by \'%s\'.",
+ cupsdLogMessage(CUPSD_LOG_INFO, "All jobs were %s by \'%s\'.",
purge ? "purged" : "cancelled", con->username);
}
else
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "cancel_all_jobs: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cancel_all_jobs: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
cupsdCancelJobs(dest, username, purge);
- cupsdLogMessage(L_INFO, "All jobs on \'%s\' were %s by \'%s\'.", dest,
- purge ? "purged" : "cancelled", con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "All jobs on \'%s\' were %s by \'%s\'.",
+ dest, purge ? "purged" : "cancelled", con->username);
}
con->response->request.status.status_code = IPP_OK;
*/
static void
-cancel_job(cupsd_client_t *con, /* I - Client connection */
+cancel_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job or Printer URI */
{
ipp_attribute_t *attr; /* Current attribute */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_job_t *job; /* Job information */
+ cupsd_job_t *job; /* Job information */
const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type (printer or class) */
- cupsd_printer_t *printer; /* Printer data */
+ cupsd_printer_t *printer; /* Printer data */
- cupsdLogMessage(L_DEBUG2, "cancel_job(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_job(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Verify that the POST operation was done to a valid URI.
strncmp(con->uri, "/jobs/", 5) != 0 &&
strncmp(con->uri, "/printers/", 10) != 0)
{
- cupsdLogMessage(L_ERROR, "cancel_job: cancel request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_job: cancel request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* See if we have a job URI or a printer URI...
*/
- if (strcmp(uri->name, "printer-uri") == 0)
+ if (!strcmp(uri->name, "printer-uri"))
{
/*
* Got a printer URI; see if we also have a job-id attribute...
if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cancel_job: got a printer-uri attribute but no job-id!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_job: got a printer-uri attribute but no job-id!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "cancel_job: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_job: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
jobid = job->id;
else
{
- cupsdLogMessage(L_ERROR, "cancel_job: No active jobs on %s!", dest);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cancel_job: No active jobs on %s!",
+ dest);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
* Got a job URI; parse it to get the job ID...
*/
- httpSeparate(uri->values[0].string.text, method, username, host, &port, resource);
+ httpSeparate(uri->values[0].string.text, method, username, host, &port,
+ resource);
if (strncmp(resource, "/jobs/", 6) != 0)
{
* Not a valid URI!
*/
- cupsdLogMessage(L_ERROR, "cancel_job: bad job-uri attribute \'%s\'!",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_job: bad job-uri attribute \'%s\'!",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Nope - return a "not found" error...
*/
- cupsdLogMessage(L_ERROR, "cancel_job: job #%d doesn't exist!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cancel_job: job #%d doesn't exist!",
+ jobid);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- cupsdLogMessage(L_ERROR, "cancel_job: \"%s\" not authorized to delete job id %d owned by \"%s\"!",
- username, jobid, job->username);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_job: \"%s\" not authorized to delete job id %d "
+ "owned by \"%s\"!",
+ username, jobid, job->username);
send_ipp_error(con, IPP_FORBIDDEN);
return;
}
if (job->state->values[0].integer >= IPP_JOB_CANCELLED)
{
- cupsdLogMessage(L_ERROR, "cancel_job: job id %d is %s - can't cancel!",
- jobid,
- job->state->values[0].integer == IPP_JOB_CANCELLED ? "cancelled" :
- job->state->values[0].integer == IPP_JOB_ABORTED ? "aborted" :
- "completed");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cancel_job: job id %d is %s - can't cancel!",
+ jobid,
+ job->state->values[0].integer == IPP_JOB_CANCELLED ? "cancelled" :
+ job->state->values[0].integer == IPP_JOB_ABORTED ? "aborted" :
+ "completed");
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
cupsdCancelJob(jobid, 0);
cupsdCheckJobs();
- cupsdLogMessage(L_INFO, "Job %d was cancelled by \'%s\'.", jobid, username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was cancelled by \'%s\'.", jobid,
+ username);
con->response->request.status.status_code = IPP_OK;
}
*/
static void
-cancel_subscription(cupsd_client_t *con, /* I - Client connection */
- int sub_id) /* I - Subscription ID */
+cancel_subscription(
+ cupsd_client_t *con, /* I - Client connection */
+ int sub_id) /* I - Subscription ID */
{
}
*/
static int /* O - 1 if OK, 0 if not */
-check_quotas(cupsd_client_t *con, /* I - Client connection */
- cupsd_printer_t *p) /* I - Printer or class */
+check_quotas(cupsd_client_t *con, /* I - Client connection */
+ cupsd_printer_t *p) /* I - Printer or class */
{
int i; /* Looping var */
ipp_attribute_t *attr; /* Current attribute */
struct passwd *pw; /* User password data */
- cupsdLogMessage(L_DEBUG2, "check_quotas(%p[%d], %p[%s])\n",
- con, con->http.fd, p, p->name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "check_quotas(%p[%d], %p[%s])",
+ con, con->http.fd, p, p->name);
/*
* Check input...
strlcpy(username, con->username, sizeof(username));
else if (attr != NULL)
{
- cupsdLogMessage(L_DEBUG, "check_quotas: requesting-user-name = \'%s\'",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "check_quotas: requesting-user-name = \'%s\'",
+ attr->values[0].string.text);
strlcpy(username, attr->values[0].string.text, sizeof(username));
}
if (cupsdGetPrinterJobCount(p->name) >= MaxJobsPerPrinter)
{
- cupsdLogMessage(L_INFO, "Too many jobs for printer \"%s\"...", p->name);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Too many jobs for printer \"%s\"...",
+ p->name);
return (0);
}
}
if (cupsdGetUserJobCount(username) >= MaxJobsPerUser)
{
- cupsdLogMessage(L_INFO, "Too many jobs for user \"%s\"...", username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Too many jobs for user \"%s\"...",
+ username);
return (0);
}
}
if ((i < p->num_users) == p->deny_users)
{
- cupsdLogMessage(L_INFO, "Denying user \"%s\" access to printer \"%s\"...",
- username, p->name);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Denying user \"%s\" access to printer \"%s\"...",
+ username, p->name);
return (0);
}
}
{
if ((q = cupsdUpdateQuota(p, username, 0, 0)) == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to allocate quota data for user \"%s\"!",
- username);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to allocate quota data for user \"%s\"!",
+ username);
return (0);
}
if ((q->k_count >= p->k_limit && p->k_limit) ||
(q->page_count >= p->page_limit && p->page_limit))
{
- cupsdLogMessage(L_INFO, "User \"%s\" is over the quota limit...",
- username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "User \"%s\" is over the quota limit...",
+ username);
return (0);
}
}
ipp_attribute_t *toattr; /* Destination attribute */
- cupsdLogMessage(L_DEBUG2, "copy_attribute(%p, %p[%s,%x,%x])\n", to, attr,
- attr->name ? attr->name : "(null)", attr->group_tag,
- attr->value_tag);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "copy_attribute(%p, %p[%s,%x,%x])", to, attr,
+ attr->name ? attr->name : "(null)", attr->group_tag,
+ attr->value_tag);
switch (attr->value_tag & ~IPP_TAG_COPY)
{
ipp_attribute_t *fromattr; /* Source attribute */
- cupsdLogMessage(L_DEBUG2, "copy_attrs(%p, %p, %p, %x)\n", to, from, req, group);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "copy_attrs(%p, %p, %p, %x)", to, from,
+ req, group);
if (to == NULL || from == NULL)
return;
*/
static int /* O - Size of banner file in kbytes */
-copy_banner(cupsd_client_t *con, /* I - Client connection */
- cupsd_job_t *job, /* I - Job information */
- const char *name) /* I - Name of banner */
+copy_banner(cupsd_client_t *con, /* I - Client connection */
+ cupsd_job_t *job, /* I - Job information */
+ const char *name) /* I - Name of banner */
{
int i; /* Looping var */
int kbytes; /* Size of banner file in kbytes */
char filename[1024]; /* Job filename */
- cupsd_banner_t *banner; /* Pointer to banner */
+ cupsd_banner_t *banner; /* Pointer to banner */
cups_file_t *in; /* Input file */
cups_file_t *out; /* Output file */
int ch; /* Character from file */
ipp_attribute_t *attr; /* Attribute */
- cupsdLogMessage(L_DEBUG2, "copy_banner(%p[%d], %p[%d], %s)",
- con, con->http.fd, job, job->id, name ? name : "(null)");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "copy_banner(%p[%d], %p[%d], %s)",
+ con, con->http.fd, job, job->id, name ? name : "(null)");
/*
* Find the banner; return if not found or "none"...
job->num_files);
if ((out = cupsFileOpen(filename, "w")) == NULL)
{
- cupsdLogMessage(L_ERROR, "copy_banner: Unable to create banner job file %s - %s",
- filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "copy_banner: Unable to create banner job file %s - %s",
+ filename, strerror(errno));
job->num_files --;
return (0);
}
{
cupsFileClose(out);
unlink(filename);
- cupsdLogMessage(L_ERROR, "copy_banner: Unable to open banner template file %s - %s",
- filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "copy_banner: Unable to open banner template file %s - %s",
+ filename, strerror(errno));
job->num_files --;
return (0);
}
char buffer[2048]; /* Copy buffer */
- cupsdLogMessage(L_DEBUG2, "copy_file(\"%s\", \"%s\")\n", from, to);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "copy_file(\"%s\", \"%s\")", from, to);
/*
* Open the source and destination file for a copy...
*/
static int /* O - 0 = success, -1 = error */
-copy_model(cupsd_client_t *con, /* I - Client connection */
- const char *from, /* I - Source file */
- const char *to) /* I - Destination file */
+copy_model(cupsd_client_t *con, /* I - Client connection */
+ const char *from, /* I - Source file */
+ const char *to) /* I - Destination file */
{
fd_set *input; /* select() input set */
struct timeval timeout; /* select() timeout */
#endif /* HAVE_LIBPAPER */
- cupsdLogMessage(L_DEBUG2, "copy_model(con=%p, from=\"%s\", to=\"%s\")\n",
- con, from, to);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "copy_model(con=%p, from=\"%s\", to=\"%s\")",
+ con, from, to);
/*
* Run cups-driverd to get the PPD file...
close(tempfd);
unlink(tempfile);
- cupsdLogMessage(L_ERROR, "copy_model: Unable to allocate %d bytes for select()...",
- SetSize);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "copy_model: Unable to allocate %d bytes for select()...",
+ SetSize);
return (-1);
}
- cupsdLogMessage(L_DEBUG, "copy_model: Running \"cups-driverd cat %s\"...", from);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "copy_model: Running \"cups-driverd cat %s\"...", from);
if (!cupsdStartProcess(buffer, argv, envp, -1, temppipe[1], CGIPipes[1],
-1, 0, &temppid))
* No data from cups-deviced...
*/
- cupsdLogMessage(L_ERROR, "copy_model: empty PPD file!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "copy_model: empty PPD file!");
unlink(tempfile);
return (-1);
}
*/
static void
-create_job(cupsd_client_t *con, /* I - Client connection */
+create_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
ipp_attribute_t *attr; /* Current attribute */
cups_ptype_t dtype; /* Destination type (printer or class) */
int priority; /* Job priority */
char *title; /* Job name/title */
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
char job_uri[HTTP_MAX_URI], /* Job URI */
method[HTTP_MAX_URI], /* Method portion of URI */
username[HTTP_MAX_URI], /* Username portion of URI */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_printer_t *printer; /* Printer data */
+ cupsd_printer_t *printer; /* Printer data */
int kbytes; /* Size of print file */
int i; /* Looping var */
int lowerpagerange; /* Page range bound */
- cupsdLogMessage(L_DEBUG2, "create_job(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "create_job(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Verify that the POST operation was done to a valid URI.
if (strncmp(con->uri, "/classes/", 9) != 0 &&
strncmp(con->uri, "/printers/", 10) != 0)
{
- cupsdLogMessage(L_ERROR, "create_job: cancel request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "create_job: cancel request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "create_job: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "create_job: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
strcasecmp(con->http.hostname, "localhost") &&
strcasecmp(con->http.hostname, ServerName))
{
- cupsdLogMessage(L_ERROR, "print_job: printer not shared!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "print_job: printer not shared!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL) ||
((printer->type & CUPS_PRINTER_AUTHENTICATED) && !con->username[0]))
{
- cupsdLogMessage(L_ERROR, "create_job: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "create_job: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if (!printer->accepting)
{
- cupsdLogMessage(L_INFO, "create_job: destination \'%s\' is not accepting jobs.",
- dest);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "create_job: destination \'%s\' is not accepting jobs.",
+ dest);
send_ipp_error(con, IPP_NOT_ACCEPTING);
return;
}
{
if (attr->values[0].integer < 1 || attr->values[0].integer > MaxCopies)
{
- cupsdLogMessage(L_ERROR, "create_job: Bad copies value %d.",
- attr->values[0].integer);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "create_job: Bad copies value %d.",
+ attr->values[0].integer);
send_ipp_error(con, IPP_ATTRIBUTES);
ippAddInteger(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_INTEGER,
"copies", attr->values[0].integer);
if (attr->values[i].range.lower < lowerpagerange ||
attr->values[i].range.lower > attr->values[i].range.upper)
{
- cupsdLogMessage(L_ERROR, "create_job: bad page-ranges values %d-%d.",
- attr->values[i].range.lower, attr->values[i].range.upper);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "create_job: bad page-ranges values %d-%d.",
+ attr->values[i].range.lower,
+ attr->values[i].range.upper);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
if (cupsArrayCount(Jobs) >= MaxJobs && MaxJobs)
{
- cupsdLogMessage(L_INFO, "create_job: too many jobs.");
+ cupsdLogMessage(CUPSD_LOG_INFO, "create_job: too many jobs.");
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
if ((job = cupsdAddJob(priority, printer->name)) == NULL)
{
- cupsdLogMessage(L_ERROR, "create_job: unable to add job for destination \'%s\'!",
- dest);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "create_job: unable to add job for destination \'%s\'!",
+ dest);
send_ipp_error(con, IPP_INTERNAL_ERROR);
return;
}
}
else if (attr != NULL)
{
- cupsdLogMessage(L_DEBUG, "create_job: requesting-user-name = \'%s\'",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "create_job: requesting-user-name = \'%s\'",
+ attr->values[0].string.text);
cupsdSetString(&job->username, attr->values[0].string.text);
}
cupsdSetString(&job->username, "anonymous");
if (attr == NULL)
- ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-originating-user-name",
- NULL, job->username);
+ ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME,
+ "job-originating-user-name", NULL, job->username);
else
{
attr->group_tag = IPP_TAG_JOB;
if ((attr = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_ZERO)) == NULL)
{
- cupsdLogMessage(L_DEBUG, "Adding default job-sheets values \"%s,%s\"...",
- printer->cupsd_job_sheets[0], printer->cupsd_job_sheets[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "Adding default job-sheets values \"%s,%s\"...",
+ printer->job_sheets[0], printer->job_sheets[1]);
attr = ippAddStrings(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-sheets",
2, NULL, NULL);
- attr->values[0].string.text = strdup(printer->cupsd_job_sheets[0]);
- attr->values[1].string.text = strdup(printer->cupsd_job_sheets[1]);
+ attr->values[0].string.text = strdup(printer->job_sheets[0]);
+ attr->values[1].string.text = strdup(printer->job_sheets[1]);
}
- job->cupsd_job_sheets = attr;
+ job->job_sheets = attr;
/*
* Enforce classification level if set...
if (Classification)
{
- cupsdLogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d",
- Classification ? Classification : "(null)", ClassifyOverride);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Classification=\"%s\", ClassifyOverride=%d",
+ Classification ? Classification : "(null)",
+ ClassifyOverride);
if (ClassifyOverride)
{
- if (strcmp(attr->values[0].string.text, "none") == 0 &&
+ if (!strcmp(attr->values[0].string.text, "none") &&
(attr->num_values == 1 ||
- strcmp(attr->values[1].string.text, "none") == 0))
+ !strcmp(attr->values[1].string.text, "none")))
{
/*
* Force the leading banner to have the classification on it...
cupsdSetString(&attr->values[0].string.text, Classification);
- cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED "
- "job-sheets=\"%s,none\", "
- "job-originating-user-name=\"%s\"",
- job->id, Classification,
- job->username);
+ cupsdLogMessage(CUPSD_LOG_NOTICE, "[Job %d] CLASSIFICATION FORCED "
+ "job-sheets=\"%s,none\", "
+ "job-originating-user-name=\"%s\"",
+ job->id, Classification, job->username);
}
else if (attr->num_values == 2 &&
strcmp(attr->values[0].string.text, attr->values[1].string.text) != 0 &&
cupsdSetString(&attr->values[1].string.text, attr->values[0].string.text);
- cupsdLogMessage(L_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);
+ 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);
}
else if (strcmp(attr->values[0].string.text, Classification) &&
strcmp(attr->values[0].string.text, "none") &&
strcmp(attr->values[1].string.text, "none"))))
{
if (attr->num_values == 1)
- cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN "
- "job-sheets=\"%s\", "
- "job-originating-user-name=\"%s\"",
- job->id, attr->values[0].string.text,
- job->username);
+ 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);
else
- cupsdLogMessage(L_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);
+ 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);
}
}
else if (strcmp(attr->values[0].string.text, Classification) != 0 &&
}
if (attr->num_values > 1)
- cupsdLogMessage(L_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);
+ 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);
else
- cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED "
- "job-sheets=\"%s\", "
- "job-originating-user-name=\"%s\"",
- job->id, Classification,
- job->username);
+ cupsdLogMessage(CUPSD_LOG_NOTICE,
+ "[Job %d] CLASSIFICATION FORCED "
+ "job-sheets=\"%s\", "
+ "job-originating-user-name=\"%s\"",
+ job->id, Classification, job->username);
}
}
if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)))
{
- cupsdLogMessage(L_INFO, "Adding start banner page \"%s\" to job %d.",
- attr->values[0].string.text, job->id);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Adding start banner page \"%s\" to job %d.",
+ attr->values[0].string.text, job->id);
kbytes = copy_banner(con, job, attr->values[0].string.text);
* Add any job subscriptions...
*/
- add_cupsd_job_subscriptions(con, job);
+ add_job_subscriptions(con, job);
/*
* Set all but the first two attributes to the job attributes group...
cupsdSaveJob(job->id);
- cupsdLogMessage(L_INFO, "Job %d created on \'%s\' by \'%s\'.", job->id,
- job->dest, job->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Job %d created on \'%s\' by \'%s\'.",
+ job->id, job->dest, job->username);
cupsdAddEvent(CUPSD_EVENT_JOB_CREATED, printer, job, "Job created.");
static void
create_subscription(
- cupsd_client_t *con, /* I - Client connection */
+ cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
}
*/
static void
-delete_printer(cupsd_client_t *con, /* I - Client connection */
+delete_printer(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - URI of printer or class */
{
const char *dest; /* Destination */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_printer_t *printer; /* Printer/class */
+ cupsd_printer_t *printer; /* Printer/class */
char filename[1024]; /* Script/PPD filename */
- cupsdLogMessage(L_DEBUG2, "delete_printer(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "delete_printer(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Was this operation called from the correct URI?
if (strncmp(con->uri, "/admin/", 7) != 0)
{
- cupsdLogMessage(L_ERROR, "delete_printer: admin request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "delete_printer: admin request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "delete_printer: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "delete_printer: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "delete_printer: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "delete_printer: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if (dtype & CUPS_PRINTER_CLASS)
{
- cupsdLogMessage(L_INFO, "Class \'%s\' deleted by \'%s\'.", dest,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \'%s\' deleted by \'%s\'.", dest,
+ con->username);
cupsdDeletePrinter(printer, 0);
cupsdSaveAllClasses();
}
else
{
- cupsdLogMessage(L_INFO, "Printer \'%s\' deleted by \'%s\'.", dest,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \'%s\' deleted by \'%s\'.", dest,
+ con->username);
cupsdDeletePrinter(printer, 0);
cupsdSaveAllPrinters();
*/
static void
-get_default(cupsd_client_t *con) /* I - Client connection */
+get_default(cupsd_client_t *con) /* I - Client connection */
{
int i; /* Looping var */
ipp_attribute_t *requested, /* requested-attributes */
time_t curtime; /* Current time */
- cupsdLogMessage(L_DEBUG2, "get_default(%p[%d])\n", con, con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_default(%p[%d])", con, con->http.fd);
/*
* Check policy...
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "get_default: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_default: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
con->servername, con->serverport, DefaultPrinter->name);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI,
"printer-uri-supported", NULL, printer_uri);
- cupsdLogMessage(L_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "printer-uri-supported=\"%s\"",
+ printer_uri);
}
ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
DefaultPrinter->state);
- add_cupsd_printer_state_reasons(con, DefaultPrinter);
+ add_printer_state_reasons(con, DefaultPrinter);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_TEXT,
"printer-state-message", NULL, DefaultPrinter->state_message);
*/
static void
-get_devices(cupsd_client_t *con) /* I - Client connection */
+get_devices(cupsd_client_t *con) /* I - Client connection */
{
int i; /* Looping var */
ipp_attribute_t *limit, /* Limit attribute */
int alen; /* Length of attribute value */
- cupsdLogMessage(L_DEBUG2, "get_devices(%p[%d])\n", con, con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_devices(%p[%d])", con, con->http.fd);
/*
* Check policy...
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "get_devices: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_devices: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
*/
static void
-get_jobs(cupsd_client_t *con, /* I - Client connection */
+get_jobs(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
ipp_attribute_t *attr, /* Current attribute */
int first; /* First job ID */
int limit; /* Maximum number of jobs to return */
int count; /* Number of jobs that match */
- cupsd_job_t *job; /* Current job pointer */
+ cupsd_job_t *job; /* Current job pointer */
char job_uri[HTTP_MAX_URI]; /* Job URI... */
- cupsd_printer_t *printer; /* Printer */
+ cupsd_printer_t *printer; /* Printer */
cups_array_t *list; /* Which job list... */
- cupsdLogMessage(L_DEBUG2, "get_jobs(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs(%p[%d], %s)", con, con->http.fd,
+ uri->values[0].string.text);
/*
* Is the destination valid?
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "get_jobs: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_jobs: resource name \'%s\' no good!",
+ resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
{
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "get_jobs: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_jobs: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
}
else if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "get_jobs: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_jobs: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* Filter out jobs that don't match...
*/
- cupsdLogMessage(L_DEBUG2, "get_jobs: job->id = %d", job->id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: job->id = %d", job->id);
if ((dest != NULL && strcmp(job->dest, dest) != 0) &&
(job->printer == NULL || dest == NULL ||
count ++;
- cupsdLogMessage(L_DEBUG2, "get_jobs: count = %d", count);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count = %d", count);
/*
* Send the requested attributes for each job...
copy_attrs(con->response, job->attrs, requested, IPP_TAG_JOB, 0);
- add_cupsd_job_state_reasons(con, job);
+ add_job_state_reasons(con, job);
ippAddSeparator(con->response);
}
*/
static void
-get_job_attrs(cupsd_client_t *con, /* I - Client connection */
+get_job_attrs(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job URI */
{
ipp_attribute_t *attr, /* Current attribute */
*requested; /* Requested attributes */
int jobid; /* Job ID */
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
char method[HTTP_MAX_URI], /* Method portion of URI */
username[HTTP_MAX_URI], /* Username portion of URI */
host[HTTP_MAX_URI], /* Host portion of URI */
char job_uri[HTTP_MAX_URI]; /* Job URI... */
- cupsdLogMessage(L_DEBUG2, "get_job_attrs(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_job_attrs(%p[%d], %s)\n", con,
+ con->http.fd, uri->values[0].string.text);
/*
* See if we have a job URI or a printer URI...
if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "get_job_attrs: got a printer-uri attribute but no job-id!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "get_job_attrs: got a printer-uri attribute but no job-id!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Got a job URI; parse it to get the job ID...
*/
- httpSeparate(uri->values[0].string.text, method, username, host, &port, resource);
+ httpSeparate(uri->values[0].string.text, method, username, host, &port,
+ resource);
if (strncmp(resource, "/jobs/", 6) != 0)
{
* Not a valid URI!
*/
- cupsdLogMessage(L_ERROR, "get_job_attrs: bad job-uri attribute \'%s\'!\n",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "get_job_attrs: bad job-uri attribute \'%s\'!\n",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Nope - return a "not found" error...
*/
- cupsdLogMessage(L_ERROR, "get_job_attrs: job #%d doesn't exist!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_job_attrs: job #%d doesn't exist!",
+ jobid);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "get_job_attrs: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_job_attrs: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
copy_attrs(con->response, job->attrs, requested, IPP_TAG_JOB, 0);
- add_cupsd_job_state_reasons(con, job);
+ add_job_state_reasons(con, job);
if (requested != NULL)
con->response->request.status.status_code = IPP_OK_SUBST;
static void
get_notifications(cupsd_client_t *con, /* I - Client connection */
- int id) /* I - Subscription ID */
+ int id) /* I - Subscription ID */
{
}
*/
static void
-get_ppds(cupsd_client_t *con) /* I - Client connection */
+get_ppds(cupsd_client_t *con) /* I - Client connection */
{
int i; /* Looping var */
ipp_attribute_t *limit, /* Limit attribute */
int alen; /* Length of attribute value */
- cupsdLogMessage(L_DEBUG2, "get_ppds(%p[%d])\n", con, con->http.fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppds(%p[%d])", con, con->http.fd);
/*
* Check policy...
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "get_ppds: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_ppds: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
*/
static void
-get_printer_attrs(cupsd_client_t *con, /* I - Client connection */
+get_printer_attrs(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
const char *dest; /* Destination */
resource[HTTP_MAX_URI];
/* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_printer_t *printer; /* Printer/class */
+ cupsd_printer_t *printer; /* Printer/class */
char printer_uri[HTTP_MAX_URI];
/* Printer URI */
time_t curtime; /* Current time */
int need_history; /* Need to send history collection? */
- cupsdLogMessage(L_DEBUG2, "get_printer_attrs(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printer_attrs(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Is the destination valid?
*/
- httpSeparate(uri->values[0].string.text, method, username, host, &port, resource);
+ httpSeparate(uri->values[0].string.text, method, username, host, &port,
+ resource);
if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "get_printer_attrs: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "get_printer_attrs: resource name \'%s\' no good!",
+ resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "get_printer_attrs: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_printer_attrs: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
con->servername, con->serverport, printer->name);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI,
"printer-uri-supported", NULL, printer_uri);
- cupsdLogMessage(L_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "printer-uri-supported=\"%s\"",
+ printer_uri);
}
ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
printer->state);
- add_cupsd_printer_state_reasons(con, printer);
+ add_printer_state_reasons(con, printer);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_TEXT,
"printer-state-message", NULL, printer->state_message);
*/
static void
-get_printers(cupsd_client_t *con, /* I - Client connection */
- int type) /* I - 0 or CUPS_PRINTER_CLASS */
+get_printers(cupsd_client_t *con, /* I - Client connection */
+ int type) /* I - 0 or CUPS_PRINTER_CLASS */
{
int i; /* Looping var */
ipp_attribute_t *requested, /* requested-attributes */
int need_history; /* Need to send history collection? */
int limit; /* Maximum number of printers to return */
int count; /* Number of printers that match */
- cupsd_printer_t *printer; /* Current printer pointer */
+ cupsd_printer_t *printer; /* Current printer pointer */
time_t curtime; /* Current time */
- int cupsd_printer_type, /* printer-type attribute */
+ int printer_type, /* printer-type attribute */
printer_mask; /* printer-type-mask attribute */
char *location; /* Location string */
char name[IPP_MAX_NAME], /* Printer name */
*nameptr; /* Pointer into name */
- cupsd_printer_t *iclass; /* Implicit class */
+ cupsd_printer_t *iclass; /* Implicit class */
const char *username; /* Current user */
char printer_uri[HTTP_MAX_URI];
/* Printer URI */
- cupsdLogMessage(L_DEBUG2, "get_printers(%p[%d], %x)\n", con, con->http.fd, type);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printers(%p[%d], %x)", con,
+ con->http.fd, type);
if (!Printers || !cupsArrayCount(Printers))
{
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "get_printers: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "get_printers: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
*/
if ((attr = ippFindAttribute(con->request, "printer-type", IPP_TAG_ENUM)) != NULL)
- cupsd_printer_type = attr->values[0].integer;
+ printer_type = attr->values[0].integer;
else
- cupsd_printer_type = 0;
+ printer_type = 0;
if ((attr = ippFindAttribute(con->request, "printer-type-mask", IPP_TAG_ENUM)) != NULL)
printer_mask = attr->values[0].integer;
count < limit && printer != NULL;
printer = (cupsd_printer_t *)cupsArrayNext(Printers))
if ((!type || (printer->type & CUPS_PRINTER_CLASS) == type) &&
- (printer->type & printer_mask) == cupsd_printer_type &&
+ (printer->type & printer_mask) == printer_type &&
(location == NULL || printer->location == NULL ||
!strcasecmp(printer->location, location)))
{
con->servername, con->serverport, printer->name);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI,
"printer-uri-supported", NULL, printer_uri);
- cupsdLogMessage(L_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri);
}
ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM,
"printer-state", printer->state);
- add_cupsd_printer_state_reasons(con, printer);
+ add_printer_state_reasons(con, printer);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_TEXT,
"printer-state-message", NULL, printer->state_message);
*/
static void
-get_subscription_attrs(cupsd_client_t *con, /* I - Client connection */
- int sub_id) /* I - Subscription ID */
+get_subscription_attrs(
+ cupsd_client_t *con, /* I - Client connection */
+ int sub_id) /* I - Subscription ID */
{
}
*/
static void
-get_subscriptions(cupsd_client_t *con, /* I - Client connection */
+get_subscriptions(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
}
*/
static void
-hold_job(cupsd_client_t *con, /* I - Client connection */
+hold_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job or Printer URI */
{
ipp_attribute_t *attr, /* Current job-hold-until */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_job_t *job; /* Job information */
+ cupsd_job_t *job; /* Job information */
- cupsdLogMessage(L_DEBUG2, "hold_job(%p[%d], %s)\n", con, con->http.fd,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "hold_job(%p[%d], %s)", con, con->http.fd,
uri->values[0].string.text);
/*
strncmp(con->uri, "/jobs/", 5) != 0 &&
strncmp(con->uri, "/printers/", 10) != 0)
{
- cupsdLogMessage(L_ERROR, "hold_job: hold request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "hold_job: hold request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "hold_job: got a printer-uri attribute but no job-id!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "hold_job: got a printer-uri attribute but no job-id!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Not a valid URI!
*/
- cupsdLogMessage(L_ERROR, "hold_job: bad job-uri attribute \'%s\'!",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "hold_job: bad job-uri attribute \'%s\'!",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Nope - return a "not found" error...
*/
- cupsdLogMessage(L_ERROR, "hold_job: job #%d doesn't exist!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "hold_job: job #%d doesn't exist!", jobid);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- cupsdLogMessage(L_ERROR, "hold_job: \"%s\" not authorized to hold job id %d owned by \"%s\"!",
- username, jobid, job->username);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "hold_job: \"%s\" not authorized to hold job id %d owned by \"%s\"!",
+ username, jobid, job->username);
send_ipp_error(con, IPP_FORBIDDEN);
return;
}
cupsdSetJobHoldUntil(job->id, attr->values[0].string.text);
}
- cupsdLogMessage(L_INFO, "Job %d was held by \'%s\'.", jobid, username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was held by \'%s\'.", jobid, username);
con->response->request.status.status_code = IPP_OK;
}
*/
static void
-move_job(cupsd_client_t *con, /* I - Client connection */
+move_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job URI */
{
ipp_attribute_t *attr; /* Current attribute */
int jobid; /* Job ID */
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type (printer or class) */
char method[HTTP_MAX_URI], /* Method portion of URI */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_printer_t *printer; /* Printer */
+ cupsd_printer_t *printer; /* Printer */
- cupsdLogMessage(L_DEBUG2, "move_job(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "move_job(%p[%d], %s)", con, con->http.fd,
+ uri->values[0].string.text);
/*
* See if we have a job URI or a printer URI...
if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "move_job: got a printer-uri attribute but no job-id!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "move_job: got a printer-uri attribute but no job-id!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Got a job URI; parse it to get the job ID...
*/
- httpSeparate(uri->values[0].string.text, method, username, host, &port, resource);
+ httpSeparate(uri->values[0].string.text, method, username, host, &port,
+ resource);
if (strncmp(resource, "/jobs/", 6) != 0)
{
* Not a valid URI!
*/
- cupsdLogMessage(L_ERROR, "move_job: bad job-uri attribute \'%s\'!\n",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "move_job: bad job-uri attribute \'%s\'!\n",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Nope - return a "not found" error...
*/
- cupsdLogMessage(L_ERROR, "move_job: job #%d doesn't exist!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "move_job: job #%d doesn't exist!", jobid);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
* Return a "not-possible" error...
*/
- cupsdLogMessage(L_ERROR, "move_job: job #%d is finished and cannot be altered!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "move_job: job #%d is finished and cannot be altered!",
+ jobid);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- cupsdLogMessage(L_ERROR, "move_job: \"%s\" not authorized to move job id %d owned by \"%s\"!",
- username, jobid, job->username);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "move_job: \"%s\" not authorized to move job id %d owned "
+ "by \"%s\"!",
+ username, jobid, job->username);
send_ipp_error(con, IPP_FORBIDDEN);
return;
}
* Need job-printer-uri...
*/
- cupsdLogMessage(L_ERROR, "move_job: job-printer-uri attribute missing!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "move_job: job-printer-uri attribute missing!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "move_job: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "move_job: resource name \'%s\' no good!",
+ resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "move_job: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "move_job: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if (!temp)
{
- cupsdLogMessage(L_ERROR, "ppd_add_default: Unable to add default value for \"%s\" - %s",
+ cupsdLogMessage(CUPSD_LOG_ERROR, "ppd_add_default: Unable to add default value for \"%s\" - %s",
option, strerror(errno));
return (num_defaults);
}
*/
static void
-print_job(cupsd_client_t *con, /* I - Client connection */
+print_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
ipp_attribute_t *attr; /* Current attribute */
cups_ptype_t dtype; /* Destination type (printer or class) */
int priority; /* Job priority */
char *title; /* Job name/title */
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
int jobid; /* Job ID number */
char job_uri[HTTP_MAX_URI], /* Job URI */
method[HTTP_MAX_URI], /* Method portion of URI */
type[MIME_MAX_TYPE], /* Subtype of file */
mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE + 2];
/* Textual name of mime type */
- cupsd_printer_t *printer; /* Printer data */
+ cupsd_printer_t *printer; /* Printer data */
struct stat fileinfo; /* File information */
int kbytes; /* Size of file */
int i; /* Looping var */
int compression; /* Document compression */
- cupsdLogMessage(L_DEBUG2, "print_job(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "print_job(%p[%d], %s)", con, con->http.fd,
+ uri->values[0].string.text);
/*
* Verify that the POST operation was done to a valid URI.
if (strncmp(con->uri, "/classes/", 9) != 0 &&
strncmp(con->uri, "/printers/", 10) != 0)
{
- cupsdLogMessage(L_ERROR, "print_job: cancel request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "print_job: cancel request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
{
if (attr->values[0].integer < 1 || attr->values[0].integer > MaxCopies)
{
- cupsdLogMessage(L_ERROR, "print_job: Bad copies value %d.",
- attr->values[0].integer);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "print_job: Bad copies value %d.",
+ attr->values[0].integer);
send_ipp_error(con, IPP_ATTRIBUTES);
ippAddInteger(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_INTEGER,
- "copies", attr->values[0].integer);
+ "copies", attr->values[0].integer);
return;
}
}
if (attr->values[i].range.lower < lowerpagerange ||
attr->values[i].range.lower > attr->values[i].range.upper)
{
- cupsdLogMessage(L_ERROR, "print_job: bad page-ranges values %d-%d.",
- attr->values[i].range.lower, attr->values[i].range.upper);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "print_job: bad page-ranges values %d-%d.",
+ attr->values[i].range.lower,
+ attr->values[i].range.upper);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
#endif /* HAVE_LIBZ */
)
{
- cupsdLogMessage(L_ERROR, "print_job: Unsupported compression \"%s\"!",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "print_job: Unsupported compression \"%s\"!",
+ attr->values[0].string.text);
send_ipp_error(con, IPP_ATTRIBUTES);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
"compression", NULL, attr->values[0].string.text);
if (!con->filename)
{
- cupsdLogMessage(L_ERROR, "print_job: No file!?!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "print_job: No file!?!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Is it a format we support?
*/
- if ((format = ippFindAttribute(con->request, "document-format", IPP_TAG_MIMETYPE)) != NULL)
+ if ((format = ippFindAttribute(con->request, "document-format",
+ IPP_TAG_MIMETYPE)) != NULL)
{
/*
* Grab format from client...
if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super, type) != 2)
{
- cupsdLogMessage(L_ERROR, "print_job: could not scan type \'%s\'!",
- format->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "print_job: could not scan type \'%s\'!",
+ format->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Auto-type the file...
*/
- cupsdLogMessage(L_DEBUG, "print_job: auto-typing file...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "print_job: auto-typing file...");
filetype = mimeFileType(MimeDatabase, con->filename, &compression);
if (filetype == NULL)
{
- cupsdLogMessage(L_ERROR, "print_job: Unsupported format \'%s/%s\'!",
- super, type);
- cupsdLogMessage(L_INFO, "Hint: Do you have the raw file printing rules enabled?");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "print_job: Unsupported format \'%s/%s\'!",
+ super, type);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Hint: Do you have the raw file printing rules enabled?");
send_ipp_error(con, IPP_DOCUMENT_FORMAT);
if (format)
return;
}
- cupsdLogMessage(L_DEBUG, "print_job: request file type is %s/%s.",
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "print_job: request file type is %s/%s.",
filetype->super, filetype->type);
/*
if (!strcasecmp(filetype->super, "application") &&
!strcasecmp(filetype->type, "postscript"))
- read_ps_cupsd_job_ticket(con);
+ read_ps_job_ticket(con);
/*
* Is the destination valid?
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "print_job: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "print_job: resource name \'%s\' no good!",
+ resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
strcasecmp(con->http.hostname, "localhost") &&
strcasecmp(con->http.hostname, ServerName))
{
- cupsdLogMessage(L_ERROR, "print_job: printer not shared!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "print_job: printer not shared!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL) ||
((printer->type & CUPS_PRINTER_AUTHENTICATED) && !con->username[0]))
{
- cupsdLogMessage(L_ERROR, "print_job: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "print_job: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if (!printer->accepting)
{
- cupsdLogMessage(L_INFO, "print_job: destination \'%s\' is not accepting jobs.",
- dest);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "print_job: destination \'%s\' is not accepting jobs.",
+ dest);
send_ipp_error(con, IPP_NOT_ACCEPTING);
return;
}
if (cupsArrayCount(Jobs) >= MaxJobs && MaxJobs)
{
- cupsdLogMessage(L_INFO, "print_job: too many jobs - %d jobs, max jobs is %d.",
- cupsArrayCount(Jobs), MaxJobs);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "print_job: too many jobs - %d jobs, max jobs is %d.",
+ cupsArrayCount(Jobs), MaxJobs);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
if ((job = cupsdAddJob(priority, printer->name)) == NULL)
{
- cupsdLogMessage(L_ERROR, "print_job: unable to add job for destination \'%s\'!",
- dest);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "print_job: unable to add job for destination \'%s\'!",
+ dest);
send_ipp_error(con, IPP_INTERNAL_ERROR);
return;
}
}
else if (attr != NULL)
{
- cupsdLogMessage(L_DEBUG, "print_job: requesting-user-name = \'%s\'",
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "print_job: requesting-user-name = \'%s\'",
attr->values[0].string.text);
cupsdSetString(&job->username, attr->values[0].string.text);
cupsdSetString(&job->username, "anonymous");
if (attr == NULL)
- ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-originating-user-name",
- NULL, job->username);
+ ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME,
+ "job-originating-user-name", NULL, job->username);
else
{
attr->group_tag = IPP_TAG_JOB;
if ((attr = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_ZERO)) == NULL)
{
- cupsdLogMessage(L_DEBUG, "Adding default job-sheets values \"%s,%s\"...",
- printer->cupsd_job_sheets[0], printer->cupsd_job_sheets[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "Adding default job-sheets values \"%s,%s\"...",
+ printer->job_sheets[0], printer->job_sheets[1]);
attr = ippAddStrings(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-sheets",
2, NULL, NULL);
- attr->values[0].string.text = strdup(printer->cupsd_job_sheets[0]);
- attr->values[1].string.text = strdup(printer->cupsd_job_sheets[1]);
+ attr->values[0].string.text = strdup(printer->job_sheets[0]);
+ attr->values[1].string.text = strdup(printer->job_sheets[1]);
}
- job->cupsd_job_sheets = attr;
+ job->job_sheets = attr;
/*
* Enforce classification level if set...
if (Classification)
{
- cupsdLogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d",
- Classification ? Classification : "(null)", ClassifyOverride);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Classification=\"%s\", ClassifyOverride=%d",
+ Classification ? Classification : "(null)",
+ ClassifyOverride);
if (ClassifyOverride)
{
cupsdSetString(&attr->values[0].string.text, Classification);
- cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED "
- "job-sheets=\"%s,none\", "
- "job-originating-user-name=\"%s\"",
- job->id, Classification,
- job->username);
+ cupsdLogMessage(CUPSD_LOG_NOTICE,
+ "[Job %d] CLASSIFICATION FORCED "
+ "job-sheets=\"%s,none\", "
+ "job-originating-user-name=\"%s\"",
+ job->id, Classification, job->username);
}
else if (attr->num_values == 2 &&
strcmp(attr->values[0].string.text, attr->values[1].string.text) != 0 &&
cupsdSetString(&attr->values[1].string.text, attr->values[0].string.text);
- cupsdLogMessage(L_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);
+ 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);
}
else if (strcmp(attr->values[0].string.text, Classification) &&
strcmp(attr->values[0].string.text, "none") &&
strcmp(attr->values[1].string.text, "none"))))
{
if (attr->num_values == 1)
- cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN "
- "job-sheets=\"%s\", "
- "job-originating-user-name=\"%s\"",
- job->id, attr->values[0].string.text,
- job->username);
+ 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);
else
- cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN "
- "job-sheets=\"%s,%s\", "
- "job-originating-user-name=\"%s\"",
- job->id, attr->values[0].string.text,
- attr->values[1].string.text,
- job->username);
+ cupsdLogMessage(CUPSD_LOG_NOTICE,
+ "[Job %d] CLASSIFICATION OVERRIDDEN "
+ "job-sheets=\"%s,%s\", "
+ "job-originating-user-name=\"%s\"",
+ job->id, attr->values[0].string.text,
+ attr->values[1].string.text, job->username);
}
}
else if (strcmp(attr->values[0].string.text, Classification) != 0 &&
}
if (attr->num_values > 1)
- cupsdLogMessage(L_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);
+ 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);
else
- cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED "
- "job-sheets=\"%s\", "
- "job-originating-user-name=\"%s\"",
- job->id, Classification,
- job->username);
+ cupsdLogMessage(CUPSD_LOG_NOTICE,
+ "[Job %d] CLASSIFICATION FORCED "
+ "job-sheets=\"%s\", "
+ "job-originating-user-name=\"%s\"",
+ job->id, Classification, job->username);
}
}
if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)))
{
- cupsdLogMessage(L_INFO, "Adding start banner page \"%s\" to job %d.",
- attr->values[0].string.text, job->id);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Adding start banner page \"%s\" to job %d.",
+ attr->values[0].string.text, job->id);
kbytes = copy_banner(con, job, attr->values[0].string.text);
* Yes...
*/
- cupsdLogMessage(L_INFO, "Adding end banner page \"%s\" to job %d.",
- attr->values[1].string.text, job->id);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Adding end banner page \"%s\" to job %d.",
+ attr->values[1].string.text, job->id);
kbytes = copy_banner(con, job, attr->values[1].string.text);
* Add any job subscriptions...
*/
- add_cupsd_job_subscriptions(con, job);
+ add_job_subscriptions(con, job);
/*
* Set all but the first two attributes to the job attributes group...
* Log and save the job...
*/
- cupsdLogMessage(L_INFO, "Job %d queued on \'%s\' by \'%s\'.", job->id,
- job->dest, job->username);
- cupsdLogMessage(L_DEBUG, "Job %d hold_until = %d", job->id, (int)job->hold_until);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Job %d queued on \'%s\' by \'%s\'.", job->id,
+ job->dest, job->username);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Job %d hold_until = %d", job->id,
+ (int)job->hold_until);
cupsdSaveJob(job->id);
cupsdAddEvent(CUPSD_EVENT_JOB_CREATED, printer, job, "Job created.");
/*
- * Start the job if possible... Since cupsdCheckJobs() can cancel a job if it
- * doesn't print, we need to re-find the job afterwards...
+ * 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;
snprintf(job_uri, sizeof(job_uri), "http://%s:%d/jobs/%d", ServerName,
LocalPort, jobid);
- ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL, job_uri);
+ ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL,
+ job_uri);
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->values[0].integer : IPP_JOB_CANCELLED);
- add_cupsd_job_state_reasons(con, job);
+ add_job_state_reasons(con, job);
con->response->request.status.status_code = IPP_OK;
}
/*
- * 'read_ps_cupsd_job_ticket()' - Reads a job ticket embedded in a PS file.
+ * 'read_ps_job_ticket()' - Reads a job ticket embedded in a PS file.
*
* This function only gets called when printing a single PostScript
* file using the Print-Job operation. It doesn't work for Create-Job +
*/
static void
-read_ps_cupsd_job_ticket(cupsd_client_t *con) /* I - Client connection */
+read_ps_job_ticket(cupsd_client_t *con) /* I - Client connection */
{
cups_file_t *fp; /* File to read from */
char line[256]; /* Line data */
if ((fp = cupsFileOpen(con->filename, "rb")) == NULL)
{
- cupsdLogMessage(L_ERROR, "read_ps_cupsd_job_ticket: Unable to open PostScript print file - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "read_ps_job_ticket: Unable to open PostScript print file "
+ "- %s",
+ strerror(errno));
return;
}
if (cupsFileGets(fp, line, sizeof(line)) == NULL)
{
- cupsdLogMessage(L_ERROR, "read_ps_cupsd_job_ticket: Unable to read from PostScript print file - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "read_ps_job_ticket: Unable to read from PostScript print "
+ "file - %s",
+ strerror(errno));
cupsFileClose(fp);
return;
}
if (attr->group_tag != IPP_TAG_JOB || !attr->name)
continue;
- if (strcmp(attr->name, "job-originating-host-name") == 0 ||
- strcmp(attr->name, "job-originating-user-name") == 0 ||
- strcmp(attr->name, "job-media-sheets-completed") == 0 ||
- strcmp(attr->name, "job-k-octets") == 0 ||
- strcmp(attr->name, "job-id") == 0 ||
- strncmp(attr->name, "job-state", 9) == 0 ||
- strncmp(attr->name, "time-at-", 8) == 0)
+ if (!strcmp(attr->name, "job-originating-host-name") ||
+ !strcmp(attr->name, "job-originating-user-name") ||
+ !strcmp(attr->name, "job-media-sheets-completed") ||
+ !strcmp(attr->name, "job-k-octets") ||
+ !strcmp(attr->name, "job-id") ||
+ !strncmp(attr->name, "job-state", 9) ||
+ !strncmp(attr->name, "time-at-", 8))
continue; /* Read-only attrs */
if ((attr2 = ippFindAttribute(con->request, attr->name, IPP_TAG_ZERO)) != NULL)
*/
static void
-reject_jobs(cupsd_client_t *con, /* I - Client connection */
+reject_jobs(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer or class URI */
{
cups_ptype_t dtype; /* Destination type (printer or class) */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
const char *name; /* Printer name */
- cupsd_printer_t *printer; /* Printer data */
+ cupsd_printer_t *printer; /* Printer data */
ipp_attribute_t *attr; /* printer-state-message text */
- cupsdLogMessage(L_DEBUG2, "reject_jobs(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "reject_jobs(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Was this operation called from the correct URI?
if (strncmp(con->uri, "/admin/", 7) != 0)
{
- cupsdLogMessage(L_ERROR, "reject_jobs: admin request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "reject_jobs: admin request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* Is the destination valid?
*/
- httpSeparate(uri->values[0].string.text, method, username, host, &port, resource);
+ httpSeparate(uri->values[0].string.text, method, username, host, &port,
+ resource);
if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "reject_jobs: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "reject_jobs: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "reject_jobs: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "reject_jobs: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
{
cupsdSaveAllClasses();
- cupsdLogMessage(L_INFO, "Class \'%s\' rejecting jobs (\'%s\').", name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \'%s\' rejecting jobs (\'%s\').",
+ name, con->username);
}
else
{
cupsdSaveAllPrinters();
- cupsdLogMessage(L_INFO, "Printer \'%s\' rejecting jobs (\'%s\').", name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \'%s\' rejecting jobs (\'%s\').",
+ name, con->username);
}
/*
*/
static void
-release_job(cupsd_client_t *con, /* I - Client connection */
+release_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job or Printer URI */
{
ipp_attribute_t *attr; /* Current attribute */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_job_t *job; /* Job information */
+ cupsd_job_t *job; /* Job information */
- cupsdLogMessage(L_DEBUG2, "release_job(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "release_job(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Verify that the POST operation was done to a valid URI.
strncmp(con->uri, "/jobs/", 5) != 0 &&
strncmp(con->uri, "/printers/", 10) != 0)
{
- cupsdLogMessage(L_ERROR, "release_job: release request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "release_job: release request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "release_job: got a printer-uri attribute but no job-id!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "release_job: got a printer-uri attribute but no job-id!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Got a job URI; parse it to get the job ID...
*/
- httpSeparate(uri->values[0].string.text, method, username, host, &port, resource);
+ httpSeparate(uri->values[0].string.text, method, username, host, &port,
+ resource);
if (strncmp(resource, "/jobs/", 6) != 0)
{
* Not a valid URI!
*/
- cupsdLogMessage(L_ERROR, "release_job: bad job-uri attribute \'%s\'!",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "release_job: bad job-uri attribute \'%s\'!",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Nope - return a "not found" error...
*/
- cupsdLogMessage(L_ERROR, "release_job: job #%d doesn't exist!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "release_job: job #%d doesn't exist!",
+ jobid);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
* Nope - return a "not possible" error...
*/
- cupsdLogMessage(L_ERROR, "release_job: job #%d is not held!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "release_job: job #%d is not held!",
+ jobid);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- cupsdLogMessage(L_ERROR, "release_job: \"%s\" not authorized to release job id %d owned by \"%s\"!",
- username, jobid, job->username);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "release_job: \"%s\" not authorized to release job id "
+ "%d owned by \"%s\"!",
+ username, jobid, job->username);
send_ipp_error(con, IPP_FORBIDDEN);
return;
}
cupsdReleaseJob(jobid);
- cupsdLogMessage(L_INFO, "Job %d was released by \'%s\'.", jobid, username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was released by \'%s\'.", jobid,
+ username);
con->response->request.status.status_code = IPP_OK;
}
*/
static void
-renew_subscription(cupsd_client_t *con, /* I - Client connection */
- int sub_id) /* I - Subscription ID */
+renew_subscription(
+ cupsd_client_t *con, /* I - Client connection */
+ int sub_id) /* I - Subscription ID */
{
}
*/
static void
-restart_job(cupsd_client_t *con, /* I - Client connection */
+restart_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job or Printer URI */
{
ipp_attribute_t *attr; /* Current attribute */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
- cupsd_job_t *job; /* Job information */
+ cupsd_job_t *job; /* Job information */
- cupsdLogMessage(L_DEBUG2, "restart_job(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "restart_job(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Verify that the POST operation was done to a valid URI.
strncmp(con->uri, "/jobs/", 5) != 0 &&
strncmp(con->uri, "/printers/", 10) != 0)
{
- cupsdLogMessage(L_ERROR, "restart_job: restart request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "restart_job: restart request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "restart_job: got a printer-uri attribute but no job-id!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "restart_job: got a printer-uri attribute but no job-id!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Got a job URI; parse it to get the job ID...
*/
- httpSeparate(uri->values[0].string.text, method, username, host, &port, resource);
+ httpSeparate(uri->values[0].string.text, method, username, host, &port,
+ resource);
if (strncmp(resource, "/jobs/", 6) != 0)
{
* Not a valid URI!
*/
- cupsdLogMessage(L_ERROR, "restart_job: bad job-uri attribute \'%s\'!",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "restart_job: bad job-uri attribute \'%s\'!",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Nope - return a "not found" error...
*/
- cupsdLogMessage(L_ERROR, "restart_job: job #%d doesn't exist!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "restart_job: job #%d doesn't exist!",
+ jobid);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
* Nope - return a "not possible" error...
*/
- cupsdLogMessage(L_ERROR, "restart_job: job #%d is not complete!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "restart_job: job #%d is not complete!",
+ jobid);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
* Nope - return a "not possible" error...
*/
- cupsdLogMessage(L_ERROR, "restart_job: job #%d cannot be restarted - no files!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "restart_job: job #%d cannot be restarted - no files!",
+ jobid);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- cupsdLogMessage(L_ERROR, "restart_job: \"%s\" not authorized to restart job id %d owned by \"%s\"!",
- username, jobid, job->username);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "restart_job: \"%s\" not authorized to restart job id "
+ "%d owned by \"%s\"!",
+ username, jobid, job->username);
send_ipp_error(con, IPP_FORBIDDEN);
return;
}
cupsdRestartJob(jobid);
- cupsdLogMessage(L_INFO, "Job %d was restarted by \'%s\'.", jobid, username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was restarted by \'%s\'.", jobid,
+ username);
con->response->request.status.status_code = IPP_OK;
}
*/
static void
-save_auth_info(cupsd_client_t *con, /* I - Client connection */
- int job_id) /* I - Job ID */
+save_auth_info(cupsd_client_t *con, /* I - Client connection */
+ int job_id) /* I - Job ID */
{
int i; /* Looping var */
char filename[1024]; /* Job authentication filename */
snprintf(filename, sizeof(filename), "%s/a%05d", RequestRoot, job_id);
if ((fp = cupsFileOpen(filename, "w")) == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to save authentication info to \"%s\" - %s",
- filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to save authentication info to \"%s\" - %s",
+ filename, strerror(errno));
return;
}
*/
static void
-send_document(cupsd_client_t *con, /* I - Client connection */
+send_document(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
ipp_attribute_t *attr; /* Current attribute */
ipp_attribute_t *format; /* Document-format attribute */
int jobid; /* Job ID number */
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
char job_uri[HTTP_MAX_URI],
/* Job URI */
method[HTTP_MAX_URI],
mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE + 2];
/* Textual name of mime type */
char filename[1024]; /* Job filename */
- cupsd_printer_t *printer; /* Current printer */
+ cupsd_printer_t *printer; /* Current printer */
struct stat fileinfo; /* File information */
int kbytes; /* Size of file */
int compression; /* Type of compression */
- cupsdLogMessage(L_DEBUG2, "send_document(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "send_document(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Verify that the POST operation was done to a valid URI.
strncmp(con->uri, "/jobs/", 6) != 0 &&
strncmp(con->uri, "/printers/", 10) != 0)
{
- cupsdLogMessage(L_ERROR, "send_document: print request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "send_document: print request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "send_document: got a printer-uri attribute but no job-id!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "send_document: got a printer-uri attribute but no job-id!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Not a valid URI!
*/
- cupsdLogMessage(L_ERROR, "send_document: bad job-uri attribute \'%s\'!",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "send_document: bad job-uri attribute \'%s\'!",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Nope - return a "not found" error...
*/
- cupsdLogMessage(L_ERROR, "send_document: job #%d doesn't exist!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "send_document: job #%d doesn't exist!",
+ jobid);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- cupsdLogMessage(L_ERROR, "send_document: \"%s\" not authorized to send document for job id %d owned by \"%s\"!",
- username, jobid, job->username);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "send_document: \"%s\" not authorized to send document "
+ "for job id %d owned by \"%s\"!",
+ username, jobid, job->username);
send_ipp_error(con, IPP_FORBIDDEN);
return;
}
#endif /* HAVE_LIBZ */
)
{
- cupsdLogMessage(L_ERROR, "print_job: Unsupported compression \"%s\"!",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "print_job: Unsupported compression \"%s\"!",
+ attr->values[0].string.text);
send_ipp_error(con, IPP_ATTRIBUTES);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
"compression", NULL, attr->values[0].string.text);
if (!con->filename)
{
- cupsdLogMessage(L_ERROR, "send_document: No file!?!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "send_document: No file!?!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Is it a format we support?
*/
- if ((format = ippFindAttribute(con->request, "document-format", IPP_TAG_MIMETYPE)) != NULL)
+ if ((format = ippFindAttribute(con->request, "document-format",
+ IPP_TAG_MIMETYPE)) != NULL)
{
/*
* Grab format from client...
if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super, type) != 2)
{
- cupsdLogMessage(L_ERROR, "send_document: could not scan type \'%s\'!",
- format->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "send_document: could not scan type \'%s\'!",
+ format->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Auto-type the file...
*/
- cupsdLogMessage(L_DEBUG, "send_document: auto-typing file...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "send_document: auto-typing file...");
filetype = mimeFileType(MimeDatabase, con->filename, &compression);
if (filetype == NULL)
{
- cupsdLogMessage(L_ERROR, "send_document: Unsupported format \'%s/%s\'!",
- super, type);
- cupsdLogMessage(L_INFO, "Hint: Do you have the raw file printing rules enabled?");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "send_document: Unsupported format \'%s/%s\'!",
+ super, type);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Hint: Do you have the raw file printing rules enabled?");
send_ipp_error(con, IPP_DOCUMENT_FORMAT);
if (format)
return;
}
- cupsdLogMessage(L_DEBUG, "send_document: request file type is %s/%s.",
- filetype->super, filetype->type);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "send_document: request file type is %s/%s.",
+ filetype->super, filetype->type);
/*
* Add the file to the job...
cupsdClearString(&con->filename);
- cupsdLogMessage(L_INFO, "File of type %s/%s queued in job #%d by \'%s\'.",
- filetype->super, filetype->type, job->id, job->username);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "File of type %s/%s queued in job #%d by \'%s\'.",
+ filetype->super, filetype->type, job->id, job->username);
/*
* Start the job if this is the last document...
* Yes...
*/
- cupsdLogMessage(L_INFO, "Adding end banner page \"%s\" to job %d.",
- attr->values[1].string.text, job->id);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Adding end banner page \"%s\" to job %d.",
+ attr->values[1].string.text, job->id);
kbytes = copy_banner(con, job, attr->values[1].string.text);
cupsdSaveJob(job->id);
/*
- * Start the job if possible... Since cupsdCheckJobs() can cancel a job if it
- * doesn't print, we need to re-find the job afterwards...
+ * 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;
ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state",
job ? job->state->values[0].integer : IPP_JOB_CANCELLED);
- add_cupsd_job_state_reasons(con, job);
+ add_job_state_reasons(con, job);
con->response->request.status.status_code = IPP_OK;
}
*/
static void
-send_ipp_error(cupsd_client_t *con, /* I - Client connection */
- ipp_status_t status) /* I - IPP status code */
+send_ipp_error(cupsd_client_t *con, /* I - Client connection */
+ ipp_status_t status) /* I - IPP status code */
{
- cupsdLogMessage(L_DEBUG2, "send_ipp_error(%p[%d], %x)\n", con, con->http.fd,
- status);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "send_ipp_error(%p[%d], %x)", con,
+ con->http.fd, status);
- cupsdLogMessage(L_DEBUG, "Sending error: %s", ippErrorString(status));
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Sending error: %s", ippErrorString(status));
if (status == IPP_NOT_AUTHORIZED)
{
*/
static void
-set_default(cupsd_client_t *con, /* I - Client connection */
+set_default(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
cups_ptype_t dtype; /* Destination type (printer or class) */
/* Resource portion of URI */
int port; /* Port portion of URI */
const char *name; /* Printer name */
- cupsd_printer_t *printer; /* Printer */
+ cupsd_printer_t *printer; /* Printer */
- cupsdLogMessage(L_DEBUG2, "set_default(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_default(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Was this operation called from the correct URI?
if (strncmp(con->uri, "/admin/", 7) != 0)
{
- cupsdLogMessage(L_ERROR, "set_default: admin request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "set_default: admin request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* Is the destination valid?
*/
- httpSeparate(uri->values[0].string.text, method, username, host, &port, resource);
+ httpSeparate(uri->values[0].string.text, method, username, host, &port,
+ resource);
if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "set_default: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "set_default: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "set_default: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "set_default: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
cupsdSaveAllPrinters();
cupsdSaveAllClasses();
- cupsdLogMessage(L_INFO, "Default destination set to \'%s\' by \'%s\'.", name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Default destination set to \'%s\' by \'%s\'.", name,
+ con->username);
/*
* Everything was ok, so return OK status...
*/
static void
-set_job_attrs(cupsd_client_t *con, /* I - Client connection */
+set_job_attrs(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job URI */
{
ipp_attribute_t *attr, /* Current attribute */
*attr2, /* Job attribute */
*prev2; /* Previous job attribute */
int jobid; /* Job ID */
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
char method[HTTP_MAX_URI],
/* Method portion of URI */
username[HTTP_MAX_URI],
int port; /* Port portion of URI */
- cupsdLogMessage(L_DEBUG2, "set_job_attrs(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_job_attrs(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Start with "everything is OK" status...
if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "set_job_attrs: got a printer-uri attribute but no job-id!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "set_job_attrs: got a printer-uri attribute but no job-id!");
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Not a valid URI!
*/
- cupsdLogMessage(L_ERROR, "set_job_attrs: bad job-uri attribute \'%s\'!\n",
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "set_job_attrs: bad job-uri attribute \'%s\'!\n",
+ uri->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
* Nope - return a "not found" error...
*/
- cupsdLogMessage(L_ERROR, "set_job_attrs: job #%d doesn't exist!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "set_job_attrs: job #%d doesn't exist!",
+ jobid);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
* Return a "not-possible" error...
*/
- cupsdLogMessage(L_ERROR, "set_job_attrs: job #%d is finished and cannot be altered!", jobid);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "set_job_attrs: job #%d is finished and cannot be altered!",
+ jobid);
send_ipp_error(con, IPP_NOT_POSSIBLE);
return;
}
if (!validate_user(job, con, job->username, username, sizeof(username)))
{
- cupsdLogMessage(L_ERROR, "set_job_attrs: \"%s\" not authorized to alter job id %d owned by \"%s\"!",
- username, jobid, job->username);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "set_job_attrs: \"%s\" not authorized to alter job id "
+ "%d owned by \"%s\"!",
+ username, jobid, job->username);
send_ipp_error(con, IPP_FORBIDDEN);
return;
}
* See if the job-name or job-hold-until is being changed.
*/
- if (strcmp(attr->name, "job-hold-until") == 0)
+ if (!strcmp(attr->name, "job-hold-until"))
{
cupsdSetJobHoldUntil(job->id, attr->values[0].string.text);
- if (strcmp(attr->values[0].string.text, "no-hold") == 0)
+ if (!strcmp(attr->values[0].string.text, "no-hold"))
cupsdReleaseJob(job->id);
else
cupsdHoldJob(job->id);
*/
static void
-start_printer(cupsd_client_t *con, /* I - Client connection */
+start_printer(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
cups_ptype_t dtype; /* Destination type (printer or class) */
/* Resource portion of URI */
int port; /* Port portion of URI */
const char *name; /* Printer name */
- cupsd_printer_t *printer; /* Printer data */
+ cupsd_printer_t *printer; /* Printer data */
- cupsdLogMessage(L_DEBUG2, "start_printer(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_printer(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Was this operation called from the correct URI?
if (strncmp(con->uri, "/admin/", 7) != 0)
{
- cupsdLogMessage(L_ERROR, "start_printer: admin request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "start_printer: admin request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* Is the destination valid?
*/
- httpSeparate(uri->values[0].string.text, method, username, host, &port, resource);
+ httpSeparate(uri->values[0].string.text, method, username, host, &port,
+ resource);
if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "start_printer: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "start_printer: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "start_printer: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "start_printer: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
cupsdStartPrinter(printer, 1);
if (dtype & CUPS_PRINTER_CLASS)
- cupsdLogMessage(L_INFO, "Class \'%s\' started by \'%s\'.", name,
- con->username);
- cupsdLogMessage(L_INFO, "Printer \'%s\' started by \'%s\'.", name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \'%s\' started by \'%s\'.", name,
+ con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \'%s\' started by \'%s\'.", name,
+ con->username);
cupsdCheckJobs();
*/
static void
-stop_printer(cupsd_client_t *con, /* I - Client connection */
+stop_printer(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
cups_ptype_t dtype; /* Destination type (printer or class) */
/* Resource portion of URI */
int port; /* Port portion of URI */
const char *name; /* Printer name */
- cupsd_printer_t *printer; /* Printer data */
+ cupsd_printer_t *printer; /* Printer data */
ipp_attribute_t *attr; /* printer-state-message attribute */
- cupsdLogMessage(L_DEBUG2, "stop_printer(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "stop_printer(%p[%d], %s)", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Was this operation called from the correct URI?
if (strncmp(con->uri, "/admin/", 7) != 0)
{
- cupsdLogMessage(L_ERROR, "stop_printer: admin request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "stop_printer: admin request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "stop_printer: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "stop_printer: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "stop_printer: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "stop_printer: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
cupsdStopPrinter(printer, 1);
if (dtype & CUPS_PRINTER_CLASS)
- cupsdLogMessage(L_INFO, "Class \'%s\' stopped by \'%s\'.", name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \'%s\' stopped by \'%s\'.", name,
+ con->username);
else
- cupsdLogMessage(L_INFO, "Printer \'%s\' stopped by \'%s\'.", name,
- con->username);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \'%s\' stopped by \'%s\'.", name,
+ con->username);
/*
* Everything was ok, so return OK status...
*/
static int /* O - 0 if not allowed, 1 if allowed */
-user_allowed(cupsd_printer_t *p, /* I - Printer or class */
- const char *username) /* I - Username */
+user_allowed(cupsd_printer_t *p, /* I - Printer or class */
+ const char *username) /* I - Username */
{
int i; /* Looping var */
struct passwd *pw; /* User password data */
*/
static void
-validate_job(cupsd_client_t *con, /* I - Client connection */
+validate_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
ipp_attribute_t *attr; /* Current attribute */
/* Supertype of file */
type[MIME_MAX_TYPE];
/* Subtype of file */
- cupsd_printer_t *printer; /* Printer */
+ cupsd_printer_t *printer; /* Printer */
- cupsdLogMessage(L_DEBUG2, "validate_job(%p[%d], %s)\n", con, con->http.fd,
- uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "validate_job(%p[%d], %s)\n", con,
+ con->http.fd, uri->values[0].string.text);
/*
* Verify that the POST operation was done to a valid URI.
if (strncmp(con->uri, "/classes/", 9) != 0 &&
strncmp(con->uri, "/printers/", 10) != 0)
{
- cupsdLogMessage(L_ERROR, "validate_job: request on bad resource \'%s\'!",
- con->uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "validate_job: request on bad resource \'%s\'!",
+ con->uri);
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
if ((attr = ippFindAttribute(con->request, "compression", IPP_TAG_KEYWORD)) != NULL &&
strcmp(attr->values[0].string.text, "none") == 0)
{
- cupsdLogMessage(L_ERROR, "validate_job: Unsupported compression attribute %s!",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "validate_job: Unsupported compression attribute %s!",
+ attr->values[0].string.text);
send_ipp_error(con, IPP_ATTRIBUTES);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
"compression", NULL, attr->values[0].string.text);
* Is it a format we support?
*/
- if ((format = ippFindAttribute(con->request, "document-format", IPP_TAG_MIMETYPE)) != NULL)
+ if ((format = ippFindAttribute(con->request, "document-format",
+ IPP_TAG_MIMETYPE)) != NULL)
{
if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super, type) != 2)
{
- cupsdLogMessage(L_ERROR, "validate_job: could not scan type \'%s\'!\n",
- format->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "validate_job: could not scan type \'%s\'!\n",
+ format->values[0].string.text);
send_ipp_error(con, IPP_BAD_REQUEST);
return;
}
strcmp(type, "octet-stream") != 0) &&
mimeType(MimeDatabase, super, type) == NULL)
{
- cupsdLogMessage(L_ERROR, "validate_job: Unsupported format \'%s\'!\n",
- format->values[0].string.text);
- cupsdLogMessage(L_INFO, "Hint: Do you have the raw file printing rules enabled?");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "validate_job: Unsupported format \'%s\'!\n",
+ format->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Hint: Do you have the raw file printing rules enabled?");
send_ipp_error(con, IPP_DOCUMENT_FORMAT);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE,
"document-format", NULL, format->values[0].string.text);
* Bad URI...
*/
- cupsdLogMessage(L_ERROR, "validate_job: resource name \'%s\' no good!", resource);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "validate_job: resource name \'%s\' no good!", resource);
send_ipp_error(con, IPP_NOT_FOUND);
return;
}
if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL))
{
- cupsdLogMessage(L_ERROR, "validate_job: not authorized!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "validate_job: not authorized!");
send_ipp_error(con, IPP_NOT_AUTHORIZED);
return;
}
*/
static int /* O - 1 if permitted, 0 otherwise */
-validate_user(cupsd_job_t *job, /* I - Job */
- cupsd_client_t *con, /* I - Client connection */
- const char *owner, /* I - Owner of job/resource */
- char *username, /* O - Authenticated username */
- int userlen) /* I - Length of username */
+validate_user(cupsd_job_t *job, /* I - Job */
+ cupsd_client_t *con, /* I - Client connection */
+ const char *owner, /* I - Owner of job/resource */
+ char *username, /* O - Authenticated username */
+ int userlen) /* I - Length of username */
{
ipp_attribute_t *attr; /* requesting-user-name attribute */
- cupsd_printer_t *printer; /* Printer for job */
+ cupsd_printer_t *printer; /* Printer for job */
- cupsdLogMessage(L_DEBUG2, "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, userlen=%d)\n",
- job ? job->id : 0, con->http.fd, owner ? owner : "(null)",
- username, userlen);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, "
+ "userlen=%d)",
+ job ? job->id : 0, con->http.fd, owner ? owner : "(null)",
+ username, userlen);
/*
* Validate input...
if (con->username[0])
strlcpy(username, con->username, userlen);
- else if ((attr = ippFindAttribute(con->request, "requesting-user-name", IPP_TAG_NAME)) != NULL)
+ else if ((attr = ippFindAttribute(con->request, "requesting-user-name",
+ IPP_TAG_NAME)) != NULL)
strlcpy(username, attr->values[0].string.text, userlen);
else
strlcpy(username, "anonymous", userlen);
* cupsdCancelJob() - Cancel the specified print job.
* cupsdCancelJobs() - Cancel all jobs for the given destination/user...
* cupsdCheckJobs() - Check the pending jobs and start any if the
- * destination is available.
+ * destination is available.
* cupsdCleanJobs() - Clean out old jobs.
* cupsdFreeAllJobs() - Free all jobs from memory.
* cupsdFindJob() - Find the specified job.
* cupsdGetPrinterJobCount() - Get the number of pending, processing,
- * or held jobs in a printer or class.
+ * or held jobs in a printer or class.
* cupsdGetUserJobCount() - Get the number of pending, processing,
- * or held jobs for a user.
+ * or held jobs for a user.
* cupsdHoldJob() - Hold the specified job.
* cupsdLoadAllJobs() - Load all jobs from disk.
* cupsdMoveJob() - Move the specified job to a different
- * destination.
+ * destination.
* cupsdReleaseJob() - Release the specified job.
* cupsdRestartJob() - Restart the specified job.
* cupsdSaveJob() - Save a job to disk.
* cupsdSetJobHoldUntil() - Set the hold time for a job...
* cupsdSetJobPriority() - Set the priority of a job, moving it up/down
- * in the list as needed.
+ * in the list as needed.
* cupsdStartJob() - Start a print job.
* cupsdStopAllJobs() - Stop all print jobs.
* cupsdStopJob() - Stop a print job.
* cupsdUpdateJob() - Read a status update from a job's filters.
- * compare_active_jobs() - Compare the job IDs and priorities of two jobs.
- * compare_jobs() - Compare the job IDs of two jobs.
- * ipp_length() - Compute the size of the buffer needed to hold
- * the textual IPP attributes.
- * set_hold_until() - Set the hold time and update job-hold-until attribute.
+ * compare_active_jobs() - Compare the job IDs and priorities of two jobs.
+ * compare_jobs() - Compare the job IDs of two jobs.
+ * ipp_length() - Compute the size of the buffer needed to hold
+ * the textual IPP attributes.
+ * set_hold_until() - Set the hold time and update job-hold-until attribute.
*/
/*
* 'cupsdAddJob()' - Add a new job to the job queue...
*/
-cupsd_job_t * /* O - New job record */
-cupsdAddJob(int priority, /* I - Job priority */
- const char *dest) /* I - Job destination */
+cupsd_job_t * /* O - New job record */
+cupsdAddJob(int priority, /* I - Job priority */
+ const char *dest) /* I - Job destination */
{
- cupsd_job_t *job; /* New job record */
+ cupsd_job_t *job; /* New job record */
job = calloc(sizeof(cupsd_job_t), 1);
void
cupsdCancelJob(int id, /* I - Job to cancel */
- int purge) /* I - Purge jobs? */
+ int purge) /* I - Purge jobs? */
{
- int i; /* Looping var */
- cupsd_job_t *job; /* Current job */
- char filename[1024]; /* Job filename */
+ int i; /* Looping var */
+ cupsd_job_t *job; /* Current job */
+ char filename[1024]; /* Job filename */
- cupsdLogMessage(L_DEBUG, "cupsdCancelJob: id = %d", id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdCancelJob: id = %d", id);
/*
* Find the job...
*/
void
-cupsdCancelJobs(const char *dest, /* I - Destination to cancel */
- const char *username, /* I - Username or NULL */
- int purge) /* I - Purge jobs? */
+cupsdCancelJobs(const char *dest, /* I - Destination to cancel */
+ const char *username, /* I - Username or NULL */
+ int purge) /* I - Purge jobs? */
{
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
for (job = (cupsd_job_t *)cupsArrayFirst(Jobs);
/*
* 'cupsdCheckJobs()' - Check the pending jobs and start any if the destination
- * is available.
+ * is available.
*/
void
cupsdCheckJobs(void)
{
- cupsd_job_t *job; /* Current job in queue */
- cupsd_printer_t *printer, /* Printer destination */
- *pclass; /* Printer class destination */
+ cupsd_job_t *job; /* Current job in queue */
+ cupsd_printer_t *printer, /* Printer destination */
+ *pclass; /* Printer class destination */
DEBUG_puts("cupsdCheckJobs()");
* cancel the job...
*/
- cupsdLogMessage(L_WARN, "Printer/class %s has gone away; cancelling job %d!",
- job->dest, job->id);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Printer/class %s has gone away; cancelling job %d!",
+ job->dest, job->id);
cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
"Job cancelled because the destination printer/class has gone away.");
void
cupsdCleanJobs(void)
{
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
if (!MaxJobs)
*/
void
-cupsdFinishJob(cupsd_job_t *job) /* I - Job */
+cupsdFinishJob(cupsd_job_t *job) /* I - Job */
{
- int job_history; /* Did cupsdCancelJob() keep the job? */
- cupsd_printer_t *printer; /* Current printer */
+ int job_history; /* Did cupsdCancelJob() keep the job? */
+ cupsd_printer_t *printer; /* Current printer */
- cupsdLogMessage(L_DEBUG, "cupsdFinishJob: job %d, file %d is complete.",
- job->id, job->current_file - 1);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdFinishJob: job %d, file %d is complete.",
+ job->id, job->current_file - 1);
- cupsdLogMessage(L_DEBUG2, "cupsdFinishJob: job->status is %d", job->status);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFinishJob: job->status is %d",
+ job->status);
if (job->status_buffer && job->current_file >= job->num_files)
{
* Close the pipe and clear the input bit.
*/
- cupsdLogMessage(L_DEBUG2, "cupsdFinishJob: Removing fd %d from InputSet...",
- job->status_buffer->fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdFinishJob: Removing fd %d from InputSet...",
+ job->status_buffer->fd);
FD_CLR(job->status_buffer->fd, InputSet);
- cupsdLogMessage(L_DEBUG2, "cupsdFinishJob: Closing status input pipe %d...",
- job->status_buffer->fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdFinishJob: Closing status input pipe %d...",
+ job->status_buffer->fd);
cupsdStatBufDelete(job->status_buffer);
* Too many tries...
*/
- cupsdLogMessage(L_ERROR, "Canceling job %d since it could not be sent after %d tries.",
- job->id, FaxRetryLimit);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Canceling job %d since it could not be sent after %d tries.",
+ job->id, FaxRetryLimit);
cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
"Job cancelled since it could not be sent after %d tries.",
void
cupsdFreeAllJobs(void)
{
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
cupsdHoldSignals();
* 'cupsdFindJob()' - Find the specified job.
*/
-cupsd_job_t * /* O - Job data */
-cupsdFindJob(int id) /* I - Job ID */
+cupsd_job_t * /* O - Job data */
+cupsdFindJob(int id) /* I - Job ID */
{
- cupsd_job_t key; /* Search key */
+ cupsd_job_t key; /* Search key */
key.id = id;
/*
* 'cupsdGetPrinterJobCount()' - Get the number of pending, processing,
- * or held jobs in a printer or class.
+ * or held jobs in a printer or class.
*/
int /* O - Job count */
-cupsdGetPrinterJobCount(const char *dest) /* I - Printer or class name */
+cupsdGetPrinterJobCount(
+ const char *dest) /* I - Printer or class name */
{
- int count; /* Job count */
- cupsd_job_t *job; /* Current job */
+ int count; /* Job count */
+ cupsd_job_t *job; /* Current job */
for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs), count = 0;
/*
* 'cupsdGetUserJobCount()' - Get the number of pending, processing,
- * or held jobs for a user.
+ * or held jobs for a user.
*/
int /* O - Job count */
-cupsdGetUserJobCount(const char *username) /* I - Username */
+cupsdGetUserJobCount(
+ const char *username) /* I - Username */
{
- int count; /* Job count */
- cupsd_job_t *job; /* Current job */
+ int count; /* Job count */
+ cupsd_job_t *job; /* Current job */
for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs), count = 0;
*/
void
-cupsdHoldJob(int id) /* I - Job ID */
+cupsdHoldJob(int id) /* I - Job ID */
{
- cupsd_job_t *job; /* Job data */
+ cupsd_job_t *job; /* Job data */
- cupsdLogMessage(L_DEBUG, "cupsdHoldJob: id = %d", id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdHoldJob: id = %d", id);
if ((job = cupsdFindJob(id)) == NULL)
return;
void
cupsdLoadAllJobs(void)
{
- cups_dir_t *dir; /* Directory */
- cups_dentry_t *dent; /* Directory entry */
- char filename[1024]; /* Full filename of job file */
- int fd; /* File descriptor */
- cupsd_job_t *job; /* New job */
- int jobid, /* Current job ID */
- fileid; /* Current file ID */
- ipp_attribute_t *attr; /* Job attribute */
- char method[HTTP_MAX_URI], /* Method portion of URI */
- username[HTTP_MAX_URI], /* Username portion of URI */
- host[HTTP_MAX_URI], /* Host portion of URI */
- resource[HTTP_MAX_URI]; /* Resource portion of URI */
- int port; /* Port portion of URI */
- cupsd_printer_t *p; /* Printer or class */
- const char *dest; /* Destination */
- mime_type_t **filetypes; /* New filetypes array */
- int *compressions; /* New compressions array */
+ cups_dir_t *dir; /* Directory */
+ cups_dentry_t *dent; /* Directory entry */
+ char filename[1024]; /* Full filename of job file */
+ int fd; /* File descriptor */
+ cupsd_job_t *job; /* New job */
+ int jobid, /* Current job ID */
+ fileid; /* Current file ID */
+ ipp_attribute_t *attr; /* Job attribute */
+ char method[HTTP_MAX_URI],
+ /* Method portion of URI */
+ username[HTTP_MAX_URI],
+ /* Username portion of URI */
+ host[HTTP_MAX_URI],
+ /* Host portion of URI */
+ resource[HTTP_MAX_URI];
+ /* Resource portion of URI */
+ int port; /* Port portion of URI */
+ cupsd_printer_t *p; /* Printer or class */
+ const char *dest; /* Destination */
+ mime_type_t **filetypes; /* New filetypes array */
+ int *compressions; /* New compressions array */
/*
* Then open the requests directory...
*/
- cupsdLogMessage(L_DEBUG, "cupsdLoadAllJobs: Scanning %s...", RequestRoot);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdLoadAllJobs: Scanning %s...",
+ RequestRoot);
if ((dir = cupsDirOpen(RequestRoot)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Unable to open spool directory %s: %s",
- RequestRoot, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Unable to open spool directory %s: %s",
+ RequestRoot, strerror(errno));
return;
}
if ((job = calloc(sizeof(cupsd_job_t), 1)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Ran out of memory for jobs!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Ran out of memory for jobs!");
cupsDirClose(dir);
return;
}
if ((job->attrs = ippNew()) == NULL)
{
free(job);
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Ran out of memory for job attributes!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Ran out of memory for job attributes!");
cupsDirClose(dir);
return;
}
job->print_pipes[0] = -1;
job->print_pipes[1] = -1;
- cupsdLogMessage(L_DEBUG, "cupsdLoadAllJobs: Loading attributes for job %d...\n",
- job->id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdLoadAllJobs: Loading attributes for job %d...",
+ job->id);
if (job->id >= NextJobId)
NextJobId = job->id + 1;
snprintf(filename, sizeof(filename), "%s/%s", RequestRoot, dent->filename);
if ((fd = open(filename, O_RDONLY)) < 0)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Unable to open job control file \"%s\" - %s!",
- filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Unable to open job control file \"%s\" - %s!",
+ filename, strerror(errno));
ippDelete(job->attrs);
free(job);
unlink(filename);
{
if (ippReadFile(fd, job->attrs) != IPP_DATA)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Unable to read job control file \"%s\"!",
- filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Unable to read job control file \"%s\"!",
+ filename);
close(fd);
ippDelete(job->attrs);
free(job);
if ((job->state = ippFindAttribute(job->attrs, "job-state", IPP_TAG_ENUM)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Missing or bad job-state attribute in control file \"%s\"!",
- filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Missing or bad job-state attribute in control file \"%s\"!",
+ filename);
ippDelete(job->attrs);
free(job);
unlink(filename);
if ((attr = ippFindAttribute(job->attrs, "job-printer-uri", IPP_TAG_URI)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: No job-printer-uri attribute in control file \"%s\"!",
- filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: No job-printer-uri attribute in control file \"%s\"!",
+ filename);
ippDelete(job->attrs);
free(job);
unlink(filename);
if (dest == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Unable to queue job for destination \"%s\"!",
- attr->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Unable to queue job for destination \"%s\"!",
+ attr->values[0].string.text);
ippDelete(job->attrs);
free(job);
unlink(filename);
job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-completed",
IPP_TAG_INTEGER);
- job->cupsd_job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
+ job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
if ((attr = ippFindAttribute(job->attrs, "job-priority", IPP_TAG_INTEGER)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Missing or bad job-priority attribute in control file \"%s\"!",
- filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Missing or bad job-priority attribute in control file \"%s\"!",
+ filename);
ippDelete(job->attrs);
free(job);
unlink(filename);
if ((attr = ippFindAttribute(job->attrs, "job-originating-user-name", IPP_TAG_NAME)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Missing or bad job-originating-user-name attribute in control file \"%s\"!",
- filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Missing or bad job-originating-user-name attribute in control file \"%s\"!",
+ filename);
ippDelete(job->attrs);
free(job);
unlink(filename);
jobid = atoi(dent->filename + 1);
fileid = atoi(strchr(dent->filename, '-') + 1);
- cupsdLogMessage(L_DEBUG, "cupsdLoadAllJobs: Auto-typing document file %s...",
- dent->filename);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdLoadAllJobs: Auto-typing document file %s...",
+ dent->filename);
snprintf(filename, sizeof(filename), "%s/%s", RequestRoot, dent->filename);
if ((job = cupsdFindJob(jobid)) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Orphaned print file \"%s\"!",
- filename);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllJobs: Orphaned print file \"%s\"!",
+ filename);
unlink(filename);
continue;
}
if (compressions == NULL || filetypes == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Ran out of memory for job file types!");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdLoadAllJobs: Ran out of memory for job file types!");
continue;
}
*/
void
-cupsdMoveJob(int id, /* I - Job ID */
- const char *dest) /* I - Destination */
+cupsdMoveJob(int id, /* I - Job ID */
+ const char *dest) /* I - Destination */
{
- cupsd_job_t *job; /* Current job */
+ cupsd_job_t *job; /* Current job */
ipp_attribute_t *attr; /* job-printer-uri attribute */
- cupsd_printer_t *p; /* Destination printer or class */
+ cupsd_printer_t *p; /* Destination printer or class */
/*
void
cupsdReleaseJob(int id) /* I - Job ID */
{
- cupsd_job_t *job; /* Job data */
+ cupsd_job_t *job; /* Job data */
- cupsdLogMessage(L_DEBUG, "cupsdReleaseJob: id = %d", id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdReleaseJob: id = %d", id);
if ((job = cupsdFindJob(id)) == NULL)
return;
void
cupsdRestartJob(int id) /* I - Job ID */
{
- cupsd_job_t *job; /* Job data */
+ cupsd_job_t *job; /* Job data */
if ((job = cupsdFindJob(id)) == NULL)
*/
void
-cupsdSaveJob(int id) /* I - Job ID */
+cupsdSaveJob(int id) /* I - Job ID */
{
- cupsd_job_t *job; /* Pointer to job */
- char filename[1024]; /* Job control filename */
- int fd; /* File descriptor */
+ cupsd_job_t *job; /* Pointer to job */
+ char filename[1024]; /* Job control filename */
+ int fd; /* File descriptor */
if ((job = cupsdFindJob(id)) == NULL)
if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0)
{
- cupsdLogMessage(L_ERROR, "cupsdSaveJob: Unable to create job control file \"%s\" - %s.",
- filename, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdSaveJob: Unable to create job control file \"%s\" - %s.",
+ filename, strerror(errno));
return;
}
ippWriteFile(fd, job->attrs);
- cupsdLogMessage(L_DEBUG2, "cupsdSaveJob: Closing file %d...", fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob: Closing file %d...", fd);
close(fd);
}
*/
void
-cupsdSetJobHoldUntil(int id, /* I - Job ID */
- const char *when) /* I - When to resume */
+cupsdSetJobHoldUntil(int id, /* I - Job ID */
+ const char *when) /* I - When to resume */
{
- cupsd_job_t *job; /* Pointer to job */
+ cupsd_job_t *job; /* Pointer to job */
time_t curtime; /* Current time */
struct tm *curdate; /* Current date */
int hour; /* Hold hour */
int second; /* Hold second */
- cupsdLogMessage(L_DEBUG, "cupsdSetJobHoldUntil(%d, \"%s\")", id, when);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdSetJobHoldUntil(%d, \"%s\")", id, when);
if ((job = cupsdFindJob(id)) == NULL)
return;
job->hold_until += 24 * 60 * 60 * 60;
}
- cupsdLogMessage(L_DEBUG, "cupsdSetJobHoldUntil: hold_until = %d", (int)job->hold_until);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdSetJobHoldUntil: hold_until = %d",
+ (int)job->hold_until);
}
*/
void
-cupsdSetJobPriority(int id, /* I - Job ID */
- int priority) /* I - New priority (0 to 100) */
+cupsdSetJobPriority(int id, /* I - Job ID */
+ int priority) /* I - New priority (0 to 100) */
{
- cupsd_job_t *job; /* Job to change */
- ipp_attribute_t *attr; /* Job attribute */
+ cupsd_job_t *job; /* Job to change */
+ ipp_attribute_t *attr; /* Job attribute */
/*
*/
void
-cupsdStartJob(int id, /* I - Job ID */
- cupsd_printer_t *printer) /* I - Printer to print job */
+cupsdStartJob(int id, /* I - Job ID */
+ cupsd_printer_t *printer) /* I - Printer to print job */
{
cupsd_job_t *job; /* Current job */
- int i; /* Looping var */
- int slot; /* Pipe slot */
- int num_filters; /* Number of filters for job */
- mime_filter_t *filters; /* Filters for job */
- char method[255], /* Method for output */
- *optptr, /* Pointer to options */
- *valptr; /* Pointer in value string */
- ipp_attribute_t *attr; /* Current attribute */
- int pid; /* Process ID of new filter process */
- int banner_page; /* 1 if banner page, 0 otherwise */
- int statusfds[2], /* Pipes used between the filters and scheduler */
- filterfds[2][2]; /* Pipes used between the filters */
- int envc; /* Number of environment variables */
- char *argv[8], /* Filter command-line arguments */
- sani_uri[1024], /* Sanitized DEVICE_URI env var */
- filename[1024], /* Job filename */
- command[1024], /* Full path to filter/backend command */
- jobid[255], /* Job ID string */
- title[IPP_MAX_NAME], /* Job title string */
- copies[255], /* # copies string */
- *envp[100], /* Environment variables */
- charset[255], /* CHARSET environment variable */
- class_name[255], /* CLASS environment variable */
- classification[1024], /* CLASSIFICATION environment variable */
- content_type[1024], /* CONTENT_TYPE environment variable */
- device_uri[1024], /* DEVICE_URI environment variable */
- lang[255], /* LANG environment variable */
- ppd[1024], /* PPD environment variable */
- printer_name[255], /* PRINTER environment variable */
- rip_max_cache[255]; /* RIP_MAX_CACHE environment variable */
- static char *options = NULL; /* Full list of options */
- static int optlength = 0; /* Length of option buffer */
-
-
- cupsdLogMessage(L_DEBUG, "cupsdStartJob(%d, %p)", id, printer);
+ int i; /* Looping var */
+ int slot; /* Pipe slot */
+ int num_filters; /* Number of filters for job */
+ mime_filter_t *filters; /* Filters for job */
+ char method[255], /* Method for output */
+ *optptr, /* Pointer to options */
+ *valptr; /* Pointer in value string */
+ ipp_attribute_t *attr; /* Current attribute */
+ int pid; /* Process ID of new filter process */
+ int banner_page; /* 1 if banner page, 0 otherwise */
+ int statusfds[2], /* Pipes used between the filters and scheduler */
+ filterfds[2][2];/* Pipes used between the filters */
+ int envc; /* Number of environment variables */
+ char *argv[8], /* Filter command-line arguments */
+ sani_uri[1024], /* Sanitized DEVICE_URI env var */
+ filename[1024], /* Job filename */
+ command[1024], /* Full path to filter/backend command */
+ jobid[255], /* Job ID string */
+ title[IPP_MAX_NAME],
+ /* Job title string */
+ copies[255], /* # copies string */
+ *envp[100], /* Environment variables */
+ charset[255], /* CHARSET environment variable */
+ class_name[255],/* CLASS environment variable */
+ classification[1024],
+ /* CLASSIFICATION environment variable */
+ content_type[1024],
+ /* CONTENT_TYPE environment variable */
+ device_uri[1024],
+ /* DEVICE_URI environment variable */
+ lang[255], /* LANG environment variable */
+ ppd[1024], /* PPD environment variable */
+ printer_name[255],
+ /* PRINTER environment variable */
+ rip_max_cache[255];
+ /* RIP_MAX_CACHE environment variable */
+ static char *options = NULL;/* Full list of options */
+ static int optlength = 0; /* Length of option buffer */
+
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStartJob(%d, %p)", id, printer);
if ((job = cupsdFindJob(id)) == NULL)
return;
- cupsdLogMessage(L_DEBUG, "cupsdStartJob() id = %d, file = %d/%d", id,
- job->current_file, job->num_files);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStartJob() id = %d, file = %d/%d", id,
+ job->current_file, job->num_files);
if (job->num_files == 0)
{
- cupsdLogMessage(L_ERROR, "Job ID %d has no files! Cancelling it!", id);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Job ID %d has no files! Cancelling it!",
+ id);
cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
"Job cancelled because it has no files.");
* filtering...
*/
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: Sending job to queue tagged as raw...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdStartJob: Sending job to queue tagged as raw...");
filters = NULL;
}
if (num_filters == 0)
{
- cupsdLogMessage(L_ERROR, "Unable to convert file %d to printable format for job %d!",
- job->current_file, job->id);
- cupsdLogMessage(L_INFO, "Hint: Do you have ESP Ghostscript installed?");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to convert file %d to printable format for job %d!",
+ job->current_file, job->id);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Hint: Do you have ESP Ghostscript installed?");
- if (LogLevel < L_DEBUG)
- cupsdLogMessage(L_INFO, "Hint: Try setting the LogLevel to \"debug\".");
+ if (LogLevel < CUPSD_LOG_DEBUG)
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Hint: Try setting the LogLevel to \"debug\".");
job->current_file ++;
if (filters != NULL)
free(filters);
- cupsdLogMessage(L_INFO, "Holding job %d because filter limit has been reached.",
- id);
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: id = %d, file = %d, "
- "cost = %d, level = %d, limit = %d",
- id, job->current_file, job->cost, FilterLevel,
- FilterLimit);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Holding job %d because filter limit has been reached.",
+ id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdStartJob: id=%d, file=%d, cost=%d, level=%d, limit=%d",
+ id, job->current_file, job->cost, FilterLevel, FilterLimit);
return;
}
if (temp_filters == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to add decompression filter - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to add decompression filter - %s",
+ strerror(errno));
if (filters != NULL)
free(filters);
if (temp_filters == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to add port monitor - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to add port monitor - %s",
+ strerror(errno));
if (filters != NULL)
free(filters);
* Determine if we are printing a banner page or not...
*/
- if (job->cupsd_job_sheets == NULL)
+ if (job->job_sheets == NULL)
{
- cupsdLogMessage(L_DEBUG, "No job-sheets attribute.");
- if ((job->cupsd_job_sheets =
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "No job-sheets attribute.");
+ if ((job->job_sheets =
ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_ZERO)) != NULL)
- cupsdLogMessage(L_DEBUG, "... but someone added one without setting cupsd_job_sheets!");
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "... but someone added one without setting job_sheets!");
}
- else if (job->cupsd_job_sheets->num_values == 1)
- cupsdLogMessage(L_DEBUG, "job-sheets=%s",
- job->cupsd_job_sheets->values[0].string.text);
+ else if (job->job_sheets->num_values == 1)
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "job-sheets=%s",
+ job->job_sheets->values[0].string.text);
else
- cupsdLogMessage(L_DEBUG, "job-sheets=%s,%s",
- job->cupsd_job_sheets->values[0].string.text,
- job->cupsd_job_sheets->values[1].string.text);
+ cupsdLogMessage(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;
- else if (job->cupsd_job_sheets == NULL)
+ else if (job->job_sheets == NULL)
banner_page = 0;
- else if (strcasecmp(job->cupsd_job_sheets->values[0].string.text, "none") != 0 &&
+ else if (strcasecmp(job->job_sheets->values[0].string.text, "none") != 0 &&
job->current_file == 0)
banner_page = 1;
- else if (job->cupsd_job_sheets->num_values > 1 &&
- strcasecmp(job->cupsd_job_sheets->values[1].string.text, "none") != 0 &&
+ else if (job->job_sheets->num_values > 1 &&
+ strcasecmp(job->job_sheets->values[1].string.text, "none") != 0 &&
job->current_file == (job->num_files - 1))
banner_page = 1;
else
banner_page = 0;
- cupsdLogMessage(L_DEBUG, "banner_page = %d", banner_page);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "banner_page = %d", banner_page);
/*
* Building the options string is harder than it needs to be, but
if (optptr == NULL)
{
- cupsdLogMessage(L_CRIT, "cupsdStartJob: Unable to allocate %d bytes for option buffer for job %d!",
- i, id);
+ cupsdLogMessage(CUPSD_LOG_CRIT,
+ "cupsdStartJob: Unable to allocate %d bytes for option buffer for job %d!",
+ i, id);
if (filters != NULL)
free(filters);
argv[6] = filename;
argv[7] = NULL;
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: argv = \"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"",
- argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdStartJob: argv = \"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"",
+ argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
/*
* Create environment variable strings for the filters...
for (i = 0; i < envc; i ++)
if (strncmp(envp[i], "DEVICE_URI=", 11))
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: envp[%d]=\"%s\"", i, envp[i]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStartJob: envp[%d]=\"%s\"",
+ i, envp[i]);
else
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: envp[%d]=\"DEVICE_URI=%s\"", i, sani_uri);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdStartJob: envp[%d]=\"DEVICE_URI=%s\"", i, sani_uri);
job->current_file ++;
if (cupsdOpenPipe(statusfds))
{
- cupsdLogMessage(L_ERROR, "Unable to create job status pipes - %s.",
- strerror(errno));
+ cupsdLogMessage(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));
return;
}
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: statusfds = [ %d %d ]",
- statusfds[0], statusfds[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStartJob: statusfds = [ %d %d ]",
+ statusfds[0], statusfds[1]);
#ifdef FD_CLOEXEC
fcntl(statusfds[0], F_SETFD, FD_CLOEXEC);
if (filterfds[1][0] < 0)
{
- cupsdLogMessage(L_ERROR, "Unable to open \"/dev/null\" - %s.", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"/dev/null\" - %s.",
+ strerror(errno));
snprintf(printer->state_message, sizeof(printer->state_message),
"Unable to open \"/dev/null\" - %s.", strerror(errno));
fcntl(filterfds[1][0], F_SETFD, fcntl(filterfds[1][0], F_GETFD) | FD_CLOEXEC);
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: filterfds[%d] = [ %d %d ]", 1, filterfds[1][0],
- filterfds[1][1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStartJob: filterfds[%d] = [ %d %d ]",
+ 1, filterfds[1][0], filterfds[1][1]);
for (i = 0, slot = 0; i < num_filters; i ++)
{
{
if (cupsdOpenPipe(filterfds[slot]))
{
- cupsdLogMessage(L_ERROR, "Unable to create job filter pipes - %s.",
- strerror(errno));
+ cupsdLogMessage(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);
{
if (cupsdOpenPipe(job->print_pipes))
{
- cupsdLogMessage(L_ERROR, "Unable to create job backend pipes - %s.",
- strerror(errno));
+ cupsdLogMessage(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);
if (!strncmp(printer->device_uri, "file:/dev/", 10) &&
strcmp(printer->device_uri, "file:/dev/null"))
job->print_pipes[1] = open(printer->device_uri + 5,
- O_WRONLY | O_EXCL);
+ O_WRONLY | O_EXCL);
else if (!strncmp(printer->device_uri, "file:///dev/", 12) &&
strcmp(printer->device_uri, "file:///dev/null"))
job->print_pipes[1] = open(printer->device_uri + 7,
- O_WRONLY | O_EXCL);
+ O_WRONLY | O_EXCL);
else
job->print_pipes[1] = open(printer->device_uri + 5,
- O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (job->print_pipes[1] < 0)
{
- cupsdLogMessage(L_ERROR, "Unable to open output file \"%s\" - %s.",
- printer->device_uri, strerror(errno));
+ cupsdLogMessage(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));
fcntl(job->print_pipes[1], F_GETFD) | FD_CLOEXEC);
}
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: print_pipes = [ %d %d ]",
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdStartJob: print_pipes = [ %d %d ]",
job->print_pipes[0], job->print_pipes[1]);
}
filterfds[slot][1] = job->print_pipes[1];
}
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: filter = \"%s\"", command);
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: filterfds[%d] = [ %d %d ]",
- slot, filterfds[slot][0], filterfds[slot][1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStartJob: filter = \"%s\"", command);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStartJob: filterfds[%d] = [ %d %d ]",
+ slot, filterfds[slot][0], filterfds[slot][1]);
pid = cupsdStartProcess(command, argv, envp, filterfds[!slot][0],
filterfds[slot][1], statusfds[1],
job->back_pipes[0], 0, job->filters + i);
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing filter pipes for slot %d [ %d %d ]...",
- !slot, filterfds[!slot][0], filterfds[!slot][1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartJob: Closing filter pipes for slot %d [ %d %d ]...",
+ !slot, filterfds[!slot][0], filterfds[!slot][1]);
cupsdClosePipe(filterfds[!slot]);
if (pid == 0)
{
- cupsdLogMessage(L_ERROR, "Unable to start filter \"%s\" - %s.",
- filters[i].filter, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to start filter \"%s\" - %s.",
+ filters[i].filter, strerror(errno));
snprintf(printer->state_message, sizeof(printer->state_message),
"Unable to start filter \"%s\" - %s.",
filters[i].filter, strerror(errno));
return;
}
- cupsdLogMessage(L_INFO, "Started filter %s (PID %d) for job %d.",
- command, pid, job->id);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Started filter %s (PID %d) for job %d.",
+ command, pid, job->id);
argv[6] = NULL;
slot = !slot;
if (filterfds[slot][1] < 0)
{
- cupsdLogMessage(L_ERROR, "Unable to open \"/dev/null\" - %s.", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"/dev/null\" - %s.",
+ strerror(errno));
snprintf(printer->state_message, sizeof(printer->state_message),
"Unable to open \"/dev/null\" - %s.", strerror(errno));
fcntl(filterfds[slot][1], F_SETFD,
fcntl(filterfds[slot][1], F_GETFD) | FD_CLOEXEC);
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: backend = \"%s\"", command);
- cupsdLogMessage(L_DEBUG, "cupsdStartJob: filterfds[%d] = [ %d %d ]",
- slot, filterfds[slot][0], filterfds[slot][1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStartJob: backend = \"%s\"",
+ command);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdStartJob: filterfds[%d] = [ %d %d ]",
+ slot, filterfds[slot][0], filterfds[slot][1]);
pid = cupsdStartProcess(command, argv, envp, filterfds[!slot][0],
filterfds[slot][1], statusfds[1],
if (pid == 0)
{
- cupsdLogMessage(L_ERROR, "Unable to start backend \"%s\" - %s.",
- method, strerror(errno));
+ cupsdLogMessage(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));
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing print pipes [ %d %d ]...",
- job->print_pipes[0], job->print_pipes[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartJob: Closing print pipes [ %d %d ]...",
+ job->print_pipes[0], job->print_pipes[1]);
cupsdClosePipe(job->print_pipes);
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing back pipes [ %d %d ]...",
- job->back_pipes[0], job->back_pipes[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartJob: Closing back pipes [ %d %d ]...",
+ job->back_pipes[0], job->back_pipes[1]);
cupsdClosePipe(job->back_pipes);
}
else
{
- cupsdLogMessage(L_INFO, "Started backend %s (PID %d) for job %d.",
- command, pid, job->id);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Started backend %s (PID %d) for job %d.",
+ command, pid, job->id);
}
}
if (job->current_file == job->num_files)
{
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing print pipes [ %d %d ]...",
- job->print_pipes[0], job->print_pipes[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartJob: Closing print pipes [ %d %d ]...",
+ job->print_pipes[0], job->print_pipes[1]);
cupsdClosePipe(job->print_pipes);
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing back pipes [ %d %d ]...",
- job->back_pipes[0], job->back_pipes[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartJob: Closing back pipes [ %d %d ]...",
+ job->back_pipes[0], job->back_pipes[1]);
cupsdClosePipe(job->back_pipes);
}
if (job->current_file == job->num_files)
{
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing print pipes [ %d %d ]...",
- job->print_pipes[0], job->print_pipes[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartJob: Closing print pipes [ %d %d ]...",
+ job->print_pipes[0], job->print_pipes[1]);
cupsdClosePipe(job->print_pipes);
}
}
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing filter pipes for slot %d [ %d %d ]...",
- slot, filterfds[slot][0], filterfds[slot][1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartJob: Closing filter pipes for slot %d [ %d %d ]...",
+ slot, filterfds[slot][0], filterfds[slot][1]);
cupsdClosePipe(filterfds[slot]);
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing status output pipe %d...",
- statusfds[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartJob: Closing status output pipe %d...",
+ statusfds[1]);
close(statusfds[1]);
- cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Adding fd %d to InputSet...",
- job->status_buffer->fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartJob: Adding fd %d to InputSet...",
+ job->status_buffer->fd);
FD_SET(job->status_buffer->fd, InputSet);
}
*/
void
-cupsdStopJob(int id, /* I - Job ID */
- int force) /* I - 1 = Force all filters to stop */
+cupsdStopJob(int id, /* I - Job ID */
+ int force) /* I - 1 = Force all filters to stop */
{
- int i; /* Looping var */
+ int i; /* Looping var */
cupsd_job_t *job; /* Current job */
- cupsdLogMessage(L_DEBUG, "cupsdStopJob: id = %d, force = %d", id, force);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStopJob: id = %d, force = %d",
+ id, force);
if ((job = cupsdFindJob(id)) == NULL)
return;
else if (job->printer->state != IPP_PRINTER_STOPPED)
cupsdSetPrinterState(job->printer, IPP_PRINTER_IDLE, 0);
- cupsdLogMessage(L_DEBUG, "cupsdStopJob: printer state is %d", job->printer->state);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStopJob: printer state is %d",
+ job->printer->state);
job->state->values[0].integer = IPP_JOB_STOPPED;
job->printer->job = NULL;
job->backend = 0;
}
- cupsdLogMessage(L_DEBUG2, "cupsdStopJob: Closing print pipes [ %d %d ]...",
- job->print_pipes[0], job->print_pipes[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStopJob: Closing print pipes [ %d %d ]...",
+ job->print_pipes[0], job->print_pipes[1]);
cupsdClosePipe(job->print_pipes);
- cupsdLogMessage(L_DEBUG2, "cupsdStopJob: Closing back pipes [ %d %d ]...",
- job->back_pipes[0], job->back_pipes[1]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStopJob: Closing back pipes [ %d %d ]...",
+ job->back_pipes[0], job->back_pipes[1]);
cupsdClosePipe(job->back_pipes);
* Close the pipe and clear the input bit.
*/
- cupsdLogMessage(L_DEBUG2, "cupsdStopJob: Removing fd %d from InputSet...",
- job->status_buffer->fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStopJob: Removing fd %d from InputSet...",
+ job->status_buffer->fd);
FD_CLR(job->status_buffer->fd, InputSet);
- cupsdLogMessage(L_DEBUG2, "cupsdStopJob: Closing status input pipe %d...",
- job->status_buffer->fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStopJob: Closing status input pipe %d...",
+ job->status_buffer->fd);
cupsdStatBufDelete(job->status_buffer);
*/
void
-cupsdUpdateJob(cupsd_job_t *job) /* I - Job to check */
+cupsdUpdateJob(cupsd_job_t *job) /* I - Job to check */
{
int i; /* Looping var */
int copies; /* Number of copies printed */
* Process page and printer state messages as needed...
*/
- if (loglevel == L_PAGE)
+ if (loglevel == CUPSD_LOG_PAGE)
{
/*
* Page message; send the message to the page_log file and update the
cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job,
"Printed %d page(s).", job->sheets->values[0].integer);
}
- else if (loglevel == L_STATE)
+ else if (loglevel == CUPSD_LOG_STATE)
cupsdSetPrinterReasons(job->printer, message);
- else if (loglevel == L_ATTR)
+ else if (loglevel == CUPSD_LOG_ATTR)
{
/*
* Set attribute(s)...
*/
static void
-set_time(cupsd_job_t *job, /* I - Job to update */
- const char *name) /* I - Name of attribute */
+set_time(cupsd_job_t *job, /* I - Job to update */
+ const char *name) /* I - Name of attribute */
{
- ipp_attribute_t *attr; /* Time attribute */
+ ipp_attribute_t *attr; /* Time attribute */
if ((attr = ippFindAttribute(job->attrs, name, IPP_TAG_ZERO)) != NULL)
*/
static void
-set_hold_until(cupsd_job_t *job, /* I - Job to update */
- time_t holdtime) /* I - Hold until time */
+set_hold_until(cupsd_job_t *job, /* I - Job to update */
+ time_t holdtime) /* I - Hold until time */
{
ipp_attribute_t *attr; /* job-hold-until attribute */
struct tm *holddate; /* Hold date */
* Set the hold_until value and hold the job...
*/
- cupsdLogMessage(L_DEBUG, "set_hold_until: hold_until = %d", (int)holdtime);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "set_hold_until: hold_until = %d", (int)holdtime);
job->state->values[0].integer = IPP_JOB_HELD;
job->hold_until = holdtime;
* WWW: http://www.cups.org
*/
-/*
- * Constants...
- */
-
-#define JOB_BUFFER_SIZE 1024 /* Bytes for job status buffer */
-
-
/*
* Job request structure...
*/
typedef struct cupsd_job_s
{
- int id, /* Job ID */
- priority; /* Job priority */
- ipp_attribute_t *state; /* Job state */
- ipp_attribute_t *sheets; /* job-media-sheets-completed */
- time_t hold_until; /* Hold expiration date/time */
- char *username; /* Printing user */
- char *dest; /* Destination printer or class */
- cups_ptype_t dtype; /* Destination type (class/remote bits) */
- ipp_attribute_t *cupsd_job_sheets; /* Job sheets (NULL if none) */
- int num_files; /* Number of files in job */
- int current_file; /* Current file in job */
- mime_type_t **filetypes; /* File types */
- int *compressions; /* Compression status of each file */
- ipp_t *attrs; /* Job attributes */
- cupsd_statbuf_t *status_buffer; /* Status buffer for this job */
- int print_pipes[2], /* Print data pipes */
- back_pipes[2]; /* Backchannel pipes */
- int cost; /* Filtering cost */
- int filters[MAX_FILTERS + 1];/* Filter process IDs, 0 terminated */
- int backend; /* Backend process ID */
- int status; /* Status code from filters */
- cupsd_printer_t *printer; /* Printer this job is assigned to */
- int tries; /* Number of tries for this job */
+ int id, /* Job ID */
+ priority; /* Job priority */
+ ipp_attribute_t *state; /* Job state */
+ ipp_attribute_t *sheets; /* job-media-sheets-completed */
+ time_t hold_until; /* Hold expiration date/time */
+ char *username; /* Printing user */
+ char *dest; /* Destination printer or class */
+ cups_ptype_t dtype; /* Destination type (class/remote bits) */
+ ipp_attribute_t *job_sheets; /* Job sheets (NULL if none) */
+ int num_files; /* Number of files in job */
+ int current_file; /* Current file in job */
+ mime_type_t **filetypes; /* File types */
+ int *compressions; /* Compression status of each file */
+ ipp_t *attrs; /* Job attributes */
+ cupsd_statbuf_t *status_buffer; /* Status buffer for this job */
+ int print_pipes[2], /* Print data pipes */
+ back_pipes[2]; /* Backchannel pipes */
+ int cost; /* Filtering cost */
+ int filters[MAX_FILTERS + 1];
+ /* Filter process IDs, 0 terminated */
+ int backend; /* Backend process ID */
+ int status; /* Status code from filters */
+ cupsd_printer_t *printer; /* Printer this job is assigned to */
+ int tries; /* Number of tries for this job */
} cupsd_job_t;
*/
extern cupsd_job_t *cupsdAddJob(int priority, const char *dest);
-extern void cupsdCancelJob(int id, int purge);
-extern void cupsdCancelJobs(const char *dest, const char *username, int purge);
-extern void cupsdCheckJobs(void);
-extern void cupsdCleanJobs(void);
-extern void cupsdDeleteJob(int id);
+extern void cupsdCancelJob(int id, int purge);
+extern void cupsdCancelJobs(const char *dest, const char *username,
+ int purge);
+extern void cupsdCheckJobs(void);
+extern void cupsdCleanJobs(void);
+extern void cupsdDeleteJob(int id);
extern cupsd_job_t *cupsdFindJob(int id);
-extern void cupsdFinishJob(cupsd_job_t *job);
-extern void cupsdFreeAllJobs(void);
-extern int cupsdGetPrinterJobCount(const char *dest);
-extern int cupsdGetUserJobCount(const char *username);
-extern void cupsdHoldJob(int id);
-extern void cupsdLoadAllJobs(void);
-extern void cupsdMoveJob(int id, const char *dest);
-extern void cupsdReleaseJob(int id);
-extern void cupsdRestartJob(int id);
-extern void cupsdSaveJob(int id);
-extern void cupsdSetJobHoldUntil(int id, const char *when);
-extern void cupsdSetJobPriority(int id, int priority);
-extern void cupsdStartJob(int id, cupsd_printer_t *printer);
-extern void cupsdStopAllJobs(void);
-extern void cupsdStopJob(int id, int force);
-extern void cupsdUpdateJob(cupsd_job_t *job);
+extern void cupsdFinishJob(cupsd_job_t *job);
+extern void cupsdFreeAllJobs(void);
+extern int cupsdGetPrinterJobCount(const char *dest);
+extern int cupsdGetUserJobCount(const char *username);
+extern void cupsdHoldJob(int id);
+extern void cupsdLoadAllJobs(void);
+extern void cupsdMoveJob(int id, const char *dest);
+extern void cupsdReleaseJob(int id);
+extern void cupsdRestartJob(int id);
+extern void cupsdSaveJob(int id);
+extern void cupsdSetJobHoldUntil(int id, const char *when);
+extern void cupsdSetJobPriority(int id, int priority);
+extern void cupsdStartJob(int id, cupsd_printer_t *printer);
+extern void cupsdStopAllJobs(void);
+extern void cupsdStopJob(int id, int force);
+extern void cupsdUpdateJob(cupsd_job_t *job);
/*
void
cupsdPauseListening(void)
{
- int i; /* Looping var */
+ int i; /* Looping var */
cupsd_listener_t *lis; /* Current listening socket */
return;
if (NumClients == MaxClients)
- cupsdLogMessage(L_WARN, "Max clients reached, holding new connections...");
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Max clients reached, holding new connections...");
- cupsdLogMessage(L_DEBUG, "cupsdPauseListening: Clearing input bits...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdPauseListening: Clearing input bits...");
for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)
{
- cupsdLogMessage(L_DEBUG2, "cupsdPauseListening: Removing fd %d from InputSet...",
- lis->fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdPauseListening: Removing fd %d from InputSet...",
+ lis->fd);
FD_CLR(lis->fd, InputSet);
}
void
cupsdResumeListening(void)
{
- int i; /* Looping var */
+ int i; /* Looping var */
cupsd_listener_t *lis; /* Current listening socket */
return;
if (NumClients >= (MaxClients - 1))
- cupsdLogMessage(L_WARN, "Resuming new connection processing...");
+ cupsdLogMessage(CUPSD_LOG_WARN, "Resuming new connection processing...");
- cupsdLogMessage(L_DEBUG, "cupsdResumeListening: Setting input bits...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdResumeListening: Setting input bits...");
for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)
{
- cupsdLogMessage(L_DEBUG2, "cupsdResumeListening: Adding fd %d to InputSet...",
- lis->fd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdResumeListening: Adding fd %d to InputSet...",
+ lis->fd);
FD_SET(lis->fd, InputSet);
}
}
void
cupsdStartListening(void)
{
- int status; /* Bind result */
- int i, /* Looping var */
- p, /* Port number */
- val; /* Parameter value */
- cupsd_listener_t *lis; /* Current listening socket */
- struct hostent *host; /* Host entry for server address */
- char s[256]; /* String addresss */
- const char *have_domain; /* Have a domain socket? */
+ int status; /* Bind result */
+ int i, /* Looping var */
+ p, /* Port number */
+ val; /* Parameter value */
+ cupsd_listener_t *lis; /* Current listening socket */
+ struct hostent *host; /* Host entry for server address */
+ char s[256]; /* String addresss */
+ const char *have_domain; /* Have a domain socket? */
static const char * const encryptions[] =
{ /* Encryption values */
"IfRequested",
};
- cupsdLogMessage(L_DEBUG, "cupsdStartListening: NumListeners=%d", NumListeners);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdStartListening: NumListeners=%d",
+ NumListeners);
/*
* Get the server's IP address...
* Didn't find it! Use an address of 0...
*/
- cupsdLogMessage(L_ERROR, "cupsdStartListening: Unable to find IP address for server name \"%s\" - %s\n",
- ServerName, hstrerror(h_errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartListening: Unable to find IP address for server name \"%s\" - %s\n",
+ ServerName, hstrerror(h_errno));
ServerAddr.ipv4.sin_family = AF_INET;
}
* Try binding to an IPv4 address instead...
*/
- cupsdLogMessage(L_NOTICE, "cupsdStartListening: Unable to use IPv6 address, trying IPv4...");
+ cupsdLogMessage(CUPSD_LOG_NOTICE,
+ "cupsdStartListening: Unable to use IPv6 address, trying IPv4...");
p = ntohs(lis->address.ipv6.sin6_port);
if (lis->fd == -1)
{
- cupsdLogMessage(L_ERROR, "cupsdStartListening: Unable to open listen socket for address %s:%d - %s.",
- s, p, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartListening: Unable to open listen socket for address %s:%d - %s.",
+ s, p, strerror(errno));
exit(errno);
}
if (status < 0)
{
- cupsdLogMessage(L_ERROR, "cupsdStartListening: Unable to bind socket for address %s:%d - %s.",
- s, p, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartListening: Unable to bind socket for address %s:%d - %s.",
+ s, p, strerror(errno));
exit(errno);
}
if (listen(lis->fd, ListenBackLog) < 0)
{
- cupsdLogMessage(L_ERROR, "cupsdStartListening: Unable to listen for clients on address %s:%d - %s.",
- s, p, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartListening: Unable to listen for clients on address %s:%d - %s.",
+ s, p, strerror(errno));
exit(errno);
}
if (p)
- cupsdLogMessage(L_INFO, "cupsdStartListening: Listening to %s:%d on fd %d...",
- s, p, lis->fd);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "cupsdStartListening: Listening to %s:%d on fd %d...",
+ s, p, lis->fd);
else
- cupsdLogMessage(L_INFO, "cupsdStartListening: Listening to %s on fd %d...",
- s, lis->fd);
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "cupsdStartListening: Listening to %s on fd %d...",
+ s, lis->fd);
}
/*
if (!LocalPort && !have_domain)
{
- cupsdLogMessage(L_EMERG, "No Listen or Port lines were found to allow access via localhost!");
+ cupsdLogMessage(CUPSD_LOG_EMERG,
+ "No Listen or Port lines were found to allow access via localhost!");
/*
* Commit suicide...
cupsd_listener_t *lis; /* Current listening socket */
- cupsdLogMessage(L_DEBUG, "cupsdStopListening: closing all listen sockets.");
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdStopListening: closing all listen sockets.");
cupsdPauseListening();
* 'cupsdGetDateTime()' - Returns a pointer to a date/time string.
*/
-char * /* O - Date/time string */
+char * /* O - Date/time string */
cupsdGetDateTime(time_t t) /* I - Time value */
{
- struct tm *date; /* Date/time value */
- static time_t last_time = -1; /* Last time value */
- static char s[1024]; /* Date/time string */
- static const char * const months[12] =
- { /* Months */
+ struct tm *date; /* Date/time value */
+ static time_t last_time = -1; /* Last time value */
+ static char s[1024]; /* Date/time string */
+ static const char * const months[12] =/* Months */
+ {
"Jan",
"Feb",
"Mar",
*/
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 */
+cupsdLogMessage(int level, /* I - Log level */
+ const char *message, /* I - printf-style message string */
+ ...) /* I - Additional args as needed */
{
- int len; /* Length of message */
- va_list ap; /* Argument pointer */
- static const char levels[] = /* Log levels... */
+ int len; /* Length of message */
+ va_list ap; /* Argument pointer */
+ static const char levels[] = /* Log levels... */
{
' ',
'X',
* See if we are logging errors via syslog...
*/
- if (strcmp(ErrorLog, "syslog") == 0)
+ if (!strcmp(ErrorLog, "syslog"))
{
va_start(ap, message);
vsyslog(syslevels[level], message, ap);
* 'cupsdLogPage()' - Log a page to the page log file.
*/
-int /* O - 1 on success, 0 on error */
-cupsdLogPage(cupsd_job_t *job, /* I - Job being printed */
- const char *page) /* I - Page being printed */
+int /* O - 1 on success, 0 on error */
+cupsdLogPage(cupsd_job_t *job, /* I - Job being printed */
+ const char *page) /* I - Page being printed */
{
- ipp_attribute_t *billing, /* job-billing attribute */
- *hostname; /* job-originating-host-name attribute */
+ ipp_attribute_t *billing, /* job-billing attribute */
+ *hostname; /* job-originating-host-name attribute */
billing = ippFindAttribute(job->attrs, "job-billing", IPP_TAG_ZERO);
* See if we are logging pages via syslog...
*/
- if (strcmp(PageLog, "syslog") == 0)
+ if (!strcmp(PageLog, "syslog"))
{
syslog(LOG_INFO, "PAGE %s %s %d %s %s %s", job->printer->name,
job->username ? job->username : "-",
* 'cupsdLogRequest()' - Log an HTTP request in Common Log Format.
*/
-int /* O - 1 on success, 0 on error */
-cupsdLogRequest(cupsd_client_t *con, /* I - Request to log */
- http_status_t code) /* I - Response code */
+int /* O - 1 on success, 0 on error */
+cupsdLogRequest(cupsd_client_t *con, /* I - Request to log */
+ http_status_t code) /* I - Response code */
{
- static const char * const states[] =
- { /* HTTP client states... */
+ static const char * const states[] = /* HTTP client states... */
+ {
"WAITING",
"OPTIONS",
"GET",
* See if we are logging accesses via syslog...
*/
- if (strcmp(AccessLog, "syslog") == 0)
+ if (!strcmp(AccessLog, "syslog"))
{
syslog(LOG_INFO, "REQUEST %s - %s \"%s %s HTTP/%d.%d\" %d %d\n",
con->http.hostname, con->username[0] != '\0' ? con->username : "-",
*
* Contents:
*
- * main() - Main entry for the CUPS scheduler.
- * cupsdClosePipe() - Close a pipe as necessary.
- * cupsdOpenPipe() - Create a pipe which is closed on exec.
+ * main() - Main entry for the CUPS scheduler.
+ * cupsdClosePipe() - Close a pipe as necessary.
+ * cupsdOpenPipe() - Create a pipe which is closed on exec.
* cupsdCatchChildSignals() - Catch SIGCHLD signals...
* cupsdHoldSignals() - Hold child and termination signals.
* cupsdIgnoreChildSignals() - Ignore SIGCHLD signals...
* cupsdReleaseSignals() - Release signals for delivery.
* cupsdSetString() - Set a string value.
* cupsdSetStringf() - Set a formatted string value.
- * parent_handler() - Catch USR1/CHLD signals...
- * process_children() - Process all dead children...
- * sigchld_handler() - Handle 'child' signals from old processes.
- * sighup_handler() - Handle 'hangup' signals to reconfigure the scheduler.
- * sigterm_handler() - Handle 'terminate' signals that stop the scheduler.
- * select_timeout() - Calculate the select timeout value.
- * usage() - Show scheduler usage.
+ * parent_handler() - Catch USR1/CHLD signals...
+ * process_children() - Process all dead children...
+ * sigchld_handler() - Handle 'child' signals from old processes.
+ * sighup_handler() - Handle 'hangup' signals to reconfigure the
+ * scheduler.
+ * sigterm_handler() - Handle 'terminate' signals that stop the
+ * scheduler.
+ * select_timeout() - Calculate the select timeout value.
+ * usage() - Show scheduler usage.
*/
/*
int fds; /* Number of ready descriptors select returns */
fd_set *input, /* Input set for select() */
*output; /* Output set for select() */
- cupsd_client_t *con; /* Current client */
- cupsd_job_t *job; /* Current job */
- cupsd_listener_t *lis; /* Current listener */
+ cupsd_client_t *con; /* Current client */
+ cupsd_job_t *job; /* Current job */
+ cupsd_listener_t *lis; /* Current listener */
time_t activity; /* Activity timer */
time_t browse_time; /* Next browse send time */
time_t senddoc_time; /* Send-Document time */
break;
default : /* Unknown option */
- fprintf(stderr, "cupsd: Unknown option \'%c\' - aborting!\n", *opt);
+ fprintf(stderr, "cupsd: Unknown option \'%c\' - aborting!\n",
+ *opt);
usage();
break;
}
while (!stop_scheduler)
{
#ifdef DEBUG
- cupsdLogMessage(L_DEBUG2, "main: Top of loop, dead_children=%d, NeedReload=%d",
- dead_children, NeedReload);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "main: Top of loop, dead_children=%d, NeedReload=%d",
+ dead_children, NeedReload);
#endif /* DEBUG */
/*
if ((fds = select(MaxFDs, input, output, NULL, &timeout)) < 0)
{
- char s[16384], /* String buffer */
- *sptr; /* Pointer into buffer */
- int slen; /* Length of string buffer */
+ char s[16384], /* String buffer */
+ *sptr; /* Pointer into buffer */
+ int slen; /* Length of string buffer */
/*
* Log all sorts of debug info to help track down the problem.
*/
- cupsdLogMessage(L_EMERG, "select() failed - %s!", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_EMERG, "select() failed - %s!",
+ strerror(errno));
strcpy(s, "InputSet =");
slen = 10;
sptr += strlen(sptr);
}
- cupsdLogMessage(L_EMERG, s);
+ cupsdLogMessage(CUPSD_LOG_EMERG, s);
strcpy(s, "OutputSet =");
slen = 11;
sptr += strlen(sptr);
}
- cupsdLogMessage(L_EMERG, s);
+ cupsdLogMessage(CUPSD_LOG_EMERG, s);
for (i = 0, con = Clients; i < NumClients; i ++, con ++)
- cupsdLogMessage(L_EMERG, "Clients[%d] = %d, file = %d, state = %d",
- i, con->http.fd, con->file, con->http.state);
+ cupsdLogMessage(CUPSD_LOG_EMERG,
+ "Clients[%d] = %d, file = %d, state = %d",
+ i, con->http.fd, con->file, con->http.state);
for (i = 0, lis = Listeners; i < NumListeners; i ++, lis ++)
- cupsdLogMessage(L_EMERG, "Listeners[%d] = %d", i, lis->fd);
+ cupsdLogMessage(CUPSD_LOG_EMERG, "Listeners[%d] = %d", i, lis->fd);
- cupsdLogMessage(L_EMERG, "BrowseSocket = %d", BrowseSocket);
+ cupsdLogMessage(CUPSD_LOG_EMERG, "BrowseSocket = %d", BrowseSocket);
for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
job;
job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
- cupsdLogMessage(L_EMERG, "Jobs[%d] = %d < [%d %d] > [%d %d]",
- job->id, job->status_buffer ? job->status_buffer->fd : -1,
- job->print_pipes[0], job->print_pipes[1],
- job->back_pipes[0], job->back_pipes[1]);
+ cupsdLogMessage(CUPSD_LOG_EMERG, "Jobs[%d] = %d < [%d %d] > [%d %d]",
+ job->id,
+ job->status_buffer ? job->status_buffer->fd : -1,
+ job->print_pipes[0], job->print_pipes[1],
+ job->back_pipes[0], job->back_pipes[1]);
break;
}
con->file_ready = 1;
#ifdef DEBUG
- cupsdLogMessage(L_DEBUG2, "main: Data ready file %d!", con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "main: Data ready file %d!",
+ con->file);
#endif /* DEBUG */
if (!FD_ISSET(con->http.fd, output))
{
- cupsdLogMessage(L_DEBUG2, "main: Removing fd %d from InputSet...", con->file);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "main: Removing fd %d from InputSet...", con->file);
FD_CLR(con->file, InputSet);
}
}
activity = time(NULL) - Timeout;
if (con->http.activity < activity && !con->pipe_pid)
{
- cupsdLogMessage(L_DEBUG, "Closing client %d after %d seconds of inactivity...",
- con->http.fd, Timeout);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "Closing client %d after %d seconds of inactivity...",
+ con->http.fd, Timeout);
cupsdCloseClient(con);
con --;
* Log memory usage every minute...
*/
- if ((time(NULL) - mallinfo_time) >= 60 && LogLevel >= L_DEBUG)
+ if ((time(NULL) - mallinfo_time) >= 60 && LogLevel >= CUPSD_LOG_DEBUG)
{
- struct mallinfo mem; /* Malloc information */
+ struct mallinfo mem; /* Malloc information */
mem = mallinfo();
- cupsdLogMessage(L_DEBUG, "mallinfo: arena = %d, used = %d, free = %d\n",
- mem.arena, mem.usmblks + mem.uordblks,
- mem.fsmblks + mem.fordblks);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "mallinfo: arena = %d, used = %d, free = %d\n",
+ mem.arena, mem.usmblks + mem.uordblks,
+ mem.fsmblks + mem.fordblks);
mallinfo_time = time(NULL);
}
#endif /* HAVE_MALLINFO */
*/
if (stop_scheduler)
- cupsdLogMessage(L_INFO, "Scheduler shutting down normally.");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Scheduler shutting down normally.");
else
- cupsdLogMessage(L_ERROR, "Scheduler shutting down due to program error.");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Scheduler shutting down due to program error.");
/*
* Close all network clients and stop all jobs...
*/
void
-cupsdClearString(char **s) /* O - String value */
+cupsdClearString(char **s) /* O - String value */
{
if (s && *s)
{
void
cupsdSetString(char **s, /* O - New string */
- const char *v) /* I - String value */
+ const char *v) /* I - String value */
{
if (!s || *s == v)
return;
void
cupsdSetStringf(char **s, /* O - New string */
- const char *f, /* I - Printf-style format string */
- ...) /* I - Additional args as needed */
+ const char *f, /* I - Printf-style format string */
+ ...) /* I - Additional args as needed */
{
char v[4096]; /* Formatting string value */
va_list ap; /* Argument pointer */
*/
static void
-parent_handler(int sig) /* I - Signal */
+parent_handler(int sig) /* I - Signal */
{
/*
* Store the signal we got from the OS and return...
static void
process_children(void)
{
- int status; /* Exit status of child */
- int pid; /* Process ID of child */
- cupsd_job_t *job; /* Current job */
- int i; /* Looping var */
+ int status; /* Exit status of child */
+ int pid; /* Process ID of child */
+ cupsd_job_t *job; /* Current job */
+ int i; /* Looping var */
- cupsdLogMessage(L_DEBUG2, "process_children()");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "process_children()");
/*
* Reset the dead_children flag...
if ((pid = wait(&status)) > 0)
#endif /* HAVE_WAITPID */
{
- cupsdLogMessage(L_DEBUG2, "process_children: pid = %d, status = %d\n", pid, status);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "process_children: pid = %d, status = %d\n", pid, status);
/*
* Ignore SIGTERM errors - that comes when a job is cancelled...
if (status)
{
if (WIFEXITED(status))
- cupsdLogMessage(L_ERROR, "PID %d stopped with status %d!", pid,
- WEXITSTATUS(status));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "PID %d stopped with status %d!", pid,
+ WEXITSTATUS(status));
else
- cupsdLogMessage(L_ERROR, "PID %d crashed on signal %d!", pid,
- WTERMSIG(status));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "PID %d crashed on signal %d!", pid,
+ WTERMSIG(status));
- if (LogLevel < L_DEBUG)
- cupsdLogMessage(L_INFO, "Hint: Try setting the LogLevel to \"debug\" to find out more.");
+ if (LogLevel < CUPSD_LOG_DEBUG)
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Hint: Try setting the LogLevel to \"debug\" to find out more.");
}
else
- cupsdLogMessage(L_DEBUG2, "PID %d exited with no errors.", pid);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "PID %d exited with no errors.", pid);
/*
* Delete certificates for CGI processes...
int i; /* Looping var */
long timeout; /* Timeout for select */
time_t now; /* Current time */
- cupsd_client_t *con; /* Client information */
- cupsd_printer_t *p; /* Printer information */
- cupsd_job_t *job; /* Job information */
+ cupsd_client_t *con; /* Client information */
+ cupsd_printer_t *p; /* Printer information */
+ cupsd_job_t *job; /* Job information */
const char *why; /* Debugging aid */
* Log memory usage every minute...
*/
- if (LogLevel >= L_DEBUG && (mallinfo_time + 60) < timeout)
+ if (LogLevel >= CUPSD_LOG_DEBUG && (mallinfo_time + 60) < timeout)
{
timeout = mallinfo_time + 60;
why = "display memory usage";
* Log and return the timeout value...
*/
- cupsdLogMessage(L_DEBUG2, "select_timeout: %ld seconds to %s", timeout, why);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "select_timeout: %ld seconds to %s",
+ timeout, why);
return (timeout);
}
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ * cupsdNetIFFind() - Find a network interface.
+ * cupsdNetIFFree() - Free the current network interface list.
+ * cupsdNetIFUpdate() - Update the network interface list as needed...
+ * getifaddrs() - Get a list of network interfaces on the system.
+ * freeifaddrs() - Free an interface list...
*/
/*
# define ifr_netmask ifr_addr
# endif /* !ifr_netmask */
-struct ifaddrs /**** Interface Structure ****/
+struct ifaddrs /**** Interface Structure ****/
{
struct ifaddrs *ifa_next; /* Next interface in list */
char *ifa_name; /* Name of interface */
/*
- * 'NetIFFind()' - Find a network interface.
+ * 'cupsdNetIFFind()' - Find a network interface.
*/
-cupsd_netif_t * /* O - Network interface data */
-NetIFFind(const char *name) /* I - Name of interface */
+cupsd_netif_t * /* O - Network interface data */
+cupsdNetIFFind(const char *name) /* I - Name of interface */
{
- cupsd_netif_t *temp; /* Current network interface */
+ cupsd_netif_t *temp; /* Current network interface */
/*
*/
for (temp = NetIFList; temp != NULL; temp = temp->next)
- if (strcasecmp(name, temp->name) == 0)
+ if (!strcasecmp(name, temp->name))
return (temp);
return (NULL);
void
cupsdNetIFFree(void)
{
- cupsd_netif_t *next; /* Next interface in list */
+ cupsd_netif_t *next; /* Next interface in list */
/*
void
cupsdNetIFUpdate(void)
{
- int i, /* Looping var */
- match; /* Matching address? */
+ int i, /* Looping var */
+ match; /* Matching address? */
cupsd_listener_t *lis; /* Listen address */
- cupsd_netif_t *temp; /* Current interface */
- struct ifaddrs *addrs, /* Interface address list */
- *addr; /* Current interface address */
+ cupsd_netif_t *temp; /* Current interface */
+ struct ifaddrs *addrs, /* Interface address list */
+ *addr; /* Current interface address */
/*
memcpy(&(temp->mask), addr->ifa_netmask, sizeof(struct sockaddr_in));
if (addr->ifa_dstaddr)
- memcpy(&(temp->broadcast), addr->ifa_dstaddr, sizeof(struct sockaddr_in));
+ memcpy(&(temp->broadcast), addr->ifa_dstaddr,
+ sizeof(struct sockaddr_in));
}
#ifdef AF_INET6
else
memcpy(&(temp->mask), addr->ifa_netmask, sizeof(struct sockaddr_in6));
if (addr->ifa_dstaddr)
- memcpy(&(temp->broadcast), addr->ifa_dstaddr, sizeof(struct sockaddr_in6));
+ memcpy(&(temp->broadcast), addr->ifa_dstaddr,
+ sizeof(struct sockaddr_in6));
}
#endif /* AF_INET6 */
addrs = next;
}
}
-
#endif /* !HAVE_GETIFADDRS */
* Prototypes...
*/
-extern cupsd_netif_t *NetIFFind(const char *name);
+extern cupsd_netif_t *cupsdNetIFFind(const char *name);
extern void cupsdNetIFFree(void);
extern void cupsdNetIFUpdate(void);
* Types and structures...
*/
-typedef struct cupsd_subscription_str /**** Subscription object ****/
+typedef struct cupsd_subscription_s /**** Subscription object ****/
{
- struct cupsd_subscription_str *next; /* Pointer to next subscription */
+ struct cupsd_subscription_s *next; /* Pointer to next subscription */
int id; /* subscription-id */
unsigned mask; /* Event mask */
ipp_t *attrs; /* Subscription attributes */
time_t last_time; /* Time of last notification */
} cupsd_subscription_t;
-typedef struct cupsd_event_str /**** Event object ****/
+typedef struct cupsd_event_s /**** Event object ****/
{
- struct cupsd_event_str *next; /* Pointer to next event */
+ struct cupsd_event_s *next; /* Pointer to next event */
int id; /* event-id */
time_t event_time; /* event-time */
ipp_t *attrs; /* Event attributes */
* 'cupsdAddPolicyOp()' - Add an operation to a policy.
*/
-cupsd_location_t * /* O - New policy operation */
-cupsdAddPolicyOp(cupsd_policy_t *p, /* I - Policy */
- cupsd_location_t *po, /* I - Policy operation to copy */
- ipp_op_t op) /* I - IPP operation code */
+cupsd_location_t * /* O - New policy operation */
+cupsdAddPolicyOp(cupsd_policy_t *p, /* I - Policy */
+ cupsd_location_t *po, /* I - Policy operation to copy */
+ ipp_op_t op) /* I - IPP operation code */
{
- int i; /* Looping var */
- cupsd_location_t *temp, /* New policy operation */
- **tempa; /* New policy operation array */
- char name[1024]; /* Interface name */
+ int i; /* Looping var */
+ cupsd_location_t *temp, /* New policy operation */
+ **tempa; /* New policy operation array */
+ char name[1024]; /* Interface name */
- cupsdLogMessage(L_DEBUG2, "cupsdAddPolicyOp(p=%p, po=%p, op=%x(%s))",
- p, po, op, ippOpString(op));
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddPolicyOp(p=%p, po=%p, op=%x(%s))",
+ p, po, op, ippOpString(op));
if (p == NULL)
return (NULL);
int /* I - 1 if OK, 0 otherwise */
cupsdCheckPolicy(cupsd_policy_t *p, /* I - Policy */
- cupsd_client_t *con, /* I - Client connection */
+ cupsd_client_t *con, /* I - Client connection */
const char *owner) /* I - Owner of object */
{
- cupsd_location_t *po; /* Current policy operation */
+ cupsd_location_t *po; /* Current policy operation */
/*
if (!p || !con)
{
- cupsdLogMessage(L_CRIT, "cupsdCheckPolicy: p=%p, con=%p!", p, con);
+ cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdCheckPolicy: p=%p, con=%p!", p, con);
return (0);
}
if ((po = cupsdFindPolicyOp(p, con->request->request.op.operation_id)) == NULL)
{
- cupsdLogMessage(L_DEBUG2, "cupsdCheckPolicy: No matching operation, returning 0!");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCheckPolicy: No matching operation, returning 0!");
return (0);
}
{
int i, j; /* Looping vars */
cupsd_policy_t **p; /* Current policy */
- cupsd_location_t **po; /* Current policy op */
+ cupsd_location_t **po; /* Current policy op */
if (NumPolicies == 0)
* 'cupsdFindPolicyOp()' - Find a policy operation.
*/
-cupsd_location_t * /* O - Policy operation */
+cupsd_location_t * /* O - Policy operation */
cupsdFindPolicyOp(cupsd_policy_t *p, /* I - Policy */
ipp_op_t op) /* I - IPP operation */
{
- int i; /* Looping var */
- cupsd_location_t **po; /* Current policy operation */
+ int i; /* Looping var */
+ cupsd_location_t **po; /* Current policy operation */
- cupsdLogMessage(L_DEBUG2, "cupsdFindPolicyOp(p=%p, op=%x(%s))\n",
- p, op, ippOpString(op));
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindPolicyOp(p=%p, op=%x(%s))\n",
+ p, op, ippOpString(op));
/*
* Range check...
for (i = p->num_ops, po = p->ops; i > 0; i --, po ++)
if ((*po)->op == op)
{
- cupsdLogMessage(L_DEBUG2, "cupsdFindPolicyOp: Found exact match...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdFindPolicyOp: Found exact match...");
return (*po);
}
for (i = p->num_ops, po = p->ops; i > 0; i --, po ++)
if ((*po)->op == IPP_ANY_OPERATION)
{
- cupsdLogMessage(L_DEBUG2, "cupsdFindPolicyOp: Found wildcard match...");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdFindPolicyOp: Found wildcard match...");
return (*po);
}
- cupsdLogMessage(L_DEBUG2, "cupsdFindPolicyOp: No match found!");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindPolicyOp: No match found!");
return (NULL);
}
typedef struct
{
- char *name; /* Policy name */
- int num_ops; /* Number of operations */
- cupsd_location_t **ops; /* Operations */
+ char *name; /* Policy name */
+ int num_ops; /* Number of operations */
+ cupsd_location_t **ops; /* Operations */
} cupsd_policy_t;
*/
extern cupsd_policy_t *cupsdAddPolicy(const char *policy);
-extern cupsd_location_t *cupsdAddPolicyOp(cupsd_policy_t *p, cupsd_location_t *po,
+extern cupsd_location_t *cupsdAddPolicyOp(cupsd_policy_t *p,
+ cupsd_location_t *po,
ipp_op_t op);
extern int cupsdCheckPolicy(cupsd_policy_t *p, cupsd_client_t *con,
const char *owner);
+++ /dev/null
-/*
- * "$Id$"
- *
- * PPD scanning routines for the Common UNIX Printing System (CUPS).
- *
- * Copyright 1997-2005 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Easy Software Products and are protected by Federal
- * copyright law. Distribution and use rights are outlined in the file
- * "LICENSE.txt" which should have been included with this file. If this
- * file is missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
- *
- * Contents:
- *
- * LoadPPDs() - Load PPD files from the specified directory...
- * buf_read() - Read a buffer of data into memory...
- * check_ppds() - Check to see if we need to regenerate the PPD file
- * list...
- * compare_names() - Compare PPD filenames for sorting.
- * compare_ppds() - Compare PPD file make and model names for sorting.
- * load_ppds() - Load PPD files recursively.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "cupsd.h"
-#include <ctype.h>
-
-
-/*
- * PPD information structures...
- */
-
-typedef struct
-{
- char ppd_make[128], /* Manufacturer */
- ppd_make_and_model[248]; /* Make and model */
- int ppd_size, /* Size in bytes */
- ppd_mtime; /* Modification time */
- char ppd_name[256], /* PPD filename */
- ppd_natural_language[16]; /* Natural language */
-} ppd_rec_t;
-
-typedef struct
-{
- int found; /* 1 if PPD is found */
- ppd_rec_t record; /* ppds.dat record */
-} ppd_info_t;
-
-
-/*
- * Local globals...
- */
-
-static int num_ppds, /* Number of PPD files */
- sorted_ppds, /* Number of sorted PPD files */
- alloc_ppds; /* Number of allocated entries */
-static ppd_info_t *ppds; /* PPD file info */
-static int changed_ppd; /* Did we change the PPD database? */
-
-
-/*
- * Local functions...
- */
-
-static int compare_names(const ppd_info_t *p0, const ppd_info_t *p1);
-static int compare_ppds(const ppd_info_t *p0, const ppd_info_t *p1);
-static void load_ppds(const char *d, const char *p);
-
-
-/*
- * 'LoadPPDs()' - Load PPD files from the specified directory...
- */
-
-void
-LoadPPDs(const char *d) /* I - Directory to scan... */
-{
- int i; /* Looping var */
- ppd_info_t *ppd; /* Current PPD file */
- cups_file_t *fp; /* ppds.dat file */
- struct stat fileinfo; /* ppds.dat information */
- char filename[1024]; /* ppds.dat filename */
-
-
- /*
- * See if we a PPD database file...
- */
-
- num_ppds = 0;
- alloc_ppds = 0;
- ppds = (ppd_info_t *)0;
- changed_ppd = 0;
-
- snprintf(filename, sizeof(filename), "%s/ppds.dat", ServerRoot);
- if (!stat(filename, &fileinfo) &&
- (num_ppds = fileinfo.st_size / sizeof(ppd_rec_t)) > 0)
- {
- /*
- * We have a ppds.dat file, so read it!
- */
-
- alloc_ppds = num_ppds;
-
- if ((ppds = malloc(sizeof(ppd_info_t) * num_ppds)) == NULL)
- {
- cupsdLogMessage(L_ERROR, "LoadPPDs: Unable to allocate memory for %d PPD files!",
- num_ppds);
- num_ppds = 0;
- alloc_ppds = 0;
- }
- else if ((fp = cupsFileOpen(filename, "rb")) != NULL)
- {
- for (i = num_ppds, ppd = ppds; i > 0; i --, ppd ++)
- {
- cupsFileRead(fp, (char *)&(ppd->record), sizeof(ppd_rec_t));
- ppd->found = 0;
- }
-
- cupsFileClose(fp);
-
- cupsdLogMessage(L_INFO, "LoadPPDs: Read \"%s\", %d PPDs...", filename,
- num_ppds);
-
- /*
- * Sort the PPDs by name...
- */
-
- if (num_ppds > 1)
- {
- qsort(ppds, num_ppds, sizeof(ppd_info_t),
- (int (*)(const void *, const void *))compare_names);
- }
- }
- else
- {
- cupsdLogMessage(L_ERROR, "LoadPPDs: Unable to read \"%s\" - %s", filename,
- strerror(errno));
- num_ppds = 0;
- }
- }
-
- /*
- * Load all PPDs in the specified directory and below...
- */
-
- sorted_ppds = num_ppds;
-
- load_ppds(d, "");
-
- /*
- * Cull PPD files that are no longer present...
- */
-
- for (i = num_ppds, ppd = ppds; i > 0; i --, ppd ++)
- if (!ppd->found)
- {
- /*
- * Remove this PPD file from the list...
- */
-
- if (i > 1)
- memmove(ppd, ppd + 1, (i - 1) * sizeof(ppd_info_t));
-
- num_ppds --;
- ppd --;
- }
-
- /*
- * Sort the PPDs by make and model...
- */
-
- if (num_ppds > 1)
- qsort(ppds, num_ppds, sizeof(ppd_info_t),
- (int (*)(const void *, const void *))compare_ppds);
-
- /*
- * Write the new ppds.dat file...
- */
-
- if (changed_ppd)
- {
- if ((fp = cupsFileOpen(filename, "wb")) != NULL)
- {
- for (i = num_ppds, ppd = ppds; i > 0; i --, ppd ++)
- cupsFileWrite(fp, (char *)&(ppd->record), sizeof(ppd_rec_t));
-
- cupsFileClose(fp);
-
- cupsdLogMessage(L_INFO, "LoadPPDs: Wrote \"%s\", %d PPDs...", filename,
- num_ppds);
- }
- else
- cupsdLogMessage(L_ERROR, "LoadPPDs: Unable to write \"%s\" - %s", filename,
- strerror(errno));
- }
- else
- cupsdLogMessage(L_INFO, "LoadPPDs: No new or changed PPDs...");
-
- /*
- * Create the list of PPDs...
- */
-
- PPDs = ippNew();
-
- /*
- * First the raw driver...
- */
-
- ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_NAME,
- "ppd-name", NULL, "raw");
- ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
- "ppd-make", NULL, "Raw");
- ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
- "ppd-make-and-model", NULL, "Raw Queue");
- ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_LANGUAGE,
- "ppd-natural-language", NULL, "en");
-
- /*
- * Then the PPD files...
- */
-
- for (i = num_ppds, ppd = ppds; i > 0; i --, ppd ++)
- {
- ippAddSeparator(PPDs);
-
- ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_NAME,
- "ppd-name", NULL, ppd->record.ppd_name);
- ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
- "ppd-make", NULL, ppd->record.ppd_make);
- ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
- "ppd-make-and-model", NULL, ppd->record.ppd_make_and_model);
- ippAddString(PPDs, IPP_TAG_PRINTER, IPP_TAG_LANGUAGE,
- "ppd-natural-language", NULL, ppd->record.ppd_natural_language);
- }
-
- /*
- * Free the memory used...
- */
-
- if (alloc_ppds)
- {
- free(ppds);
- alloc_ppds = 0;
- }
-}
-
-
-/*
- * 'compare_names()' - Compare PPD filenames for sorting.
- */
-
-static int /* O - Result of comparison */
-compare_names(const ppd_info_t *p0, /* I - First PPD file */
- const ppd_info_t *p1) /* I - Second PPD file */
-{
- return (strcasecmp(p0->record.ppd_name, p1->record.ppd_name));
-}
-
-
-/*
- * 'compare_ppds()' - Compare PPD file make and model names for sorting.
- */
-
-static int /* O - Result of comparison */
-compare_ppds(const ppd_info_t *p0, /* I - First PPD file */
- const ppd_info_t *p1) /* I - Second PPD file */
-{
- const char *s, /* First name */
- *t; /* Second name */
- int diff, /* Difference between digits */
- digits; /* Number of digits */
-
-
- /*
- * First compare manufacturers...
- */
-
- if ((diff = strcasecmp(p0->record.ppd_make, p1->record.ppd_make)) != 0)
- return (diff);
-
- /*
- * Then compare names...
- */
-
- s = p0->record.ppd_make_and_model;
- t = p1->record.ppd_make_and_model;
-
- /*
- * Loop through both nicknames, returning only when a difference is
- * seen. Also, compare whole numbers rather than just characters, too!
- */
-
- while (*s && *t)
- {
- if (isdigit(*s & 255) && isdigit(*t & 255))
- {
- /*
- * Got a number; start by skipping leading 0's...
- */
-
- while (*s == '0')
- s ++;
- while (*t == '0')
- t ++;
-
- /*
- * Skip equal digits...
- */
-
- while (isdigit(*s & 255) && *s == *t)
- {
- s ++;
- t ++;
- }
-
- /*
- * Bounce out if *s and *t aren't both digits...
- */
-
- if (isdigit(*s & 255) && !isdigit(*t & 255))
- return (1);
- else if (!isdigit(*s & 255) && isdigit(*t & 255))
- return (-1);
- else if (!isdigit(*s & 255) || !isdigit(*t & 255))
- continue;
-
- if (*s < *t)
- diff = -1;
- else
- diff = 1;
-
- /*
- * Figure out how many more digits there are...
- */
-
- digits = 0;
- s ++;
- t ++;
-
- while (isdigit(*s & 255))
- {
- digits ++;
- s ++;
- }
-
- while (isdigit(*t & 255))
- {
- digits --;
- t ++;
- }
-
- /*
- * Return if the number or value of the digits is different...
- */
-
- if (digits < 0)
- return (-1);
- else if (digits > 0)
- return (1);
- else if (diff)
- return (diff);
- }
- else if (tolower(*s & 255) < tolower(*t & 255))
- return (-1);
- else if (tolower(*s & 255) > tolower(*t & 255))
- return (1);
- else
- {
- s ++;
- t ++;
- }
- }
-
- /*
- * Return the results of the final comparison...
- */
-
- if (*s)
- return (1);
- else if (*t)
- return (-1);
- else
- return (strcasecmp(p0->record.ppd_natural_language,
- p1->record.ppd_natural_language));
-}
-
-
-/*
- * 'load_ppds()' - Load PPD files recursively.
- */
-
-static void
-load_ppds(const char *d, /* I - Actual directory */
- const char *p) /* I - Virtual path in name */
-{
- int i; /* Looping var */
- cups_file_t *fp; /* Pointer to file */
- DIR *dir; /* Directory pointer */
- struct dirent *dent; /* Directory entry */
- struct stat fileinfo; /* File information */
- char filename[1024], /* Name of PPD or directory */
- line[256], /* Line from backend */
- *ptr, /* Pointer into name */
- name[128], /* Name of PPD file */
- language[64], /* PPD language version */
- country[64], /* Country code */
- manufacturer[256], /* Manufacturer */
- make_model[256], /* Make and Model */
- model_name[256], /* ModelName */
- nick_name[256]; /* NickName */
- ppd_info_t *ppd, /* New PPD file */
- key; /* Search key */
- int new_ppd; /* Is this a new PPD? */
- struct /* LanguageVersion translation table */
- {
- const char *version, /* LanguageVersion string */
- *language; /* Language code */
- } languages[] =
- {
- { "chinese", "cn" },
- { "danish", "da" },
- { "dutch", "nl" },
- { "english", "en" },
- { "finnish", "fi" },
- { "french", "fr" },
- { "german", "de" },
- { "greek", "el" },
- { "italian", "it" },
- { "japanese", "jp" },
- { "norwegian", "no" },
- { "polish", "pl" },
- { "portuguese", "pt" },
- { "russian", "ru" },
- { "slovak", "sk" },
- { "spanish", "es" },
- { "swedish", "sv" },
- { "turkish", "tr" }
- };
-
-
- if ((dir = opendir(d)) == NULL)
- {
- cupsdLogMessage(L_ERROR, "LoadPPDs: Unable to open PPD directory \"%s\": %s",
- d, strerror(errno));
- return;
- }
-
- while ((dent = readdir(dir)) != NULL)
- {
- /*
- * Skip "." and ".."...
- */
-
- if (dent->d_name[0] == '.')
- continue;
-
- /*
- * See if this is a file...
- */
-
- snprintf(filename, sizeof(filename), "%s/%s", d, dent->d_name);
-
- if (p[0])
- snprintf(name, sizeof(name), "%s/%s", p, dent->d_name);
- else
- strlcpy(name, dent->d_name, sizeof(name));
-
- if (stat(filename, &fileinfo))
- continue;
-
- if (S_ISDIR(fileinfo.st_mode))
- {
- /*
- * Do subdirectory...
- */
-
- load_ppds(filename, name);
- continue;
- }
-
- /*
- * See if this file has been scanned before...
- */
-
- if (sorted_ppds > 0)
- {
- strcpy(key.record.ppd_name, name);
-
- ppd = bsearch(&key, ppds, sorted_ppds, sizeof(ppd_info_t),
- (int (*)(const void *, const void *))compare_names);
-
- if (ppd &&
- ppd->record.ppd_size == fileinfo.st_size &&
- ppd->record.ppd_mtime == fileinfo.st_mtime)
- {
- ppd->found = 1;
- continue;
- }
- }
- else
- ppd = NULL;
-
- /*
- * No, file is new/changed, so re-scan it...
- */
-
- if ((fp = cupsFileOpen(filename, "rb")) == NULL)
- continue;
-
- /*
- * Now see if this is a PPD file...
- */
-
- line[0] = '\0';
- cupsFileGets(fp, line, sizeof(line));
-
- if (strncmp(line, "*PPD-Adobe:", 11) != 0)
- {
- /*
- * Nope, close the file and continue...
- */
-
- cupsFileClose(fp);
-
- continue;
- }
-
- /*
- * Now read until we get the NickName field...
- */
-
- model_name[0] = '\0';
- nick_name[0] = '\0';
- manufacturer[0] = '\0';
- strcpy(language, "en");
-
- while (cupsFileGets(fp, line, sizeof(line)) != NULL)
- {
- if (strncmp(line, "*Manufacturer:", 14) == 0)
- sscanf(line, "%*[^\"]\"%255[^\"]", manufacturer);
- else if (strncmp(line, "*ModelName:", 11) == 0)
- sscanf(line, "%*[^\"]\"%127[^\"]", model_name);
- else if (strncmp(line, "*LanguageVersion:", 17) == 0)
- sscanf(line, "%*[^:]:%63s", language);
- else if (strncmp(line, "*NickName:", 10) == 0)
- sscanf(line, "%*[^\"]\"%255[^\"]", nick_name);
- else if (strncmp(line, "*OpenUI", 7) == 0)
- {
- /*
- * Stop early if we have a NickName or ModelName attributes
- * before the first OpenUI...
- */
-
- if (model_name[0] || nick_name[0])
- break;
- }
-
- /*
- * Stop early if we have both the Manufacturer and NickName
- * attributes...
- */
-
- if (manufacturer[0] && nick_name[0])
- break;
- }
-
- /*
- * Close the file...
- */
-
- cupsFileClose(fp);
-
- /*
- * See if we got all of the required info...
- */
-
- if (nick_name[0])
- strcpy(make_model, nick_name);
- else
- strcpy(make_model, model_name);
-
- while (isspace(make_model[0] & 255))
- cups_strcpy(make_model, make_model + 1);
-
- if (!make_model[0])
- continue; /* Nope... */
-
- /*
- * See if we got a manufacturer...
- */
-
- while (isspace(manufacturer[0] & 255))
- cups_strcpy(manufacturer, manufacturer + 1);
-
- if (!manufacturer[0] || strcmp(manufacturer, "ESP") == 0)
- {
- /*
- * Nope, copy the first part of the make and model then...
- */
-
- strlcpy(manufacturer, make_model, sizeof(manufacturer));
-
- /*
- * Truncate at the first space, dash, or slash, or make the
- * manufacturer "Other"...
- */
-
- for (ptr = manufacturer; *ptr; ptr ++)
- if (*ptr == ' ' || *ptr == '-' || *ptr == '/')
- break;
-
- if (*ptr && ptr > manufacturer)
- *ptr = '\0';
- else if (strncasecmp(manufacturer, "agfa", 4) == 0)
- strcpy(manufacturer, "AGFA");
- else if (strncasecmp(manufacturer, "herk", 4) == 0 ||
- strncasecmp(manufacturer, "linotype", 8) == 0)
- strcpy(manufacturer, "LHAG");
- else
- strcpy(manufacturer, "Other");
-
- /*
- * Hack for various vendors...
- */
-
- if (strcasecmp(manufacturer, "XPrint") == 0)
- strcpy(manufacturer, "Xerox");
- else if (strcasecmp(manufacturer, "Eastman") == 0)
- strcpy(manufacturer, "Kodak");
- else if (strcasecmp(manufacturer, "laserwriter") == 0)
- strcpy(manufacturer, "Apple");
- else if (strcasecmp(manufacturer, "colorpoint") == 0)
- strcpy(manufacturer, "Seiko");
- else if (strcasecmp(manufacturer, "fiery") == 0)
- strcpy(manufacturer, "EFI");
- else if (strcasecmp(manufacturer, "ps") == 0 ||
- strcasecmp(manufacturer, "colorpass") == 0)
- strcpy(manufacturer, "Canon");
- else if (strncasecmp(manufacturer, "primera", 7) == 0)
- strcpy(manufacturer, "Fargo");
- else if (strcasecmp(manufacturer, "designjet") == 0)
- strcpy(manufacturer, "HP");
- }
- else if (strncasecmp(manufacturer, "LHAG", 4) == 0 ||
- strncasecmp(manufacturer, "linotype", 8) == 0)
- strcpy(manufacturer, "LHAG");
-
- /*
- * Fix the language as needed...
- */
-
- if ((ptr = strchr(language, '-')) != NULL)
- *ptr++ = '\0';
- else if ((ptr = strchr(language, '_')) != NULL)
- *ptr++ = '\0';
-
- if (ptr)
- {
- /*
- * Setup the country suffix...
- */
-
- country[0] = '_';
- cups_strcpy(country + 1, ptr);
- }
- else
- {
- /*
- * No country suffix...
- */
-
- country[0] = '\0';
- }
-
- for (i = 0; i < (int)(sizeof(languages) / sizeof(languages[0])); i ++)
- if (strcasecmp(languages[i].version, language) == 0)
- break;
-
- if (i < (int)(sizeof(languages) / sizeof(languages[0])))
- {
- /*
- * Found a known language...
- */
-
- snprintf(language, sizeof(language), "%s%s", languages[i].language,
- country);
- }
- else
- {
- /*
- * Unknown language; use "xx"...
- */
-
- strcpy(language, "xx");
- }
-
- /*
- * Add the PPD file...
- */
-
- new_ppd = !ppd;
-
- if (new_ppd)
- {
- /*
- * Allocate memory for the new PPD file...
- */
-
- cupsdLogMessage(L_DEBUG, "LoadPPDs: Adding ppd \"%s\"...", name);
-
- if (num_ppds >= alloc_ppds)
- {
- /*
- * Allocate (more) memory for the PPD files...
- */
-
- if (alloc_ppds == 0)
- ppd = malloc(sizeof(ppd_info_t) * 32);
- else
- ppd = realloc(ppds, sizeof(ppd_info_t) * (alloc_ppds + 32));
-
- if (ppd == NULL)
- {
- cupsdLogMessage(L_ERROR, "load_ppds: Ran out of memory for %d PPD files!",
- alloc_ppds + 32);
- closedir(dir);
- return;
- }
-
- ppds = ppd;
- alloc_ppds += 32;
- }
-
- ppd = ppds + num_ppds;
- num_ppds ++;
- }
- else
- cupsdLogMessage(L_DEBUG, "LoadPPDs: Updating ppd \"%s\"...", name);
-
- /*
- * Zero the PPD record and copy the info over...
- */
-
- memset(ppd, 0, sizeof(ppd_info_t));
-
- ppd->found = 1;
- ppd->record.ppd_mtime = fileinfo.st_mtime;
- ppd->record.ppd_size = fileinfo.st_size;
-
- strlcpy(ppd->record.ppd_name, name,
- sizeof(ppd->record.ppd_name));
- strlcpy(ppd->record.ppd_make, manufacturer,
- sizeof(ppd->record.ppd_make));
- strlcpy(ppd->record.ppd_make_and_model, make_model,
- sizeof(ppd->record.ppd_make_and_model));
- strlcpy(ppd->record.ppd_natural_language, language,
- sizeof(ppd->record.ppd_natural_language));
-
- changed_ppd = 1;
- }
-
- closedir(dir);
-}
-
-
-/*
- * End of "$Id$".
- */
* cupsdSetPrinterAttrs() - Set printer attributes based upon the PPD file.
* cupsdSetPrinterReasons() - Set/update the reasons strings.
* cupsdSetPrinterState() - Update the current state of a printer.
- * SortPrinters() - Sort the printer list when a printer name is
- * changed.
* cupsdStopPrinter() - Stop a printer from printing any jobs...
* cupsdValidateDest() - Validate a printer/class destination.
* cupsdWritePrintcap() - Write a pseudo-printcap file for older
- * applications that need it...
- * cupsdSanitizeURI() - Sanitize a device URI...
- * write_irix_config() - Update the config files used by the IRIX
- * desktop tools.
- * write_irix_state() - Update the status files used by IRIX printing
- * desktop tools.
+ * applications that need it...
+ * cupsdSanitizeURI() - Sanitize a device URI...
+ * compare_printers() - Compare two printers.
+ * write_irix_config() - Update the config files used by the IRIX
+ * desktop tools.
+ * write_irix_state() - Update the status files used by IRIX printing
+ * desktop tools.
*/
/*
* Range check input...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdAddPrinter(\"%s\")", name ? name : "(null)");
-
- if (name == NULL)
- return (NULL);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddPrinter(\"%s\")", name);
/*
* Create a new printer entity...
if ((p = calloc(1, sizeof(cupsd_printer_t))) == NULL)
{
- cupsdLogMessage(L_CRIT, "Unable to allocate memory for printer - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_CRIT, "Unable to allocate memory for printer - %s",
+ strerror(errno));
return (NULL);
}
p->shared = 1;
p->filetype = mimeAddType(MimeDatabase, "printer", name);
- cupsdSetString(&p->cupsd_job_sheets[0], "none");
- cupsdSetString(&p->cupsd_job_sheets[1], "none");
+ cupsdSetString(&p->job_sheets[0], "none");
+ cupsdSetString(&p->job_sheets[1], "none");
cupsdSetString(&p->error_policy, "stop-printer");
cupsdSetString(&p->op_policy, DefaultPolicy);
*/
void
-cupsdAddPrinterFilter(cupsd_printer_t *p, /* I - Printer to add to */
- const char *filter) /* I - Filter to add */
+cupsdAddPrinterFilter(
+ cupsd_printer_t *p, /* I - Printer to add to */
+ const char *filter) /* I - Filter to add */
{
int i; /* Looping var */
char super[MIME_MAX_SUPER], /* Super-type for filter */
if (sscanf(filter, "%15[^/]/%31s%d%1023s", super, type, &cost, program) != 4)
{
- cupsdLogMessage(L_ERROR, "cupsdAddPrinterFilter: Invalid filter string \"%s\"!",
- filter);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdAddPrinterFilter: Invalid filter string \"%s\"!",
+ filter);
return;
}
!strcasecmp((*temptype)->super, super)) &&
(type[0] == '*' || !strcasecmp((*temptype)->type, type)))
{
- cupsdLogMessage(L_DEBUG2, "Adding filter %s/%s %s/%s %d %s",
- (*temptype)->super, (*temptype)->type,
- p->filetype->super, p->filetype->type,
- cost, program);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "Adding filter %s/%s %s/%s %d %s",
+ (*temptype)->super, (*temptype)->type,
+ p->filetype->super, p->filetype->type,
+ cost, program);
mimeAddFilter(MimeDatabase, *temptype, p->filetype, cost, program);
}
}
*/
void
-cupsdAddPrinterHistory(cupsd_printer_t *p) /* I - Printer */
+cupsdAddPrinterHistory(
+ cupsd_printer_t *p) /* I - Printer */
{
ipp_t *history; /* History collection */
*/
void
-cupsdAddPrinterUser(cupsd_printer_t *p, /* I - Printer */
- const char *username) /* I - User */
+cupsdAddPrinterUser(
+ cupsd_printer_t *p, /* I - Printer */
+ const char *username) /* I - User */
{
const char **temp; /* Temporary array pointer */
void
cupsdCreateCommonData(void)
{
- int i; /* Looping var */
- ipp_attribute_t *attr; /* Attribute data */
- cupsd_printer_t *p; /* Current printer */
+ int i; /* Looping var */
+ ipp_attribute_t *attr; /* Attribute data */
+ cupsd_printer_t *p; /* Current printer */
static const int nups[] = /* number-up-supported values */
{ 1, 2, 4, 6, 9, 16 };
static const ipp_orient_t orients[4] =/* orientation-requested-supported values */
"job-sheets-supported", NumBanners + 1, NULL, NULL);
if (attr == NULL)
- cupsdLogMessage(L_EMERG, "cupsdSetPrinterAttrs: Unable to allocate memory for "
- "job-sheets-supported attribute: %s!",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_EMERG,
+ "cupsdSetPrinterAttrs: Unable to allocate memory for "
+ "job-sheets-supported attribute: %s!", strerror(errno));
else if (!Classification || ClassifyOverride)
{
attr->values[0].string.text = strdup("none");
void
cupsdDeleteAllPrinters(void)
{
- cupsd_printer_t *p; /* Pointer to current printer/class */
+ cupsd_printer_t *p; /* Pointer to current printer/class */
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
*/
void
-cupsdDeletePrinter(cupsd_printer_t *p, /* I - Printer to delete */
- int update) /* I - Update printers.conf? */
+cupsdDeletePrinter(
+ cupsd_printer_t *p, /* I - Printer to delete */
+ int update) /* I - Update printers.conf? */
{
int i; /* Looping var */
#ifdef __sgi
cupsdClearString(&p->location);
cupsdClearString(&p->make_model);
cupsdClearString(&p->info);
- cupsdClearString(&p->cupsd_job_sheets[0]);
- cupsdClearString(&p->cupsd_job_sheets[1]);
+ cupsdClearString(&p->job_sheets[0]);
+ cupsdClearString(&p->job_sheets[1]);
cupsdClearString(&p->device_uri);
cupsdClearString(&p->port_monitor);
cupsdClearString(&p->op_policy);
*/
void
-cupsdDeletePrinterFilters(cupsd_printer_t *p) /* I - Printer to remove from */
+cupsdDeletePrinterFilters(
+ cupsd_printer_t *p) /* I - Printer to remove from */
{
int i; /* Looping var */
mime_filter_t *filter; /* MIME filter looping var */
*/
cupsd_printer_t * /* O - Destination in list */
-cupsdFindDest(const char *name) /* I - Name of printer or class to find */
+cupsdFindDest(const char *name) /* I - Name of printer or class to find */
{
cupsd_printer_t key; /* Search key */
*/
void
-cupsdFreePrinterUsers(cupsd_printer_t *p) /* I - Printer */
+cupsdFreePrinterUsers(
+ cupsd_printer_t *p) /* I - Printer */
{
- int i; /* Looping var */
+ int i; /* Looping var */
if (!p || !p->num_users)
void
cupsdLoadAllPrinters(void)
{
- cups_file_t *fp; /* printers.conf file */
- int linenum; /* Current line number */
- char line[1024], /* Line from file */
- *value, /* Pointer to value */
- *valueptr; /* Pointer into value */
- cupsd_printer_t *p; /* Current printer */
+ cups_file_t *fp; /* printers.conf file */
+ int linenum; /* Current line number */
+ char line[1024], /* Line from file */
+ *value, /* Pointer to value */
+ *valueptr; /* Pointer into value */
+ cupsd_printer_t *p; /* Current printer */
/*
snprintf(line, sizeof(line), "%s/printers.conf", ServerRoot);
if ((fp = cupsFileOpen(line, "r")) == NULL)
{
- cupsdLogMessage(L_ERROR, "cupsdLoadAllPrinters: Unable to open %s - %s", line,
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdLoadAllPrinters: Unable to open %s - %s", line,
+ strerror(errno));
return;
}
* Add the printer and a base file type...
*/
- cupsdLogMessage(L_DEBUG, "cupsdLoadAllPrinters: Loading printer %s...", value);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdLoadAllPrinters: Loading printer %s...", value);
p = cupsdAddPrinter(value);
p->accepting = 1;
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
else if (!p)
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
else if (!strcasecmp(line, "Info"))
cupsdSetString(&p->device_uri, value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
cupsdClearString(&p->port_monitor);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
p->state = IPP_PRINTER_STOPPED;
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
p->accepting = 0;
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
p->shared = 0;
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
if (*valueptr)
*valueptr++ = '\0';
- cupsdSetString(&p->cupsd_job_sheets[0], value);
+ cupsdSetString(&p->job_sheets[0], value);
while (isspace(*valueptr & 255))
valueptr ++;
if (*valueptr)
*valueptr++ = '\0';
- cupsdSetString(&p->cupsd_job_sheets[1], value);
+ cupsdSetString(&p->job_sheets[1], value);
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
p->quota_period = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
p->page_limit = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
p->k_limit = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
cupsdSetString(&p->op_policy, value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
cupsdSetString(&p->error_policy, value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of printers.conf.", linenum);
return;
}
}
* Something else we don't understand...
*/
- cupsdLogMessage(L_ERROR, "Unknown configuration directive %s on line %d of printers.conf.",
- line, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown configuration directive %s on line %d of printers.conf.",
+ line, linenum);
}
}
void
cupsdSaveAllPrinters(void)
{
- int i; /* Looping var */
- cups_file_t *fp; /* printers.conf file */
- char temp[1024]; /* Temporary string */
- char backup[1024]; /* printers.conf.O file */
- cupsd_printer_t *printer; /* Current printer class */
- time_t curtime; /* Current time */
- struct tm *curdate; /* Current date */
+ int i; /* Looping var */
+ cups_file_t *fp; /* printers.conf file */
+ char temp[1024]; /* Temporary string */
+ char backup[1024]; /* printers.conf.O file */
+ cupsd_printer_t *printer; /* Current printer class */
+ time_t curtime; /* Current time */
+ struct tm *curdate; /* Current date */
/*
snprintf(backup, sizeof(backup), "%s/printers.conf.O", ServerRoot);
if (rename(temp, backup))
- cupsdLogMessage(L_ERROR, "Unable to backup printers.conf - %s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to backup printers.conf - %s", strerror(errno));
if ((fp = cupsFileOpen(temp, "w")) == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to save printers.conf - %s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to save printers.conf - %s", strerror(errno));
if (rename(backup, temp))
- cupsdLogMessage(L_ERROR, "Unable to restore printers.conf - %s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to restore printers.conf - %s", strerror(errno));
return;
}
else
- cupsdLogMessage(L_INFO, "Saving printers.conf...");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Saving printers.conf...");
/*
* Restrict access to the file...
else
cupsFilePuts(fp, "Shared No\n");
- cupsFilePrintf(fp, "JobSheets %s %s\n", printer->cupsd_job_sheets[0],
- printer->cupsd_job_sheets[1]);
+ cupsFilePrintf(fp, "JobSheets %s %s\n", printer->job_sheets[0],
+ printer->job_sheets[1]);
cupsFilePrintf(fp, "QuotaPeriod %d\n", printer->quota_period);
cupsFilePrintf(fp, "PageLimit %d\n", printer->page_limit);
*/
void
-cupsdSetPrinterAttrs(cupsd_printer_t *p) /* I - Printer to setup */
+cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
{
- char uri[HTTP_MAX_URI]; /* URI for printer */
- char resource[HTTP_MAX_URI]; /* Resource portion of URI */
- int i; /* Looping var */
- char filename[1024]; /* Name of PPD file */
- int num_media; /* Number of media options */
- cupsd_location_t *auth; /* Pointer to authentication element */
- const char *auth_supported; /* Authentication supported */
- cups_ptype_t cupsd_printer_type; /* Printer type data */
- ppd_file_t *ppd; /* PPD file data */
- ppd_option_t *input_slot, /* InputSlot options */
- *media_type, /* MediaType options */
- *page_size, /* PageSize options */
- *output_bin, /* OutputBin options */
- *media_quality; /* EFMediaQualityMode options */
- ppd_attr_t *ppdattr; /* PPD attribute */
- ipp_attribute_t *attr; /* Attribute data */
- ipp_value_t *val; /* Attribute value */
- int num_finishings;
- ipp_finish_t finishings[5]; /* finishings-supported values */
+ char uri[HTTP_MAX_URI];
+ /* URI for printer */
+ char resource[HTTP_MAX_URI];
+ /* Resource portion of URI */
+ int i; /* Looping var */
+ char filename[1024]; /* Name of PPD file */
+ int num_media; /* Number of media options */
+ cupsd_location_t *auth; /* Pointer to authentication element */
+ const char *auth_supported;/* Authentication supported */
+ cups_ptype_t cupsd_printer_type;
+ /* Printer type data */
+ ppd_file_t *ppd; /* PPD file data */
+ ppd_option_t *input_slot, /* InputSlot options */
+ *media_type, /* MediaType options */
+ *page_size, /* PageSize options */
+ *output_bin, /* OutputBin options */
+ *media_quality; /* EFMediaQualityMode options */
+ ppd_attr_t *ppdattr; /* PPD attribute */
+ ipp_attribute_t *attr; /* Attribute data */
+ ipp_value_t *val; /* Attribute value */
+ int num_finishings; /* Number of finishings */
+ ipp_finish_t finishings[5]; /* finishings-supported values */
static const char * const sides[3] = /* sides-supported values */
{
"one",
if (attr != NULL)
{
attr->values[0].string.text = strdup(Classification ?
- Classification : p->cupsd_job_sheets[0]);
+ Classification : p->job_sheets[0]);
attr->values[1].string.text = strdup(Classification ?
- Classification : p->cupsd_job_sheets[1]);
+ Classification : p->job_sheets[1]);
}
}
if (num_media == 0)
{
- cupsdLogMessage(L_CRIT, "cupsdSetPrinterAttrs: The PPD file for printer %s "
+ cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdSetPrinterAttrs: The PPD file for printer %s "
"contains no media options and is therefore "
"invalid!", p->name);
}
pstatus = ppdLastError(&pline);
- cupsdLogMessage(L_ERROR, "PPD file for %s cannot be loaded!", p->name);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "PPD file for %s cannot be loaded!", p->name);
if (pstatus <= PPD_ALLOC_ERROR)
- cupsdLogMessage(L_ERROR, "%s", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s", strerror(errno));
else
- cupsdLogMessage(L_ERROR, "%s on line %d.", ppdErrorString(pstatus),
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s on line %d.", ppdErrorString(pstatus),
pline);
- cupsdLogMessage(L_INFO, "Hint: Run \"cupstestppd %s\" and fix any errors.",
+ cupsdLogMessage(CUPSD_LOG_INFO, "Hint: Run \"cupstestppd %s\" and fix any errors.",
filename);
/*
*/
void
-cupsdSetPrinterReasons(cupsd_printer_t *p, /* I - Printer */
- const char *s) /* I - Reasons strings */
+cupsdSetPrinterReasons(
+ cupsd_printer_t *p, /* I - Printer */
+ const char *s) /* I - Reasons strings */
{
int i; /* Looping var */
const char *sptr; /* Pointer into reasons */
*/
void
-cupsdSetPrinterState(cupsd_printer_t *p, /* I - Printer to change */
- ipp_pstate_t s, /* I - New state */
- int update) /* I - Update printers.conf? */
+cupsdSetPrinterState(
+ cupsd_printer_t *p, /* I - Printer to change */
+ ipp_pstate_t s, /* I - New state */
+ int update) /* I - Update printers.conf? */
{
ipp_pstate_t old_state; /* Old printer state */
*/
void
-cupsdStopPrinter(cupsd_printer_t *p, /* I - Printer to stop */
- int update) /* I - Update printers.conf? */
+cupsdStopPrinter(cupsd_printer_t *p, /* I - Printer to stop */
+ int update)/* I - Update printers.conf? */
{
- cupsd_job_t *job; /* Active print job */
+ cupsd_job_t *job; /* Active print job */
/*
*/
const char * /* O - Printer or class name */
-cupsdValidateDest(const char *hostname, /* I - Host name */
- const char *resource, /* I - Resource name */
- cups_ptype_t *dtype, /* O - Type (printer or class) */
- cupsd_printer_t **printer) /* O - Printer pointer */
+cupsdValidateDest(
+ const char *hostname, /* I - Host name */
+ const char *resource, /* I - Resource name */
+ cups_ptype_t *dtype, /* O - Type (printer or class) */
+ cupsd_printer_t **printer) /* O - Printer pointer */
{
- cupsd_printer_t *p; /* Current printer */
- char localname[1024], /* Localized hostname */
- *lptr, /* Pointer into localized hostname */
- *sptr; /* Pointer into server name */
+ cupsd_printer_t *p; /* Current printer */
+ char localname[1024],/* Localized hostname */
+ *lptr, /* Pointer into localized hostname */
+ *sptr; /* Pointer into server name */
DEBUG_printf(("cupsdValidateDest(\"%s\", \"%s\", %p, %p)\n", hostname, resource,
/*
* 'cupsdWritePrintcap()' - Write a pseudo-printcap file for older applications
- * that need it...
+ * that need it...
*/
void
cupsdWritePrintcap(void)
{
- cups_file_t *fp; /* printcap file */
+ cups_file_t *fp; /* printcap file */
cupsd_printer_t *p; /* Current printer */
cupsFilePuts(fp, "# This file was automatically generated by cupsd(8) from the\n");
cupsFilePrintf(fp, "# %s/printers.conf file. All changes to this file\n",
- ServerRoot);
+ ServerRoot);
cupsFilePuts(fp, "# will be lost.\n");
if (Printers)
*/
static void
-write_irix_config(cupsd_printer_t *p) /* I - Printer to update */
+write_irix_config(cupsd_printer_t *p) /* I - Printer to update */
{
char filename[1024]; /* Interface script filename */
cups_file_t *fp; /* Interface script file */
*/
static void
-write_irix_state(cupsd_printer_t *p) /* I - Printer to update */
+write_irix_state(cupsd_printer_t *p) /* I - Printer to update */
{
char filename[1024]; /* Interface script filename */
cups_file_t *fp; /* Interface script file */
typedef struct
{
- char username[33]; /* User data */
- time_t next_update; /* Next update time */
- int page_count, /* Count of pages */
- k_count; /* Count of kilobytes */
+ char username[33]; /* User data */
+ time_t next_update; /* Next update time */
+ int page_count, /* Count of pages */
+ k_count; /* Count of kilobytes */
} cupsd_quota_t;
int num_reasons; /* Number of printer-state-reasons */
char *reasons[16]; /* printer-state-reasons strings */
time_t state_time; /* Time at this state */
- char *cupsd_job_sheets[2]; /* Banners/job sheets */
+ char *job_sheets[2]; /* Banners/job sheets */
cups_ptype_t type; /* Printer type (color, small, etc.) */
time_t browse_time; /* Last time update was sent/received */
char *device_uri; /* Device URI */
ipp_t *attrs; /* Attributes supported by this printer */
int num_printers, /* Number of printers in class */
last_printer; /* Last printer job was sent to */
- struct cupsd_printer_s **printers; /* Printers in class */
+ struct cupsd_printer_s **printers; /* Printers in class */
int quota_period, /* Period for quotas */
page_limit, /* Maximum number of pages */
k_limit, /* Maximum number of kilobytes */
/* Common printer object attrs */
VAR cups_array_t *Printers VALUE(NULL);
/* Printer list */
-VAR cupsd_printer_t *DefaultPrinter VALUE(NULL);
+VAR cupsd_printer_t *DefaultPrinter VALUE(NULL);
/* Default printer */
VAR char *DefaultPolicy VALUE(NULL);
/* Default policy name */
extern void cupsdAddPrinterFilter(cupsd_printer_t *p, const char *filter);
extern void cupsdAddPrinterHistory(cupsd_printer_t *p);
extern void cupsdAddPrinterUser(cupsd_printer_t *p, const char *username);
-extern cupsd_quota_t *cupsdAddQuota(cupsd_printer_t *p, const char *username);
+extern cupsd_quota_t *cupsdAddQuota(cupsd_printer_t *p, const char *username);
extern void cupsdCreateCommonData(void);
extern void cupsdDeleteAllPrinters(void);
extern void cupsdDeletePrinter(cupsd_printer_t *p, int update);
extern void cupsdDeletePrinterFilters(cupsd_printer_t *p);
extern cupsd_printer_t *cupsdFindDest(const char *name);
extern cupsd_printer_t *cupsdFindPrinter(const char *name);
-extern cupsd_quota_t *cupsdFindQuota(cupsd_printer_t *p, const char *username);
+extern cupsd_quota_t *cupsdFindQuota(cupsd_printer_t *p, const char *username);
extern void cupsdFreePrinterUsers(cupsd_printer_t *p);
extern void cupsdFreeQuotas(cupsd_printer_t *p);
extern void cupsdLoadAllPrinters(void);
extern void cupsdSetPrinterState(cupsd_printer_t *p, ipp_pstate_t s, int update);
#define cupsdStartPrinter(p,u) cupsdSetPrinterState((p), IPP_PRINTER_IDLE, (u))
extern void cupsdStopPrinter(cupsd_printer_t *p, int update);
-extern cupsd_quota_t *cupsdUpdateQuota(cupsd_printer_t *p, const char *username,
- int pages, int k);
+extern cupsd_quota_t *cupsdUpdateQuota(cupsd_printer_t *p, const char *username,
+ int pages, int k);
extern const char *cupsdValidateDest(const char *hostname,
- const char *resource,
- cups_ptype_t *dtype,
- cupsd_printer_t **printer);
+ const char *resource,
+ cups_ptype_t *dtype,
+ cupsd_printer_t **printer);
extern void cupsdWritePrintcap(void);
extern char *cupsdSanitizeURI(const char *uri, char *buffer,
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
- cupsdLogMessage(L_DEBUG2, "cupsdStartProcess(\"%s\", %p, %p, %d, %d, %d)",
- command, argv, envp, infd, outfd, errfd);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartProcess(\"%s\", %p, %p, %d, %d, %d)",
+ command, argv, envp, infd, outfd, errfd);
/*
* Block signals before forking...
* Error - couldn't fork a new process!
*/
- cupsdLogMessage(L_ERROR, "Unable to fork %s - %s.", command, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to fork %s - %s.", command,
+ strerror(errno));
*pid = 0;
}
* cupsdFindQuota() - Find a quota record.
* cupsdFreeQuotas() - Free quotas for a printer.
* cupsdUpdateQuota() - Update quota data for the specified printer and user.
- * compare() - Compare two quota records...
+ * compare() - Compare two quota records...
*/
/*
*/
cupsd_quota_t * /* O - Quota data */
-cupsdAddQuota(cupsd_printer_t *p, /* I - Printer */
- const char *username) /* I - User */
+cupsdAddQuota(cupsd_printer_t *p, /* I - Printer */
+ const char *username)/* I - User */
{
cupsd_quota_t *q; /* New quota data */
*/
cupsd_quota_t * /* O - Quota data */
-cupsdFindQuota(cupsd_printer_t *p, /* I - Printer */
- const char *username) /* I - User */
+cupsdFindQuota(
+ cupsd_printer_t *p, /* I - Printer */
+ const char *username) /* I - User */
{
cupsd_quota_t *q, /* Quota data pointer */
match; /* Search data */
*/
cupsd_quota_t * /* O - Quota data */
-cupsdUpdateQuota(cupsd_printer_t *p, /* I - Printer */
- const char *username, /* I - User */
- int pages, /* I - Number of pages */
- int k) /* I - Number of kilobytes */
+cupsdUpdateQuota(
+ cupsd_printer_t *p, /* I - Printer */
+ const char *username, /* I - User */
+ int pages, /* I - Number of pages */
+ int k) /* I - Number of kilobytes */
{
- cupsd_quota_t *q; /* Quota data */
- cupsd_job_t *job; /* Current job */
- time_t curtime; /* Current time */
- ipp_attribute_t *attr; /* Job attribute */
+ cupsd_quota_t *q; /* Quota data */
+ cupsd_job_t *job; /* Current job */
+ time_t curtime; /* Current time */
+ ipp_attribute_t *attr; /* Job attribute */
if (!p || !username)
if ((q = cupsdFindQuota(p, username)) == NULL)
return (NULL);
- cupsdLogMessage(L_DEBUG, "cupsdUpdateQuota: p=%s username=%s pages=%d k=%d",
- p->name, username, pages, k);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdUpdateQuota: p=%s username=%s pages=%d k=%d",
+ p->name, username, pages, k);
curtime = time(NULL);
*/
static int /* O - Result of comparison */
-compare(const cupsd_quota_t *q1, /* I - First quota record */
- const cupsd_quota_t *q2) /* I - Second quota record */
+compare(const cupsd_quota_t *q1, /* I - First quota record */
+ const cupsd_quota_t *q2) /* I - Second quota record */
{
return (strcasecmp(q1->username, q2->username));
}
cupsdStartServer(void)
{
#ifdef HAVE_LIBSSL
- int i; /* Looping var */
- struct timeval curtime; /* Current time in microseconds */
- unsigned char data[1024]; /* Seed data */
+ int i; /* Looping var */
+ struct timeval curtime; /* Current time in microseconds */
+ unsigned char data[1024]; /* Seed data */
#endif /* HAVE_LIBSSL */
*/
if (cupsdOpenPipe(CGIPipes))
- cupsdLogMessage(L_ERROR, "cupsdStartServer: Unable to create pipes for CGI status!");
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartServer: Unable to create pipes for CGI status!");
else
{
CGIStatusBuffer = cupsdStatBufNew(CGIPipes[0], "[CGI]");
- cupsdLogMessage(L_DEBUG2, "cupsdStartServer: Adding fd %d to InputSet...", CGIPipes[0]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStartServer: Adding fd %d to InputSet...",
+ CGIPipes[0]);
FD_SET(CGIPipes[0], InputSet);
}
}
if (CGIPipes[0] >= 0)
{
- cupsdLogMessage(L_DEBUG2, "cupsdStopServer: Removing fd %d from InputSet...",
- CGIPipes[0]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStopServer: Removing fd %d from InputSet...",
+ CGIPipes[0]);
FD_CLR(CGIPipes[0], InputSet);
* Return an empty line if we are interrupted...
*/
- *loglevel = L_NONE;
+ *loglevel = CUPSD_LOG_NONE;
line[0] = '\0';
return (line);
* End of file...
*/
- *loglevel = L_NONE;
+ *loglevel = CUPSD_LOG_NONE;
line[0] = '\0';
return (NULL);
if (!strncmp(sb->buffer, "EMERG:", 6))
{
- *loglevel = L_EMERG;
+ *loglevel = CUPSD_LOG_EMERG;
message = sb->buffer + 6;
}
else if (!strncmp(sb->buffer, "ALERT:", 6))
{
- *loglevel = L_ALERT;
+ *loglevel = CUPSD_LOG_ALERT;
message = sb->buffer + 6;
}
else if (!strncmp(sb->buffer, "CRIT:", 5))
{
- *loglevel = L_CRIT;
+ *loglevel = CUPSD_LOG_CRIT;
message = sb->buffer + 5;
}
else if (!strncmp(sb->buffer, "ERROR:", 6))
{
- *loglevel = L_ERROR;
+ *loglevel = CUPSD_LOG_ERROR;
message = sb->buffer + 6;
}
else if (!strncmp(sb->buffer, "WARNING:", 8))
{
- *loglevel = L_WARN;
+ *loglevel = CUPSD_LOG_WARN;
message = sb->buffer + 8;
}
else if (!strncmp(sb->buffer, "NOTICE:", 7))
{
- *loglevel = L_NOTICE;
+ *loglevel = CUPSD_LOG_NOTICE;
message = sb->buffer + 7;
}
else if (!strncmp(sb->buffer, "INFO:", 5))
{
- *loglevel = L_INFO;
+ *loglevel = CUPSD_LOG_INFO;
message = sb->buffer + 5;
}
else if (!strncmp(sb->buffer, "DEBUG:", 6))
{
- *loglevel = L_DEBUG;
+ *loglevel = CUPSD_LOG_DEBUG;
message = sb->buffer + 6;
}
else if (!strncmp(sb->buffer, "DEBUG2:", 7))
{
- *loglevel = L_DEBUG2;
+ *loglevel = CUPSD_LOG_DEBUG2;
message = sb->buffer + 7;
}
else if (!strncmp(sb->buffer, "PAGE:", 5))
{
- *loglevel = L_PAGE;
+ *loglevel = CUPSD_LOG_PAGE;
message = sb->buffer + 5;
}
else if (!strncmp(sb->buffer, "STATE:", 6))
{
- *loglevel = L_STATE;
+ *loglevel = CUPSD_LOG_STATE;
message = sb->buffer + 6;
}
else if (!strncmp(sb->buffer, "ATTR:", 5))
{
- *loglevel = L_ATTR;
+ *loglevel = CUPSD_LOG_ATTR;
message = sb->buffer + 5;
}
else
{
- *loglevel = L_DEBUG;
+ *loglevel = CUPSD_LOG_DEBUG;
message = sb->buffer;
}
* Send it to the log file as needed...
*/
- if (*loglevel > L_NONE && (*loglevel != L_INFO || LogLevel == L_DEBUG2))
+ if (*loglevel > CUPSD_LOG_NONE &&
+ (*loglevel != CUPSD_LOG_INFO || LogLevel == CUPSD_LOG_DEBUG2))
{
/*
* General status message; send it to the error_log file...
void
cupsdAddEvent(
cupsd_eventmask_t event, /* I - Event */
- cupsd_printer_t *dest, /* I - Printer associated with event */
- cupsd_job_t *job, /* I - Job associated with event */
+ cupsd_printer_t *dest, /* I - Printer associated with event */
+ cupsd_job_t *job, /* I - Job associated with event */
const char *text, /* I - Notification text */
...) /* I - Additional arguments as needed */
{
if (MaxEvents <= 0)
{
- cupsdLogMessage(L_WARN, "cupsdAddEvent: Discarding %s event since MaxEvents is %d!",
- cupsdEventName(event), MaxEvents);
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "cupsdAddEvent: Discarding %s event since MaxEvents is %d!",
+ cupsdEventName(event), MaxEvents);
return;
}
if (!Events)
{
- cupsdLogMessage(L_CRIT, "Unable to allocate memory for event cache - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_CRIT,
+ "Unable to allocate memory for event cache - %s",
+ strerror(errno));
return;
}
}
if ((temp = (cupsd_event_t *)calloc(1, sizeof(cupsd_event_t))) == NULL)
{
- cupsdLogMessage(L_CRIT, "Unable to allocate memory for event - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_CRIT,
+ "Unable to allocate memory for event - %s",
+ strerror(errno));
return;
}
if (temp)
cupsdSaveAllSubscriptions();
else
- cupsdLogMessage(L_DEBUG, "Discarding unused %s event...",
- cupsdEventName(event));
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Discarding unused %s event...",
+ cupsdEventName(event));
}
cupsd_subscription_t *temp; /* New subscription object */
- cupsdLogMessage(L_DEBUG, "cupsdAddSubscription(mask=%x(%s), dest=%p(%s), job=%p(%d), uri=\"%s\")",
- mask, cupsdEventName(mask), dest, dest ? dest->name : "",
- job, job ? job->id : 0, uri);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdAddSubscription(mask=%x(%s), dest=%p(%s), job=%p(%d), uri=\"%s\")",
+ mask, cupsdEventName(mask), dest, dest ? dest->name : "",
+ job, job ? job->id : 0, uri);
if (!Subscriptions)
{
if (!Subscriptions)
{
- cupsdLogMessage(L_CRIT, "Unable to allocate memory for subscriptions - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_CRIT,
+ "Unable to allocate memory for subscriptions - %s",
+ strerror(errno));
return (NULL);
}
}
if ((temp = calloc(1, sizeof(cupsd_subscription_t))) == NULL)
{
- cupsdLogMessage(L_CRIT, "Unable to allocate memory for subscription object - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_CRIT,
+ "Unable to allocate memory for subscription object - %s",
+ strerror(errno));
return (NULL);
}
void
cupsdExpireSubscriptions(
- cupsd_printer_t *dest, /* I - Printer, if any */
- cupsd_job_t *job) /* I - Job, if any */
+ cupsd_printer_t *dest, /* I - Printer, if any */
+ cupsd_job_t *job) /* I - Job, if any */
{
int i; /* Looping var */
cupsd_subscription_t *sub; /* Current subscription */
(dest && sub->dest == dest) ||
(job && sub->job == job))
{
- cupsdLogMessage(L_INFO, "Subscription %d has expired...", sub->id);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Subscription %d has expired...", sub->id);
cupsdDeleteSubscription(sub, 0);
snprintf(line, sizeof(line), "%s/subscriptions.conf", ServerRoot);
if ((fp = cupsFileOpen(line, "r")) == NULL)
{
- cupsdLogMessage(L_ERROR, "LoadAllSubscriptions: Unable to open %s - %s", line,
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "LoadAllSubscriptions: Unable to open %s - %s", line,
+ strerror(errno));
return;
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
{
if (!sub)
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
else if (!sub)
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
else if (!strcasecmp(name, "Events"))
if (!value)
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
if ((sub->mask |= cupsdEventValue(value)) == CUPSD_EVENT_NONE)
{
- cupsdLogMessage(L_ERROR, "Unknown event name \'%s\' on line %d of subscriptions.conf.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown event name \'%s\' on line %d of subscriptions.conf.",
+ value, linenum);
return;
}
cupsdSetString(&sub->owner, value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
cupsdSetString(&sub->recipient, value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
{
if ((sub->job = cupsdFindJob(atoi(value))) == NULL)
{
- cupsdLogMessage(L_ERROR, "Job %s not found on line %d of subscriptions.conf.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Job %s not found on line %d of subscriptions.conf.",
+ value, linenum);
delete_sub = 1;
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
{
if ((sub->dest = cupsdFindDest(value)) == NULL)
{
- cupsdLogMessage(L_ERROR, "Printer \'%s\' not found on line %d of subscriptions.conf.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Printer \'%s\' not found on line %d of subscriptions.conf.",
+ value, linenum);
delete_sub = 1;
}
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
if (*valueptr)
{
- cupsdLogMessage(L_ERROR, "Bad UserData \'%s\' on line %d of subscriptions.conf.",
- value, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad UserData \'%s\' on line %d of subscriptions.conf.",
+ value, linenum);
}
else
sub->user_data_len = i;
}
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
sub->lease = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
sub->interval = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
sub->expire = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
sub->next_event_id = sub->first_event_id = atoi(value);
else
{
- cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.",
- linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Syntax error on line %d of subscriptions.conf.",
+ linenum);
return;
}
}
* Something else we don't understand...
*/
- cupsdLogMessage(L_ERROR, "Unknown configuration directive %s on line %d of subscriptions.conf.",
- name, linenum);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unknown configuration directive %s on line %d of subscriptions.conf.",
+ name, linenum);
}
}
snprintf(backup, sizeof(backup), "%s/subscriptions.conf.O", ServerRoot);
if (rename(temp, backup))
- cupsdLogMessage(L_ERROR, "Unable to backup subscriptions.conf - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to backup subscriptions.conf - %s",
+ strerror(errno));
if ((fp = cupsFileOpen(temp, "w")) == NULL)
{
- cupsdLogMessage(L_ERROR, "Unable to save subscriptions.conf - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to save subscriptions.conf - %s",
+ strerror(errno));
if (rename(backup, temp))
- cupsdLogMessage(L_ERROR, "Unable to restore subscriptions.conf - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Unable to restore subscriptions.conf - %s",
+ strerror(errno));
return;
}
else
- cupsdLogMessage(L_INFO, "Saving subscriptions.conf...");
+ cupsdLogMessage(CUPSD_LOG_INFO, "Saving subscriptions.conf...");
/*
* Restrict access to the file...
cupsd_subscription_t *sub, /* I - Subscription object */
cupsd_event_t *event) /* I - Event to send */
{
- cupsdLogMessage(L_DEBUG, "cupsdSendNotification(sub=%p(%d), event=%p(%s))\n",
- sub, sub->id, event, cupsdEventName(event->event));
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "cupsdSendNotification(sub=%p(%d), event=%p(%s))\n",
+ sub, sub->id, event, cupsdEventName(event->event));
/*
* Allocate the events array as needed...
if (!sub->events)
{
- cupsdLogMessage(L_CRIT, "Unable to allocate memory for subscription #%d!",
- sub->id);
+ cupsdLogMessage(CUPSD_LOG_CRIT,
+ "Unable to allocate memory for subscription #%d!",
+ sub->id);
return;
}
}
* Close the status pipes...
*/
- cupsdLogMessage(L_DEBUG2, "cupsdStopAllNotifiers: Removing fd %d from InputSet...",
- NotifierPipes[0]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdStopAllNotifiers: Removing fd %d from InputSet...",
+ NotifierPipes[0]);
FD_CLR(NotifierPipes[0], InputSet);
cupsdStatBufDelete(NotifierStatusBuffer);
* Fatal error on pipe - should never happen!
*/
- cupsdLogMessage(L_CRIT, "cupsdUpdateNotifierStatus: error reading from notifier error pipe - %s",
- strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_CRIT,
+ "cupsdUpdateNotifierStatus: error reading from notifier error pipe - %s",
+ strerror(errno));
}
}
typedef struct cupsd_event_s /**** Event structure ****/
{
- cupsd_eventmask_t event; /* Event */
- time_t time; /* Time of event */
- ipp_t *attrs; /* Notification message */
- cupsd_printer_t *dest; /* Associated printer, if any */
- cupsd_job_t *job; /* Associated job, if any */
+ cupsd_eventmask_t event; /* Event */
+ time_t time; /* Time of event */
+ ipp_t *attrs; /* Notification message */
+ cupsd_printer_t *dest; /* Associated printer, if any */
+ cupsd_job_t *job; /* Associated job, if any */
} cupsd_event_t;
typedef struct cupsd_subscription_s /**** Subscription structure ****/
{
- int id; /* subscription-id */
- unsigned mask; /* Event mask */
- char *owner; /* notify-subscriber-user-name */
- char *recipient; /* notify-recipient-uri, if applicable */
- unsigned char user_data[64]; /* notify-user-data */
- int user_data_len; /* Length of notify-user-data */
- int lease; /* notify-lease-time */
- int interval; /* notify-interval */
- cupsd_printer_t *dest; /* notify-printer-uri, if any */
- cupsd_job_t *job; /* notify-job-id, if any */
- int pid; /* Process ID of notifier */
- int pipe; /* Pipe to notifier */
- int status; /* Exit status of notifier */
- time_t last; /* Time of last notification */
- time_t expire; /* Lease expiration time */
- int first_event_id, /* First event-id in cache */
- next_event_id, /* Next event-id to use */
- num_events; /* Number of cached events */
- cupsd_event_t **events; /* Cached events */
+ int id; /* subscription-id */
+ unsigned mask; /* Event mask */
+ char *owner; /* notify-subscriber-user-name */
+ char *recipient; /* notify-recipient-uri, if applicable */
+ unsigned char user_data[64]; /* notify-user-data */
+ int user_data_len; /* Length of notify-user-data */
+ int lease; /* notify-lease-time */
+ int interval; /* notify-interval */
+ cupsd_printer_t *dest; /* notify-printer-uri, if any */
+ cupsd_job_t *job; /* notify-job-id, if any */
+ int pid; /* Process ID of notifier */
+ int pipe; /* Pipe to notifier */
+ int status; /* Exit status of notifier */
+ time_t last; /* Time of last notification */
+ time_t expire; /* Lease expiration time */
+ int first_event_id, /* First event-id in cache */
+ next_event_id, /* Next event-id to use */
+ num_events; /* Number of cached events */
+ cupsd_event_t **events; /* Cached events */
} cupsd_subscription_t;
extern cupsd_subscription_t *
cupsdFindSubscription(int id);
-extern void cupsdExpireSubscriptions(cupsd_printer_t *dest, cupsd_job_t *job);
+extern void cupsdExpireSubscriptions(cupsd_printer_t *dest,
+ cupsd_job_t *job);
extern void cupsdLoadAllSubscriptions(void);
extern void cupsdSaveAllSubscriptions(void);
extern void cupsdSendNotification(cupsd_subscription_t *sub,
}
-
/*
* End of "$Id$".
*/
*
* Contents:
*
+ * cupsdCompareNames() - Compare two names.
* cupsdSendIPPGroup() - Send a group tag.
* cupsdSendIPPHeader() - Send the IPP response header.
* cupsdSendIPPInteger() - Send an integer attribute.