From: mike Date: Wed, 28 Sep 2005 15:10:59 +0000 (+0000) Subject: Rename all types and functions to use cupsd prefix. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=589eb420b1ac13ae0cfe0260a60c657029b1f6ce;p=thirdparty%2Fcups.git Rename all types and functions to use cupsd prefix. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@4717 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/scheduler/auth.c b/scheduler/auth.c index 3301e781a..a83b4a937 100644 --- a/scheduler/auth.c +++ b/scheduler/auth.c @@ -23,25 +23,25 @@ * * Contents: * - * AddLocation() - Add a location for authorization. - * AddName() - Add a name to a location... - * AllowHost() - Add a host name that is allowed to access the + * 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. - * AllowIP() - Add an IP address or network that is allowed to + * cupsdAllowIP() - Add an IP address or network that is allowed to * access the location. - * CheckAuth() - Check authorization masks. + * cupsdCheckAuth() - Check authorization masks. * cupsdCheckGroup() - Check for a user's group membership. - * CopyLocation() - Make a copy of a location... - * DeleteAllLocations() - Free all memory used for location authorization. + * cupsdCopyLocation() - Make a copy of a location... + * cupsdDeleteAllLocations() - Free all memory used for location authorization. * cupsdDeleteLocation() - Free all memory used by a location. - * DenyHost() - Add a host name that is not allowed to access the + * cupsdDenyHost() - Add a host name that is not allowed to access the * location. - * DenyIP() - Add an IP address or network that is not allowed + * cupsdDenyIP() - Add an IP address or network that is not allowed * to access the location. - * FindBest() - Find the location entry that best matches the + * cupsdFindBest() - Find the location entry that best matches the * resource. - * FindLocation() - Find the named location. - * GetMD5Passwd() - Get an MD5 password. + * 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. @@ -79,8 +79,8 @@ * Local functions... */ -static authmask_t *add_allow(location_t *loc); -static authmask_t *add_deny(location_t *loc); +static cupsd_authmask_t *add_allow(cupsd_location_t *loc); +static cupsd_authmask_t *add_deny(cupsd_location_t *loc); #if !HAVE_LIBPAM static char *cups_crypt(const char *pw, const char *salt); #endif /* !HAVE_LIBPAM */ @@ -97,18 +97,18 @@ static void to64(char *s, unsigned long v, int n); */ #if defined(__hpux) && defined(HAVE_LIBPAM) -static client_t *auth_client; /* Current client being authenticated */ +static cupsd_client_t *auth_client; /* Current client being authenticated */ #endif /* __hpux && HAVE_LIBPAM */ /* - * 'AddLocation()' - Add a location for authorization. + * 'cupsdAddLocation()' - Add a location for authorization. */ -location_t * /* O - Pointer to new location record */ -AddLocation(const char *location) /* I - Location path */ +cupsd_location_t * /* O - Pointer to new location record */ +cupsdAddLocation(const char *location) /* I - Location path */ { - location_t *temp; /* New location */ + cupsd_location_t *temp; /* New location */ /* @@ -116,9 +116,9 @@ AddLocation(const char *location) /* I - Location path */ */ if (NumLocations == 0) - temp = malloc(sizeof(location_t)); + temp = malloc(sizeof(cupsd_location_t)); else - temp = realloc(Locations, sizeof(location_t) * (NumLocations + 1)); + temp = realloc(Locations, sizeof(cupsd_location_t) * (NumLocations + 1)); if (temp == NULL) return (NULL); @@ -131,11 +131,11 @@ AddLocation(const char *location) /* I - Location path */ * Initialize the record and copy the name over... */ - memset(temp, 0, sizeof(location_t)); + memset(temp, 0, sizeof(cupsd_location_t)); strlcpy(temp->location, location, sizeof(temp->location)); temp->length = strlen(temp->location); - LogMessage(L_DEBUG, "AddLocation: added location \'%s\'", location); + cupsdLogMessage(L_DEBUG, "cupsdAddLocation: added location \'%s\'", location); /* * Return the new record... @@ -146,17 +146,17 @@ AddLocation(const char *location) /* I - Location path */ /* - * 'AddName()' - Add a name to a location... + * 'cupsdAddName()' - Add a name to a location... */ void -AddName(location_t *loc, /* I - Location to add to */ +cupsdAddName(cupsd_location_t *loc, /* I - Location to add to */ char *name) /* I - Name to add */ { char **temp; /* Pointer to names array */ - LogMessage(L_DEBUG2, "AddName(loc=%p, name=\"%s\")", loc, name); + cupsdLogMessage(L_DEBUG2, "cupsdAddName(loc=%p, name=\"%s\")", loc, name); if (loc->num_names == 0) temp = malloc(sizeof(char *)); @@ -165,7 +165,7 @@ AddName(location_t *loc, /* I - Location to add to */ if (temp == NULL) { - LogMessage(L_ERROR, "Unable to add name to location %s: %s", loc->location, + cupsdLogMessage(L_ERROR, "Unable to add name to location %s: %s", loc->location, strerror(errno)); return; } @@ -174,7 +174,7 @@ AddName(location_t *loc, /* I - Location to add to */ if ((temp[loc->num_names] = strdup(name)) == NULL) { - LogMessage(L_ERROR, "Unable to duplicate name for location %s: %s", + cupsdLogMessage(L_ERROR, "Unable to duplicate name for location %s: %s", loc->location, strerror(errno)); return; } @@ -184,19 +184,19 @@ AddName(location_t *loc, /* I - Location to add to */ /* - * 'AllowHost()' - Add a host name that is allowed to access the location. + * 'cupsdAllowHost()' - Add a host name that is allowed to access the location. */ void -AllowHost(location_t *loc, /* I - Location to add to */ +cupsdAllowHost(cupsd_location_t *loc, /* I - Location to add to */ char *name) /* I - Name of host or domain to add */ { - authmask_t *temp; /* New host/domain mask */ + cupsd_authmask_t *temp; /* New host/domain mask */ char ifname[32], /* Interface name */ *ifptr; /* Pointer to end of name */ - LogMessage(L_DEBUG2, "AllowHost(loc=%p(%s), name=\"%s\")", loc, + cupsdLogMessage(L_DEBUG2, "cupsdAllowHost(loc=%p(%s), name=\"%s\")", loc, loc->location, name); if ((temp = add_allow(loc)) == NULL) @@ -246,19 +246,19 @@ AllowHost(location_t *loc, /* I - Location to add to */ /* - * 'AllowIP()' - Add an IP address or network that is allowed to access the + * 'cupsdAllowIP()' - Add an IP address or network that is allowed to access the * location. */ void -AllowIP(location_t *loc, /* I - Location to add to */ +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 */ { - authmask_t *temp; /* New host/domain mask */ + cupsd_authmask_t *temp; /* New host/domain mask */ - LogMessage(L_DEBUG2, "AllowIP(loc=%p(%s), address=%x:%x:%x:%x, netmask=%x:%x:%x:%x)", + 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]); @@ -273,18 +273,18 @@ AllowIP(location_t *loc, /* I - Location to add to */ /* - * 'CheckAuth()' - Check authorization masks. + * 'cupsdCheckAuth()' - Check authorization masks. */ int /* O - 1 if mask matches, 0 otherwise */ -CheckAuth(unsigned ip[4], /* I - Client address */ +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 */ - authmask_t *masks) /* I - Masks */ + cupsd_authmask_t *masks) /* I - Masks */ { int i; /* Looping var */ - cups_netif_t *iface; /* Network interface */ + cupsd_netif_t *iface; /* Network interface */ unsigned netip4; /* IPv4 network address */ #ifdef AF_INET6 unsigned netip6[4]; /* IPv6 network address */ @@ -314,7 +314,7 @@ CheckAuth(unsigned ip[4], /* I - Client address */ * Check against all local interfaces... */ - NetIFUpdate(); + cupsdNetIFUpdate(); for (iface = NetIFList; iface != NULL; iface = iface->next) { @@ -451,7 +451,7 @@ cupsdCheckGroup( char junk[33]; /* MD5 password (not used) */ - LogMessage(L_DEBUG2, "cupsdCheckGroup(username=\"%s\", user=%p, groupname=\"%s\")\n", + cupsdLogMessage(L_DEBUG2, "cupsdCheckGroup(username=\"%s\", user=%p, groupname=\"%s\")\n", username, user, groupname); /* @@ -493,7 +493,7 @@ cupsdCheckGroup( * file... */ - if (GetMD5Passwd(username, groupname, junk) != NULL) + if (cupsdGetMD5Passwd(username, groupname, junk) != NULL) return (1); /* @@ -505,15 +505,15 @@ cupsdCheckGroup( /* - * 'CopyLocation()' - Make a copy of a location... + * 'cupsdCopyLocation()' - Make a copy of a location... */ -location_t * /* O - New location */ -CopyLocation(location_t **loc) /* IO - Original location */ +cupsd_location_t * /* O - New location */ +cupsdCopyLocation(cupsd_location_t **loc) /* IO - Original location */ { int i; /* Looping var */ int locindex; /* Index into Locations array */ - location_t *temp; /* New location */ + cupsd_location_t *temp; /* New location */ char location[HTTP_MAX_URI]; /* Location of resource */ @@ -525,13 +525,13 @@ CopyLocation(location_t **loc) /* IO - Original location */ locindex = *loc - Locations; /* - * Use a local copy of location because AddLocation may cause + * Use a local copy of location because cupsdAddLocation may cause * this memory to be moved... */ strlcpy(location, (*loc)->location, sizeof(location)); - if ((temp = AddLocation(location)) == NULL) + if ((temp = cupsdAddLocation(location)) == NULL) return (NULL); *loc = Locations + locindex; @@ -555,7 +555,7 @@ CopyLocation(location_t **loc) /* IO - Original location */ if ((temp->names = calloc(temp->num_names, sizeof(char *))) == NULL) { - LogMessage(L_ERROR, "CopyLocation: Unable to allocate memory for %d names: %s", + cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to allocate memory for %d names: %s", temp->num_names, strerror(errno)); NumLocations --; return (NULL); @@ -564,7 +564,7 @@ CopyLocation(location_t **loc) /* IO - Original location */ for (i = 0; i < temp->num_names; i ++) if ((temp->names[i] = strdup((*loc)->names[i])) == NULL) { - LogMessage(L_ERROR, "CopyLocation: Unable to copy name \"%s\": %s", + cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to copy name \"%s\": %s", (*loc)->names[i], strerror(errno)); NumLocations --; @@ -578,9 +578,9 @@ CopyLocation(location_t **loc) /* IO - Original location */ * Copy allow rules... */ - if ((temp->allow = calloc(temp->num_allow, sizeof(authmask_t))) == NULL) + if ((temp->allow = calloc(temp->num_allow, sizeof(cupsd_authmask_t))) == NULL) { - LogMessage(L_ERROR, "CopyLocation: Unable to allocate memory for %d allow rules: %s", + cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to allocate memory for %d allow rules: %s", temp->num_allow, strerror(errno)); NumLocations --; return (NULL); @@ -595,7 +595,7 @@ CopyLocation(location_t **loc) /* IO - Original location */ if (temp->allow[i].mask.name.name == NULL) { - LogMessage(L_ERROR, "CopyLocation: Unable to copy allow name \"%s\": %s", + cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to copy allow name \"%s\": %s", (*loc)->allow[i].mask.name.name, strerror(errno)); NumLocations --; return (NULL); @@ -603,7 +603,7 @@ CopyLocation(location_t **loc) /* IO - Original location */ break; case AUTH_IP : memcpy(&(temp->allow[i].mask.ip), &((*loc)->allow[i].mask.ip), - sizeof(ipmask_t)); + sizeof(cupsd_ipmask_t)); break; } } @@ -614,9 +614,9 @@ CopyLocation(location_t **loc) /* IO - Original location */ * Copy deny rules... */ - if ((temp->deny = calloc(temp->num_deny, sizeof(authmask_t))) == NULL) + if ((temp->deny = calloc(temp->num_deny, sizeof(cupsd_authmask_t))) == NULL) { - LogMessage(L_ERROR, "CopyLocation: Unable to allocate memory for %d deny rules: %s", + cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to allocate memory for %d deny rules: %s", temp->num_deny, strerror(errno)); NumLocations --; return (NULL); @@ -631,7 +631,7 @@ CopyLocation(location_t **loc) /* IO - Original location */ if (temp->deny[i].mask.name.name == NULL) { - LogMessage(L_ERROR, "CopyLocation: Unable to copy deny name \"%s\": %s", + cupsdLogMessage(L_ERROR, "cupsdCopyLocation: Unable to copy deny name \"%s\": %s", (*loc)->deny[i].mask.name.name, strerror(errno)); NumLocations --; return (NULL); @@ -639,7 +639,7 @@ CopyLocation(location_t **loc) /* IO - Original location */ break; case AUTH_IP : memcpy(&(temp->deny[i].mask.ip), &((*loc)->deny[i].mask.ip), - sizeof(ipmask_t)); + sizeof(cupsd_ipmask_t)); break; } } @@ -649,14 +649,14 @@ CopyLocation(location_t **loc) /* IO - Original location */ /* - * 'DeleteAllLocations()' - Free all memory used for location authorization. + * 'cupsdDeleteAllLocations()' - Free all memory used for location authorization. */ void -DeleteAllLocations(void) +cupsdDeleteAllLocations(void) { int i; /* Looping var */ - location_t *loc; /* Current location */ + cupsd_location_t *loc; /* Current location */ /* @@ -683,10 +683,10 @@ DeleteAllLocations(void) */ void -cupsdDeleteLocation(location_t *loc) /* I - Location to delete */ +cupsdDeleteLocation(cupsd_location_t *loc) /* I - Location to delete */ { int i; /* Looping var */ - authmask_t *mask; /* Current mask */ + cupsd_authmask_t *mask; /* Current mask */ for (i = loc->num_names - 1; i >= 0; i --) @@ -712,19 +712,19 @@ cupsdDeleteLocation(location_t *loc) /* I - Location to delete */ /* - * 'DenyHost()' - 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 -DenyHost(location_t *loc, /* I - Location to add to */ +cupsdDenyHost(cupsd_location_t *loc, /* I - Location to add to */ char *name) /* I - Name of host or domain to add */ { - authmask_t *temp; /* New host/domain mask */ + cupsd_authmask_t *temp; /* New host/domain mask */ char ifname[32], /* Interface name */ *ifptr; /* Pointer to end of name */ - LogMessage(L_DEBUG2, "DenyHost(loc=%p(%s), name=\"%s\")", loc, + cupsdLogMessage(L_DEBUG2, "cupsdDenyHost(loc=%p(%s), name=\"%s\")", loc, loc->location, name); if ((temp = add_deny(loc)) == NULL) @@ -774,19 +774,19 @@ DenyHost(location_t *loc, /* I - Location to add to */ /* - * 'DenyIP()' - Add an IP address or network that is not allowed to access + * 'cupsdDenyIP()' - Add an IP address or network that is not allowed to access * the location. */ void -DenyIP(location_t *loc, /* I - Location to add to */ +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 */ { - authmask_t *temp; /* New host/domain mask */ + cupsd_authmask_t *temp; /* New host/domain mask */ - LogMessage(L_DEBUG, "DenyIP(loc=%p(%s), address=%x:%x:%x:%x, netmask=%x:%x:%x:%x)", + 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]); @@ -801,17 +801,17 @@ DenyIP(location_t *loc, /* I - Location to add to */ /* - * 'FindBest()' - Find the location entry that best matches the resource. + * 'cupsdFindBest()' - Find the location entry that best matches the resource. */ -location_t * /* O - Location that matches */ -FindBest(const char *path, /* I - Resource path */ +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 */ - location_t *loc, /* Current location */ + cupsd_location_t *loc, /* Current location */ *best; /* Best match for location so far */ int bestlen; /* Length of best match */ int limit; /* Limit field */ @@ -855,7 +855,7 @@ FindBest(const char *path, /* I - Resource path */ *uriptr = '\0'; } - LogMessage(L_DEBUG2, "FindBest: uri = \"%s\"...", uri); + cupsdLogMessage(L_DEBUG2, "cupsdFindBest: uri = \"%s\"...", uri); /* * Loop through the list of locations to find a match... @@ -867,7 +867,7 @@ FindBest(const char *path, /* I - Resource path */ for (i = NumLocations, loc = Locations; i > 0; i --, loc ++) { - LogMessage(L_DEBUG2, "FindBest: Location %s Limit %x", + cupsdLogMessage(L_DEBUG2, "cupsdFindBest: Location %s Limit %x", loc->location, loc->limit); if (!strncmp(uri, "/printers/", 10) || !strncmp(uri, "/classes/", 9)) @@ -906,18 +906,18 @@ FindBest(const char *path, /* I - Resource path */ * Return the match, if any... */ - LogMessage(L_DEBUG2, "FindBest: best = %s", best ? best->location : "NONE"); + cupsdLogMessage(L_DEBUG2, "cupsdFindBest: best = %s", best ? best->location : "NONE"); return (best); } /* - * 'FindLocation()' - Find the named location. + * 'cupsdFindLocation()' - Find the named location. */ -location_t * /* O - Location that matches */ -FindLocation(const char *location) /* I - Connection */ +cupsd_location_t * /* O - Location that matches */ +cupsdFindLocation(const char *location) /* I - Connection */ { int i; /* Looping var */ @@ -935,11 +935,11 @@ FindLocation(const char *location) /* I - Connection */ /* - * 'GetMD5Passwd()' - Get an MD5 password. + * 'cupsdGetMD5Passwd()' - Get an MD5 password. */ char * /* O - MD5 password string */ -GetMD5Passwd(const char *username, /* I - Username */ +cupsdGetMD5Passwd(const char *username, /* I - Username */ const char *group, /* I - Group */ char passwd[33]) /* O - MD5 password string */ { @@ -950,13 +950,13 @@ GetMD5Passwd(const char *username, /* I - Username */ tempgroup[33]; /* Group from file */ - LogMessage(L_DEBUG2, "GetMD5Passwd(username=\"%s\", group=\"%s\", passwd=%p)", + cupsdLogMessage(L_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) { - LogMessage(L_ERROR, "Unable to open %s - %s", filename, strerror(errno)); + cupsdLogMessage(L_ERROR, "Unable to open %s - %s", filename, strerror(errno)); return (NULL); } @@ -964,7 +964,7 @@ GetMD5Passwd(const char *username, /* I - Username */ { if (sscanf(line, "%32[^:]:%32[^:]:%32s", tempuser, tempgroup, passwd) != 3) { - LogMessage(L_ERROR, "Bad MD5 password line: %s", line); + cupsdLogMessage(L_ERROR, "Bad MD5 password line: %s", line); continue; } @@ -975,7 +975,7 @@ GetMD5Passwd(const char *username, /* I - Username */ * Found the password entry! */ - LogMessage(L_DEBUG2, "Found MD5 user %s, group %s...", username, + cupsdLogMessage(L_DEBUG2, "Found MD5 user %s, group %s...", username, tempgroup); cupsFileClose(fp); @@ -997,13 +997,13 @@ GetMD5Passwd(const char *username, /* I - Username */ */ http_status_t /* O - HTTP_OK if authorized or error code */ -cupsdIsAuthorized(client_t *con, /* I - Connection */ +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 */ - location_t *best; /* Best match for location so far */ + 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 */ @@ -1055,7 +1055,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ }; - LogMessage(L_DEBUG2, "cupsdIsAuthorized: con->uri=\"%s\", con->best=%p(%s)", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: con->uri=\"%s\", con->best=%p(%s)", con->uri, con->best, con->best ? con->best->location : ""); /* @@ -1075,12 +1075,12 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ best = con->best; - LogMessage(L_DEBUG2, "cupsdIsAuthorized: level=AUTH_%s, type=AUTH_%s, satisfy=AUTH_SATISFY_%s, num_names=%d", + 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); if (best->limit == AUTH_LIMIT_IPP) - LogMessage(L_DEBUG2, "cupsdIsAuthorized: op=%x(%s)", best->op, + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: op=%x(%s)", best->op, ippOpString(best->op)); /* @@ -1140,11 +1140,11 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ case AUTH_ALLOW : /* Order Deny,Allow */ auth = AUTH_ALLOW; - if (CheckAuth(address, con->http.hostname, hostlen, + if (cupsdCheckAuth(address, con->http.hostname, hostlen, best->num_deny, best->deny)) auth = AUTH_DENY; - if (CheckAuth(address, con->http.hostname, hostlen, + if (cupsdCheckAuth(address, con->http.hostname, hostlen, best->num_allow, best->allow)) auth = AUTH_ALLOW; break; @@ -1152,18 +1152,18 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ case AUTH_DENY : /* Order Allow,Deny */ auth = AUTH_DENY; - if (CheckAuth(address, con->http.hostname, hostlen, + if (cupsdCheckAuth(address, con->http.hostname, hostlen, best->num_allow, best->allow)) auth = AUTH_ALLOW; - if (CheckAuth(address, con->http.hostname, hostlen, + if (cupsdCheckAuth(address, con->http.hostname, hostlen, best->num_deny, best->deny)) auth = AUTH_DENY; break; } } - LogMessage(L_DEBUG2, "cupsdIsAuthorized: auth=AUTH_%s...", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: auth=AUTH_%s...", auth ? "DENY" : "ALLOW"); if (auth == AUTH_DENY && best->satisfy == AUTH_SATISFY_ALL) @@ -1176,7 +1176,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ if (best->encryption >= HTTP_ENCRYPT_REQUIRED && !con->http.tls) { - LogMessage(L_DEBUG2, "cupsdIsAuthorized: Need upgrade to TLS..."); + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: Need upgrade to TLS..."); return (HTTP_UPGRADE_REQUIRED); } #endif /* HAVE_SSL */ @@ -1201,13 +1201,13 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ attr = ippFindAttribute(con->request, "requesting-user-name", IPP_TAG_NAME); if (attr) { - LogMessage(L_DEBUG2, "cupsdIsAuthorized: requesting-user-name=\"%s\"", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: requesting-user-name=\"%s\"", attr->values[0].string.text); return (HTTP_OK); } } - LogMessage(L_DEBUG2, "cupsdIsAuthorized: username=\"%s\" password=%d chars", + cupsdLogMessage(L_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)); @@ -1224,7 +1224,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ * Check the user's password... */ - LogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking \"%s\", address = %x:%x:%x:%x, hostname = \"%s\"", + 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); @@ -1277,7 +1277,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ pamerr = pam_start("cups", con->username, &pamdata, &pamh); if (pamerr != PAM_SUCCESS) { - LogMessage(L_ERROR, "cupsdIsAuthorized: pam_start() returned %d (%s)!\n", + cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: pam_start() returned %d (%s)!\n", pamerr, pam_strerror(pamh, pamerr)); pam_end(pamh, 0); return (HTTP_UNAUTHORIZED); @@ -1286,7 +1286,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ pamerr = pam_authenticate(pamh, PAM_SILENT); if (pamerr != PAM_SUCCESS) { - LogMessage(L_ERROR, "cupsdIsAuthorized: pam_authenticate() returned %d (%s)!\n", + cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: pam_authenticate() returned %d (%s)!\n", pamerr, pam_strerror(pamh, pamerr)); pam_end(pamh, 0); return (HTTP_UNAUTHORIZED); @@ -1295,7 +1295,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ pamerr = pam_acct_mgmt(pamh, PAM_SILENT); if (pamerr != PAM_SUCCESS) { - LogMessage(L_ERROR, "cupsdIsAuthorized: pam_acct_mgmt() returned %d (%s)!\n", + cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: pam_acct_mgmt() returned %d (%s)!\n", pamerr, pam_strerror(pamh, pamerr)); pam_end(pamh, 0); return (HTTP_UNAUTHORIZED); @@ -1307,13 +1307,13 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ * Use AIX authentication interface... */ - LogMessage(L_DEBUG, "cupsdIsAuthorized: AIX authenticate of username \"%s\"", + cupsdLogMessage(L_DEBUG, "cupsdIsAuthorized: AIX authenticate of username \"%s\"", con->username); reenter = 1; if (authenticate(con->username, con->password, &reenter, &authmsg) != 0) { - LogMessage(L_DEBUG, "cupsdIsAuthorized: Unable to authenticate username \"%s\": %s", + cupsdLogMessage(L_DEBUG, "cupsdIsAuthorized: Unable to authenticate username \"%s\": %s", con->username, strerror(errno)); return (HTTP_UNAUTHORIZED); } @@ -1324,7 +1324,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ if (pw == NULL) /* No such user... */ { - LogMessage(L_WARN, "cupsdIsAuthorized: Unknown username \"%s\"; access denied.", + cupsdLogMessage(L_WARN, "cupsdIsAuthorized: Unknown username \"%s\"; access denied.", con->username); return (HTTP_UNAUTHORIZED); } @@ -1335,7 +1335,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ if (spw == NULL && strcmp(pw->pw_passwd, "x") == 0) { /* Don't allow blank passwords! */ - LogMessage(L_WARN, "cupsdIsAuthorized: Username \"%s\" has no shadow password; access denied.", + cupsdLogMessage(L_WARN, "cupsdIsAuthorized: Username \"%s\" has no shadow password; access denied.", con->username); return (HTTP_UNAUTHORIZED); /* No such user or bad shadow file */ } @@ -1352,7 +1352,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ if (pw->pw_passwd[0] == '\0') # endif /* HAVE_SHADOW_H */ { /* Don't allow blank passwords! */ - LogMessage(L_WARN, "cupsdIsAuthorized: Username \"%s\" has no password; access denied.", + cupsdLogMessage(L_WARN, "cupsdIsAuthorized: Username \"%s\" has no password; access denied.", con->username); return (HTTP_UNAUTHORIZED); } @@ -1363,7 +1363,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ pass = cups_crypt(con->password, pw->pw_passwd); - LogMessage(L_DEBUG2, "cupsdIsAuthorized: pw_passwd = %s, crypt = %s", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: pw_passwd = %s, crypt = %s", pw->pw_passwd, pass); if (pass == NULL || strcmp(pw->pw_passwd, pass) != 0) @@ -1373,7 +1373,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ { pass = cups_crypt(con->password, spw->sp_pwdp); - LogMessage(L_DEBUG2, "cupsdIsAuthorized: sp_pwdp = %s, crypt = %s", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: sp_pwdp = %s, crypt = %s", spw->sp_pwdp, pass); if (pass == NULL || strcmp(spw->sp_pwdp, pass) != 0) @@ -1394,49 +1394,49 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ if (!httpGetSubField(&(con->http), HTTP_FIELD_AUTHORIZATION, "nonce", nonce)) { - LogMessage(L_ERROR, "cupsdIsAuthorized: No nonce value for Digest authentication!"); + cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: No nonce value for Digest authentication!"); return (HTTP_UNAUTHORIZED); } if (strcmp(con->http.hostname, nonce) != 0) { - LogMessage(L_ERROR, "cupsdIsAuthorized: Nonce value error!"); - LogMessage(L_ERROR, "cupsdIsAuthorized: Expected \"%s\",", + cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: Nonce value error!"); + cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: Expected \"%s\",", con->http.hostname); - LogMessage(L_ERROR, "cupsdIsAuthorized: Got \"%s\"!", nonce); + cupsdLogMessage(L_ERROR, "cupsdIsAuthorized: Got \"%s\"!", nonce); return (HTTP_UNAUTHORIZED); } - LogMessage(L_DEBUG2, "cupsdIsAuthorized: nonce = \"%s\"", nonce); + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: nonce = \"%s\"", nonce); if (best->num_names && best->level == AUTH_GROUP) { - LogMessage(L_DEBUG2, "cupsdIsAuthorized: num_names = %d", best->num_names); + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: num_names = %d", best->num_names); for (i = 0; i < best->num_names; i ++) { if (!strcasecmp(best->names[i], "@SYSTEM")) { for (j = 0; j < NumSystemGroups; j ++) - if (GetMD5Passwd(con->username, SystemGroups[j], md5)) + if (cupsdGetMD5Passwd(con->username, SystemGroups[j], md5)) break; if (j < NumSystemGroups) break; } - else if (GetMD5Passwd(con->username, best->names[i], md5)) + else if (cupsdGetMD5Passwd(con->username, best->names[i], md5)) break; } if (i >= best->num_names) md5[0] = '\0'; } - else if (!GetMD5Passwd(con->username, NULL, md5)) + else if (!cupsdGetMD5Passwd(con->username, NULL, md5)) md5[0] = '\0'; if (!md5[0]) { - LogMessage(L_DEBUG2, "cupsdIsAuthorized: No matching user:group for \"%s\" in passwd.md5!", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: No matching user:group for \"%s\" in passwd.md5!", con->username); return (HTTP_UNAUTHORIZED); } @@ -1445,7 +1445,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ if (strcmp(md5, con->password) != 0) { - LogMessage(L_DEBUG2, "cupsdIsAuthorized: MD5s \"%s\" and \"%s\" don't match!", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: MD5s \"%s\" and \"%s\" don't match!", md5, con->password); return (HTTP_UNAUTHORIZED); } @@ -1458,32 +1458,32 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ if (best->num_names && best->level == AUTH_GROUP) { - LogMessage(L_DEBUG2, "cupsdIsAuthorized: num_names = %d", best->num_names); + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: num_names = %d", best->num_names); for (i = 0; i < best->num_names; i ++) { if (!strcasecmp(best->names[i], "@SYSTEM")) { for (j = 0; j < NumSystemGroups; j ++) - if (GetMD5Passwd(con->username, SystemGroups[j], md5)) + if (cupsdGetMD5Passwd(con->username, SystemGroups[j], md5)) break; if (j < NumSystemGroups) break; } - else if (GetMD5Passwd(con->username, best->names[i], md5)) + else if (cupsdGetMD5Passwd(con->username, best->names[i], md5)) break; } if (i >= best->num_names) md5[0] = '\0'; } - else if (!GetMD5Passwd(con->username, NULL, md5)) + else if (!cupsdGetMD5Passwd(con->username, NULL, md5)) md5[0] = '\0'; if (!md5[0]) { - LogMessage(L_DEBUG2, "cupsdIsAuthorized: No matching user:group for \"%s\" in passwd.md5!", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: No matching user:group for \"%s\" in passwd.md5!", con->username); return (HTTP_UNAUTHORIZED); } @@ -1492,7 +1492,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ if (strcmp(md5, basicmd5) != 0) { - LogMessage(L_DEBUG2, "cupsdIsAuthorized: MD5s \"%s\" and \"%s\" don't match!", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: MD5s \"%s\" and \"%s\" don't match!", md5, basicmd5); return (HTTP_UNAUTHORIZED); } @@ -1524,7 +1524,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ * any valid user is OK... */ - LogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking user membership..."); + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking user membership..."); if (best->num_names == 0) return (HTTP_OK); @@ -1561,7 +1561,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ * Check to see if this user is in any of the named groups... */ - LogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking group membership..."); + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking group membership..."); if (best->type == AUTH_BASIC) { @@ -1571,7 +1571,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ for (i = 0; i < best->num_names; i ++) { - LogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking group \"%s\" membership...", + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: Checking group \"%s\" membership...", best->names[i]); if (!strcasecmp(best->names[i], "@SYSTEM")) @@ -1588,7 +1588,7 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ * The user isn't part of the specified group, so deny access... */ - LogMessage(L_DEBUG2, "cupsdIsAuthorized: User not in group(s)!"); + cupsdLogMessage(L_DEBUG2, "cupsdIsAuthorized: User not in group(s)!"); return (HTTP_UNAUTHORIZED); } @@ -1605,10 +1605,10 @@ cupsdIsAuthorized(client_t *con, /* I - Connection */ * 'add_allow()' - Add an allow mask to the location. */ -static authmask_t * /* O - New mask record */ -add_allow(location_t *loc) /* I - Location to add to */ +static cupsd_authmask_t * /* O - New mask record */ +add_allow(cupsd_location_t *loc) /* I - Location to add to */ { - authmask_t *temp; /* New mask record */ + cupsd_authmask_t *temp; /* New mask record */ /* @@ -1623,9 +1623,9 @@ add_allow(location_t *loc) /* I - Location to add to */ */ if (loc->num_allow == 0) - temp = malloc(sizeof(authmask_t)); + temp = malloc(sizeof(cupsd_authmask_t)); else - temp = realloc(loc->allow, sizeof(authmask_t) * (loc->num_allow + 1)); + temp = realloc(loc->allow, sizeof(cupsd_authmask_t) * (loc->num_allow + 1)); if (temp == NULL) return (NULL); @@ -1638,7 +1638,7 @@ add_allow(location_t *loc) /* I - Location to add to */ * Clear the mask record and return... */ - memset(temp, 0, sizeof(authmask_t)); + memset(temp, 0, sizeof(cupsd_authmask_t)); return (temp); } @@ -1647,10 +1647,10 @@ add_allow(location_t *loc) /* I - Location to add to */ * 'add_deny()' - Add a deny mask to the location. */ -static authmask_t * /* O - New mask record */ -add_deny(location_t *loc) /* I - Location to add to */ +static cupsd_authmask_t * /* O - New mask record */ +add_deny(cupsd_location_t *loc) /* I - Location to add to */ { - authmask_t *temp; /* New mask record */ + cupsd_authmask_t *temp; /* New mask record */ /* @@ -1665,9 +1665,9 @@ add_deny(location_t *loc) /* I - Location to add to */ */ if (loc->num_deny == 0) - temp = malloc(sizeof(authmask_t)); + temp = malloc(sizeof(cupsd_authmask_t)); else - temp = realloc(loc->deny, sizeof(authmask_t) * (loc->num_deny + 1)); + temp = realloc(loc->deny, sizeof(cupsd_authmask_t) * (loc->num_deny + 1)); if (temp == NULL) return (NULL); @@ -1680,7 +1680,7 @@ add_deny(location_t *loc) /* I - Location to add to */ * Clear the mask record and return... */ - memset(temp, 0, sizeof(authmask_t)); + memset(temp, 0, sizeof(cupsd_authmask_t)); return (temp); } @@ -1821,7 +1821,7 @@ pam_func(int num_msg, /* I - Number of messages */ { int i; /* Looping var */ struct pam_response *replies; /* Replies */ - client_t *client; /* Pointer client connection */ + cupsd_client_t *client; /* Pointer client connection */ /* @@ -1846,7 +1846,7 @@ pam_func(int num_msg, /* I - Number of messages */ client = auth_client; (void)appdata_ptr; #else - client = (client_t *)appdata_ptr; + client = (cupsd_client_t *)appdata_ptr; #endif /* __hpux */ for (i = 0; i < num_msg; i ++) diff --git a/scheduler/auth.h b/scheduler/auth.h index 26f52d980..29f8bd67b 100644 --- a/scheduler/auth.h +++ b/scheduler/auth.h @@ -77,23 +77,23 @@ typedef struct { unsigned address[4], /* IP address */ netmask[4]; /* IP netmask */ -} ipmask_t; +} cupsd_ipmask_t; typedef struct { int length; /* Length of name */ char *name; /* Name string */ -} namemask_t; +} cupsd_namemask_t; typedef struct { int type; /* Mask type */ union { - namemask_t name; /* Host/Domain name */ - ipmask_t ip; /* IP address/network */ + cupsd_namemask_t name; /* Host/Domain name */ + cupsd_ipmask_t ip; /* IP address/network */ } mask; /* Mask data */ -} authmask_t; +} cupsd_authmask_t; typedef struct { @@ -108,13 +108,13 @@ typedef struct int num_names; /* Number of names */ char **names; /* User or group names */ int num_allow; /* Number of Allow lines */ - authmask_t *allow; /* Allow lines */ + cupsd_authmask_t *allow; /* Allow lines */ int num_deny; /* Number of Deny lines */ - authmask_t *deny; /* Deny lines */ + cupsd_authmask_t *deny; /* Deny lines */ http_encryption_t encryption; /* To encrypt or not to encrypt... */ -} location_t; +} cupsd_location_t; -typedef struct client_s client_t; +typedef struct cupsd_client_s cupsd_client_t; /* @@ -123,7 +123,7 @@ typedef struct client_s client_t; VAR int NumLocations VALUE(0); /* Number of authorization locations */ -VAR 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 */ @@ -133,27 +133,27 @@ VAR int DefaultAuthType VALUE(AUTH_BASIC); * Prototypes... */ -extern location_t *AddLocation(const char *location); -extern void AddName(location_t *loc, char *name); -extern void AllowHost(location_t *loc, char *name); -extern void AllowIP(location_t *loc, unsigned address[4], +extern cupsd_location_t *cupsdAddLocation(const char *location); +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]); -extern int CheckAuth(unsigned ip[4], char *name, int namelen, - int num_masks, authmask_t *masks); +extern int cupsdCheckAuth(unsigned ip[4], char *name, int namelen, + int num_masks, cupsd_authmask_t *masks); extern int cupsdCheckGroup(const char *username, struct passwd *user, const char *groupname); -extern location_t *CopyLocation(location_t **loc); -extern void DeleteAllLocations(void); -extern void cupsdDeleteLocation(location_t *loc); -extern void DenyHost(location_t *loc, char *name); -extern void DenyIP(location_t *loc, unsigned address[4], +extern cupsd_location_t *cupsdCopyLocation(cupsd_location_t **loc); +extern void cupsdDeleteAllLocations(void); +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]); -extern location_t *FindBest(const char *path, http_state_t state); -extern location_t *FindLocation(const char *location); -extern char *GetMD5Passwd(const char *username, const char *group, +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]); -extern http_status_t cupsdIsAuthorized(client_t *con, const char *owner); +extern http_status_t cupsdIsAuthorized(cupsd_client_t *con, const char *owner); /* diff --git a/scheduler/banners.c b/scheduler/banners.c index 02c720e33..17a7849ab 100644 --- a/scheduler/banners.c +++ b/scheduler/banners.c @@ -23,9 +23,9 @@ * * Contents: * - * AddBanner() - Add a banner to the array. - * FindBanner() - Find a named banner. - * LoadBanners() - Load all available banner files... + * cupsdAddBanner() - Add a banner to the array. + * cupsdFindBanner() - Find a named banner. + * cupsdLoadBanners() - Load all available banner files... * compare() - Compare two banners. */ @@ -41,19 +41,19 @@ * Local functions... */ -static int compare(const banner_t *b0, const banner_t *b1); +static int compare(const cupsd_banner_t *b0, const cupsd_banner_t *b1); /* - * 'AddBanner()' - Add a banner to the array. + * 'cupsdAddBanner()' - Add a banner to the array. */ void -AddBanner(const char *name, /* I - Name of banner */ +cupsdAddBanner(const char *name, /* I - Name of banner */ const char *filename) /* I - Filename for banner */ { mime_type_t *filetype; /* Filetype */ - banner_t *temp; /* New banner data */ + cupsd_banner_t *temp; /* New banner data */ /* @@ -62,7 +62,7 @@ AddBanner(const char *name, /* I - Name of banner */ if ((filetype = mimeFileType(MimeDatabase, filename, NULL)) == NULL) { - LogMessage(L_WARN, "AddBanner: Banner \"%s\" (\"%s\") is of an unknown file type - skipping!", + cupsdLogMessage(L_WARN, "cupsdAddBanner: Banner \"%s\" (\"%s\") is of an unknown file type - skipping!", name, filename); return; } @@ -72,13 +72,13 @@ AddBanner(const char *name, /* I - Name of banner */ */ if (NumBanners == 0) - temp = malloc(sizeof(banner_t)); + temp = malloc(sizeof(cupsd_banner_t)); else - temp = realloc(Banners, sizeof(banner_t) * (NumBanners + 1)); + temp = realloc(Banners, sizeof(cupsd_banner_t) * (NumBanners + 1)); if (temp == NULL) { - LogMessage(L_ERROR, "AddBanner: Ran out of memory adding a banner!"); + cupsdLogMessage(L_ERROR, "cupsdAddBanner: Ran out of memory adding a banner!"); return; } @@ -90,35 +90,35 @@ AddBanner(const char *name, /* I - Name of banner */ temp += NumBanners; NumBanners ++; - memset(temp, 0, sizeof(banner_t)); + memset(temp, 0, sizeof(cupsd_banner_t)); strlcpy(temp->name, name, sizeof(temp->name)); temp->filetype = filetype; } /* - * 'FindBanner()' - Find a named banner. + * 'cupsdFindBanner()' - Find a named banner. */ -banner_t * /* O - Pointer to banner or NULL */ -FindBanner(const char *name) /* I - Name of banner */ +cupsd_banner_t * /* O - Pointer to banner or NULL */ +cupsdFindBanner(const char *name) /* I - Name of banner */ { - banner_t key; /* Search key */ + cupsd_banner_t key; /* Search key */ strlcpy(key.name, name, sizeof(key.name)); - return ((banner_t *)bsearch(&key, Banners, NumBanners, sizeof(banner_t), + return ((cupsd_banner_t *)bsearch(&key, Banners, NumBanners, sizeof(cupsd_banner_t), (int (*)(const void *, const void *))compare)); } /* - * 'LoadBanners()' - Load all available banner files... + * 'cupsdLoadBanners()' - Load all available banner files... */ void -LoadBanners(const char *d) /* I - Directory to search */ +cupsdLoadBanners(const char *d) /* I - Directory to search */ { cups_dir_t *dir; /* Directory pointer */ cups_dentry_t *dent; /* Directory entry */ @@ -142,7 +142,7 @@ LoadBanners(const char *d) /* I - Directory to search */ if ((dir = cupsDirOpen(d)) == NULL) { - LogMessage(L_ERROR, "LoadBanners: Unable to open banner directory \"%s\": %s", + cupsdLogMessage(L_ERROR, "cupsdLoadBanners: Unable to open banner directory \"%s\": %s", d, strerror(errno)); return; } @@ -176,7 +176,7 @@ LoadBanners(const char *d) /* I - Directory to search */ * Must be a valid file; add it! */ - AddBanner(dent->filename, filename); + cupsdAddBanner(dent->filename, filename); } /* @@ -186,7 +186,7 @@ LoadBanners(const char *d) /* I - Directory to search */ cupsDirClose(dir); if (NumBanners > 1) - qsort(Banners, NumBanners, sizeof(banner_t), + qsort(Banners, NumBanners, sizeof(cupsd_banner_t), (int (*)(const void *, const void *))compare); } @@ -196,8 +196,8 @@ LoadBanners(const char *d) /* I - Directory to search */ */ static int /* O - -1 if name0 < name1, etc. */ -compare(const banner_t *b0, /* I - First banner */ - const banner_t *b1) /* I - Second banner */ +compare(const cupsd_banner_t *b0, /* I - First banner */ + const cupsd_banner_t *b1) /* I - Second banner */ { return (strcasecmp(b0->name, b1->name)); } diff --git a/scheduler/banners.h b/scheduler/banners.h index 054f3dad8..e1a197eb5 100644 --- a/scheduler/banners.h +++ b/scheduler/banners.h @@ -30,7 +30,7 @@ typedef struct { char name[256]; /* Name of banner */ mime_type_t *filetype; /* Filetype for banner */ -} banner_t; +} cupsd_banner_t; /* @@ -39,7 +39,7 @@ typedef struct VAR int NumBanners VALUE(0); /* Number of banner files available */ -VAR banner_t *Banners VALUE(NULL); +VAR cupsd_banner_t *Banners VALUE(NULL); /* Available banner files */ @@ -47,9 +47,9 @@ VAR banner_t *Banners VALUE(NULL); * Prototypes... */ -extern void AddBanner(const char *name, const char *filename); -extern banner_t *FindBanner(const char *name); -extern void LoadBanners(const char *d); +extern void cupsdAddBanner(const char *name, const char *filename); +extern cupsd_banner_t *cupsdFindBanner(const char *name); +extern void cupsdLoadBanners(const char *d); /* diff --git a/scheduler/cert.c b/scheduler/cert.c index b839f7c09..2b4a6262c 100644 --- a/scheduler/cert.c +++ b/scheduler/cert.c @@ -24,11 +24,11 @@ * * Contents: * - * AddCert() - Add a certificate. - * DeleteCert() - Delete a single certificate. - * DeleteAllCerts() - Delete all certificates... - * FindCert() - Find a certificate. - * InitCerts() - Initialize the certificate "system" and root + * cupsdAddCert() - Add a certificate. + * cupsdDeleteCert() - Delete a single certificate. + * cupsdDeleteAllCerts() - Delete all certificates... + * cupsdFindCert() - Find a certificate. + * cupsdInitCerts() - Initialize the certificate "system" and root * certificate. */ @@ -40,28 +40,28 @@ /* - * 'AddCert()' - Add a certificate. + * 'cupsdAddCert()' - Add a certificate. */ void -AddCert(int pid, /* I - Process ID */ +cupsdAddCert(int pid, /* I - Process ID */ const char *username) /* I - Username */ { int i; /* Looping var */ - cert_t *cert; /* Current certificate */ + cupsd_cert_t *cert; /* Current certificate */ int fd; /* Certificate file */ char filename[1024]; /* Certificate filename */ static const char hex[] = "0123456789ABCDEF"; /* Hex constants... */ - LogMessage(L_DEBUG2, "AddCert: adding certificate for pid %d", pid); + cupsdLogMessage(L_DEBUG2, "cupsdAddCert: adding certificate for pid %d", pid); /* * Allocate memory for the certificate... */ - if ((cert = calloc(sizeof(cert_t), 1)) == NULL) + if ((cert = calloc(sizeof(cupsd_cert_t), 1)) == NULL) return; /* @@ -84,7 +84,7 @@ AddCert(int pid, /* I - Process ID */ if ((fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0400)) < 0) { - LogMessage(L_ERROR, "AddCert: Unable to create certificate file %s - %s", + cupsdLogMessage(L_ERROR, "cupsdAddCert: Unable to create certificate file %s - %s", filename, strerror(errno)); free(cert); return; @@ -127,13 +127,13 @@ AddCert(int pid, /* I - Process ID */ /* - * 'DeleteCert()' - Delete a single certificate. + * 'cupsdDeleteCert()' - Delete a single certificate. */ void -DeleteCert(int pid) /* I - Process ID */ +cupsdDeleteCert(int pid) /* I - Process ID */ { - cert_t *cert, /* Current certificate */ + cupsd_cert_t *cert, /* Current certificate */ *prev; /* Previous certificate */ char filename[1024]; /* Certificate file */ @@ -145,7 +145,7 @@ DeleteCert(int pid) /* I - Process ID */ * Remove this certificate from the list... */ - LogMessage(L_DEBUG2, "DeleteCert: removing certificate for pid %d", pid); + cupsdLogMessage(L_DEBUG2, "cupsdDeleteCert: removing certificate for pid %d", pid); DEBUG_printf(("DELETE pid=%d, username=%s, cert=%s\n", cert->pid, cert->username, cert->certificate)); @@ -163,7 +163,7 @@ DeleteCert(int pid) /* I - Process ID */ snprintf(filename, sizeof(filename), "%s/certs/%d", StateDir, pid); if (unlink(filename)) - LogMessage(L_ERROR, "DeleteCert: Unable to remove %s!\n", filename); + cupsdLogMessage(L_ERROR, "cupsdDeleteCert: Unable to remove %s!\n", filename); return; } @@ -171,13 +171,13 @@ DeleteCert(int pid) /* I - Process ID */ /* - * 'DeleteAllCerts()' - Delete all certificates... + * 'cupsdDeleteAllCerts()' - Delete all certificates... */ void -DeleteAllCerts(void) +cupsdDeleteAllCerts(void) { - cert_t *cert, /* Current certificate */ + cupsd_cert_t *cert, /* Current certificate */ *next; /* Next certificate */ char filename[1024]; /* Certificate file */ @@ -194,7 +194,7 @@ DeleteAllCerts(void) snprintf(filename, sizeof(filename), "%s/certs/%d", StateDir, cert->pid); if (unlink(filename)) - LogMessage(L_ERROR, "DeleteAllCerts: Unable to remove %s!\n", filename); + cupsdLogMessage(L_ERROR, "cupsdDeleteAllCerts: Unable to remove %s!\n", filename); /* * Free memory... @@ -209,16 +209,16 @@ DeleteAllCerts(void) /* - * 'FindCert()' - Find a certificate. + * 'cupsdFindCert()' - Find a certificate. */ const char * /* O - Matching username or NULL */ -FindCert(const char *certificate) /* I - Certificate */ +cupsdFindCert(const char *certificate) /* I - Certificate */ { - cert_t *cert; /* Current certificate */ + cupsd_cert_t *cert; /* Current certificate */ - DEBUG_printf(("FindCert(certificate=%s)\n", certificate)); + DEBUG_printf(("cupsdFindCert(certificate=%s)\n", certificate)); for (cert = Certs; cert != NULL; cert = cert->next) if (strcasecmp(certificate, cert->certificate) == 0) { @@ -233,11 +233,11 @@ FindCert(const char *certificate) /* I - Certificate */ /* - * 'InitCerts()' - Initialize the certificate "system" and root certificate. + * 'cupsdInitCerts()' - Initialize the certificate "system" and root certificate. */ void -InitCerts(void) +cupsdInitCerts(void) { cups_file_t *fp; /* /dev/random file */ unsigned seed; /* Seed for random number generator */ @@ -281,7 +281,7 @@ InitCerts(void) */ if (!RunUser) - AddCert(0, "root"); + cupsdAddCert(0, "root"); } diff --git a/scheduler/cert.h b/scheduler/cert.h index 59775aa65..8890fae6f 100644 --- a/scheduler/cert.h +++ b/scheduler/cert.h @@ -27,20 +27,20 @@ * Certificate structure... */ -typedef struct cert_s +typedef struct cupsd_cert_s { - struct cert_str *next; /* Next certificate in list */ + 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 */ -} cert_t; +} cupsd_cert_t; /* * Globals... */ -VAR cert_t *Certs; /* List of certificates */ +VAR cupsd_cert_t *Certs; /* List of certificates */ VAR time_t RootCertTime; /* Root certificate update time */ @@ -48,11 +48,11 @@ VAR time_t RootCertTime; /* Root certificate update time */ * Prototypes... */ -extern void AddCert(int pid, const char *username); -extern void DeleteCert(int pid); -extern void DeleteAllCerts(void); -extern const char *FindCert(const char *certificate); -extern void InitCerts(void); +extern void cupsdAddCert(int pid, const char *username); +extern void cupsdDeleteCert(int pid); +extern void cupsdDeleteAllCerts(void); +extern const char *cupsdFindCert(const char *certificate); +extern void cupsdInitCerts(void); /* diff --git a/scheduler/classes.c b/scheduler/classes.c index 519cf3b9c..fd1a07a33 100644 --- a/scheduler/classes.c +++ b/scheduler/classes.c @@ -23,16 +23,16 @@ * * Contents: * - * AddClass() - Add a class to the system. - * AddPrinterToClass() - Add a printer to a class... - * DeletePrinterFromClass() - Delete a printer from a class. - * DeletePrinterFromClasses() - Delete a printer from all classes. - * DeleteAllClasses() - Remove all classes from the system. - * FindAvailablePrinter() - Find an available printer in a class. - * FindClass() - Find the named class. - * LoadAllClasses() - Load classes from the classes.conf file. - * SaveAllClasses() - Save classes to the classes.conf file. - * UpdateImplicitClasses() - Update the accepting state of implicit + * cupsdAddClass() - Add a class to the system. + * cupsdAddPrinterToClass() - Add a printer to a class... + * cupsdDeletePrinterFromClass() - Delete a printer from a class. + * cupsdDeletePrinterFromClasses() - Delete a printer from all classes. + * cupsdDeleteAllClasses() - Remove all classes from the system. + * cupsdFindAvailablePrinter() - Find an available printer in a class. + * cupsdFindClass() - Find the named class. + * cupsdLoadAllClasses() - Load classes from the classes.conf file. + * cupsdSaveAllClasses() - Save classes to the classes.conf file. + * cupsdUpdateImplicitClasses() - Update the accepting state of implicit * classes. */ @@ -44,20 +44,20 @@ /* - * 'AddClass()' - Add a class to the system. + * 'cupsdAddClass()' - Add a class to the system. */ -printer_t * /* O - New class */ -AddClass(const char *name) /* I - Name of class */ +cupsd_printer_t * /* O - New class */ +cupsdAddClass(const char *name) /* I - Name of class */ { - printer_t *c; /* New class */ + cupsd_printer_t *c; /* New class */ /* * Add the printer and set the type to "class"... */ - if ((c = AddPrinter(name)) != NULL) + if ((c = cupsdAddPrinter(name)) != NULL) { /* * Change from a printer to a class... @@ -65,8 +65,8 @@ AddClass(const char *name) /* I - Name of class */ c->type = CUPS_PRINTER_CLASS; - SetStringf(&c->uri, "ipp://%s:%d/classes/%s", ServerName, LocalPort, name); - SetString(&c->error_policy, "retry-job"); + cupsdSetStringf(&c->uri, "ipp://%s:%d/classes/%s", ServerName, LocalPort, name); + cupsdSetString(&c->error_policy, "retry-job"); } return (c); @@ -74,15 +74,15 @@ AddClass(const char *name) /* I - Name of class */ /* - * 'AddPrinterToClass()' - Add a printer to a class... + * 'cupsdAddPrinterToClass()' - Add a printer to a class... */ void -AddPrinterToClass(printer_t *c, /* I - Class to add to */ - 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 */ - printer_t **temp; /* Pointer to printer array */ + cupsd_printer_t **temp; /* Pointer to printer array */ /* @@ -98,13 +98,13 @@ AddPrinterToClass(printer_t *c, /* I - Class to add to */ */ if (c->num_printers == 0) - temp = malloc(sizeof(printer_t *)); + temp = malloc(sizeof(cupsd_printer_t *)); else - temp = realloc(c->printers, sizeof(printer_t *) * (c->num_printers + 1)); + temp = realloc(c->printers, sizeof(cupsd_printer_t *) * (c->num_printers + 1)); if (temp == NULL) { - LogMessage(L_ERROR, "Unable to add printer %s to class %s!", + cupsdLogMessage(L_ERROR, "Unable to add printer %s to class %s!", p->name, c->name); return; } @@ -122,12 +122,12 @@ AddPrinterToClass(printer_t *c, /* I - Class to add to */ /* - * 'DeletePrinterFromClass()' - Delete a printer from a class. + * 'cupsdDeletePrinterFromClass()' - Delete a printer from a class. */ void -DeletePrinterFromClass(printer_t *c, /* I - Class to delete from */ - 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 */ @@ -154,7 +154,7 @@ DeletePrinterFromClass(printer_t *c, /* I - Class to delete from */ c->num_printers --; if (i < c->num_printers) memmove(c->printers + i, c->printers + i + 1, - (c->num_printers - i) * sizeof(printer_t *)); + (c->num_printers - i) * sizeof(cupsd_printer_t *)); } else return; @@ -177,19 +177,19 @@ DeletePrinterFromClass(printer_t *c, /* I - Class to delete from */ * Update the IPP attributes... */ - SetPrinterAttrs(c); + cupsdSetPrinterAttrs(c); } } /* - * 'DeletePrinterFromClasses()' - Delete a printer from all classes. + * 'cupsdDeletePrinterFromClasses()' - Delete a printer from all classes. */ void -DeletePrinterFromClasses(printer_t *p) /* I - Printer to delete */ +cupsdDeletePrinterFromClasses(cupsd_printer_t *p) /* I - Printer to delete */ { - printer_t *c; /* Pointer to current class */ + cupsd_printer_t *c; /* Pointer to current class */ /* @@ -197,60 +197,60 @@ DeletePrinterFromClasses(printer_t *p) /* I - Printer to delete */ * from each class listed... */ - for (c = (printer_t *)cupsArrayFirst(Printers); + for (c = (cupsd_printer_t *)cupsArrayFirst(Printers); c; - c = (printer_t *)cupsArrayNext(Printers)) + c = (cupsd_printer_t *)cupsArrayNext(Printers)) if (c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)) - DeletePrinterFromClass(c, p); + cupsdDeletePrinterFromClass(c, p); /* * Then clean out any empty implicit classes... */ - for (c = (printer_t *)cupsArrayFirst(Printers); + for (c = (cupsd_printer_t *)cupsArrayFirst(Printers); c; - c = (printer_t *)cupsArrayNext(Printers)) + c = (cupsd_printer_t *)cupsArrayNext(Printers)) if ((c->type & CUPS_PRINTER_IMPLICIT) && c->num_printers == 0) - DeletePrinter(c, 0); + cupsdDeletePrinter(c, 0); } /* - * 'DeleteAllClasses()' - Remove all classes from the system. + * 'cupsdDeleteAllClasses()' - Remove all classes from the system. */ void -DeleteAllClasses(void) +cupsdDeleteAllClasses(void) { - printer_t *c; /* Pointer to current printer/class */ + cupsd_printer_t *c; /* Pointer to current printer/class */ - for (c = (printer_t *)cupsArrayFirst(Printers); + for (c = (cupsd_printer_t *)cupsArrayFirst(Printers); c; - c = (printer_t *)cupsArrayNext(Printers)) + c = (cupsd_printer_t *)cupsArrayNext(Printers)) if (c->type & CUPS_PRINTER_CLASS) - DeletePrinter(c, 0); + cupsdDeletePrinter(c, 0); } /* - * 'FindAvailablePrinter()' - Find an available printer in a class. + * 'cupsdFindAvailablePrinter()' - Find an available printer in a class. */ -printer_t * /* O - Available printer or NULL */ -FindAvailablePrinter(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 */ - printer_t *c; /* Printer class */ + cupsd_printer_t *c; /* Printer class */ /* * Find the class... */ - if ((c = FindClass(name)) == NULL) + if ((c = cupsdFindClass(name)) == NULL) { - LogMessage(L_ERROR, "Unable to find class \"%s\"!", name); + cupsdLogMessage(L_ERROR, "Unable to find class \"%s\"!", name); return (NULL); } @@ -285,16 +285,16 @@ FindAvailablePrinter(const char *name) /* I - Class to check */ /* - * 'FindClass()' - Find the named class. + * 'cupsdFindClass()' - Find the named class. */ -printer_t * /* O - Matching class or NULL */ -FindClass(const char *name) /* I - Name of class */ +cupsd_printer_t * /* O - Matching class or NULL */ +cupsdFindClass(const char *name) /* I - Name of class */ { - printer_t *c; /* Current class/printer */ + cupsd_printer_t *c; /* Current class/printer */ - if ((c = FindDest(name)) != NULL && !(c->type & CUPS_PRINTER_CLASS)) + if ((c = cupsdFindDest(name)) != NULL && !(c->type & CUPS_PRINTER_CLASS)) return (NULL); else return (c); @@ -302,18 +302,18 @@ FindClass(const char *name) /* I - Name of class */ /* - * 'LoadAllClasses()' - Load classes from the classes.conf file. + * 'cupsdLoadAllClasses()' - Load classes from the classes.conf file. */ void -LoadAllClasses(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 */ - printer_t *p, /* Current printer class */ + cupsd_printer_t *p, /* Current printer class */ *temp; /* Temporary pointer to printer */ @@ -324,7 +324,7 @@ LoadAllClasses(void) snprintf(line, sizeof(line), "%s/classes.conf", ServerRoot); if ((fp = cupsFileOpen(line, "r")) == NULL) { - LogMessage(L_ERROR, "LoadAllClasses: Unable to open %s - %s", line, + cupsdLogMessage(L_ERROR, "cupsdLoadAllClasses: Unable to open %s - %s", line, strerror(errno)); return; } @@ -351,9 +351,9 @@ LoadAllClasses(void) if (p == NULL && value) { - LogMessage(L_DEBUG, "LoadAllClasses: Loading class %s...", value); + cupsdLogMessage(L_DEBUG, "cupsdLoadAllClasses: Loading class %s...", value); - p = AddClass(value); + p = cupsdAddClass(value); p->accepting = 1; p->state = IPP_PRINTER_IDLE; @@ -362,7 +362,7 @@ LoadAllClasses(void) } else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -371,67 +371,67 @@ LoadAllClasses(void) { if (p != NULL) { - SetPrinterAttrs(p); + cupsdSetPrinterAttrs(p); p = NULL; } else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } } else if (!p) { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } else if (!strcasecmp(line, "Info")) { if (value) - SetString(&p->info, value); + cupsdSetString(&p->info, value); } else if (!strcasecmp(line, "Location")) { if (value) - SetString(&p->location, value); + cupsdSetString(&p->location, value); } else if (!strcasecmp(line, "Printer")) { if (!value) { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } - else if ((temp = FindPrinter(value)) == NULL) + else if ((temp = cupsdFindPrinter(value)) == NULL) { - LogMessage(L_WARN, "Unknown printer %s on line %d of classes.conf.", + cupsdLogMessage(L_WARN, "Unknown printer %s on line %d of classes.conf.", value, linenum); /* * Add the missing remote printer... */ - if ((temp = AddPrinter(value)) != NULL) + if ((temp = cupsdAddPrinter(value)) != NULL) { - SetString(&temp->make_model, "Remote Printer on unknown"); + cupsdSetString(&temp->make_model, "Remote Printer on unknown"); temp->state = IPP_PRINTER_STOPPED; temp->type |= CUPS_PRINTER_REMOTE; temp->browse_time = 2147483647; - SetString(&temp->location, "Location Unknown"); - SetString(&temp->info, "No Information Available"); + cupsdSetString(&temp->location, "Location Unknown"); + cupsdSetString(&temp->info, "No Information Available"); temp->hostname[0] = '\0'; - SetPrinterAttrs(temp); + cupsdSetPrinterAttrs(temp); } } if (temp) - AddPrinterToClass(p, temp); + cupsdAddPrinterToClass(p, temp); } else if (!strcasecmp(line, "State")) { @@ -445,7 +445,7 @@ LoadAllClasses(void) p->state = IPP_PRINTER_STOPPED; else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -477,7 +477,7 @@ LoadAllClasses(void) p->accepting = 0; else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -500,7 +500,7 @@ LoadAllClasses(void) p->shared = 0; else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -518,7 +518,7 @@ LoadAllClasses(void) if (*valueptr) *valueptr++ = '\0'; - SetString(&p->job_sheets[0], value); + cupsdSetString(&p->cupsd_job_sheets[0], value); while (isspace(*valueptr & 255)) valueptr ++; @@ -530,12 +530,12 @@ LoadAllClasses(void) if (*valueptr) *valueptr++ = '\0'; - SetString(&p->job_sheets[1], value); + cupsdSetString(&p->cupsd_job_sheets[1], value); } } else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -545,11 +545,11 @@ LoadAllClasses(void) if (value) { p->deny_users = 0; - AddPrinterUser(p, value); + cupsdAddPrinterUser(p, value); } else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -559,11 +559,11 @@ LoadAllClasses(void) if (value) { p->deny_users = 1; - AddPrinterUser(p, value); + cupsdAddPrinterUser(p, value); } else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -574,7 +574,7 @@ LoadAllClasses(void) p->quota_period = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -585,7 +585,7 @@ LoadAllClasses(void) p->page_limit = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -596,7 +596,7 @@ LoadAllClasses(void) p->k_limit = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -604,10 +604,10 @@ LoadAllClasses(void) else if (!strcasecmp(line, "OpPolicy")) { if (value) - SetString(&p->op_policy, value); + cupsdSetString(&p->op_policy, value); else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -615,10 +615,10 @@ LoadAllClasses(void) else if (!strcasecmp(line, "ErrorPolicy")) { if (value) - SetString(&p->error_policy, value); + cupsdSetString(&p->error_policy, value); else { - LogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of classes.conf.", linenum); return; } @@ -629,7 +629,7 @@ LoadAllClasses(void) * Something else we don't understand... */ - LogMessage(L_ERROR, "Unknown configuration directive %s on line %d of classes.conf.", + cupsdLogMessage(L_ERROR, "Unknown configuration directive %s on line %d of classes.conf.", line, linenum); } } @@ -639,16 +639,16 @@ LoadAllClasses(void) /* - * 'SaveAllClasses()' - Save classes to the classes.conf file. + * 'cupsdSaveAllClasses()' - Save classes to the classes.conf file. */ void -SaveAllClasses(void) +cupsdSaveAllClasses(void) { cups_file_t *fp; /* classes.conf file */ char temp[1024]; /* Temporary string */ char backup[1024]; /* classes.conf.O file */ - printer_t *pclass; /* Current printer class */ + cupsd_printer_t *pclass; /* Current printer class */ int i; /* Looping var */ time_t curtime; /* Current time */ struct tm *curdate; /* Current date */ @@ -662,18 +662,18 @@ SaveAllClasses(void) snprintf(backup, sizeof(backup), "%s/classes.conf.O", ServerRoot); if (rename(temp, backup)) - LogMessage(L_ERROR, "Unable to backup classes.conf - %s", strerror(errno)); + cupsdLogMessage(L_ERROR, "Unable to backup classes.conf - %s", strerror(errno)); if ((fp = cupsFileOpen(temp, "w")) == NULL) { - LogMessage(L_ERROR, "Unable to save classes.conf - %s", strerror(errno)); + cupsdLogMessage(L_ERROR, "Unable to save classes.conf - %s", strerror(errno)); if (rename(backup, temp)) - LogMessage(L_ERROR, "Unable to restore classes.conf - %s", strerror(errno)); + cupsdLogMessage(L_ERROR, "Unable to restore classes.conf - %s", strerror(errno)); return; } else - LogMessage(L_INFO, "Saving classes.conf..."); + cupsdLogMessage(L_INFO, "Saving classes.conf..."); /* * Restrict access to the file... @@ -697,9 +697,9 @@ SaveAllClasses(void) * Write each local class known to the system... */ - for (pclass = (printer_t *)cupsArrayFirst(Printers); + for (pclass = (cupsd_printer_t *)cupsArrayFirst(Printers); pclass; - pclass = (printer_t *)cupsArrayNext(Printers)) + pclass = (cupsd_printer_t *)cupsArrayNext(Printers)) { /* * Skip remote destinations and regular printers... @@ -743,8 +743,8 @@ SaveAllClasses(void) else cupsFilePuts(fp, "Shared No\n"); - cupsFilePrintf(fp, "JobSheets %s %s\n", pclass->job_sheets[0], - pclass->job_sheets[1]); + cupsFilePrintf(fp, "JobSheets %s %s\n", pclass->cupsd_job_sheets[0], + pclass->cupsd_job_sheets[1]); for (i = 0; i < pclass->num_printers; i ++) cupsFilePrintf(fp, "Printer %s\n", pclass->printers[i]->name); @@ -770,20 +770,20 @@ SaveAllClasses(void) /* - * 'UpdateImplicitClasses()' - Update the accepting state of implicit classes. + * 'cupsdUpdateImplicitClasses()' - Update the accepting state of implicit classes. */ void -UpdateImplicitClasses(void) +cupsdUpdateImplicitClasses(void) { int i; /* Looping var */ - printer_t *pclass; /* Current class */ + cupsd_printer_t *pclass; /* Current class */ int accepting; /* printer-is-accepting-jobs value */ - for (pclass = (printer_t *)cupsArrayFirst(Printers); + for (pclass = (cupsd_printer_t *)cupsArrayFirst(Printers); pclass; - pclass = (printer_t *)cupsArrayNext(Printers)) + pclass = (cupsd_printer_t *)cupsArrayNext(Printers)) if (pclass->type & CUPS_PRINTER_IMPLICIT) { /* diff --git a/scheduler/classes.h b/scheduler/classes.h index c20e304ab..7cf3700af 100644 --- a/scheduler/classes.h +++ b/scheduler/classes.h @@ -27,16 +27,16 @@ * Prototypes... */ -extern printer_t *AddClass(const char *name); -extern void AddPrinterToClass(printer_t *c, printer_t *p); -extern void DeletePrinterFromClass(printer_t *c, printer_t *p); -extern void DeletePrinterFromClasses(printer_t *p); -extern void DeleteAllClasses(void); -extern printer_t *FindAvailablePrinter(const char *name); -extern printer_t *FindClass(const char *name); -extern void LoadAllClasses(void); -extern void SaveAllClasses(void); -extern void UpdateImplicitClasses(void); +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 cupsdDeletePrinterFromClasses(cupsd_printer_t *p); +extern void cupsdDeleteAllClasses(void); +extern cupsd_printer_t *cupsdFindAvailablePrinter(const char *name); +extern cupsd_printer_t *cupsdFindClass(const char *name); +extern void cupsdLoadAllClasses(void); +extern void cupsdSaveAllClasses(void); +extern void cupsdUpdateImplicitClasses(void); /* diff --git a/scheduler/client.c b/scheduler/client.c index 99e3b56f0..0bd27c6f1 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -23,18 +23,18 @@ * * Contents: * - * AcceptClient() - Accept a new client. - * CloseAllClients() - Close all remote clients immediately. - * CloseClient() - Close a remote client. - * EncryptClient() - Enable encryption for the client... - * IsCGI() - Is the resource a CGI script/program? - * ReadClient() - Read data from a client. - * SendCommand() - Send output from a command via HTTP. - * SendError() - Send an error message via HTTP. - * SendFile() - Send a file via HTTP. - * SendHeader() - Send an HTTP request. - * UpdateCGI() - Read status messages from CGI scripts and programs. - * WriteClient() - Write data to a client as needed. + * 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. @@ -57,14 +57,14 @@ * Local functions... */ -static int check_if_modified(client_t *con, +static int check_if_modified(cupsd_client_t *con, struct stat *filestats); -static void decode_auth(client_t *con); -static char *get_file(client_t *con, struct stat *filestats, +static void decode_auth(cupsd_client_t *con); +static char *get_file(cupsd_client_t *con, struct stat *filestats, char *filename, int len); -static http_status_t install_conf_file(client_t *con); +static http_status_t install_conf_file(cupsd_client_t *con); static int is_path_absolute(const char *path); -static int pipe_command(client_t *con, int infile, int *outfile, +static int pipe_command(cupsd_client_t *con, int infile, int *outfile, char *command, char *options, int root); #ifdef HAVE_CDSASSL @@ -76,16 +76,16 @@ static OSStatus CDSAWriteFunc(SSLConnectionRef connection, /* - * 'AcceptClient()' - Accept a new client. + * 'cupsdAcceptClient()' - Accept a new client. */ void -AcceptClient(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 */ - client_t *con; /* New client pointer */ + 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 */ @@ -93,7 +93,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ /* Time of last DoS attack */ - LogMessage(L_DEBUG2, "AcceptClient(lis=%p) %d NumClients = %d", + cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient(lis=%p) %d NumClients = %d", lis, lis->fd, NumClients); /* @@ -109,7 +109,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ con = Clients + NumClients; - memset(con, 0, sizeof(client_t)); + memset(con, 0, sizeof(cupsd_client_t)); con->http.activity = time(NULL); con->file = -1; @@ -122,7 +122,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ if ((con->http.fd = accept(lis->fd, (struct sockaddr *)&(con->http.hostaddr), &val)) < 0) { - LogMessage(L_ERROR, "Unable to accept client connection - %s.", + cupsdLogMessage(L_ERROR, "Unable to accept client connection - %s.", strerror(errno)); return; } @@ -151,7 +151,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ if ((time(NULL) - last_dos) >= 60) { last_dos = time(NULL); - LogMessage(L_WARN, "Possible DoS attack - more than %d clients connecting from %s!", + cupsdLogMessage(L_WARN, "Possible DoS attack - more than %d clients connecting from %s!", MaxClientsPerHost, Clients[i].http.hostname); } @@ -202,7 +202,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ * Can't have an unresolved IP address with double-lookups enabled... */ - LogMessage(L_DEBUG2, "AcceptClient: Closing connection %d...", + cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient: Closing connection %d...", con->http.fd); #ifdef WIN32 @@ -211,7 +211,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ close(con->http.fd); #endif /* WIN32 */ - LogMessage(L_WARN, "Name lookup failed - connection from %s closed!", + cupsdLogMessage(L_WARN, "Name lookup failed - connection from %s closed!", con->http.hostname); return; } @@ -262,7 +262,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ * with double-lookups enabled... */ - LogMessage(L_DEBUG2, "AcceptClient: Closing connection %d...", + cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient: Closing connection %d...", con->http.fd); #ifdef WIN32 @@ -271,7 +271,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ close(con->http.fd); #endif /* WIN32 */ - LogMessage(L_WARN, "IP lookup failed - connection from %s closed!", + cupsdLogMessage(L_WARN, "IP lookup failed - connection from %s closed!", con->http.hostname); return; } @@ -279,11 +279,11 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ #ifdef AF_INET6 if (con->http.hostaddr.addr.sa_family == AF_INET6) - LogMessage(L_DEBUG, "AcceptClient: %d from %s:%d.", con->http.fd, + cupsdLogMessage(L_DEBUG, "cupsdAcceptClient: %d from %s:%d.", con->http.fd, con->http.hostname, ntohs(con->http.hostaddr.ipv6.sin6_port)); else #endif /* AF_INET6 */ - LogMessage(L_DEBUG, "AcceptClient: %d from %s:%d.", con->http.fd, + cupsdLogMessage(L_DEBUG, "cupsdAcceptClient: %d from %s:%d.", con->http.fd, con->http.hostname, ntohs(con->http.hostaddr.ipv4.sin_port)); /* @@ -293,7 +293,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ i = sizeof(temp); if (getsockname(con->http.fd, (struct sockaddr *)&temp, &i)) { - LogMessage(L_ERROR, "Unable to get local address - %s", strerror(errno)); + cupsdLogMessage(L_ERROR, "Unable to get local address - %s", strerror(errno)); strcpy(con->servername, "localhost"); con->serverport = LocalPort; @@ -320,7 +320,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ } } - LogMessage(L_DEBUG2, "AcceptClient: %d connected to server on %s:%d", + cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient: %d connected to server on %s:%d", con->http.fd, con->servername, con->serverport); /* * Using TCP_NODELAY improves responsiveness, especially on systems @@ -342,7 +342,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ * Add the socket to the select() input mask. */ - LogMessage(L_DEBUG2, "AcceptClient: Adding fd %d to InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient: Adding fd %d to InputSet...", con->http.fd); FD_SET(con->http.fd, InputSet); @@ -353,7 +353,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ */ if (NumClients == MaxClients) - PauseListening(); + cupsdPauseListening(); #ifdef HAVE_SSL /* @@ -368,7 +368,7 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ con->http.encryption = HTTP_ENCRYPT_ALWAYS; - EncryptClient(con); + cupsdEncryptClient(con); } else con->auto_ssl = 1; @@ -377,23 +377,23 @@ AcceptClient(listener_t *lis) /* I - Listener socket */ /* - * 'CloseAllClients()' - Close all remote clients immediately. + * 'cupsdCloseAllClients()' - Close all remote clients immediately. */ void -CloseAllClients(void) +cupsdCloseAllClients(void) { while (NumClients > 0) - CloseClient(Clients); + cupsdCloseClient(Clients); } /* - * 'CloseClient()' - Close a remote client. + * 'cupsdCloseClient()' - Close a remote client. */ int /* O - 1 if partial close, 0 if fully closed */ -CloseClient(client_t *con) /* I - Client to close */ +cupsdCloseClient(cupsd_client_t *con) /* I - Client to close */ { int partial; /* Do partial close for SSL? */ #if defined(HAVE_LIBSSL) @@ -410,7 +410,7 @@ CloseClient(client_t *con) /* I - Client to close */ #endif /* HAVE_LIBSSL */ - LogMessage(L_DEBUG, "CloseClient: %d", con->http.fd); + cupsdLogMessage(L_DEBUG, "cupsdCloseClient: %d", con->http.fd); /* * Flush pending writes before closing... @@ -436,13 +436,13 @@ CloseClient(client_t *con) /* I - Client to close */ switch (SSL_shutdown(conn)) { case 1 : - LogMessage(L_INFO, "CloseClient: SSL shutdown successful!"); + cupsdLogMessage(L_INFO, "cupsdCloseClient: SSL shutdown successful!"); break; case -1 : - LogMessage(L_ERROR, "CloseClient: Fatal error during SSL shutdown!"); + cupsdLogMessage(L_ERROR, "cupsdCloseClient: Fatal error during SSL shutdown!"); default : while ((error = ERR_get_error()) != 0) - LogMessage(L_ERROR, "CloseClient: %s", ERR_error_string(error, NULL)); + cupsdLogMessage(L_ERROR, "cupsdCloseClient: %s", ERR_error_string(error, NULL)); break; } @@ -457,10 +457,10 @@ CloseClient(client_t *con) /* I - Client to close */ switch (error) { case GNUTLS_E_SUCCESS: - LogMessage(L_INFO, "CloseClient: SSL shutdown successful!"); + cupsdLogMessage(L_INFO, "cupsdCloseClient: SSL shutdown successful!"); break; default: - LogMessage(L_ERROR, "CloseClient: %s", gnutls_strerror(error)); + cupsdLogMessage(L_ERROR, "cupsdCloseClient: %s", gnutls_strerror(error)); break; } @@ -484,7 +484,7 @@ CloseClient(client_t *con) /* I - Client to close */ * Stop any CGI process... */ - LogMessage(L_DEBUG2, "CloseClient: %d Killing process ID %d...", + cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: %d Killing process ID %d...", con->http.fd, con->pipe_pid); cupsdEndProcess(con->pipe_pid, 1); } @@ -493,12 +493,12 @@ CloseClient(client_t *con) /* I - Client to close */ { if (FD_ISSET(con->file, InputSet)) { - LogMessage(L_DEBUG2, "CloseClient: %d Removing fd %d from InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: %d Removing fd %d from InputSet...", con->http.fd, con->file); FD_CLR(con->file, InputSet); } - LogMessage(L_DEBUG2, "CloseClient: %d Closing data file %d.", + cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: %d Closing data file %d.", con->http.fd, con->file); close(con->file); @@ -517,7 +517,7 @@ CloseClient(client_t *con) /* I - Client to close */ * Only do a partial close so that the encrypted client gets everything. */ - LogMessage(L_DEBUG2, "CloseClient: Removing fd %d from OutputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: Removing fd %d from OutputSet...", con->http.fd); shutdown(con->http.fd, 0); FD_CLR(con->http.fd, OutputSet); @@ -528,7 +528,7 @@ CloseClient(client_t *con) /* I - Client to close */ * Shut the socket down fully... */ - LogMessage(L_DEBUG2, "CloseClient: Removing fd %d from InputSet and OutputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdCloseClient: Removing fd %d from InputSet and OutputSet...", con->http.fd); close(con->http.fd); FD_CLR(con->http.fd, InputSet); @@ -548,9 +548,9 @@ CloseClient(client_t *con) /* I - Client to close */ httpClearCookie(HTTP(con)); - ClearString(&con->filename); - ClearString(&con->command); - ClearString(&con->options); + cupsdClearString(&con->filename); + cupsdClearString(&con->command); + cupsdClearString(&con->options); if (con->request) { @@ -576,7 +576,7 @@ CloseClient(client_t *con) /* I - Client to close */ */ if (NumClients == MaxClients) - ResumeListening(); + cupsdResumeListening(); /* * Compact the list of clients as necessary... @@ -585,7 +585,7 @@ CloseClient(client_t *con) /* I - Client to close */ NumClients --; if (con < (Clients + NumClients)) - memmove(con, con + 1, (Clients + NumClients - con) * sizeof(client_t)); + memmove(con, con + 1, (Clients + NumClients - con) * sizeof(cupsd_client_t)); } return (partial); @@ -593,11 +593,11 @@ CloseClient(client_t *con) /* I - Client to close */ /* - * 'EncryptClient()' - Enable encryption for the client... + * 'cupsdEncryptClient()' - Enable encryption for the client... */ int /* O - 1 on success, 0 on error */ -EncryptClient(client_t *con) /* I - Client to encrypt */ +cupsdEncryptClient(cupsd_client_t *con) /* I - Client to encrypt */ { #if defined HAVE_LIBSSL SSL_CTX *context; /* Context for encryption */ @@ -620,18 +620,18 @@ EncryptClient(client_t *con) /* I - Client to encrypt */ SSL_set_fd(conn, con->http.fd); if (SSL_accept(conn) != 1) { - LogMessage(L_ERROR, "EncryptClient: Unable to encrypt connection from %s!", + cupsdLogMessage(L_ERROR, "cupsdEncryptClient: Unable to encrypt connection from %s!", con->http.hostname); while ((error = ERR_get_error()) != 0) - LogMessage(L_ERROR, "EncryptClient: %s", ERR_error_string(error, NULL)); + cupsdLogMessage(L_ERROR, "cupsdEncryptClient: %s", ERR_error_string(error, NULL)); SSL_CTX_free(context); SSL_free(conn); return (0); } - LogMessage(L_DEBUG, "EncryptClient: %d Connection from %s now encrypted.", + cupsdLogMessage(L_DEBUG, "cupsdEncryptClient: %d Connection from %s now encrypted.", con->http.fd, con->http.hostname); con->http.tls = conn; @@ -656,9 +656,9 @@ EncryptClient(client_t *con) /* I - Client to encrypt */ malloc(sizeof(gnutls_certificate_server_credentials)); if (credentials == NULL) { - LogMessage(L_ERROR, "EncryptClient: Unable to encrypt connection from %s!", + cupsdLogMessage(L_ERROR, "cupsdEncryptClient: Unable to encrypt connection from %s!", con->http.hostname); - LogMessage(L_ERROR, "EncryptClient: %s", strerror(errno)); + cupsdLogMessage(L_ERROR, "cupsdEncryptClient: %s", strerror(errno)); free(conn); return (0); @@ -677,9 +677,9 @@ EncryptClient(client_t *con) /* I - Client to encrypt */ if (error != GNUTLS_E_SUCCESS) { - LogMessage(L_ERROR, "EncryptClient: Unable to encrypt connection from %s!", + cupsdLogMessage(L_ERROR, "cupsdEncryptClient: Unable to encrypt connection from %s!", con->http.hostname); - LogMessage(L_ERROR, "EncryptClient: %s", gnutls_strerror(error)); + cupsdLogMessage(L_ERROR, "cupsdEncryptClient: %s", gnutls_strerror(error)); gnutls_deinit(conn->session); gnutls_certificate_free_credentials(*credentials); @@ -688,7 +688,7 @@ EncryptClient(client_t *con) /* I - Client to encrypt */ return (0); } - LogMessage(L_DEBUG, "EncryptClient: %d Connection from %s now encrypted.", + cupsdLogMessage(L_DEBUG, "cupsdEncryptClient: %d Connection from %s now encrypted.", con->http.fd, con->http.hostname); conn->credentials = credentials; @@ -749,10 +749,10 @@ EncryptClient(client_t *con) /* I - Client to encrypt */ if (error) { - LogMessage(L_ERROR, "EncryptClient: Unable to encrypt connection from %s!", + cupsdLogMessage(L_ERROR, "cupsdEncryptClient: Unable to encrypt connection from %s!", con->http.hostname); - LogMessage(L_ERROR, "EncryptClient: CDSA error code is %d", error); + cupsdLogMessage(L_ERROR, "cupsdEncryptClient: CDSA error code is %d", error); con->http.error = error; con->http.status = HTTP_ERROR; @@ -763,7 +763,7 @@ EncryptClient(client_t *con) /* I - Client to encrypt */ return (0); } - LogMessage(L_DEBUG, "EncryptClient: %d Connection from %s now encrypted.", + cupsdLogMessage(L_DEBUG, "cupsdEncryptClient: %d Connection from %s now encrypted.", con->http.fd, con->http.hostname); con->http.tls = conn; @@ -776,11 +776,11 @@ EncryptClient(client_t *con) /* I - Client to encrypt */ /* - * 'IsCGI()' - Is the resource a CGI script/program? + * 'cupsdIsCGI()' - Is the resource a CGI script/program? */ int /* O - 1 = CGI, 0 = file */ -IsCGI(client_t *con, /* I - Client connection */ +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 */ @@ -788,7 +788,7 @@ IsCGI(client_t *con, /* I - Client connection */ const char *options; /* Options on URL */ - LogMessage(L_DEBUG2, "IsCGI(con=%p, filename=\"%s\", filestats=%p, type=%s/%s)\n", + 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"); @@ -805,7 +805,7 @@ IsCGI(client_t *con, /* I - Client connection */ if (!type || strcasecmp(type->super, "application")) { - LogMessage(L_DEBUG2, "IsCGI: Returning 0..."); + cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 0..."); return (0); } @@ -816,16 +816,16 @@ IsCGI(client_t *con, /* I - Client connection */ * "application/x-httpd-cgi" is a CGI script. */ - SetString(&con->command, filename); + cupsdSetString(&con->command, filename); filename = strrchr(filename, '/') + 1; /* Filename always absolute */ if (options) - SetStringf(&con->options, "%s %s", filename, options); + cupsdSetStringf(&con->options, "%s %s", filename, options); else - SetStringf(&con->options, "%s", filename); + cupsdSetStringf(&con->options, "%s", filename); - LogMessage(L_DEBUG2, "IsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", + cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", con->command, con->options); return (1); @@ -837,14 +837,14 @@ IsCGI(client_t *con, /* I - Client connection */ * "application/x-httpd-java" is a Java servlet. */ - SetString(&con->command, CUPS_JAVA); + cupsdSetString(&con->command, CUPS_JAVA); if (options) - SetStringf(&con->options, "java %s %s", filename, options); + cupsdSetStringf(&con->options, "java %s %s", filename, options); else - SetStringf(&con->options, "java %s", filename); + cupsdSetStringf(&con->options, "java %s", filename); - LogMessage(L_DEBUG2, "IsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", + cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", con->command, con->options); return (1); @@ -857,14 +857,14 @@ IsCGI(client_t *con, /* I - Client connection */ * "application/x-httpd-perl" is a Perl page. */ - SetString(&con->command, CUPS_PERL); + cupsdSetString(&con->command, CUPS_PERL); if (options) - SetStringf(&con->options, "perl %s %s", filename, options); + cupsdSetStringf(&con->options, "perl %s %s", filename, options); else - SetStringf(&con->options, "perl %s", filename); + cupsdSetStringf(&con->options, "perl %s", filename); - LogMessage(L_DEBUG2, "IsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", + cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", con->command, con->options); return (1); @@ -877,14 +877,14 @@ IsCGI(client_t *con, /* I - Client connection */ * "application/x-httpd-php" is a PHP page. */ - SetString(&con->command, CUPS_PHP); + cupsdSetString(&con->command, CUPS_PHP); if (options) - SetStringf(&con->options, "php %s %s", filename, options); + cupsdSetStringf(&con->options, "php %s %s", filename, options); else - SetStringf(&con->options, "php %s", filename); + cupsdSetStringf(&con->options, "php %s", filename); - LogMessage(L_DEBUG2, "IsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", + cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", con->command, con->options); return (1); @@ -897,32 +897,32 @@ IsCGI(client_t *con, /* I - Client connection */ * "application/x-httpd-python" is a Python page. */ - SetString(&con->command, CUPS_PYTHON); + cupsdSetString(&con->command, CUPS_PYTHON); if (options) - SetStringf(&con->options, "python %s %s", filename, options); + cupsdSetStringf(&con->options, "python %s %s", filename, options); else - SetStringf(&con->options, "python %s", filename); + cupsdSetStringf(&con->options, "python %s", filename); - LogMessage(L_DEBUG2, "IsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", + cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 1 with command=\"%s\" and options=\"%s\"", con->command, con->options); return (1); } #endif /* HAVE_PYTHON */ - LogMessage(L_DEBUG2, "IsCGI: Returning 0..."); + cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 0..."); return (0); } /* - * 'ReadClient()' - Read data from a client. + * 'cupsdReadClient()' - Read data from a client. */ int /* O - 1 on success, 0 on error */ -ReadClient(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 */ @@ -937,19 +937,19 @@ ReadClient(client_t *con) /* I - Client to read from */ char buf[1024]; /* Buffer for real filename */ struct stat filestats; /* File information */ mime_type_t *type; /* MIME type of file */ - printer_t *p; /* Printer */ + cupsd_printer_t *p; /* Printer */ static unsigned request_id = 0; /* Request ID for temp files */ status = HTTP_CONTINUE; - LogMessage(L_DEBUG2, "ReadClient: %d, used=%d, file=%d", con->http.fd, + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d, used=%d, file=%d", con->http.fd, con->http.used, con->file); if (con->http.error) { - LogMessage(L_DEBUG2, "ReadClient: http error seen..."); - return (CloseClient(con)); + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: http error seen..."); + return (cupsdCloseClient(con)); } #ifdef HAVE_SSL @@ -968,10 +968,10 @@ ReadClient(client_t *con) /* I - Client to read from */ * Encrypt this connection... */ - LogMessage(L_DEBUG2, "ReadClient: Saw first byte %02X, auto-negotiating SSL/TLS session...", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: Saw first byte %02X, auto-negotiating SSL/TLS session...", buf[0] & 255); - EncryptClient(con); + cupsdEncryptClient(con); return (1); } } @@ -986,8 +986,8 @@ ReadClient(client_t *con) /* I - Client to read from */ if (httpGets(line, sizeof(line) - 1, HTTP(con)) == NULL) { - LogMessage(L_DEBUG2, "ReadClient: httpGets returned EOF..."); - return (CloseClient(con)); + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: httpGets returned EOF..."); + return (cupsdCloseClient(con)); } /* @@ -1017,8 +1017,8 @@ ReadClient(client_t *con) /* I - Client to read from */ con->password[0] = '\0'; con->uri[0] = '\0'; - ClearString(&con->command); - ClearString(&con->options); + cupsdClearString(&con->command); + cupsdClearString(&con->options); if (con->language != NULL) { @@ -1033,20 +1033,20 @@ ReadClient(client_t *con) /* I - Client to read from */ switch (sscanf(line, "%63s%1023s%63s", operation, con->uri, version)) { case 1 : - LogMessage(L_ERROR, "Bad request line \"%s\" from %s!", line, + cupsdLogMessage(L_ERROR, "Bad request line \"%s\" from %s!", line, con->http.hostname); - SendError(con, HTTP_BAD_REQUEST); - return (CloseClient(con)); + cupsdSendError(con, HTTP_BAD_REQUEST); + return (cupsdCloseClient(con)); case 2 : con->http.version = HTTP_0_9; break; case 3 : if (sscanf(version, "HTTP/%d.%d", &major, &minor) != 2) { - LogMessage(L_ERROR, "Bad request line \"%s\" from %s!", line, + cupsdLogMessage(L_ERROR, "Bad request line \"%s\" from %s!", line, con->http.hostname); - SendError(con, HTTP_BAD_REQUEST); - return (CloseClient(con)); + cupsdSendError(con, HTTP_BAD_REQUEST); + return (cupsdCloseClient(con)); } if (major < 2) @@ -1059,8 +1059,8 @@ ReadClient(client_t *con) /* I - Client to read from */ } else { - SendError(con, HTTP_NOT_SUPPORTED); - return (CloseClient(con)); + cupsdSendError(con, HTTP_NOT_SUPPORTED); + return (cupsdCloseClient(con)); } break; } @@ -1097,9 +1097,9 @@ ReadClient(client_t *con) /* I - Client to read from */ * Nope, we don't do proxies... */ - LogMessage(L_ERROR, "Bad URI \"%s\" in request!", con->uri); - SendError(con, HTTP_METHOD_NOT_ALLOWED); - return (CloseClient(con)); + cupsdLogMessage(L_ERROR, "Bad URI \"%s\" in request!", con->uri); + cupsdSendError(con, HTTP_METHOD_NOT_ALLOWED); + return (cupsdCloseClient(con)); } /* @@ -1130,15 +1130,15 @@ ReadClient(client_t *con) /* I - Client to read from */ con->http.state = HTTP_HEAD; else { - LogMessage(L_ERROR, "Bad operation \"%s\"!", operation); - SendError(con, HTTP_BAD_REQUEST); - return (CloseClient(con)); + cupsdLogMessage(L_ERROR, "Bad operation \"%s\"!", operation); + cupsdSendError(con, HTTP_BAD_REQUEST); + return (cupsdCloseClient(con)); } con->start = time(NULL); con->operation = con->http.state; - LogMessage(L_DEBUG, "ReadClient: %d %s %s HTTP/%d.%d", con->http.fd, + cupsdLogMessage(L_DEBUG, "cupsdReadClient: %d %s %s HTTP/%d.%d", con->http.fd, operation, con->uri, con->http.version / 100, con->http.version % 100); @@ -1159,8 +1159,8 @@ ReadClient(client_t *con) /* I - Client to read from */ if (status != HTTP_OK && status != HTTP_CONTINUE) { - SendError(con, HTTP_BAD_REQUEST); - return (CloseClient(con)); + cupsdSendError(con, HTTP_BAD_REQUEST); + return (cupsdCloseClient(con)); } break; @@ -1222,8 +1222,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * HTTP/1.1 and higher require the "Host:" field... */ - if (!SendError(con, HTTP_BAD_REQUEST)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_BAD_REQUEST)) + return (cupsdCloseClient(con)); } else if (con->operation == HTTP_OPTIONS) { @@ -1231,11 +1231,11 @@ ReadClient(client_t *con) /* I - Client to read from */ * Do OPTIONS command... */ - if ((con->best = FindBest(con->uri, con->http.state)) != NULL && + if ((con->best = cupsdFindBest(con->uri, con->http.state)) != NULL && con->best->type != AUTH_NONE) { - if (!SendHeader(con, HTTP_UNAUTHORIZED, NULL)) - return (CloseClient(con)); + if (!cupsdSendHeader(con, HTTP_UNAUTHORIZED, NULL)) + return (cupsdCloseClient(con)); } if (!strcasecmp(con->http.fields[HTTP_FIELD_CONNECTION], "Upgrade") && @@ -1246,18 +1246,18 @@ ReadClient(client_t *con) /* I - Client to read from */ * Do encryption stuff... */ - if (!SendHeader(con, HTTP_SWITCHING_PROTOCOLS, NULL)) - return (CloseClient(con)); + if (!cupsdSendHeader(con, HTTP_SWITCHING_PROTOCOLS, NULL)) + return (cupsdCloseClient(con)); httpPrintf(HTTP(con), "Connection: Upgrade\r\n"); httpPrintf(HTTP(con), "Upgrade: TLS/1.0,HTTP/1.1\r\n"); httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); - EncryptClient(con); + cupsdEncryptClient(con); #else - if (!SendError(con, HTTP_NOT_IMPLEMENTED)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_IMPLEMENTED)) + return (cupsdCloseClient(con)); #endif /* HAVE_SSL */ } @@ -1266,8 +1266,8 @@ ReadClient(client_t *con) /* I - Client to read from */ /**** TODO: send expected header ****/ } - if (!SendHeader(con, HTTP_OK, NULL)) - return (CloseClient(con)); + if (!cupsdSendHeader(con, HTTP_OK, NULL)) + return (cupsdCloseClient(con)); httpPrintf(HTTP(con), "Allow: GET, HEAD, OPTIONS, POST, PUT\r\n"); httpPrintf(HTTP(con), "Content-Length: 0\r\n"); @@ -1279,8 +1279,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * Protect against malicious users! */ - if (!SendError(con, HTTP_FORBIDDEN)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_FORBIDDEN)) + return (cupsdCloseClient(con)); } else { @@ -1292,29 +1292,29 @@ ReadClient(client_t *con) /* I - Client to read from */ * Do encryption stuff... */ - if (!SendHeader(con, HTTP_SWITCHING_PROTOCOLS, NULL)) - return (CloseClient(con)); + if (!cupsdSendHeader(con, HTTP_SWITCHING_PROTOCOLS, NULL)) + return (cupsdCloseClient(con)); httpPrintf(HTTP(con), "Connection: Upgrade\r\n"); httpPrintf(HTTP(con), "Upgrade: TLS/1.0,HTTP/1.1\r\n"); httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); - EncryptClient(con); + cupsdEncryptClient(con); #else - if (!SendError(con, HTTP_NOT_IMPLEMENTED)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_IMPLEMENTED)) + return (cupsdCloseClient(con)); #endif /* HAVE_SSL */ } - con->best = FindBest(con->uri, con->http.state); + con->best = cupsdFindBest(con->uri, con->http.state); if ((status = cupsdIsAuthorized(con, NULL)) != HTTP_OK) { - LogMessage(L_DEBUG2, "ReadClient: Unauthorized request for %s...\n", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: Unauthorized request for %s...\n", con->uri); - SendError(con, status); - return (CloseClient(con)); + cupsdSendError(con, status); + return (cupsdCloseClient(con)); } if (con->http.expect) @@ -1335,12 +1335,12 @@ ReadClient(client_t *con) /* I - Client to read from */ con->uri[strlen(con->uri) - 4] = '\0'; /* Drop ".ppd" */ - if ((p = FindPrinter(con->uri + 10)) != NULL) + if ((p = cupsdFindPrinter(con->uri + 10)) != NULL) snprintf(con->uri, sizeof(con->uri), "/ppd/%s.ppd", p->name); else { - if (!SendError(con, HTTP_NOT_FOUND)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_FOUND)) + return (cupsdCloseClient(con)); break; } @@ -1360,44 +1360,44 @@ ReadClient(client_t *con) /* I - Client to read from */ if (!strncmp(con->uri, "/admin", 6)) { - SetStringf(&con->command, "%s/cgi-bin/admin.cgi", ServerBin); + cupsdSetStringf(&con->command, "%s/cgi-bin/admin.cgi", ServerBin); if ((ptr = strchr(con->uri + 6, '?')) != NULL) - SetStringf(&con->options, "admin%s", ptr); + cupsdSetStringf(&con->options, "admin%s", ptr); else - SetString(&con->options, "admin"); + cupsdSetString(&con->options, "admin"); } else if (!strncmp(con->uri, "/printers", 9)) { - SetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin); - SetString(&con->options, con->uri + 9); + cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin); + cupsdSetString(&con->options, con->uri + 9); } else if (!strncmp(con->uri, "/classes", 8)) { - SetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin); - SetString(&con->options, con->uri + 8); + cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin); + cupsdSetString(&con->options, con->uri + 8); } else if (!strncmp(con->uri, "/jobs", 5)) { - SetStringf(&con->command, "%s/cgi-bin/jobs.cgi", ServerBin); - SetString(&con->options, con->uri + 5); + cupsdSetStringf(&con->command, "%s/cgi-bin/jobs.cgi", ServerBin); + cupsdSetString(&con->options, con->uri + 5); } else { - SetStringf(&con->command, "%s/cgi-bin/help.cgi", ServerBin); - SetString(&con->options, con->uri + 5); + 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); - if (!SendCommand(con, con->command, con->options, 0)) + if (!cupsdSendCommand(con, con->command, con->options, 0)) { - if (!SendError(con, HTTP_NOT_FOUND)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_FOUND)) + return (cupsdCloseClient(con)); } else - LogRequest(con, HTTP_OK); + cupsdLogRequest(con, HTTP_OK); if (con->http.version <= HTTP_1_0) con->http.keep_alive = HTTP_KEEPALIVE_OFF; @@ -1414,8 +1414,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * /admin/conf... */ - if (!SendError(con, HTTP_FORBIDDEN)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_FORBIDDEN)) + return (cupsdCloseClient(con)); break; } @@ -1428,28 +1428,28 @@ ReadClient(client_t *con) /* I - Client to read from */ if ((filename = get_file(con, &filestats, buf, sizeof(buf))) == NULL) { - if (!SendError(con, HTTP_NOT_FOUND)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_FOUND)) + return (cupsdCloseClient(con)); break; } type = mimeFileType(MimeDatabase, filename, NULL); - if (IsCGI(con, filename, &filestats, type)) + if (cupsdIsCGI(con, filename, &filestats, type)) { /* * Note: con->command and con->options were set by - * IsCGI()... + * cupsdIsCGI()... */ - if (!SendCommand(con, con->command, con->options, 0)) + if (!cupsdSendCommand(con, con->command, con->options, 0)) { - if (!SendError(con, HTTP_NOT_FOUND)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_FOUND)) + return (cupsdCloseClient(con)); } else - LogRequest(con, HTTP_OK); + cupsdLogRequest(con, HTTP_OK); if (con->http.version <= HTTP_1_0) con->http.keep_alive = HTTP_KEEPALIVE_OFF; @@ -1458,8 +1458,8 @@ ReadClient(client_t *con) /* I - Client to read from */ if (!check_if_modified(con, &filestats)) { - if (!SendError(con, HTTP_NOT_MODIFIED)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_MODIFIED)) + return (cupsdCloseClient(con)); } else { @@ -1468,8 +1468,8 @@ ReadClient(client_t *con) /* I - Client to read from */ else snprintf(line, sizeof(line), "%s/%s", type->super, type->type); - if (!SendFile(con, HTTP_OK, filename, line, &filestats)) - return (CloseClient(con)); + if (!cupsdSendFile(con, HTTP_OK, filename, line, &filestats)) + return (cupsdCloseClient(con)); } } break; @@ -1480,8 +1480,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * so check the length against any limits that are set... */ - LogMessage(L_DEBUG2, "POST %s", con->uri); - LogMessage(L_DEBUG2, "CONTENT_TYPE = %s", con->http.fields[HTTP_FIELD_CONTENT_TYPE]); + cupsdLogMessage(L_DEBUG2, "POST %s", con->uri); + cupsdLogMessage(L_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 && @@ -1491,8 +1491,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * Request too large... */ - if (!SendError(con, HTTP_REQUEST_TOO_LARGE)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE)) + return (cupsdCloseClient(con)); break; } @@ -1502,8 +1502,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * Negative content lengths are invalid! */ - if (!SendError(con, HTTP_BAD_REQUEST)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_BAD_REQUEST)) + return (cupsdCloseClient(con)); break; } @@ -1529,38 +1529,38 @@ ReadClient(client_t *con) /* I - Client to read from */ if (!strncmp(con->uri, "/admin", 6)) { - SetStringf(&con->command, "%s/cgi-bin/admin.cgi", ServerBin); + cupsdSetStringf(&con->command, "%s/cgi-bin/admin.cgi", ServerBin); if ((ptr = strchr(con->uri + 6, '?')) != NULL) - SetStringf(&con->options, "admin%s", ptr); + cupsdSetStringf(&con->options, "admin%s", ptr); else - SetString(&con->options, "admin"); + cupsdSetString(&con->options, "admin"); } else if (!strncmp(con->uri, "/printers", 9)) { - SetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin); - SetString(&con->options, con->uri + 9); + cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin); + cupsdSetString(&con->options, con->uri + 9); } else if (!strncmp(con->uri, "/classes", 8)) { - SetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin); - SetString(&con->options, con->uri + 8); + cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin); + cupsdSetString(&con->options, con->uri + 8); } else if (!strncmp(con->uri, "/jobs", 5)) { - SetStringf(&con->command, "%s/cgi-bin/jobs.cgi", ServerBin); - SetString(&con->options, con->uri + 5); + cupsdSetStringf(&con->command, "%s/cgi-bin/jobs.cgi", ServerBin); + cupsdSetString(&con->options, con->uri + 5); } else { - SetStringf(&con->command, "%s/cgi-bin/help.cgi", ServerBin); - SetString(&con->options, con->uri + 5); + 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); - LogMessage(L_DEBUG2, "ReadClient: %d command=\"%s\", options = \"%s\"", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d command=\"%s\", options = \"%s\"", con->http.fd, con->command, con->options); if (con->http.version <= HTTP_1_0) @@ -1575,22 +1575,22 @@ ReadClient(client_t *con) /* I - Client to read from */ if ((filename = get_file(con, &filestats, buf, sizeof(buf))) == NULL) { - if (!SendError(con, HTTP_NOT_FOUND)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_FOUND)) + return (cupsdCloseClient(con)); break; } type = mimeFileType(MimeDatabase, filename, NULL); - if (!IsCGI(con, filename, &filestats, type)) + if (!cupsdIsCGI(con, filename, &filestats, type)) { /* * Only POST to CGI's... */ - if (!SendError(con, HTTP_UNAUTHORIZED)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_UNAUTHORIZED)) + return (cupsdCloseClient(con)); } } break; @@ -1609,8 +1609,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * /admin/conf... */ - if (!SendError(con, HTTP_FORBIDDEN)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_FORBIDDEN)) + return (cupsdCloseClient(con)); break; } @@ -1620,8 +1620,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * so check the length against any limits that are set... */ - LogMessage(L_DEBUG2, "PUT %s", con->uri); - LogMessage(L_DEBUG2, "CONTENT_TYPE = %s", con->http.fields[HTTP_FIELD_CONTENT_TYPE]); + cupsdLogMessage(L_DEBUG2, "PUT %s", con->uri); + cupsdLogMessage(L_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 && @@ -1631,8 +1631,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * Request too large... */ - if (!SendError(con, HTTP_REQUEST_TOO_LARGE)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE)) + return (cupsdCloseClient(con)); break; } @@ -1642,8 +1642,8 @@ ReadClient(client_t *con) /* I - Client to read from */ * Negative content lengths are invalid! */ - if (!SendError(con, HTTP_BAD_REQUEST)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_BAD_REQUEST)) + return (cupsdCloseClient(con)); break; } @@ -1652,16 +1652,16 @@ ReadClient(client_t *con) /* I - Client to read from */ * Open a temporary file to hold the request... */ - SetStringf(&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); - LogMessage(L_DEBUG2, "ReadClient: %d REQUEST %s=%d", con->http.fd, + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d REQUEST %s=%d", con->http.fd, con->filename, con->file); if (con->file < 0) { - if (!SendError(con, HTTP_REQUEST_TOO_LARGE)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE)) + return (cupsdCloseClient(con)); } fchmod(con->file, 0640); @@ -1671,8 +1671,8 @@ ReadClient(client_t *con) /* I - Client to read from */ case HTTP_DELETE : case HTTP_TRACE : - SendError(con, HTTP_NOT_IMPLEMENTED); - return (CloseClient(con)); + cupsdSendError(con, HTTP_NOT_IMPLEMENTED); + return (cupsdCloseClient(con)); case HTTP_HEAD : if (!strncmp(con->uri, "/printers/", 10) && @@ -1685,12 +1685,12 @@ ReadClient(client_t *con) /* I - Client to read from */ con->uri[strlen(con->uri) - 4] = '\0'; /* Drop ".ppd" */ - if ((p = FindPrinter(con->uri + 10)) != NULL) + if ((p = cupsdFindPrinter(con->uri + 10)) != NULL) snprintf(con->uri, sizeof(con->uri), "/ppd/%s.ppd", p->name); else { - if (!SendError(con, HTTP_NOT_FOUND)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_FOUND)) + return (cupsdCloseClient(con)); break; } @@ -1708,13 +1708,13 @@ ReadClient(client_t *con) /* I - Client to read from */ * CGI output... */ - if (!SendHeader(con, HTTP_OK, "text/html")) - return (CloseClient(con)); + if (!cupsdSendHeader(con, HTTP_OK, "text/html")) + return (cupsdCloseClient(con)); if (httpPrintf(HTTP(con), "\r\n") < 0) - return (CloseClient(con)); + return (cupsdCloseClient(con)); - LogRequest(con, HTTP_OK); + cupsdLogRequest(con, HTTP_OK); } else if ((!strncmp(con->uri, "/admin/conf/", 12) && (strchr(con->uri + 12, '/') || @@ -1728,25 +1728,25 @@ ReadClient(client_t *con) /* I - Client to read from */ * /admin/conf... */ - if (!SendError(con, HTTP_FORBIDDEN)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_FORBIDDEN)) + return (cupsdCloseClient(con)); break; } else if ((filename = get_file(con, &filestats, buf, sizeof(buf))) == NULL) { - if (!SendHeader(con, HTTP_NOT_FOUND, "text/html")) - return (CloseClient(con)); + if (!cupsdSendHeader(con, HTTP_NOT_FOUND, "text/html")) + return (cupsdCloseClient(con)); - LogRequest(con, HTTP_NOT_FOUND); + cupsdLogRequest(con, HTTP_NOT_FOUND); } else if (!check_if_modified(con, &filestats)) { - if (!SendError(con, HTTP_NOT_MODIFIED)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_MODIFIED)) + return (cupsdCloseClient(con)); - LogRequest(con, HTTP_NOT_MODIFIED); + cupsdLogRequest(con, HTTP_NOT_MODIFIED); } else { @@ -1760,22 +1760,22 @@ ReadClient(client_t *con) /* I - Client to read from */ else snprintf(line, sizeof(line), "%s/%s", type->super, type->type); - if (!SendHeader(con, HTTP_OK, line)) - return (CloseClient(con)); + if (!cupsdSendHeader(con, HTTP_OK, line)) + return (cupsdCloseClient(con)); if (httpPrintf(HTTP(con), "Last-Modified: %s\r\n", httpGetDateString(filestats.st_mtime)) < 0) - return (CloseClient(con)); + return (cupsdCloseClient(con)); if (httpPrintf(HTTP(con), "Content-Length: %lu\r\n", (unsigned long)filestats.st_size) < 0) - return (CloseClient(con)); + return (cupsdCloseClient(con)); - LogRequest(con, HTTP_OK); + cupsdLogRequest(con, HTTP_OK); } if (httpPrintf(HTTP(con), "\r\n") < 0) - return (CloseClient(con)); + return (cupsdCloseClient(con)); con->http.state = HTTP_WAITING; break; @@ -1793,35 +1793,35 @@ ReadClient(client_t *con) /* I - Client to read from */ switch (con->http.state) { case HTTP_PUT_RECV : - LogMessage(L_DEBUG2, "ReadClient: %d con->data_encoding = %s, con->data_remaining = %d, con->file = %d", + 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); if ((bytes = httpRead(HTTP(con), line, sizeof(line))) < 0) - return (CloseClient(con)); + return (cupsdCloseClient(con)); else if (bytes > 0) { con->bytes += bytes; - LogMessage(L_DEBUG2, "ReadClient: %d writing %d bytes to %d", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d writing %d bytes to %d", con->http.fd, bytes, con->file); if (write(con->file, line, bytes) < bytes) { - LogMessage(L_ERROR, "ReadClient: Unable to write %d bytes to %s: %s", + cupsdLogMessage(L_ERROR, "cupsdReadClient: Unable to write %d bytes to %s: %s", bytes, con->filename, strerror(errno)); - LogMessage(L_DEBUG2, "ReadClient: Closing data file %d...", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: Closing data file %d...", con->file); close(con->file); con->file = -1; unlink(con->filename); - ClearString(&con->filename); + cupsdClearString(&con->filename); - if (!SendError(con, HTTP_REQUEST_TOO_LARGE)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE)) + return (cupsdCloseClient(con)); } } @@ -1833,7 +1833,7 @@ ReadClient(client_t *con) /* I - Client to read from */ fstat(con->file, &filestats); - LogMessage(L_DEBUG2, "ReadClient: %d Closing data file %d, size = %d.", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d Closing data file %d, size = %d.", con->http.fd, con->file, (int)filestats.st_size); close(con->file); @@ -1846,13 +1846,13 @@ ReadClient(client_t *con) /* I - Client to read from */ * Request is too big; remove it and send an error... */ - LogMessage(L_DEBUG2, "ReadClient: %d Removing temp file %s", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d Removing temp file %s", con->http.fd, con->filename); unlink(con->filename); - ClearString(&con->filename); + cupsdClearString(&con->filename); - if (!SendError(con, HTTP_REQUEST_TOO_LARGE)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE)) + return (cupsdCloseClient(con)); } /* @@ -1865,13 +1865,13 @@ ReadClient(client_t *con) /* I - Client to read from */ * Return the status to the client... */ - if (!SendError(con, status)) - return (CloseClient(con)); + if (!cupsdSendError(con, status)) + return (cupsdCloseClient(con)); } break; case HTTP_POST_RECV : - LogMessage(L_DEBUG2, "ReadClient: %d con->data_encoding = %s, con->data_remaining = %d, con->file = %d", + 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); @@ -1884,18 +1884,18 @@ ReadClient(client_t *con) /* I - Client to read from */ if ((ipp_state = ippRead(&(con->http), con->request)) == IPP_ERROR) { - LogMessage(L_ERROR, "ReadClient: %d IPP Read Error!", + cupsdLogMessage(L_ERROR, "cupsdReadClient: %d IPP Read Error!", con->http.fd); - SendError(con, HTTP_BAD_REQUEST); - return (CloseClient(con)); + cupsdSendError(con, HTTP_BAD_REQUEST); + return (cupsdCloseClient(con)); } else if (ipp_state != IPP_DATA) { if (con->http.state == HTTP_POST_SEND) { - SendError(con, HTTP_BAD_REQUEST); - return (CloseClient(con)); + cupsdSendError(con, HTTP_BAD_REQUEST); + return (cupsdCloseClient(con)); } break; @@ -1910,16 +1910,16 @@ ReadClient(client_t *con) /* I - Client to read from */ * Create a file as needed for the request data... */ - SetStringf(&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); - LogMessage(L_DEBUG2, "ReadClient: %d REQUEST %s=%d", con->http.fd, + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d REQUEST %s=%d", con->http.fd, con->filename, con->file); if (con->file < 0) { - if (!SendError(con, HTTP_REQUEST_TOO_LARGE)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE)) + return (cupsdCloseClient(con)); } fchmod(con->file, 0640); @@ -1930,35 +1930,35 @@ ReadClient(client_t *con) /* I - Client to read from */ if (con->http.state != HTTP_POST_SEND) { if ((bytes = httpRead(HTTP(con), line, sizeof(line))) < 0) - return (CloseClient(con)); + return (cupsdCloseClient(con)); else if (bytes > 0) { con->bytes += bytes; - LogMessage(L_DEBUG2, "ReadClient: %d writing %d bytes to %d", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d writing %d bytes to %d", con->http.fd, bytes, con->file); if (write(con->file, line, bytes) < bytes) { - LogMessage(L_ERROR, "ReadClient: Unable to write %d bytes to %s: %s", + cupsdLogMessage(L_ERROR, "cupsdReadClient: Unable to write %d bytes to %s: %s", bytes, con->filename, strerror(errno)); - LogMessage(L_DEBUG2, "ReadClient: Closing file %d...", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: Closing file %d...", con->file); close(con->file); con->file = -1; unlink(con->filename); - ClearString(&con->filename); + cupsdClearString(&con->filename); - if (!SendError(con, HTTP_REQUEST_TOO_LARGE)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE)) + return (cupsdCloseClient(con)); } } else if (con->http.state == HTTP_POST_RECV) return (1); /* ??? */ else if (con->http.state != HTTP_POST_SEND) - return (CloseClient(con)); + return (cupsdCloseClient(con)); } if (con->http.state == HTTP_POST_SEND) @@ -1967,7 +1967,7 @@ ReadClient(client_t *con) /* I - Client to read from */ { fstat(con->file, &filestats); - LogMessage(L_DEBUG2, "ReadClient: %d Closing data file %d, size = %d.", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d Closing data file %d, size = %d.", con->http.fd, con->file, (int)filestats.st_size); close(con->file); @@ -1980,10 +1980,10 @@ ReadClient(client_t *con) /* I - Client to read from */ * Request is too big; remove it and send an error... */ - LogMessage(L_DEBUG2, "ReadClient: %d Removing temp file %s", + cupsdLogMessage(L_DEBUG2, "cupsdReadClient: %d Removing temp file %s", con->http.fd, con->filename); unlink(con->filename); - ClearString(&con->filename); + cupsdClearString(&con->filename); if (con->request) { @@ -1995,24 +1995,24 @@ ReadClient(client_t *con) /* I - Client to read from */ con->request = NULL; } - if (!SendError(con, HTTP_REQUEST_TOO_LARGE)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE)) + return (cupsdCloseClient(con)); } if (con->command) { - if (!SendCommand(con, con->command, con->options, 0)) + if (!cupsdSendCommand(con, con->command, con->options, 0)) { - if (!SendError(con, HTTP_NOT_FOUND)) - return (CloseClient(con)); + if (!cupsdSendError(con, HTTP_NOT_FOUND)) + return (cupsdCloseClient(con)); } else - LogRequest(con, HTTP_OK); + cupsdLogRequest(con, HTTP_OK); } } if (con->request) - return (ProcessIPPRequest(con)); + return (cupsdProcessIPPRequest(con)); } break; @@ -2021,18 +2021,18 @@ ReadClient(client_t *con) /* I - Client to read from */ } if (!con->http.keep_alive && con->http.state == HTTP_WAITING) - return (CloseClient(con)); + return (cupsdCloseClient(con)); else return (1); } /* - * 'SendCommand()' - Send output from a command via HTTP. + * 'cupsdSendCommand()' - Send output from a command via HTTP. */ int /* O - 1 on success, 0 on failure */ -SendCommand(client_t *con, /* I - Client connection */ +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? */ @@ -2047,7 +2047,7 @@ SendCommand(client_t *con, /* I - Client connection */ if (fd < 0) { - LogMessage(L_ERROR, "SendCommand: %d Unable to open \"%s\" for reading: %s", + cupsdLogMessage(L_ERROR, "cupsdSendCommand: %d Unable to open \"%s\" for reading: %s", con->http.fd, con->filename ? con->filename : "/dev/null", strerror(errno)); return (0); @@ -2059,17 +2059,17 @@ SendCommand(client_t *con, /* I - Client connection */ close(fd); - LogMessage(L_INFO, "Started \"%s\" (pid=%d)", command, con->pipe_pid); + cupsdLogMessage(L_INFO, "Started \"%s\" (pid=%d)", command, con->pipe_pid); - LogMessage(L_DEBUG, "SendCommand: %d file=%d", con->http.fd, con->file); + cupsdLogMessage(L_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); - LogMessage(L_DEBUG2, "SendCommand: Adding fd %d to InputSet...", con->file); - LogMessage(L_DEBUG2, "SendCommand: Adding fd %d to OutputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdSendCommand: Adding fd %d to InputSet...", con->file); + cupsdLogMessage(L_DEBUG2, "cupsdSendCommand: Adding fd %d to OutputSet...", con->http.fd); FD_SET(con->file, InputSet); @@ -2085,11 +2085,11 @@ SendCommand(client_t *con, /* I - Client connection */ /* - * 'SendError()' - Send an error message via HTTP. + * 'cupsdSendError()' - Send an error message via HTTP. */ int /* O - 1 if successful, 0 otherwise */ -SendError(client_t *con, /* I - Connection */ +cupsdSendError(cupsd_client_t *con, /* I - Connection */ http_status_t code) /* I - Error code */ { char message[1024]; /* Message for user */ @@ -2099,9 +2099,9 @@ SendError(client_t *con, /* I - Connection */ * Put the request in the access_log file... */ - LogRequest(con, code); + cupsdLogRequest(con, code); - LogMessage(L_DEBUG, "SendError: %d code=%d (%s)", con->http.fd, code, + cupsdLogMessage(L_DEBUG, "cupsdSendError: %d code=%d (%s)", con->http.fd, code, httpStatus(code)); /* @@ -2117,7 +2117,7 @@ SendError(client_t *con, /* I - Connection */ * 400 or 500 series, make sure the message contains some text, too! */ - if (!SendHeader(con, code, NULL)) + if (!cupsdSendHeader(con, code, NULL)) return (0); #ifdef HAVE_SSL @@ -2169,11 +2169,11 @@ SendError(client_t *con, /* I - Connection */ /* - * 'SendFile()' - Send a file via HTTP. + * 'cupsdSendFile()' - Send a file via HTTP. */ int -SendFile(client_t *con, +cupsdSendFile(cupsd_client_t *con, http_status_t code, char *filename, char *type, @@ -2181,7 +2181,7 @@ SendFile(client_t *con, { con->file = open(filename, O_RDONLY); - LogMessage(L_DEBUG, "SendFile: %d file=%d", con->http.fd, con->file); + cupsdLogMessage(L_DEBUG, "cupsdSendFile: %d file=%d", con->http.fd, con->file); if (con->file < 0) return (0); @@ -2190,7 +2190,7 @@ SendFile(client_t *con, con->pipe_pid = 0; - if (!SendHeader(con, code, type)) + if (!cupsdSendHeader(con, code, type)) return (0); if (httpPrintf(HTTP(con), "Last-Modified: %s\r\n", httpGetDateString(filestats->st_mtime)) < 0) @@ -2201,7 +2201,7 @@ SendFile(client_t *con, if (httpPrintf(HTTP(con), "\r\n") < 0) return (0); - LogMessage(L_DEBUG2, "SendFile: Adding fd %d to OutputSet...", con->http.fd); + cupsdLogMessage(L_DEBUG2, "cupsdSendFile: Adding fd %d to OutputSet...", con->http.fd); FD_SET(con->http.fd, OutputSet); @@ -2210,11 +2210,11 @@ SendFile(client_t *con, /* - * 'SendHeader()' - Send an HTTP request. + * 'cupsdSendHeader()' - Send an HTTP request. */ int /* O - 1 on success, 0 on failure */ -SendHeader(client_t *con, /* I - Client to send to */ +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 */ { @@ -2283,11 +2283,11 @@ SendHeader(client_t *con, /* I - Client to send to */ /* - * 'UpdateCGI()' - Read status messages from CGI scripts and programs. + * 'cupsdUpdateCGI()' - Read status messages from CGI scripts and programs. */ void -UpdateCGI(void) +cupsdUpdateCGI(void) { char *ptr, /* Pointer to end of line in buffer */ message[1024]; /* Pointer to message text */ @@ -2305,18 +2305,18 @@ UpdateCGI(void) * Fatal error on pipe - should never happen! */ - LogMessage(L_CRIT, "UpdateCGI: error reading from CGI error pipe - %s", + cupsdLogMessage(L_CRIT, "cupsdUpdateCGI: error reading from CGI error pipe - %s", strerror(errno)); } } /* - * 'WriteClient()' - Write data to a client as needed. + * 'cupsdWriteClient()' - Write data to a client as needed. */ int /* O - 1 if success, 0 if fail */ -WriteClient(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 */ @@ -2325,7 +2325,7 @@ WriteClient(client_t *con) /* I - Client connection */ #ifdef DEBUG - LogMessage(L_DEBUG2, "WriteClient(con=%p) %d response=%p, file=%d pipe_pid=%d", + 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); #endif /* DEBUG */ @@ -2340,7 +2340,7 @@ WriteClient(client_t *con) /* I - Client connection */ } else if ((bytes = read(con->file, buf, sizeof(buf) - 1)) > 0) { - LogMessage(L_DEBUG2, "WriteClient: Read %d bytes from file %d...", + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: Read %d bytes from file %d...", bytes, con->file); if (con->pipe_pid && !con->got_fields) @@ -2362,7 +2362,7 @@ WriteClient(client_t *con) /* I - Client connection */ bufptr[-1] = '\0'; *bufptr++ = '\0'; - LogMessage(L_DEBUG2, "Script header: %s", buf); + cupsdLogMessage(L_DEBUG2, "Script header: %s", buf); if (!con->sent_header) { @@ -2371,11 +2371,11 @@ WriteClient(client_t *con) /* I - Client connection */ */ if (!strncasecmp(buf, "Location:", 9)) - SendHeader(con, HTTP_SEE_OTHER, NULL); + cupsdSendHeader(con, HTTP_SEE_OTHER, NULL); else if (!strncasecmp(buf, "Status:", 7)) - SendHeader(con, atoi(buf + 7), NULL); + cupsdSendHeader(con, atoi(buf + 7), NULL); else - SendHeader(con, HTTP_OK, NULL); + cupsdSendHeader(con, HTTP_OK, NULL); if (con->http.version == HTTP_1_1) { @@ -2391,7 +2391,7 @@ WriteClient(client_t *con) /* I - Client connection */ if (strncasecmp(buf, "Status:", 7)) httpPrintf(HTTP(con), "%s\r\n", buf); - LogMessage(L_DEBUG2, "WriteClient: %d %s", con->http.fd, buf); + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d %s", con->http.fd, buf); /* * Update buffer... @@ -2413,7 +2413,7 @@ WriteClient(client_t *con) /* I - Client connection */ else if (*bufptr != '\r') con->field_col ++; - LogMessage(L_DEBUG2, "WriteClient: %d bytes=%d, got_fields=%d", + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d bytes=%d, got_fields=%d", con->http.fd, bytes, con->got_fields); if (bytes > 0 && !con->got_fields) @@ -2436,10 +2436,10 @@ WriteClient(client_t *con) /* I - Client connection */ if (httpWrite(HTTP(con), buf, bytes) < 0) { - LogMessage(L_DEBUG2, "WriteClient: %d Write of %d bytes failed!", + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d Write of %d bytes failed!", con->http.fd, bytes); - CloseClient(con); + cupsdCloseClient(con); return (0); } @@ -2448,9 +2448,9 @@ WriteClient(client_t *con) /* I - Client connection */ if (bytes <= 0) { - LogMessage(L_DEBUG2, "WriteClient: %d bytes < 0", con->http.fd); + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d bytes < 0", con->http.fd); - LogRequest(con, HTTP_OK); + cupsdLogRequest(con, HTTP_OK); httpFlushWrite(HTTP(con)); @@ -2458,14 +2458,14 @@ WriteClient(client_t *con) /* I - Client connection */ { if (httpPrintf(HTTP(con), "0\r\n\r\n") < 0) { - CloseClient(con); + cupsdCloseClient(con); return (0); } } con->http.state = HTTP_WAITING; - LogMessage(L_DEBUG2, "WriteClient: Removing fd %d from OutputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: Removing fd %d from OutputSet...", con->http.fd); FD_CLR(con->http.fd, OutputSet); @@ -2474,7 +2474,7 @@ WriteClient(client_t *con) /* I - Client connection */ { if (FD_ISSET(con->file, InputSet)) { - LogMessage(L_DEBUG2, "WriteClient: Removing fd %d from InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: Removing fd %d from InputSet...", con->file); FD_CLR(con->file, InputSet); } @@ -2482,7 +2482,7 @@ WriteClient(client_t *con) /* I - Client connection */ if (con->pipe_pid) cupsdEndProcess(con->pipe_pid, 0); - LogMessage(L_DEBUG2, "WriteClient: %d Closing data file %d.", + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d Closing data file %d.", con->http.fd, con->file); close(con->file); @@ -2492,10 +2492,10 @@ WriteClient(client_t *con) /* I - Client connection */ if (con->filename) { - LogMessage(L_DEBUG2, "WriteClient: %d Removing temp file %s", + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: %d Removing temp file %s", con->http.fd, con->filename); unlink(con->filename); - ClearString(&con->filename); + cupsdClearString(&con->filename); } if (con->request != NULL) @@ -2510,12 +2510,12 @@ WriteClient(client_t *con) /* I - Client connection */ con->response = NULL; } - ClearString(&con->command); - ClearString(&con->options); + cupsdClearString(&con->command); + cupsdClearString(&con->options); if (!con->http.keep_alive) { - CloseClient(con); + cupsdCloseClient(con); return (0); } } @@ -2525,7 +2525,7 @@ WriteClient(client_t *con) /* I - Client connection */ if (con->pipe_pid && !FD_ISSET(con->file, InputSet)) { - LogMessage(L_DEBUG2, "WriteClient: Adding fd %d to InputSet...", con->file); + cupsdLogMessage(L_DEBUG2, "cupsdWriteClient: Adding fd %d to InputSet...", con->file); FD_SET(con->file, InputSet); } } @@ -2541,7 +2541,7 @@ WriteClient(client_t *con) /* I - Client connection */ */ static int /* O - 1 if modified since */ -check_if_modified(client_t *con, /* I - Client connection */ +check_if_modified(cupsd_client_t *con, /* I - Client connection */ struct stat *filestats) /* I - File information */ { char *ptr; /* Pointer into field */ @@ -2556,7 +2556,7 @@ check_if_modified(client_t *con, /* I - Client connection */ if (*ptr == '\0') return (1); - LogMessage(L_DEBUG2, "check_if_modified: %d If-Modified-Since=\"%s\"", + cupsdLogMessage(L_DEBUG2, "check_if_modified: %d If-Modified-Since=\"%s\"", con->http.fd, ptr); while (*ptr != '\0') @@ -2580,7 +2580,7 @@ check_if_modified(client_t *con, /* I - Client connection */ } } - LogMessage(L_DEBUG2, "check_if_modified: %d sizes=%d,%d dates=%d,%d", + 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); @@ -2595,7 +2595,7 @@ check_if_modified(client_t *con, /* I - Client connection */ */ static void -decode_auth(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 */ @@ -2608,7 +2608,7 @@ decode_auth(client_t *con) /* I - Client to decode to */ s = con->http.fields[HTTP_FIELD_AUTHORIZATION]; - LogMessage(L_DEBUG2, "decode_auth(%p): Authorization string = \"%s\"", + cupsdLogMessage(L_DEBUG2, "decode_auth(%p): Authorization string = \"%s\"", con, s); if (strncmp(s, "Basic", 5) == 0) @@ -2625,7 +2625,7 @@ decode_auth(client_t *con) /* I - Client to decode to */ if ((s = strchr(value, ':')) == NULL) { - LogMessage(L_DEBUG, "decode_auth: %d no colon in auth string \"%s\"", + cupsdLogMessage(L_DEBUG, "decode_auth: %d no colon in auth string \"%s\"", con->http.fd, value); return; } @@ -2641,7 +2641,7 @@ decode_auth(client_t *con) /* I - Client to decode to */ while (isspace(*s)) s ++; - if ((username = FindCert(s)) != NULL) + if ((username = cupsdFindCert(s)) != NULL) strlcpy(con->username, username, sizeof(con->username)); } else if (strncmp(s, "Digest", 5) == 0) @@ -2659,7 +2659,7 @@ decode_auth(client_t *con) /* I - Client to decode to */ strlcpy(con->password, value, sizeof(con->password)); } - LogMessage(L_DEBUG2, "decode_auth: %d username=\"%s\"", + cupsdLogMessage(L_DEBUG2, "decode_auth: %d username=\"%s\"", con->http.fd, con->username); } @@ -2669,7 +2669,7 @@ decode_auth(client_t *con) /* I - Client to decode to */ */ static char * /* O - Real filename */ -get_file(client_t *con, /* I - Client connection */ +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 */ @@ -2785,7 +2785,7 @@ get_file(client_t *con, /* I - Client connection */ #endif /* HAVE_PYTHON */ } - LogMessage(L_DEBUG2, "get_file: %d filename=%s size=%d", + cupsdLogMessage(L_DEBUG2, "get_file: %d filename=%s size=%d", con->http.fd, filename, status ? -1 : (int)filestats->st_size); if (!status) @@ -2803,7 +2803,7 @@ get_file(client_t *con, /* I - Client connection */ */ static http_status_t /* O - Status */ -install_conf_file(client_t *con) /* I - Connection */ +install_conf_file(cupsd_client_t *con) /* I - Connection */ { cups_file_t *in, /* Input file */ *out; /* Output file */ @@ -2823,7 +2823,7 @@ install_conf_file(client_t *con) /* I - Connection */ snprintf(newfile, sizeof(newfile), "%s%s.N", ServerRoot, con->uri + 11); snprintf(oldfile, sizeof(oldfile), "%s%s.O", ServerRoot, con->uri + 11); - LogMessage(L_INFO, "Installing config file \"%s\"...", conffile); + cupsdLogMessage(L_INFO, "Installing config file \"%s\"...", conffile); /* * Get the owner, group, and permissions of the configuration file. @@ -2844,7 +2844,7 @@ install_conf_file(client_t *con) /* I - Connection */ if ((in = cupsFileOpen(con->filename, "rb")) == NULL) { - LogMessage(L_ERROR, "Unable to open request file \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to open request file \"%s\" - %s", con->filename, strerror(errno)); return (HTTP_SERVER_ERROR); } @@ -2852,7 +2852,7 @@ install_conf_file(client_t *con) /* I - Connection */ if ((out = cupsFileOpen(newfile, "wb")) == NULL) { cupsFileClose(in); - LogMessage(L_ERROR, "Unable to open config file \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to open config file \"%s\" - %s", newfile, strerror(errno)); return (HTTP_SERVER_ERROR); } @@ -2867,7 +2867,7 @@ install_conf_file(client_t *con) /* I - Connection */ while ((bytes = cupsFileRead(in, buffer, sizeof(buffer))) > 0) if (cupsFileWrite(out, buffer, bytes) < bytes) { - LogMessage(L_ERROR, "Unable to copy to config file \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to copy to config file \"%s\" - %s", newfile, strerror(errno)); cupsFileClose(in); @@ -2884,7 +2884,7 @@ install_conf_file(client_t *con) /* I - Connection */ cupsFileClose(in); if (cupsFileClose(out)) { - LogMessage(L_ERROR, "Error file closing config file \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Error file closing config file \"%s\" - %s", newfile, strerror(errno)); unlink(newfile); @@ -2897,7 +2897,7 @@ install_conf_file(client_t *con) /* I - Connection */ */ unlink(con->filename); - ClearString(&con->filename); + cupsdClearString(&con->filename); /* * Unlink the old backup, rename the current config file to the backup @@ -2907,7 +2907,7 @@ install_conf_file(client_t *con) /* I - Connection */ if (unlink(oldfile)) if (errno != ENOENT) { - LogMessage(L_ERROR, "Unable to remove backup config file \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to remove backup config file \"%s\" - %s", oldfile, strerror(errno)); unlink(newfile); @@ -2918,7 +2918,7 @@ install_conf_file(client_t *con) /* I - Connection */ if (rename(conffile, oldfile)) if (errno != ENOENT) { - LogMessage(L_ERROR, "Unable to rename old config file \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to rename old config file \"%s\" - %s", conffile, strerror(errno)); unlink(newfile); @@ -2928,7 +2928,7 @@ install_conf_file(client_t *con) /* I - Connection */ if (rename(newfile, conffile)) { - LogMessage(L_ERROR, "Unable to rename new config file \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to rename new config file \"%s\" - %s", newfile, strerror(errno)); rename(oldfile, conffile); @@ -2996,7 +2996,7 @@ is_path_absolute(const char *path) /* I - Input path */ */ static int /* O - Process ID */ -pipe_command(client_t *con, /* I - Client connection */ +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 */ @@ -3083,7 +3083,7 @@ pipe_command(client_t *con, /* I - Client connection */ * be consistent with Apache... */ - LogMessage(L_DEBUG2, "pipe_command: command=\"%s\", options=\"%s\"", + cupsdLogMessage(L_DEBUG2, "pipe_command: command=\"%s\", options=\"%s\"", command, options); strlcpy(argbuf, options, sizeof(argbuf)); @@ -3126,7 +3126,7 @@ pipe_command(client_t *con, /* I - Client connection */ */ if (argc == 2 && strchr(commptr, '=') && con->operation == HTTP_GET) - SetStringf(&query_string, "QUERY_STRING=%s", commptr); + cupsdSetStringf(&query_string, "QUERY_STRING=%s", commptr); /* * Don't skip the first non-blank character... @@ -3234,7 +3234,7 @@ pipe_command(client_t *con, /* I - Client connection */ if (con->operation == HTTP_GET) { for (i = 0; i < argc; i ++) - LogMessage(L_DEBUG2, "argv[%d] = \"%s\"", i, argv[i]); + cupsdLogMessage(L_DEBUG2, "argv[%d] = \"%s\"", i, argv[i]); envp[envc ++] = "REQUEST_METHOD=GET"; @@ -3274,9 +3274,9 @@ pipe_command(client_t *con, /* I - Client connection */ if (LogLevel == L_DEBUG2) { for (i = 0; i < argc; i ++) - LogMessage(L_DEBUG2, "pipe_command: argv[%d] = \"%s\"", i, argv[i]); + cupsdLogMessage(L_DEBUG2, "pipe_command: argv[%d] = \"%s\"", i, argv[i]); for (i = 0; i < envc; i ++) - LogMessage(L_DEBUG2, "pipe_command: envp[%d] = \"%s\"", i, envp[i]); + cupsdLogMessage(L_DEBUG2, "pipe_command: envp[%d] = \"%s\"", i, envp[i]); } /* @@ -3285,9 +3285,9 @@ pipe_command(client_t *con, /* I - Client connection */ if (cupsdOpenPipe(fds)) { - ClearString(&query_string); + cupsdClearString(&query_string); - LogMessage(L_ERROR, "Unable to create pipes for CGI %s - %s", + cupsdLogMessage(L_ERROR, "Unable to create pipes for CGI %s - %s", argv[0], strerror(errno)); return (0); } @@ -3303,7 +3303,7 @@ pipe_command(client_t *con, /* I - Client connection */ * Error - can't fork! */ - LogMessage(L_ERROR, "Unable to fork for CGI %s - %s", argv[0], + cupsdLogMessage(L_ERROR, "Unable to fork for CGI %s - %s", argv[0], strerror(errno)); cupsdClosePipe(fds); @@ -3316,15 +3316,15 @@ pipe_command(client_t *con, /* I - Client connection */ */ if (con->username[0]) - AddCert(pid, con->username); + cupsdAddCert(pid, con->username); - LogMessage(L_DEBUG, "CGI %s started - PID = %d", command, pid); + cupsdLogMessage(L_DEBUG, "CGI %s started - PID = %d", command, pid); *outfile = fds[0]; close(fds[1]); } - ClearString(&query_string); + cupsdClearString(&query_string); return (pid); } diff --git a/scheduler/client.h b/scheduler/client.h index 679ddb923..d0fe636d6 100644 --- a/scheduler/client.h +++ b/scheduler/client.h @@ -26,12 +26,12 @@ * HTTP client structure... */ -struct client_s +struct cupsd_client_s { http_t http; /* HTTP client connection */ ipp_t *request, /* IPP request information */ *response; /* IPP response information */ - location_t *best; /* Best match for AAA */ + 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 */ @@ -67,7 +67,7 @@ typedef struct int fd; /* File descriptor for this server */ http_addr_t address; /* Bind address of socket */ http_encryption_t encryption; /* To encrypt or not to encrypt... */ -} listener_t; +} cupsd_listener_t; /* @@ -82,11 +82,11 @@ VAR http_encryption_t LocalEncryption VALUE(HTTP_ENCRYPT_IF_REQUESTED); /* Local port encryption to use */ VAR int NumListeners VALUE(0); /* Number of listening sockets */ -VAR listener_t *Listeners VALUE(NULL); +VAR cupsd_listener_t *Listeners VALUE(NULL); /* Listening sockets */ VAR int NumClients VALUE(0); /* Number of HTTP clients */ -VAR client_t *Clients VALUE(NULL); +VAR cupsd_client_t *Clients VALUE(NULL); /* HTTP clients */ VAR http_addr_t ServerAddr; /* Server address */ VAR char *ServerHeader VALUE(NULL); @@ -101,27 +101,27 @@ VAR cupsd_statbuf_t *CGIStatusBuffer VALUE(NULL); * Prototypes... */ -extern void AcceptClient(listener_t *lis); -extern void CloseAllClients(void); -extern int CloseClient(client_t *con); -extern int EncryptClient(client_t *con); -extern int IsCGI(client_t *con, const char *filename, +extern void cupsdAcceptClient(cupsd_listener_t *lis); +extern void cupsdCloseAllClients(void); +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); -extern void PauseListening(void); -extern int ProcessIPPRequest(client_t *con); -extern int ReadClient(client_t *con); -extern void ResumeListening(void); -extern int SendCommand(client_t *con, char *command, char *options, +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 SendError(client_t *con, http_status_t code); -extern int SendFile(client_t *con, http_status_t code, char *filename, +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 SendHeader(client_t *con, http_status_t code, char *type); -extern void ShutdownClient(client_t *con); -extern void StartListening(void); -extern void StopListening(void); -extern void UpdateCGI(void); -extern int WriteClient(client_t *con); +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); +extern void cupsdUpdateCGI(void); +extern int cupsdWriteClient(cupsd_client_t *con); /* diff --git a/scheduler/conf.c b/scheduler/conf.c index a2443a071..549de038e 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -23,7 +23,7 @@ * * Contents: * - * ReadConfiguration() - Read the cupsd.conf file. + * 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 @@ -183,18 +183,18 @@ static int get_address(const char *value, unsigned defaddress, int defport, int deffamily, http_addr_t *address); static int get_addr_and_mask(const char *value, unsigned *ip, unsigned *mask); -static int parse_aaa(location_t *loc, char *line, char *value, int linenum); +static int parse_aaa(cupsd_location_t *loc, char *line, char *value, int linenum); static int read_configuration(cups_file_t *fp); static int read_location(cups_file_t *fp, char *name, int linenum); static int read_policy(cups_file_t *fp, char *name, int linenum); /* - * 'ReadConfiguration()' - Read the cupsd.conf file. + * 'cupsdReadConfiguration()' - Read the cupsd.conf file. */ int /* O - 1 on success, 0 otherwise */ -ReadConfiguration(void) +cupsdReadConfiguration(void) { int i; /* Looping var */ cups_file_t *fp; /* Configuration file */ @@ -214,22 +214,22 @@ ReadConfiguration(void) * Shutdown the server... */ - StopServer(); + cupsdStopServer(); /* * Save the old root paths... */ old_serverroot = NULL; - SetString(&old_serverroot, ServerRoot); + cupsdSetString(&old_serverroot, ServerRoot); old_requestroot = NULL; - SetString(&old_requestroot, RequestRoot); + cupsdSetString(&old_requestroot, RequestRoot); /* * Reset the server configuration data... */ - DeleteAllLocations(); + cupsdDeleteAllLocations(); if (NumBrowsers > 0) { @@ -260,11 +260,11 @@ ReadConfiguration(void) { #ifdef HAVE_DOMAINSOCKETS int i; /* Looping var */ - listener_t *lis; /* Current listening socket */ + cupsd_listener_t *lis; /* Current listening socket */ for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++) if (lis->address.sin_family == AF_LOCAL) - ClearString((char **)&lis->address.sin_addr); + cupsdClearString((char **)&lis->address.sin_addr); #endif /* HAVE_DOMAINSOCKETS */ free(Listeners); @@ -276,38 +276,38 @@ ReadConfiguration(void) * String options... */ - SetString(&ServerName, httpGetHostname(temp, sizeof(temp))); - SetStringf(&ServerAdmin, "root@%s", temp); - SetString(&ServerBin, CUPS_SERVERBIN); - SetString(&RequestRoot, CUPS_REQUESTS); - SetString(&CacheDir, CUPS_CACHEDIR); - SetString(&DataDir, CUPS_DATADIR); - SetString(&DocumentRoot, CUPS_DOCROOT); - SetString(&AccessLog, CUPS_LOGDIR "/access_log"); - SetString(&ErrorLog, CUPS_LOGDIR "/error_log"); - SetString(&PageLog, CUPS_LOGDIR "/page_log"); - SetString(&Printcap, "/etc/printcap"); - SetString(&PrintcapGUI, "/usr/bin/glpoptions"); - SetString(&FontPath, CUPS_FONTPATH); - SetString(&RemoteRoot, "remroot"); - SetString(&ServerHeader, "CUPS/1.1"); - SetString(&StateDir, CUPS_STATEDIR); + cupsdSetString(&ServerName, httpGetHostname(temp, sizeof(temp))); + cupsdSetStringf(&ServerAdmin, "root@%s", temp); + cupsdSetString(&ServerBin, CUPS_SERVERBIN); + cupsdSetString(&RequestRoot, CUPS_REQUESTS); + cupsdSetString(&CacheDir, CUPS_CACHEDIR); + cupsdSetString(&DataDir, CUPS_DATADIR); + cupsdSetString(&DocumentRoot, CUPS_DOCROOT); + cupsdSetString(&AccessLog, CUPS_LOGDIR "/access_log"); + cupsdSetString(&ErrorLog, CUPS_LOGDIR "/error_log"); + cupsdSetString(&PageLog, CUPS_LOGDIR "/page_log"); + cupsdSetString(&Printcap, "/etc/printcap"); + cupsdSetString(&PrintcapGUI, "/usr/bin/glpoptions"); + cupsdSetString(&FontPath, CUPS_FONTPATH); + cupsdSetString(&RemoteRoot, "remroot"); + cupsdSetString(&ServerHeader, "CUPS/1.1"); + cupsdSetString(&StateDir, CUPS_STATEDIR); strlcpy(temp, ConfigurationFile, sizeof(temp)); if ((slash = strrchr(temp, '/')) != NULL) *slash = '\0'; - SetString(&ServerRoot, temp); + cupsdSetString(&ServerRoot, temp); - ClearString(&Classification); + cupsdClearString(&Classification); ClassifyOverride = 0; #ifdef HAVE_SSL # ifdef HAVE_CDSASSL - SetString(&ServerCertificate, "/var/root/Library/Keychains/CUPS"); + cupsdSetString(&ServerCertificate, "/var/root/Library/Keychains/CUPS"); # else - SetString(&ServerCertificate, "ssl/server.crt"); - SetString(&ServerKey, "ssl/server.key"); + cupsdSetString(&ServerCertificate, "ssl/server.crt"); + cupsdSetString(&ServerKey, "ssl/server.key"); # endif /* HAVE_CDSASSL */ #endif /* HAVE_SSL */ @@ -316,15 +316,15 @@ ReadConfiguration(void) else if (!strcmp(language, "C") || !strcmp(language, "POSIX")) language = "en"; - SetString(&DefaultLanguage, language); - SetString(&DefaultCharset, DEFAULT_CHARSET); + cupsdSetString(&DefaultLanguage, language); + cupsdSetString(&DefaultCharset, DEFAULT_CHARSET); - SetString(&RIPCache, "8m"); + cupsdSetString(&RIPCache, "8m"); if (getenv("TMPDIR") == NULL) - SetString(&TempDir, CUPS_REQUESTS "/tmp"); + cupsdSetString(&TempDir, CUPS_REQUESTS "/tmp"); else - SetString(&TempDir, getenv("TMPDIR")); + cupsdSetString(&TempDir, getenv("TMPDIR")); /* * Find the default system group: "sys", "system", or "root"... @@ -341,7 +341,7 @@ ReadConfiguration(void) * Found the group, use it! */ - SetString(&SystemGroups[0], CUPS_DEFAULT_GROUP); + cupsdSetString(&SystemGroups[0], CUPS_DEFAULT_GROUP); SystemGroupIDs[0] = group->gr_gid; } @@ -355,9 +355,9 @@ ReadConfiguration(void) endgrent(); if (group != NULL) - SetString(&SystemGroups[0], group->gr_name); + cupsdSetString(&SystemGroups[0], group->gr_name); else - SetString(&SystemGroups[0], "unknown"); + cupsdSetString(&SystemGroups[0], "unknown"); SystemGroupIDs[0] = 0; } @@ -438,8 +438,8 @@ ReadConfiguration(void) BrowseTimeout = DEFAULT_TIMEOUT; Browsing = TRUE; - ClearString(&BrowseLocalOptions); - ClearString(&BrowseRemoteOptions); + cupsdClearString(&BrowseLocalOptions); + cupsdClearString(&BrowseRemoteOptions); JobHistory = DEFAULT_HISTORY; JobFiles = DEFAULT_FILES; @@ -450,7 +450,7 @@ ReadConfiguration(void) MaxJobsPerPrinter = 0; MaxCopies = 100; - ClearString(&DefaultPolicy); + cupsdClearString(&DefaultPolicy); /* * Read the configuration file... @@ -482,7 +482,7 @@ ReadConfiguration(void) * Get the access control list for browsing... */ - BrowseACL = FindLocation("CUPS_INTERNAL_BROWSE_ACL"); + BrowseACL = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL"); /* * Open the system log for cupsd if necessary... @@ -499,7 +499,7 @@ ReadConfiguration(void) * Log the configuration file that was used... */ - LogMessage(L_INFO, "Loaded configuration file \"%s\"", ConfigurationFile); + cupsdLogMessage(L_INFO, "Loaded configuration file \"%s\"", ConfigurationFile); /* * Validate the Group and SystemGroup settings - they cannot be the same, @@ -519,8 +519,8 @@ ReadConfiguration(void) * Log the error and reset the group to a safe value... */ - LogMessage(L_NOTICE, "Group and SystemGroup cannot use the same groups!"); - LogMessage(L_INFO, "Resetting Group to \"nobody\"..."); + cupsdLogMessage(L_NOTICE, "Group and SystemGroup cannot use the same groups!"); + cupsdLogMessage(L_INFO, "Resetting Group to \"nobody\"..."); group = getgrnam("nobody"); endgrent(); @@ -550,7 +550,7 @@ ReadConfiguration(void) * No listeners! */ - LogMessage(L_EMERG, "No valid Listen or Port lines were found in the configuration file!"); + cupsdLogMessage(L_EMERG, "No valid Listen or Port lines were found in the configuration file!"); /* * Commit suicide... @@ -563,37 +563,37 @@ ReadConfiguration(void) * Set the default locale using the language and charset... */ - SetStringf(&DefaultLocale, "%s.%s", DefaultLanguage, DefaultCharset); + cupsdSetStringf(&DefaultLocale, "%s.%s", DefaultLanguage, DefaultCharset); /* * Update all relative filenames to include the full path from ServerRoot... */ if (DocumentRoot[0] != '/') - SetStringf(&DocumentRoot, "%s/%s", ServerRoot, DocumentRoot); + cupsdSetStringf(&DocumentRoot, "%s/%s", ServerRoot, DocumentRoot); if (RequestRoot[0] != '/') - SetStringf(&RequestRoot, "%s/%s", ServerRoot, RequestRoot); + cupsdSetStringf(&RequestRoot, "%s/%s", ServerRoot, RequestRoot); if (ServerBin[0] != '/') - SetStringf(&ServerBin, "%s/%s", ServerRoot, ServerBin); + cupsdSetStringf(&ServerBin, "%s/%s", ServerRoot, ServerBin); if (StateDir[0] != '/') - SetStringf(&StateDir, "%s/%s", ServerRoot, StateDir); + cupsdSetStringf(&StateDir, "%s/%s", ServerRoot, StateDir); if (CacheDir[0] != '/') - SetStringf(&CacheDir, "%s/%s", ServerRoot, CacheDir); + cupsdSetStringf(&CacheDir, "%s/%s", ServerRoot, CacheDir); #ifdef HAVE_SSL if (ServerCertificate[0] != '/') - SetStringf(&ServerCertificate, "%s/%s", ServerRoot, ServerCertificate); + cupsdSetStringf(&ServerCertificate, "%s/%s", ServerRoot, ServerCertificate); # if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS) chown(ServerCertificate, RunUser, Group); chmod(ServerCertificate, ConfigFilePerm); if (ServerKey[0] != '/') - SetStringf(&ServerKey, "%s/%s", ServerRoot, ServerKey); + cupsdSetStringf(&ServerKey, "%s/%s", ServerRoot, ServerKey); chown(ServerKey, RunUser, Group); chmod(ServerKey, ConfigFilePerm); @@ -693,7 +693,7 @@ ReadConfiguration(void) if ((dir = cupsDirOpen(TempDir)) != NULL) { - LogMessage(L_INFO, "Cleaning out old temporary files in \"%s\"...", + cupsdLogMessage(L_INFO, "Cleaning out old temporary files in \"%s\"...", TempDir); while ((dent = cupsDirRead(dir)) != NULL) @@ -701,16 +701,16 @@ ReadConfiguration(void) snprintf(tempfile, sizeof(tempfile), "%s/%s", TempDir, dent->filename); if (unlink(tempfile)) - LogMessage(L_ERROR, "Unable to remove temporary file \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to remove temporary file \"%s\" - %s", tempfile, strerror(errno)); else - LogMessage(L_DEBUG, "Removed temporary file \"%s\"...", tempfile); + cupsdLogMessage(L_DEBUG, "Removed temporary file \"%s\"...", tempfile); } cupsDirClose(dir); } else - LogMessage(L_ERROR, "Unable to open temporary directory \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to open temporary directory \"%s\" - %s", TempDir, strerror(errno)); } @@ -727,20 +727,20 @@ ReadConfiguration(void) if (MaxClients > (MaxFDs / 3) || MaxClients <= 0) { if (MaxClients > 0) - LogMessage(L_INFO, "MaxClients limited to 1/3 (%d) of the file descriptor limit (%d)...", + cupsdLogMessage(L_INFO, "MaxClients limited to 1/3 (%d) of the file descriptor limit (%d)...", MaxFDs / 3, MaxFDs); MaxClients = MaxFDs / 3; } - if ((Clients = calloc(sizeof(client_t), MaxClients)) == NULL) + if ((Clients = calloc(sizeof(cupsd_client_t), MaxClients)) == NULL) { - LogMessage(L_ERROR, "ReadConfiguration: Unable to allocate memory for %d clients: %s", + cupsdLogMessage(L_ERROR, "cupsdReadConfiguration: Unable to allocate memory for %d clients: %s", MaxClients, strerror(errno)); exit(1); } else - LogMessage(L_INFO, "Configured for up to %d clients.", MaxClients); + cupsdLogMessage(L_INFO, "Configured for up to %d clients.", MaxClients); /* * Check the MaxActiveJobs setting; limit to 1/3 the available @@ -751,10 +751,10 @@ ReadConfiguration(void) MaxActiveJobs = MaxFDs / 3; if (Classification && strcasecmp(Classification, "none") == 0) - ClearString(&Classification); + cupsdClearString(&Classification); if (Classification) - LogMessage(L_INFO, "Security set to \"%s\"", Classification); + cupsdLogMessage(L_INFO, "Security set to \"%s\"", Classification); /* * Update the MaxClientsPerHost value, as needed... @@ -766,7 +766,7 @@ ReadConfiguration(void) if (MaxClientsPerHost > MaxClients) MaxClientsPerHost = MaxClients; - LogMessage(L_INFO, "Allowing up to %d client connections per host.", + cupsdLogMessage(L_INFO, "Allowing up to %d client connections per host.", MaxClientsPerHost); /* @@ -781,37 +781,37 @@ ReadConfiguration(void) if (!DefaultPolicyPtr) { cupsd_policy_t *p; /* New policy */ - location_t *po; /* New policy operation */ + cupsd_location_t *po; /* New policy operation */ if (DefaultPolicy) - LogMessage(L_ERROR, "Default policy \"%s\" not found!", DefaultPolicy); + cupsdLogMessage(L_ERROR, "Default policy \"%s\" not found!", DefaultPolicy); if ((DefaultPolicyPtr = cupsdFindPolicy("default")) != NULL) - LogMessage(L_INFO, "Using policy \"default\" as the default!"); + cupsdLogMessage(L_INFO, "Using policy \"default\" as the default!"); else { - LogMessage(L_INFO, "Creating CUPS default administrative policy:"); + cupsdLogMessage(L_INFO, "Creating CUPS default administrative policy:"); DefaultPolicyPtr = p = cupsdAddPolicy("default"); - LogMessage(L_INFO, ""); - LogMessage(L_INFO, ""); + cupsdLogMessage(L_INFO, ""); - LogMessage(L_INFO, "Order Deny,Allow"); + cupsdLogMessage(L_INFO, "Order Deny,Allow"); po = cupsdAddPolicyOp(p, NULL, IPP_SEND_DOCUMENT); po->order_type = AUTH_ALLOW; po->level = AUTH_USER; - AddName(po, "@OWNER"); - AddName(po, "@SYSTEM"); - LogMessage(L_INFO, "Require user @OWNER @SYSTEM"); + cupsdAddName(po, "@OWNER"); + cupsdAddName(po, "@SYSTEM"); + cupsdLogMessage(L_INFO, "Require user @OWNER @SYSTEM"); cupsdAddPolicyOp(p, po, IPP_SEND_URI); cupsdAddPolicyOp(p, po, IPP_CANCEL_JOB); @@ -831,9 +831,9 @@ ReadConfiguration(void) cupsdAddPolicyOp(p, po, CUPS_MOVE_JOB); cupsdAddPolicyOp(p, po, CUPS_AUTHENTICATE_JOB); - LogMessage(L_INFO, ""); + cupsdLogMessage(L_INFO, ""); - LogMessage(L_INFO, ""); - LogMessage(L_INFO, "Order Deny,Allow"); - LogMessage(L_INFO, "AuthType Basic"); + cupsdLogMessage(L_INFO, "Order Deny,Allow"); + cupsdLogMessage(L_INFO, "AuthType Basic"); po = cupsdAddPolicyOp(p, NULL, IPP_PAUSE_PRINTER); po->order_type = AUTH_ALLOW; po->type = AUTH_BASIC; po->level = AUTH_USER; - AddName(po, "@SYSTEM"); - LogMessage(L_INFO, "Require user @SYSTEM"); + cupsdAddName(po, "@SYSTEM"); + cupsdLogMessage(L_INFO, "Require user @SYSTEM"); cupsdAddPolicyOp(p, po, IPP_RESUME_PRINTER); cupsdAddPolicyOp(p, po, IPP_SET_PRINTER_ATTRIBUTES); @@ -875,16 +875,16 @@ ReadConfiguration(void) cupsdAddPolicyOp(p, po, CUPS_REJECT_JOBS); cupsdAddPolicyOp(p, po, CUPS_SET_DEFAULT); - LogMessage(L_INFO, ""); + cupsdLogMessage(L_INFO, ""); - LogMessage(L_INFO, ""); - LogMessage(L_INFO, "Order Deny,Allow"); + cupsdLogMessage(L_INFO, ""); + cupsdLogMessage(L_INFO, "Order Deny,Allow"); po = cupsdAddPolicyOp(p, NULL, IPP_ANY_OPERATION); po->order_type = AUTH_ALLOW; - LogMessage(L_INFO, ""); - LogMessage(L_INFO, ""); + cupsdLogMessage(L_INFO, ""); + cupsdLogMessage(L_INFO, ""); } } @@ -897,15 +897,15 @@ ReadConfiguration(void) !old_serverroot || !ServerRoot || strcmp(old_serverroot, ServerRoot) || !old_requestroot || !RequestRoot || strcmp(old_requestroot, RequestRoot)) { - LogMessage(L_INFO, "Full reload is required."); + cupsdLogMessage(L_INFO, "Full reload is required."); /* * Free all memory... */ - FreeAllJobs(); - DeleteAllClasses(); - DeleteAllPrinters(); + cupsdFreeAllJobs(); + cupsdDeleteAllClasses(); + cupsdDeleteAllPrinters(); DefaultPrinter = NULL; @@ -930,12 +930,12 @@ ReadConfiguration(void) if (!MimeDatabase) { - LogMessage(L_EMERG, "Unable to load MIME database from \'%s\'!", + cupsdLogMessage(L_EMERG, "Unable to load MIME database from \'%s\'!", ServerRoot); exit(errno); } - LogMessage(L_INFO, "Loaded MIME database from \'%s\': %d types, %d filters...", + cupsdLogMessage(L_INFO, "Loaded MIME database from \'%s\': %d types, %d filters...", ServerRoot, MimeDatabase->num_types, MimeDatabase->num_filters); /* @@ -965,30 +965,30 @@ ReadConfiguration(void) */ snprintf(temp, sizeof(temp), "%s/banners", DataDir); - LoadBanners(temp); + cupsdLoadBanners(temp); /* * Load printers and classes... */ - LoadAllPrinters(); - LoadAllClasses(); + cupsdLoadAllPrinters(); + cupsdLoadAllClasses(); - CreateCommonData(); + cupsdCreateCommonData(); /* * Load queued jobs... */ - LoadAllJobs(); + cupsdLoadAllJobs(); - LogMessage(L_INFO, "Full reload complete."); + cupsdLogMessage(L_INFO, "Full reload complete."); } else { - CreateCommonData(); + cupsdCreateCommonData(); - LogMessage(L_INFO, "Partial reload complete."); + cupsdLogMessage(L_INFO, "Partial reload complete."); } /* @@ -997,14 +997,14 @@ ReadConfiguration(void) NeedReload = RELOAD_NONE; - ClearString(&old_serverroot); - ClearString(&old_requestroot); + cupsdClearString(&old_serverroot); + cupsdClearString(&old_requestroot); /* * Startup the server and return... */ - StartServer(); + cupsdStartServer(); return (1); } @@ -1034,7 +1034,7 @@ get_address(const char *value, /* I - Value string */ if (!*value) { - LogMessage(L_ERROR, "Bad (empty) address!"); + cupsdLogMessage(L_ERROR, "Bad (empty) address!"); return (0); } @@ -1071,7 +1071,7 @@ get_address(const char *value, /* I - Value string */ { if (strlen(value) >= sizeof(address->un.sun_path)) { - LogMessage(L_ERROR, "Domain socket name \"%s\" too long!", value); + cupsdLogMessage(L_ERROR, "Domain socket name \"%s\" too long!", value); return (0); } @@ -1124,7 +1124,7 @@ get_address(const char *value, /* I - Value string */ { if ((host = httpGetHostByName(hostname)) == NULL) { - LogMessage(L_ERROR, "httpGetHostByName(\"%s\") failed - %s!", hostname, + cupsdLogMessage(L_ERROR, "httpGetHostByName(\"%s\") failed - %s!", hostname, hstrerror(h_errno)); return (0); } @@ -1147,7 +1147,7 @@ get_address(const char *value, /* I - Value string */ { if ((port = getservbyname(portname, NULL)) == NULL) { - LogMessage(L_ERROR, "getservbyname(\"%s\") failed - %s!", portname, + cupsdLogMessage(L_ERROR, "getservbyname(\"%s\") failed - %s!", portname, strerror(errno)); return (0); } @@ -1349,7 +1349,7 @@ get_addr_and_mask(const char *value, /* I - String from config file */ else memcpy(mask, netmasks[ipcount - 1], sizeof(unsigned) * 4); - LogMessage(L_DEBUG2, "get_addr_and_mask(value=\"%s\", " + cupsdLogMessage(L_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]); @@ -1373,7 +1373,7 @@ get_addr_and_mask(const char *value, /* I - String from config file */ */ static int /* O - 1 on success, 0 on failure */ -parse_aaa(location_t *loc, /* I - Location */ +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 */ @@ -1393,7 +1393,7 @@ parse_aaa(location_t *loc, /* I - Location */ loc->encryption = HTTP_ENCRYPT_NEVER; else if (!strcasecmp(value, "always")) { - LogMessage(L_ERROR, "Encryption value \"%s\" on line %d is invalid in this context. " + cupsdLogMessage(L_ERROR, "Encryption value \"%s\" on line %d is invalid in this context. " "Using \"required\" instead.", value, linenum); loc->encryption = HTTP_ENCRYPT_REQUIRED; @@ -1404,7 +1404,7 @@ parse_aaa(location_t *loc, /* I - Location */ loc->encryption = HTTP_ENCRYPT_IF_REQUESTED; else { - LogMessage(L_ERROR, "Unknown Encryption value %s on line %d.", + cupsdLogMessage(L_ERROR, "Unknown Encryption value %s on line %d.", value, linenum); return (0); } @@ -1421,7 +1421,7 @@ parse_aaa(location_t *loc, /* I - Location */ loc->order_type = AUTH_DENY; else { - LogMessage(L_ERROR, "Unknown Order value %s on line %d.", + cupsdLogMessage(L_ERROR, "Unknown Order value %s on line %d.", value, linenum); return (0); } @@ -1468,9 +1468,9 @@ parse_aaa(location_t *loc, /* I - Location */ */ if (!strcasecmp(line, "Allow")) - AllowIP(loc, zeros, zeros); + cupsdAllowIP(loc, zeros, zeros); else - DenyIP(loc, zeros, zeros); + cupsdDenyIP(loc, zeros, zeros); } else if (!strcasecmp(value, "none")) { @@ -1479,9 +1479,9 @@ parse_aaa(location_t *loc, /* I - Location */ */ if (!strcasecmp(line, "Allow")) - AllowIP(loc, ones, zeros); + cupsdAllowIP(loc, ones, zeros); else - DenyIP(loc, ones, zeros); + cupsdDenyIP(loc, ones, zeros); } else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0] & 255)) { @@ -1493,9 +1493,9 @@ parse_aaa(location_t *loc, /* I - Location */ value ++; if (!strcasecmp(line, "Allow")) - AllowHost(loc, value); + cupsdAllowHost(loc, value); else - DenyHost(loc, value); + cupsdDenyHost(loc, value); } else { @@ -1505,15 +1505,15 @@ parse_aaa(location_t *loc, /* I - Location */ if (!get_addr_and_mask(value, ip, mask)) { - LogMessage(L_ERROR, "Bad netmask value %s on line %d.", + cupsdLogMessage(L_ERROR, "Bad netmask value %s on line %d.", value, linenum); return (0); } if (!strcasecmp(line, "Allow")) - AllowIP(loc, ip, mask); + cupsdAllowIP(loc, ip, mask); else - DenyIP(loc, ip, mask); + cupsdDenyIP(loc, ip, mask); } } else if (!strcasecmp(line, "AuthType")) @@ -1550,7 +1550,7 @@ parse_aaa(location_t *loc, /* I - Location */ } else { - LogMessage(L_WARN, "Unknown authorization type %s on line %d.", + cupsdLogMessage(L_WARN, "Unknown authorization type %s on line %d.", value, linenum); return (0); } @@ -1574,17 +1574,17 @@ parse_aaa(location_t *loc, /* I - Location */ { loc->level = AUTH_GROUP; - AddName(loc, "@SYSTEM"); + cupsdAddName(loc, "@SYSTEM"); } else { - LogMessage(L_WARN, "Unknown authorization class %s on line %d.", + cupsdLogMessage(L_WARN, "Unknown authorization class %s on line %d.", value, linenum); return (0); } } else if (!strcasecmp(line, "AuthGroupName")) - AddName(loc, value); + cupsdAddName(loc, value); else if (!strcasecmp(line, "Require")) { /* @@ -1609,7 +1609,7 @@ parse_aaa(location_t *loc, /* I - Location */ loc->level = AUTH_GROUP; else { - LogMessage(L_WARN, "Unknown Require type %s on line %d.", + cupsdLogMessage(L_WARN, "Unknown Require type %s on line %d.", value, linenum); return (0); } @@ -1645,7 +1645,7 @@ parse_aaa(location_t *loc, /* I - Location */ if (*valptr) *valptr++ = '\0'; - AddName(loc, value); + cupsdAddName(loc, value); for (value = valptr; isspace(*value & 255); value ++); } @@ -1658,7 +1658,7 @@ parse_aaa(location_t *loc, /* I - Location */ loc->satisfy = AUTH_SATISFY_ANY; else { - LogMessage(L_WARN, "Unknown Satisfy value %s on line %d.", value, + cupsdLogMessage(L_WARN, "Unknown Satisfy value %s on line %d.", value, linenum); return (0); } @@ -1688,10 +1688,10 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ var_t *var; /* Current variable */ unsigned ip[4], /* Address value */ mask[4]; /* Netmask value */ - dirsvc_relay_t *relay; /* Relay data */ - dirsvc_poll_t *poll; /* Polling data */ + cupsd_dirsvc_relay_t *relay; /* Relay data */ + cupsd_dirsvc_poll_t *poll; /* Polling data */ http_addr_t polladdr; /* Polling address */ - location_t *location; /* Browse location */ + cupsd_location_t *location; /* Browse location */ cups_file_t *incfile; /* Include file */ char incname[1024]; /* Include filename */ struct group *group; /* Group */ @@ -1721,7 +1721,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ snprintf(incname, sizeof(incname), "%s/%s", ServerRoot, value); if ((incfile = cupsFileOpen(incname, "rb")) == NULL) - LogMessage(L_ERROR, "Unable to include config file \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to include config file \"%s\" - %s", incname, strerror(errno)); else { @@ -1743,7 +1743,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ } else { - LogMessage(L_ERROR, "Syntax error on line %d.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d.", linenum); return (0); } @@ -1762,7 +1762,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ } else { - LogMessage(L_ERROR, "Syntax error on line %d.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d.", linenum); return (0); } @@ -1773,17 +1773,17 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ * Add a listening address to the list... */ - listener_t *lis; /* New listeners array */ + cupsd_listener_t *lis; /* New listeners array */ if (NumListeners == 0) - lis = malloc(sizeof(listener_t)); + lis = malloc(sizeof(cupsd_listener_t)); else - lis = realloc(Listeners, (NumListeners + 1) * sizeof(listener_t)); + lis = realloc(Listeners, (NumListeners + 1) * sizeof(cupsd_listener_t)); if (!lis) { - LogMessage(L_ERROR, "Unable to allocate %s at line %d - %s.", + cupsdLogMessage(L_ERROR, "Unable to allocate %s at line %d - %s.", line, linenum, strerror(errno)); continue; } @@ -1791,7 +1791,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ Listeners = lis; lis += NumListeners; - memset(lis, 0, sizeof(listener_t)); + memset(lis, 0, sizeof(cupsd_listener_t)); #if defined(AF_INET6) && !defined(__OpenBSD__) if (get_address(value, INADDR_ANY, IPP_PORT, AF_INET6, &(lis->address))) @@ -1803,22 +1803,22 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ #ifdef AF_INET6 if (lis->address.addr.sa_family == AF_INET6) - LogMessage(L_INFO, "Listening to %s:%d (IPv6)", temp, + cupsdLogMessage(L_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) - LogMessage(L_INFO, "Listening to %s (Domain)", temp); + cupsdLogMessage(L_INFO, "Listening to %s (Domain)", temp); else #endif /* AF_LOCAL */ - LogMessage(L_INFO, "Listening to %s:%d", temp, + cupsdLogMessage(L_INFO, "Listening to %s:%d", temp, ntohs(lis->address.ipv4.sin_port)); NumListeners ++; } else - LogMessage(L_ERROR, "Bad %s address %s at line %d.", line, + cupsdLogMessage(L_ERROR, "Bad %s address %s at line %d.", line, value, linenum); } #ifdef HAVE_SSL @@ -1828,17 +1828,17 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ * Add a listening address to the list... */ - listener_t *lis; /* New listeners array */ + cupsd_listener_t *lis; /* New listeners array */ if (NumListeners == 0) - lis = malloc(sizeof(listener_t)); + lis = malloc(sizeof(cupsd_listener_t)); else - lis = realloc(Listeners, (NumListeners + 1) * sizeof(listener_t)); + lis = realloc(Listeners, (NumListeners + 1) * sizeof(cupsd_listener_t)); if (!lis) { - LogMessage(L_ERROR, "Unable to allocate %s at line %d - %s.", + cupsdLogMessage(L_ERROR, "Unable to allocate %s at line %d - %s.", line, linenum, strerror(errno)); continue; } @@ -1852,17 +1852,17 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ #ifdef AF_INET6 if (lis->address.addr.sa_family == AF_INET6) - LogMessage(L_INFO, "Listening to %s:%d (IPv6)", temp, + cupsdLogMessage(L_INFO, "Listening to %s:%d (IPv6)", temp, ntohs(lis->address.ipv6.sin6_port)); else #endif /* AF_INET6 */ - LogMessage(L_INFO, "Listening to %s:%d", temp, + cupsdLogMessage(L_INFO, "Listening to %s:%d", temp, ntohs(lis->address.ipv4.sin_port)); lis->encryption = HTTP_ENCRYPT_ALWAYS; NumListeners ++; } else - LogMessage(L_ERROR, "Bad %s address %s at line %d.", line, + cupsdLogMessage(L_ERROR, "Bad %s address %s at line %d.", line, value, linenum); } #endif /* HAVE_SSL */ @@ -1872,17 +1872,17 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ * Add a browse address to the list... */ - dirsvc_addr_t *dira; /* New browse address array */ + cupsd_dirsvc_addr_t *dira; /* New browse address array */ if (NumBrowsers == 0) - dira = malloc(sizeof(dirsvc_addr_t)); + dira = malloc(sizeof(cupsd_dirsvc_addr_t)); else - dira = realloc(Browsers, (NumBrowsers + 1) * sizeof(dirsvc_addr_t)); + dira = realloc(Browsers, (NumBrowsers + 1) * sizeof(cupsd_dirsvc_addr_t)); if (!dira) { - LogMessage(L_ERROR, "Unable to allocate BrowseAddress at line %d - %s.", + cupsdLogMessage(L_ERROR, "Unable to allocate BrowseAddress at line %d - %s.", linenum, strerror(errno)); continue; } @@ -1890,7 +1890,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ Browsers = dira; dira += NumBrowsers; - memset(dira, 0, sizeof(dirsvc_addr_t)); + memset(dira, 0, sizeof(cupsd_dirsvc_addr_t)); if (!strcasecmp(value, "@LOCAL")) { @@ -1921,17 +1921,17 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ #ifdef AF_INET6 if (dira->to.addr.sa_family == AF_INET6) - LogMessage(L_INFO, "Sending browsing info to %s:%d (IPv6)", temp, + cupsdLogMessage(L_INFO, "Sending browsing info to %s:%d (IPv6)", temp, ntohs(dira->to.ipv6.sin6_port)); else #endif /* AF_INET6 */ - LogMessage(L_INFO, "Sending browsing info to %s:%d", temp, + cupsdLogMessage(L_INFO, "Sending browsing info to %s:%d", temp, ntohs(dira->to.ipv4.sin_port)); NumBrowsers ++; } else - LogMessage(L_ERROR, "Bad BrowseAddress %s at line %d.", value, + cupsdLogMessage(L_ERROR, "Bad BrowseAddress %s at line %d.", value, linenum); } else if (!strcasecmp(line, "BrowseOrder")) @@ -1940,17 +1940,17 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ * "BrowseOrder Deny,Allow" or "BrowseOrder Allow,Deny"... */ - if ((location = FindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL) - location = AddLocation("CUPS_INTERNAL_BROWSE_ACL"); + if ((location = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL) + location = cupsdAddLocation("CUPS_INTERNAL_BROWSE_ACL"); if (location == NULL) - LogMessage(L_ERROR, "Unable to initialize browse access control list!"); + cupsdLogMessage(L_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 - LogMessage(L_ERROR, "Unknown BrowseOrder value %s on line %d.", + cupsdLogMessage(L_ERROR, "Unknown BrowseOrder value %s on line %d.", value, linenum); } else if (!strcasecmp(line, "BrowseProtocols") || @@ -2008,7 +2008,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ } else { - LogMessage(L_ERROR, "Unknown browse protocol \"%s\" on line %d.", + cupsdLogMessage(L_ERROR, "Unknown browse protocol \"%s\" on line %d.", value, linenum); break; } @@ -2026,11 +2026,11 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ * BrowseDeny [From] host/ip... */ - if ((location = FindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL) - location = AddLocation("CUPS_INTERNAL_BROWSE_ACL"); + if ((location = cupsdFindLocation("CUPS_INTERNAL_BROWSE_ACL")) == NULL) + location = cupsdAddLocation("CUPS_INTERNAL_BROWSE_ACL"); if (location == NULL) - LogMessage(L_ERROR, "Unable to initialize browse access control list!"); + cupsdLogMessage(L_ERROR, "Unable to initialize browse access control list!"); else { if (!strncasecmp(value, "from ", 5)) @@ -2068,9 +2068,9 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ */ if (!strcasecmp(line, "BrowseAllow")) - AllowIP(location, zeros, zeros); + cupsdAllowIP(location, zeros, zeros); else - DenyIP(location, zeros, zeros); + cupsdDenyIP(location, zeros, zeros); } else if (!strcasecmp(value, "none")) { @@ -2079,9 +2079,9 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ */ if (!strcasecmp(line, "BrowseAllow")) - AllowIP(location, ones, zeros); + cupsdAllowIP(location, ones, zeros); else - DenyIP(location, ones, zeros); + cupsdDenyIP(location, ones, zeros); } else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0])) { @@ -2093,9 +2093,9 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ value ++; if (!strcasecmp(line, "BrowseAllow")) - AllowHost(location, value); + cupsdAllowHost(location, value); else - DenyHost(location, value); + cupsdDenyHost(location, value); } else { @@ -2105,15 +2105,15 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ if (!get_addr_and_mask(value, ip, mask)) { - LogMessage(L_ERROR, "Bad netmask value %s on line %d.", + cupsdLogMessage(L_ERROR, "Bad netmask value %s on line %d.", value, linenum); break; } if (!strcasecmp(line, "BrowseAllow")) - AllowIP(location, ip, mask); + cupsdAllowIP(location, ip, mask); else - DenyIP(location, ip, mask); + cupsdDenyIP(location, ip, mask); } } } @@ -2124,13 +2124,13 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ */ if (NumRelays == 0) - relay = malloc(sizeof(dirsvc_relay_t)); + relay = malloc(sizeof(cupsd_dirsvc_relay_t)); else - relay = realloc(Relays, (NumRelays + 1) * sizeof(dirsvc_relay_t)); + relay = realloc(Relays, (NumRelays + 1) * sizeof(cupsd_dirsvc_relay_t)); if (!relay) { - LogMessage(L_ERROR, "Unable to allocate BrowseRelay at line %d - %s.", + cupsdLogMessage(L_ERROR, "Unable to allocate BrowseRelay at line %d - %s.", linenum, strerror(errno)); continue; } @@ -2138,7 +2138,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ Relays = relay; relay += NumRelays; - memset(relay, 0, sizeof(dirsvc_relay_t)); + memset(relay, 0, sizeof(cupsd_dirsvc_relay_t)); if (!strncasecmp(value, "from ", 5)) { @@ -2191,7 +2191,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ if (!get_addr_and_mask(value, ip, mask)) { - LogMessage(L_ERROR, "Bad netmask value %s on line %d.", + cupsdLogMessage(L_ERROR, "Bad netmask value %s on line %d.", value, linenum); break; } @@ -2249,11 +2249,11 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ #ifdef AF_INET6 if (relay->to.addr.sa_family == AF_INET6) - LogMessage(L_INFO, "Relaying from %s to %s:%d", temp, temp2, + cupsdLogMessage(L_INFO, "Relaying from %s to %s:%d", temp, temp2, ntohs(relay->to.ipv6.sin6_port)); else #endif /* AF_INET6 */ - LogMessage(L_INFO, "Relaying from %s to %s:%d", temp, temp2, + cupsdLogMessage(L_INFO, "Relaying from %s to %s:%d", temp, temp2, ntohs(relay->to.ipv4.sin_port)); NumRelays ++; @@ -2263,7 +2263,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ if (relay->from.type == AUTH_NAME) free(relay->from.mask.name.name); - LogMessage(L_ERROR, "Bad relay address %s at line %d.", value, linenum); + cupsdLogMessage(L_ERROR, "Bad relay address %s at line %d.", value, linenum); } } else if (!strcasecmp(line, "BrowsePoll")) @@ -2273,13 +2273,13 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ */ if (NumPolled == 0) - poll = malloc(sizeof(dirsvc_poll_t)); + poll = malloc(sizeof(cupsd_dirsvc_poll_t)); else - poll = realloc(Polled, (NumPolled + 1) * sizeof(dirsvc_poll_t)); + poll = realloc(Polled, (NumPolled + 1) * sizeof(cupsd_dirsvc_poll_t)); if (!poll) { - LogMessage(L_ERROR, "Unable to allocate BrowsePoll at line %d - %s.", + cupsdLogMessage(L_ERROR, "Unable to allocate BrowsePoll at line %d - %s.", linenum, strerror(errno)); continue; } @@ -2294,7 +2294,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ if (get_address(value, INADDR_NONE, ippPort(), AF_INET, &polladdr)) { NumPolled ++; - memset(poll, 0, sizeof(dirsvc_poll_t)); + memset(poll, 0, sizeof(cupsd_dirsvc_poll_t)); httpAddrString(&polladdr, poll->hostname, sizeof(poll->hostname)); @@ -2305,10 +2305,10 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ #endif /* AF_INET6 */ poll->port = ntohs(polladdr.ipv4.sin_port); - LogMessage(L_INFO, "Polling %s:%d", poll->hostname, poll->port); + cupsdLogMessage(L_INFO, "Polling %s:%d", poll->hostname, poll->port); } else - LogMessage(L_ERROR, "Bad poll address %s at line %d.", value, linenum); + cupsdLogMessage(L_ERROR, "Bad poll address %s at line %d.", value, linenum); } else if (!strcasecmp(line, "DefaultAuthType")) { @@ -2324,7 +2324,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ DefaultAuthType = AUTH_BASICDIGEST; else { - LogMessage(L_WARN, "Unknown default authorization type %s on line %d.", + cupsdLogMessage(L_WARN, "Unknown default authorization type %s on line %d.", value, linenum); return (0); } @@ -2347,7 +2347,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ if (p != NULL) User = p->pw_uid; else - LogMessage(L_ERROR, "Unknown User \"%s\" on line %d, ignoring!", + cupsdLogMessage(L_ERROR, "Unknown User \"%s\" on line %d, ignoring!", value, linenum); } } @@ -2367,7 +2367,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ if (group != NULL) Group = group->gr_gid; else - LogMessage(L_ERROR, "Unknown Group \"%s\" on line %d, ignoring!", + cupsdLogMessage(L_ERROR, "Unknown Group \"%s\" on line %d, ignoring!", value, linenum); } } @@ -2412,13 +2412,13 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ group = getgrnam(value); if (group) { - SetString(SystemGroups + i, value); + cupsdSetString(SystemGroups + i, value); SystemGroupIDs[i] = group->gr_gid; i ++; } else - LogMessage(L_ERROR, "Unknown SystemGroup \"%s\" on line %d, ignoring!", + cupsdLogMessage(L_ERROR, "Unknown SystemGroup \"%s\" on line %d, ignoring!", value, linenum); endgrent(); @@ -2445,7 +2445,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ else if (!strcasecmp(value, "double")) HostNameLookups = 2; else - LogMessage(L_WARN, "Unknown HostNameLookups %s on line %d.", + cupsdLogMessage(L_WARN, "Unknown HostNameLookups %s on line %d.", value, linenum); } else if (!strcasecmp(line, "LogLevel")) @@ -2475,7 +2475,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ else if (!strcasecmp(value, "none")) LogLevel = L_NONE; else - LogMessage(L_WARN, "Unknown LogLevel %s on line %d.", value, linenum); + cupsdLogMessage(L_WARN, "Unknown LogLevel %s on line %d.", value, linenum); } else if (!strcasecmp(line, "PrintcapFormat")) { @@ -2488,7 +2488,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ else if (!strcasecmp(value, "solaris")) PrintcapFormat = PRINTCAP_SOLARIS; else - LogMessage(L_WARN, "Unknown PrintcapFormat %s on line %d.", + cupsdLogMessage(L_WARN, "Unknown PrintcapFormat %s on line %d.", value, linenum); } else if (!strcasecmp(line, "ServerTokens")) @@ -2503,21 +2503,21 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ uname(&plat); if (!strcasecmp(value, "ProductOnly")) - SetString(&ServerHeader, "CUPS"); + cupsdSetString(&ServerHeader, "CUPS"); else if (!strcasecmp(value, "Major")) - SetString(&ServerHeader, "CUPS/1"); + cupsdSetString(&ServerHeader, "CUPS/1"); else if (!strcasecmp(value, "Minor")) - SetString(&ServerHeader, "CUPS/1.1"); + cupsdSetString(&ServerHeader, "CUPS/1.1"); else if (!strcasecmp(value, "Minimal")) - SetString(&ServerHeader, CUPS_MINIMAL); + cupsdSetString(&ServerHeader, CUPS_MINIMAL); else if (!strcasecmp(value, "OS")) - SetStringf(&ServerHeader, CUPS_MINIMAL " (%s)", plat.sysname); + cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s)", plat.sysname); else if (!strcasecmp(value, "Full")) - SetStringf(&ServerHeader, CUPS_MINIMAL " (%s) IPP/1.1", plat.sysname); + cupsdSetStringf(&ServerHeader, CUPS_MINIMAL " (%s) IPP/1.1", plat.sysname); else if (!strcasecmp(value, "None")) - ClearString(&ServerHeader); + cupsdClearString(&ServerHeader); else - LogMessage(L_WARN, "Unknown ServerTokens %s on line %d.", value, linenum); + cupsdLogMessage(L_WARN, "Unknown ServerTokens %s on line %d.", value, linenum); } else { @@ -2535,7 +2535,7 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ * Unknown directive! Output an error message and continue... */ - LogMessage(L_ERROR, "Unknown directive %s on line %d.", line, + cupsdLogMessage(L_ERROR, "Unknown directive %s on line %d.", line, linenum); continue; } @@ -2580,12 +2580,12 @@ read_configuration(cups_file_t *fp) /* I - File to read from */ !strcasecmp(value, "0")) *((int *)var->ptr) = FALSE; else - LogMessage(L_ERROR, "Unknown boolean value %s on line %d.", + cupsdLogMessage(L_ERROR, "Unknown boolean value %s on line %d.", value, linenum); break; case VAR_STRING : - SetString((char **)var->ptr, value); + cupsdSetString((char **)var->ptr, value); break; } } @@ -2604,14 +2604,14 @@ read_location(cups_file_t *fp, /* I - Configuration file */ char *location, /* I - Location name/path */ int linenum) /* I - Current line number */ { - location_t *loc, /* New location */ + 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 = AddLocation(location)) == NULL) + if ((parent = cupsdAddLocation(location)) == NULL) return (0); parent->limit = AUTH_LIMIT_ALL; @@ -2630,11 +2630,11 @@ read_location(cups_file_t *fp, /* I - Configuration file */ { if (!value) { - LogMessage(L_ERROR, "Syntax error on line %d.", linenum); + cupsdLogMessage(L_ERROR, "Syntax error on line %d.", linenum); return (0); } - if ((loc = CopyLocation(&parent)) == NULL) + if ((loc = cupsdCopyLocation(&parent)) == NULL) return (0); loc->limit = 0; @@ -2660,7 +2660,7 @@ read_location(cups_file_t *fp, /* I - Configuration file */ else if (!strcmp(value, "TRACE")) loc->limit |= AUTH_LIMIT_TRACE; else - LogMessage(L_WARN, "Unknown request type %s on line %d!", value, + cupsdLogMessage(L_WARN, "Unknown request type %s on line %d!", value, linenum); for (value = valptr; isspace(*value & 255); value ++); @@ -2675,13 +2675,13 @@ read_location(cups_file_t *fp, /* I - Configuration file */ loc = parent; else if (!parse_aaa(loc, line, value, linenum)) { - LogMessage(L_ERROR, "Unknown Location directive %s on line %d.", + cupsdLogMessage(L_ERROR, "Unknown Location directive %s on line %d.", line, linenum); return (0); } } - LogMessage(L_ERROR, "Unexpected end-of-file at line %d while reading location!", + cupsdLogMessage(L_ERROR, "Unexpected end-of-file at line %d while reading location!", linenum); return (0); @@ -2699,7 +2699,7 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ { int i; /* Looping var */ cupsd_policy_t *pol; /* Policy */ - 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], @@ -2731,7 +2731,7 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ if (!strcasecmp(line, "")) { if (op) - LogMessage(L_WARN, "Missing before on line %d!", + cupsdLogMessage(L_WARN, "Missing before on line %d!", linenum); return (linenum); @@ -2740,7 +2740,7 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ { if (!value) { - LogMessage(L_ERROR, "Syntax error on line %d.", linenum); + cupsdLogMessage(L_ERROR, "Syntax error on line %d.", linenum); return (0); } @@ -2762,13 +2762,13 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ if (!strcasecmp(value, "All")) ops[num_ops] = IPP_ANY_OPERATION; else if ((ops[num_ops] = ippOpValue(value)) == IPP_BAD_OPERATION) - LogMessage(L_ERROR, "Bad IPP operation name \"%s\" on line %d!", + cupsdLogMessage(L_ERROR, "Bad IPP operation name \"%s\" on line %d!", value, linenum); else num_ops ++; } else - LogMessage(L_ERROR, "Too many operations listed on line %d!", + cupsdLogMessage(L_ERROR, "Too many operations listed on line %d!", linenum); for (value = valptr; isspace(*value & 255); value ++); @@ -2810,24 +2810,24 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ } else if (!op) { - LogMessage(L_ERROR, "Missing directive before %s on line %d.", + cupsdLogMessage(L_ERROR, "Missing directive before %s on line %d.", line, linenum); return (0); } else if (!parse_aaa(op, line, value, linenum)) { if (op) - LogMessage(L_ERROR, "Unknown Policy Limit directive %s on line %d.", + cupsdLogMessage(L_ERROR, "Unknown Policy Limit directive %s on line %d.", line, linenum); else - LogMessage(L_ERROR, "Unknown Policy directive %s on line %d.", + cupsdLogMessage(L_ERROR, "Unknown Policy directive %s on line %d.", line, linenum); return (0); } } - LogMessage(L_ERROR, "Unexpected end-of-file at line %d while reading policy \"%s\"!", + cupsdLogMessage(L_ERROR, "Unexpected end-of-file at line %d while reading policy \"%s\"!", linenum, policy); return (0); @@ -2868,7 +2868,7 @@ CDSAGetServerCerts(void) err = SecKeychainOpen(ServerCertificate, &kcRef); if (err) - LogMessage(L_ERROR, "Cannot open keychain \"%s\", error %d.", + cupsdLogMessage(L_ERROR, "Cannot open keychain \"%s\", error %d.", ServerCertificate, err); else { @@ -2880,7 +2880,7 @@ CDSAGetServerCerts(void) err = SecIdentitySearchCreate(kcRef, CSSM_KEYUSE_SIGN, &srchRef); if (err) - LogMessage(L_ERROR, + cupsdLogMessage(L_ERROR, "Cannot find signing key in keychain \"%s\", error %d", ServerCertificate, err); else @@ -2888,13 +2888,13 @@ CDSAGetServerCerts(void) err = SecIdentitySearchCopyNext(srchRef, &identity); if (err) - LogMessage(L_ERROR, + cupsdLogMessage(L_ERROR, "Cannot find signing key in keychain \"%s\", error %d", ServerCertificate, err); else { if (CFGetTypeID(identity) != SecIdentityGetTypeID()) - LogMessage(L_ERROR, "SecIdentitySearchCopyNext CFTypeID failure!"); + cupsdLogMessage(L_ERROR, "SecIdentitySearchCopyNext CFTypeID failure!"); else { /* @@ -2906,7 +2906,7 @@ CDSAGetServerCerts(void) ca = CFArrayCreate(NULL, (const void **)&identity, 1, NULL); if (ca == nil) - LogMessage(L_ERROR, "CFArrayCreate error"); + cupsdLogMessage(L_ERROR, "CFArrayCreate error"); } /*CFRelease(identity);*/ diff --git a/scheduler/conf.h b/scheduler/conf.h index 72036b51d..7c2528c80 100644 --- a/scheduler/conf.h +++ b/scheduler/conf.h @@ -192,15 +192,15 @@ VAR CFArrayRef ServerCertificatesArray VALUE(NULL); * Prototypes... */ -extern char *GetDateTime(time_t t); -extern int ReadConfiguration(void); -extern int LogRequest(client_t *con, http_status_t code); -extern int LogMessage(int level, const char *message, ...) +extern char *cupsdGetDateTime(time_t t); +extern int cupsdReadConfiguration(void); +extern int cupsdLogRequest(cupsd_client_t *con, http_status_t code); +extern int cupsdLogMessage(int level, const char *message, ...) #ifdef __GNUC__ __attribute__ ((__format__ (__printf__, 2, 3))) #endif /* __GNUC__ */ ; -extern int LogPage(job_t *job, const char *page); +extern int cupsdLogPage(cupsd_job_t *job, const char *page); /* diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c index 7318e090c..e51a29019 100644 --- a/scheduler/cups-lpd.c +++ b/scheduler/cups-lpd.c @@ -517,7 +517,7 @@ recv_print_job(const char *dest, /* I - Destination */ command, /* Command from line */ *count, /* Number of bytes */ *name; /* Name of file */ - const char *job_sheets; /* Job sheets */ + const char *cupsd_job_sheets; /* Job sheets */ int num_data; /* Number of data files */ char control[1024], /* Control filename */ data[32][256], /* Data files */ @@ -855,10 +855,10 @@ recv_print_job(const char *dest, /* I - Destination */ if (banner && cupsGetOption("job-sheets", num_defaults, defaults) == NULL && - ((job_sheets = cupsGetOption("job-sheets", + ((cupsd_job_sheets = cupsGetOption("job-sheets", destptr->num_options, destptr->options)) == NULL || - !strcmp(job_sheets, "none,none"))) + !strcmp(cupsd_job_sheets, "none,none"))) { num_options = cupsAddOption("job-sheets", "standard", num_options, &options); diff --git a/scheduler/cupsd.h b/scheduler/cupsd.h index 388fab90b..6fc3ebaf7 100644 --- a/scheduler/cupsd.h +++ b/scheduler/cupsd.h @@ -166,19 +166,19 @@ VAR int NeedReload VALUE(RELOAD_ALL); * Prototypes... */ -extern void CatchChildSignals(void); -extern void ClearString(char **s); -extern void HoldSignals(void); -extern void IgnoreChildSignals(void); -extern void ReleaseSignals(void); -extern void SetString(char **s, const char *v); -extern void SetStringf(char **s, const char *f, ...) +extern void cupsdCatchChildSignals(void); +extern void cupsdClearString(char **s); +extern void cupsdHoldSignals(void); +extern void cupsdIgnoreChildSignals(void); +extern void cupsdReleaseSignals(void); +extern void cupsdSetString(char **s, const char *v); +extern void cupsdSetStringf(char **s, const char *f, ...) #ifdef __GNUC__ __attribute__ ((__format__ (__printf__, 2, 3))) #endif /* __GNUC__ */ ; -extern void StartServer(void); -extern void StopServer(void); +extern void cupsdStartServer(void); +extern void cupsdStopServer(void); extern void cupsdClosePipe(int *fds); extern int cupsdOpenPipe(int *fds); diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index 7e82c06a5..59d2e39de 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -23,23 +23,23 @@ * * Contents: * - * ProcessBrowseData() - Process new browse data. - * SendBrowseDelete() - Send a "browse delete" message for a printer. - * SendBrowseList() - Send new browsing information as necessary. - * SendCUPSBrowse() - Send new browsing information using the CUPS protocol. - * StartBrowsing() - Start sending and receiving broadcast information. - * StartPolling() - Start polling servers as needed. - * StopBrowsing() - Stop sending and receiving broadcast information. - * StopPolling() - Stop polling servers as needed. - * UpdateCUPSBrowse() - Update the browse lists using the CUPS protocol. - * UpdatePolling() - Read status messages from the poll daemons. + * cupsdProcessBrowseData() - Process new browse data. + * cupsdSendBrowseDelete() - Send a "browse delete" message for a printer. + * cupsdSendBrowseList() - Send new browsing information as necessary. + * cupsdSendCUPSBrowse() - Send new browsing information using the CUPS protocol. + * cupsdStartBrowsing() - Start sending and receiving broadcast information. + * cupsdStartPolling() - Start polling servers as needed. + * cupsdStopBrowsing() - Stop sending and receiving broadcast information. + * 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. - * SendSLPBrowse() - Register the specified printer with SLP. + * 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 - * UpdateSLPBrowse() - Get browsing information via SLP. + * cupsdUpdateSLPBrowse() - Get browsing information via SLP. */ /* @@ -51,16 +51,16 @@ #ifdef HAVE_LIBSLP -void SLPDeregPrinter(printer_t *p); +void SLPDeregPrinter(cupsd_printer_t *p); #endif /* HAVE_LIBSLP */ /* - * 'ProcessBrowseData()' - Process new browse data. + * 'cupsdProcessBrowseData()' - Process new browse data. */ void -ProcessBrowseData(const char *uri, /* I - URI of printer/class */ +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 */ @@ -80,7 +80,7 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ *sptr; /* Pointer into ServerName */ char local_make_model[IPP_MAX_NAME]; /* Local make and model */ - printer_t *p, /* Printer information */ + cupsd_printer_t *p, /* Printer information */ *pclass, /* Printer class */ *first; /* First printer in class */ int offset, /* Offset of name */ @@ -101,7 +101,7 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ (strncmp(resource, "/printers/", 10) && strncmp(resource, "/classes/", 9))) { - LogMessage(L_ERROR, "ProcessBrowseData: Bad printer URI in browse data: %s", + cupsdLogMessage(L_ERROR, "cupsdProcessBrowseData: Bad printer URI in browse data: %s", uri); return; } @@ -110,7 +110,7 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ (!strncmp(resource, "/printers/", 10) && strchr(resource + 10, '/')) || (!strncmp(resource, "/classes/", 9) && strchr(resource + 9, '/'))) { - LogMessage(L_ERROR, "ProcessBrowseData: Bad resource in browse data: %s", + cupsdLogMessage(L_ERROR, "cupsdProcessBrowseData: Bad resource in browse data: %s", resource); return; } @@ -199,9 +199,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ else return; - if ((p = FindClass(name)) == NULL && BrowseShortNames) + if ((p = cupsdFindClass(name)) == NULL && BrowseShortNames) { - if ((p = FindClass(resource + 9)) != NULL) + if ((p = cupsdFindClass(resource + 9)) != NULL) { if (p->hostname && strcasecmp(p->hostname, host)) { @@ -213,15 +213,15 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ if (p->type & CUPS_PRINTER_REMOTE) { - LogMessage(L_INFO, "Renamed remote class \"%s\" to \"%s@%s\"...", + cupsdLogMessage(L_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); cupsArrayRemove(Printers, p); - SetStringf(&p->name, "%s@%s", p->name, p->hostname); - SetPrinterAttrs(p); + cupsdSetStringf(&p->name, "%s@%s", p->name, p->hostname); + cupsdSetPrinterAttrs(p); cupsArrayAdd(Printers, p); cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, @@ -238,9 +238,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ * that was created for a pending print job... */ - SetString(&p->hostname, host); - SetString(&p->uri, uri); - SetString(&p->device_uri, uri); + cupsdSetString(&p->hostname, host); + cupsdSetString(&p->uri, uri); + cupsdSetString(&p->device_uri, uri); update = 1; } } @@ -260,9 +260,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ * that was created for a pending print job... */ - SetString(&p->hostname, host); - SetString(&p->uri, uri); - SetString(&p->device_uri, uri); + cupsdSetString(&p->hostname, host); + cupsdSetString(&p->uri, uri); + cupsdSetString(&p->device_uri, uri); update = 1; } @@ -272,9 +272,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ * Class doesn't exist; add it... */ - p = AddClass(name); + p = cupsdAddClass(name); - LogMessage(L_INFO, "Added remote class \"%s\"...", name); + cupsdLogMessage(L_INFO, "Added remote class \"%s\"...", name); cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, "Class \'%s\' added by directory services.", name); @@ -285,9 +285,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ p->type = type & ~CUPS_PRINTER_REJECTING; p->accepting = 1; - SetString(&p->uri, uri); - SetString(&p->device_uri, uri); - SetString(&p->hostname, host); + cupsdSetString(&p->uri, uri); + cupsdSetString(&p->device_uri, uri); + cupsdSetString(&p->hostname, host); update = 1; } @@ -303,9 +303,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ else return; - if ((p = FindPrinter(name)) == NULL && BrowseShortNames) + if ((p = cupsdFindPrinter(name)) == NULL && BrowseShortNames) { - if ((p = FindPrinter(resource + 10)) != NULL) + if ((p = cupsdFindPrinter(resource + 10)) != NULL) { if (p->hostname && strcasecmp(p->hostname, host)) { @@ -317,15 +317,15 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ if (p->type & CUPS_PRINTER_REMOTE) { - LogMessage(L_INFO, "Renamed remote printer \"%s\" to \"%s@%s\"...", + cupsdLogMessage(L_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); cupsArrayRemove(Printers, p); - SetStringf(&p->name, "%s@%s", p->name, p->hostname); - SetPrinterAttrs(p); + cupsdSetStringf(&p->name, "%s@%s", p->name, p->hostname); + cupsdSetPrinterAttrs(p); cupsArrayAdd(Printers, p); cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, @@ -342,9 +342,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ * that was created for a pending print job... */ - SetString(&p->hostname, host); - SetString(&p->uri, uri); - SetString(&p->device_uri, uri); + cupsdSetString(&p->hostname, host); + cupsdSetString(&p->uri, uri); + cupsdSetString(&p->device_uri, uri); update = 1; } } @@ -364,9 +364,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ * that was created for a pending print job... */ - SetString(&p->hostname, host); - SetString(&p->uri, uri); - SetString(&p->device_uri, uri); + cupsdSetString(&p->hostname, host); + cupsdSetString(&p->uri, uri); + cupsdSetString(&p->device_uri, uri); update = 1; } @@ -376,12 +376,12 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ * Printer doesn't exist; add it... */ - p = AddPrinter(name); + p = cupsdAddPrinter(name); cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL, "Printer \'%s\' added by directory services.", name); - LogMessage(L_INFO, "Added remote printer \"%s\"...", name); + cupsdLogMessage(L_INFO, "Added remote printer \"%s\"...", name); /* * Force the URI to point to the real server... @@ -389,9 +389,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ p->type = type & ~CUPS_PRINTER_REJECTING; p->accepting = 1; - SetString(&p->hostname, host); - SetString(&p->uri, uri); - SetString(&p->device_uri, uri); + cupsdSetString(&p->hostname, host); + cupsdSetString(&p->uri, uri); + cupsdSetString(&p->device_uri, uri); update = 1; } @@ -428,13 +428,13 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ if (location && (!p->location || strcmp(p->location, location))) { - SetString(&p->location, location); + cupsdSetString(&p->location, location); update = 1; } if (info && (!p->info || strcmp(p->info, info))) { - SetString(&p->info, info); + cupsdSetString(&p->info, info); update = 1; } @@ -453,7 +453,7 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ if (!p->make_model || strcmp(p->make_model, local_make_model)) { - SetString(&p->make_model, local_make_model); + cupsdSetString(&p->make_model, local_make_model); update = 1; } @@ -465,13 +465,13 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ cupsdExpireSubscriptions(p, NULL); - DeletePrinter(p, 1); - UpdateImplicitClasses(); + cupsdDeletePrinter(p, 1); + cupsdUpdateImplicitClasses(); } else if (update) { - SetPrinterAttrs(p); - UpdateImplicitClasses(); + cupsdSetPrinterAttrs(p); + cupsdUpdateImplicitClasses(); } /* @@ -481,9 +481,9 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ if (DefaultPrinter == NULL && Printers != NULL) { - DefaultPrinter = (printer_t *)cupsArrayFirst(Printers); + DefaultPrinter = (cupsd_printer_t *)cupsArrayFirst(Printers); - WritePrintcap(); + cupsdWritePrintcap(); } /* @@ -496,10 +496,10 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ * Loop through all available printers and create classes as needed... */ - for (p = (printer_t *)cupsArrayFirst(Printers), len = 0, offset = 0, update = 0, + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers), len = 0, offset = 0, update = 0, pclass = NULL, first = NULL; p != NULL; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) { /* * Skip implicit classes... @@ -528,29 +528,29 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ if (pclass && strcasecmp(pclass->name, name)) { if (update) - SetPrinterAttrs(pclass); + cupsdSetPrinterAttrs(pclass); update = 0; pclass = NULL; } - if (!pclass && (pclass = FindDest(name)) == NULL) + if (!pclass && (pclass = cupsdFindDest(name)) == NULL) { /* * Need to add the class... */ - pclass = AddPrinter(name); + pclass = cupsdAddPrinter(name); pclass->type |= CUPS_PRINTER_IMPLICIT; pclass->accepting = 1; pclass->state = IPP_PRINTER_IDLE; - SetString(&pclass->location, p->location); - SetString(&pclass->info, p->info); + cupsdSetString(&pclass->location, p->location); + cupsdSetString(&pclass->info, p->info); update = 1; - LogMessage(L_INFO, "Added implicit class \"%s\"...", name); + cupsdLogMessage(L_INFO, "Added implicit class \"%s\"...", name); } if (first != NULL) @@ -560,7 +560,7 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ break; if (i >= pclass->num_printers) - AddPrinterToClass(pclass, first); + cupsdAddPrinterToClass(pclass, first); first = NULL; } @@ -571,7 +571,7 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ if (i >= pclass->num_printers) { - AddPrinterToClass(pclass, p); + cupsdAddPrinterToClass(pclass, p); update = 1; } } @@ -591,7 +591,7 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ name[len] = '\0'; offset = 0; - if ((first = FindDest(name)) != NULL && + if ((first = cupsdFindDest(name)) != NULL && !(first->type & CUPS_PRINTER_IMPLICIT)) { /* @@ -632,17 +632,17 @@ ProcessBrowseData(const char *uri, /* I - URI of printer/class */ */ if (pclass && update) - SetPrinterAttrs(pclass); + cupsdSetPrinterAttrs(pclass); } } /* - * 'SendBrowseDelete()' - Send a "browse delete" message for a printer. + * 'cupsdSendBrowseDelete()' - Send a "browse delete" message for a printer. */ void -SendBrowseDelete(printer_t *p) /* I - Printer to delete */ +cupsdSendBrowseDelete(cupsd_printer_t *p) /* I - Printer to delete */ { /* * Only announce if browsing is enabled... @@ -662,7 +662,7 @@ SendBrowseDelete(printer_t *p) /* I - Printer to delete */ */ if (BrowseLocalProtocols & BROWSE_CUPS) - SendCUPSBrowse(p); + cupsdSendCUPSBrowse(p); #ifdef HAVE_LIBSLP if (BrowseLocalProtocols & BROWSE_SLP) SLPDeregPrinter(p); @@ -671,14 +671,14 @@ SendBrowseDelete(printer_t *p) /* I - Printer to delete */ /* - * 'SendBrowseList()' - Send new browsing information as necessary. + * 'cupsdSendBrowseList()' - Send new browsing information as necessary. */ void -SendBrowseList(void) +cupsdSendBrowseList(void) { int count; /* Number of dests to update */ - printer_t *p; /* Current printer */ + cupsd_printer_t *p; /* Current printer */ time_t ut, /* Minimum update time */ to; /* Timeout time */ @@ -710,9 +710,9 @@ SendBrowseList(void) max_count = 2 * cupsArrayCount(Printers) / BrowseInterval + 1; - for (count = 0, p = (printer_t *)cupsArrayFirst(Printers); + for (count = 0, p = (cupsd_printer_t *)cupsArrayFirst(Printers); count < max_count && p != NULL; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) if (!(p->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) && p->shared && p->browse_time < ut) count ++; @@ -721,16 +721,16 @@ SendBrowseList(void) * Loop through all of the printers and send local updates as needed... */ - for (p = (printer_t *)cupsArrayFind(Printers, BrowseNext->name); + for (p = (cupsd_printer_t *)cupsArrayFind(Printers, BrowseNext->name); count > 0; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) { /* * Check for wraparound... */ if (!p) - p = (printer_t *)cupsArrayFirst(Printers); + p = (cupsd_printer_t *)cupsArrayFirst(Printers); if (!p) break; @@ -748,11 +748,11 @@ SendBrowseList(void) p->browse_time = time(NULL); if (BrowseLocalProtocols & BROWSE_CUPS) - SendCUPSBrowse(p); + cupsdSendCUPSBrowse(p); #ifdef HAVE_LIBSLP if (BrowseLocalProtocols & BROWSE_SLP) - SendSLPBrowse(p); + cupsdSendSLPBrowse(p); #endif /* HAVE_LIBSLP */ } } @@ -768,9 +768,9 @@ SendBrowseList(void) * Loop through all of the printers and send local updates as needed... */ - for (p = (printer_t *)cupsArrayFirst(Printers); + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) { /* * If this is a remote queue, see if it needs to be timed out... @@ -785,10 +785,10 @@ SendBrowseList(void) (p->type & CUPS_PRINTER_CLASS) ? "Class" : "Printer", p->name); - LogMessage(L_INFO, "Remote destination \"%s\" has timed out; deleting it...", + cupsdLogMessage(L_INFO, "Remote destination \"%s\" has timed out; deleting it...", p->name); - DeletePrinter(p, 1); + cupsdDeletePrinter(p, 1); } } } @@ -796,19 +796,19 @@ SendBrowseList(void) /* - * 'SendCUPSBrowse()' - Send new browsing information using the CUPS protocol. + * 'cupsdSendCUPSBrowse()' - Send new browsing information using the CUPS protocol. */ void -SendCUPSBrowse(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 */ - 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 */ - cups_netif_t *iface; /* Network interface */ + cupsd_netif_t *iface; /* Network interface */ /* @@ -851,7 +851,7 @@ SendCUPSBrowse(printer_t *p) /* I - Printer to send */ * Send to all local interfaces... */ - NetIFUpdate(); + cupsdNetIFUpdate(); for (iface = NetIFList; iface != NULL; iface = iface->next) { @@ -871,7 +871,7 @@ SendCUPSBrowse(printer_t *p) /* I - Printer to send */ bytes = strlen(packet); - LogMessage(L_DEBUG2, "SendBrowseList: (%d bytes to \"%s\") %s", bytes, + cupsdLogMessage(L_DEBUG2, "cupsdSendBrowseList: (%d bytes to \"%s\") %s", bytes, iface->name, packet); if (iface->broadcast.addr.sa_family == AF_INET) @@ -912,7 +912,7 @@ SendCUPSBrowse(printer_t *p) /* I - Printer to send */ bytes = strlen(packet); - LogMessage(L_DEBUG2, "SendBrowseList: (%d bytes to \"%s\") %s", bytes, + cupsdLogMessage(L_DEBUG2, "cupsdSendBrowseList: (%d bytes to \"%s\") %s", bytes, iface->name, packet); if (iface->broadcast.addr.sa_family == AF_INET) @@ -949,7 +949,7 @@ SendCUPSBrowse(printer_t *p) /* I - Printer to send */ p->make_model ? p->make_model : "Unknown"); bytes = strlen(packet); - LogMessage(L_DEBUG2, "SendBrowseList: (%d bytes) %s", bytes, packet); + cupsdLogMessage(L_DEBUG2, "cupsdSendBrowseList: (%d bytes) %s", bytes, packet); #ifdef AF_INET6 if (sendto(BrowseSocket, packet, bytes, 0, @@ -968,11 +968,11 @@ SendCUPSBrowse(printer_t *p) /* I - Printer to send */ * list... */ - LogMessage(L_ERROR, "SendBrowseList: sendto failed for browser %d - %s.", + cupsdLogMessage(L_ERROR, "cupsdSendBrowseList: sendto failed for browser %d - %s.", b - Browsers + 1, strerror(errno)); if (i > 1) - memcpy(b, b + 1, (i - 1) * sizeof(dirsvc_addr_t)); + memcpy(b, b + 1, (i - 1) * sizeof(cupsd_dirsvc_addr_t)); b --; NumBrowsers --; @@ -982,11 +982,11 @@ SendCUPSBrowse(printer_t *p) /* I - Printer to send */ /* - * 'StartBrowsing()' - Start sending and receiving broadcast information. + * 'cupsdStartBrowsing()' - Start sending and receiving broadcast information. */ void -StartBrowsing(void) +cupsdStartBrowsing(void) { int val; /* Socket option value */ struct sockaddr_in addr; /* Broadcast address */ @@ -1003,7 +1003,7 @@ StartBrowsing(void) if ((BrowseSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - LogMessage(L_ERROR, "StartBrowsing: Unable to create broadcast socket - %s.", + cupsdLogMessage(L_ERROR, "cupsdStartBrowsing: Unable to create broadcast socket - %s.", strerror(errno)); BrowseLocalProtocols &= ~BROWSE_CUPS; BrowseRemoteProtocols &= ~BROWSE_CUPS; @@ -1017,7 +1017,7 @@ StartBrowsing(void) val = 1; if (setsockopt(BrowseSocket, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val))) { - LogMessage(L_ERROR, "StartBrowsing: Unable to set broadcast mode - %s.", + cupsdLogMessage(L_ERROR, "cupsdStartBrowsing: Unable to set broadcast mode - %s.", strerror(errno)); #ifdef WIN32 @@ -1043,7 +1043,7 @@ StartBrowsing(void) if (bind(BrowseSocket, (struct sockaddr *)&addr, sizeof(addr))) { - LogMessage(L_ERROR, "StartBrowsing: Unable to bind broadcast socket - %s.", + cupsdLogMessage(L_ERROR, "cupsdStartBrowsing: Unable to bind broadcast socket - %s.", strerror(errno)); #ifdef WIN32 @@ -1068,7 +1068,7 @@ StartBrowsing(void) * Finally, add the socket to the input selection set... */ - LogMessage(L_DEBUG2, "StartBrowsing: Adding fd %d to InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdStartBrowsing: Adding fd %d to InputSet...", BrowseSocket); FD_SET(BrowseSocket, InputSet); @@ -1085,7 +1085,7 @@ StartBrowsing(void) if (SLPOpen("en", SLP_FALSE, &BrowseSLPHandle) != SLP_OK) { - LogMessage(L_ERROR, "Unable to open an SLP handle; disabling SLP browsing!"); + cupsdLogMessage(L_ERROR, "Unable to open an SLP handle; disabling SLP browsing!"); BrowseLocalProtocols &= ~BROWSE_SLP; BrowseRemoteProtocols &= ~BROWSE_SLP; } @@ -1097,14 +1097,14 @@ StartBrowsing(void) /* - * 'StartPolling()' - Start polling servers as needed. + * 'cupsdStartPolling()' - Start polling servers as needed. */ void -StartPolling(void) +cupsdStartPolling(void) { int i; /* Looping var */ - dirsvc_poll_t *poll; /* Current polling server */ + cupsd_dirsvc_poll_t *poll; /* Current polling server */ char polld[1024]; /* Poll daemon path */ char sport[10]; /* Server port */ char bport[10]; /* Browser port */ @@ -1153,7 +1153,7 @@ StartPolling(void) if (cupsdOpenPipe(statusfds)) { - LogMessage(L_ERROR, "Unable to create polling status pipes - %s.", + cupsdLogMessage(L_ERROR, "Unable to create polling status pipes - %s.", strerror(errno)); PollPipe = -1; PollStatusBuffer = NULL; @@ -1176,13 +1176,13 @@ StartPolling(void) if (cupsdStartProcess(polld, argv, envp, -1, -1, statusfds[1], -1, 0, &(poll->pid)) < 0) { - LogMessage(L_ERROR, "StartPolling: Unable to fork polling daemon - %s", + cupsdLogMessage(L_ERROR, "cupsdStartPolling: Unable to fork polling daemon - %s", strerror(errno)); poll->pid = 0; break; } else - LogMessage(L_DEBUG, "StartPolling: Started polling daemon for %s:%d, pid = %d", + cupsdLogMessage(L_DEBUG, "cupsdStartPolling: Started polling daemon for %s:%d, pid = %d", poll->hostname, poll->port, poll->pid); } @@ -1192,7 +1192,7 @@ StartPolling(void) * Finally, add the pipe to the input selection set... */ - LogMessage(L_DEBUG2, "StartPolling: Adding fd %d to InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdStartPolling: Adding fd %d to InputSet...", PollPipe); FD_SET(PollPipe, InputSet); @@ -1200,11 +1200,11 @@ StartPolling(void) /* - * 'StopBrowsing()' - Stop sending and receiving broadcast information. + * 'cupsdStopBrowsing()' - Stop sending and receiving broadcast information. */ void -StopBrowsing(void) +cupsdStopBrowsing(void) { if (!Browsing || !(BrowseLocalProtocols | BrowseRemoteProtocols)) return; @@ -1223,7 +1223,7 @@ StopBrowsing(void) close(BrowseSocket); #endif /* WIN32 */ - LogMessage(L_DEBUG2, "StopBrowsing: Removing fd %d from InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdStopBrowsing: Removing fd %d from InputSet...", BrowseSocket); FD_CLR(BrowseSocket, InputSet); @@ -1245,14 +1245,14 @@ StopBrowsing(void) /* - * 'StopPolling()' - Stop polling servers as needed. + * 'cupsdStopPolling()' - Stop polling servers as needed. */ void -StopPolling(void) +cupsdStopPolling(void) { int i; /* Looping var */ - dirsvc_poll_t *poll; /* Current polling server */ + cupsd_dirsvc_poll_t *poll; /* Current polling server */ if (PollPipe >= 0) @@ -1260,7 +1260,7 @@ StopPolling(void) cupsdStatBufDelete(PollStatusBuffer); close(PollPipe); - LogMessage(L_DEBUG2, "StopPolling: removing fd %d from InputSet.", + cupsdLogMessage(L_DEBUG2, "cupsdStopPolling: removing fd %d from InputSet.", PollPipe); FD_CLR(PollPipe, InputSet); @@ -1275,11 +1275,11 @@ StopPolling(void) /* - * 'UpdateCUPSBrowse()' - Update the browse lists using the CUPS protocol. + * 'cupsdUpdateCUPSBrowse()' - Update the browse lists using the CUPS protocol. */ void -UpdateCUPSBrowse(void) +cupsdUpdateCUPSBrowse(void) { int i; /* Looping var */ int auth; /* Authorization status */ @@ -1302,7 +1302,7 @@ UpdateCUPSBrowse(void) location[IPP_MAX_NAME], /* Location string */ make_model[IPP_MAX_NAME];/* Make and model string */ int port; /* Port portion of URI */ - cups_netif_t *iface; /* Network interface */ + cupsd_netif_t *iface; /* Network interface */ /* @@ -1321,10 +1321,10 @@ UpdateCUPSBrowse(void) if (errno != ECONNREFUSED && errno != EAGAIN) { - LogMessage(L_ERROR, "Browse recv failed - %s.", strerror(errno)); - LogMessage(L_ERROR, "Browsing turned off."); + cupsdLogMessage(L_ERROR, "Browse recv failed - %s.", strerror(errno)); + cupsdLogMessage(L_ERROR, "Browsing turned off."); - StopBrowsing(); + cupsdStopBrowsing(); Browsing = 0; } @@ -1395,11 +1395,11 @@ UpdateCUPSBrowse(void) case AUTH_ALLOW : /* Order Deny,Allow */ auth = AUTH_ALLOW; - if (CheckAuth(address, srcname, len, + if (cupsdCheckAuth(address, srcname, len, BrowseACL->num_deny, BrowseACL->deny)) auth = AUTH_DENY; - if (CheckAuth(address, srcname, len, + if (cupsdCheckAuth(address, srcname, len, BrowseACL->num_allow, BrowseACL->allow)) auth = AUTH_ALLOW; break; @@ -1407,11 +1407,11 @@ UpdateCUPSBrowse(void) case AUTH_DENY : /* Order Allow,Deny */ auth = AUTH_DENY; - if (CheckAuth(address, srcname, len, + if (cupsdCheckAuth(address, srcname, len, BrowseACL->num_allow, BrowseACL->allow)) auth = AUTH_ALLOW; - if (CheckAuth(address, srcname, len, + if (cupsdCheckAuth(address, srcname, len, BrowseACL->num_deny, BrowseACL->deny)) auth = AUTH_DENY; break; @@ -1423,12 +1423,12 @@ UpdateCUPSBrowse(void) if (auth == AUTH_DENY) { - LogMessage(L_DEBUG, "UpdateCUPSBrowse: Refused %d bytes from %s", bytes, + cupsdLogMessage(L_DEBUG, "cupsdUpdateCUPSBrowse: Refused %d bytes from %s", bytes, srcname); return; } - LogMessage(L_DEBUG2, "UpdateCUPSBrowse: (%d bytes from %s) %s", bytes, srcname, + cupsdLogMessage(L_DEBUG2, "cupsdUpdateCUPSBrowse: (%d bytes from %s) %s", bytes, srcname, packet); /* @@ -1437,7 +1437,7 @@ UpdateCUPSBrowse(void) if (sscanf(packet, "%x%x%1023s", &type, &state, uri) < 3) { - LogMessage(L_WARN, "UpdateCUPSBrowse: Garbled browse packet - %s", + cupsdLogMessage(L_WARN, "cupsdUpdateCUPSBrowse: Garbled browse packet - %s", packet); return; } @@ -1516,7 +1516,7 @@ UpdateCUPSBrowse(void) if (!strcasecmp(host, ServerName) && port == LocalPort) return; - NetIFUpdate(); + cupsdNetIFUpdate(); for (iface = NetIFList; iface != NULL; iface = iface->next) if (!strcasecmp(host, iface->hostname) && port == LocalPort) @@ -1527,12 +1527,12 @@ UpdateCUPSBrowse(void) */ for (i = 0; i < NumRelays; i ++) - if (CheckAuth(address, srcname, len, 1, &(Relays[i].from))) + if (cupsdCheckAuth(address, srcname, len, 1, &(Relays[i].from))) if (sendto(BrowseSocket, packet, bytes, 0, (struct sockaddr *)&(Relays[i].to), sizeof(http_addr_t)) <= 0) { - LogMessage(L_ERROR, "UpdateCUPSBrowse: sendto failed for relay %d - %s.", + cupsdLogMessage(L_ERROR, "cupsdUpdateCUPSBrowse: sendto failed for relay %d - %s.", i + 1, strerror(errno)); return; } @@ -1541,17 +1541,17 @@ UpdateCUPSBrowse(void) * Process the browse data... */ - ProcessBrowseData(uri, (cups_ptype_t)type, (ipp_pstate_t)state, location, + cupsdProcessBrowseData(uri, (cups_ptype_t)type, (ipp_pstate_t)state, location, info, make_model); } /* - * 'UpdatePolling()' - Read status messages from the poll daemons. + * 'cupsdUpdatePolling()' - Read status messages from the poll daemons. */ void -UpdatePolling(void) +cupsdUpdatePolling(void) { char *ptr, /* Pointer to end of line in buffer */ message[1024]; /* Pointer to message text */ @@ -1569,8 +1569,8 @@ UpdatePolling(void) * All polling processes have died; stop polling... */ - LogMessage(L_ERROR, "UpdatePolling: all polling processes have exited!"); - StopPolling(); + cupsdLogMessage(L_ERROR, "cupsdUpdatePolling: all polling processes have exited!"); + cupsdStopPolling(); } } @@ -1617,11 +1617,11 @@ RegReportCallback(SLPHandle hslp, /* - * 'SendSLPBrowse()' - Register the specified printer with SLP. + * 'cupsdSendSLPBrowse()' - Register the specified printer with SLP. */ void -SendSLPBrowse(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 */ @@ -1638,7 +1638,7 @@ SendSLPBrowse(printer_t *p) /* I - Printer to register */ SLPError error; /* SLP error, if any */ - LogMessage(L_DEBUG, "SendSLPBrowse(%p = \"%s\")", p, p->name); + cupsdLogMessage(L_DEBUG, "cupsdSendSLPBrowse(%p = \"%s\")", p, p->name); /* * Make the SLP service URL that conforms to the IANA @@ -1647,7 +1647,7 @@ SendSLPBrowse(printer_t *p) /* I - Printer to register */ snprintf(srvurl, sizeof(srvurl), SLP_CUPS_SRVTYPE ":%s", p->uri); - LogMessage(L_DEBUG2, "Service URL = \"%s\"", srvurl); + cupsdLogMessage(L_DEBUG2, "Service URL = \"%s\"", srvurl); /* * Figure out the finishings string... @@ -1779,7 +1779,7 @@ SendSLPBrowse(printer_t *p) /* I - Printer to register */ p->type & CUPS_PRINTER_DUPLEX ? ",two-sided-long-edge,two-sided-short-edge" : ""); - LogMessage(L_DEBUG2, "Attributes = \"%s\"", attrs); + cupsdLogMessage(L_DEBUG2, "Attributes = \"%s\"", attrs); /* * Register the printer with the SLP server... @@ -1789,7 +1789,7 @@ SendSLPBrowse(printer_t *p) /* I - Printer to register */ SLP_CUPS_SRVTYPE, attrs, SLP_TRUE, RegReportCallback, 0); if (error != SLP_OK) - LogMessage(L_ERROR, "SLPReg of \"%s\" failed with status %d!", p->name, + cupsdLogMessage(L_ERROR, "SLPReg of \"%s\" failed with status %d!", p->name, error); } @@ -1799,12 +1799,12 @@ SendSLPBrowse(printer_t *p) /* I - Printer to register */ */ void -SLPDeregPrinter(printer_t *p) +SLPDeregPrinter(cupsd_printer_t *p) { char srvurl[HTTP_MAX_URI]; /* Printer service URI */ - LogMessage(L_DEBUG, "SLPDeregPrinter: printer=\"%s\"", p->name); + cupsdLogMessage(L_DEBUG, "SLPDeregPrinter: printer=\"%s\"", p->name); if((p->type & CUPS_PRINTER_REMOTE) == 0) { @@ -1837,7 +1837,7 @@ GetSlpAttrVal(const char *attrlist, /* I - Attribute list string */ *ptr2; /* ... */ - ClearString(valbuf); + cupsdClearString(valbuf); if ((ptr1 = strstr(attrlist, tag)) != NULL) { @@ -1879,7 +1879,7 @@ AttrCallback(SLPHandle hslp, /* I - SLP handle */ void *cookie) /* I - Current printer */ { char *tmp = 0; - printer_t *p = (printer_t*)cookie; + cupsd_printer_t *p = (cupsd_printer_t*)cookie; /* @@ -1899,7 +1899,7 @@ AttrCallback(SLPHandle hslp, /* I - SLP handle */ * Parse the attrlist to obtain things needed to build CUPS browse packet */ - memset(p, 0, sizeof(printer_t)); + memset(p, 0, sizeof(cupsd_printer_t)); p->type = CUPS_PRINTER_REMOTE; @@ -1929,7 +1929,7 @@ AttrCallback(SLPHandle hslp, /* I - SLP handle */ if (strstr(tmp,"two-sided")) p->type |= CUPS_PRINTER_DUPLEX; - ClearString(&tmp); + cupsdClearString(&tmp); return (SLP_TRUE); } @@ -1997,15 +1997,15 @@ SrvUrlCallback(SLPHandle hslp, /* I - SLP handle */ /* - * 'UpdateSLPBrowse()' - Get browsing information via SLP. + * 'cupsdUpdateSLPBrowse()' - Get browsing information via SLP. */ void -UpdateSLPBrowse(void) +cupsdUpdateSLPBrowse(void) { slpsrvurl_t *s, /* Temporary list of service URLs */ *next; /* Next service in list */ - printer_t p; /* Printer information */ + cupsd_printer_t p; /* Printer information */ const char *uri; /* Pointer to printer URI */ char method[HTTP_MAX_URI], /* Method portion of URI */ username[HTTP_MAX_URI], /* Username portion of URI */ @@ -2014,7 +2014,7 @@ UpdateSLPBrowse(void) int port; /* Port portion of URI */ - LogMessage(L_DEBUG, "UpdateSLPBrowse() Start..."); + cupsdLogMessage(L_DEBUG, "cupsdUpdateSLPBrowse() Start..."); /* * Reset the refresh time... @@ -2044,7 +2044,7 @@ UpdateSLPBrowse(void) next = s->next; /* - * Load a printer_t structure with the SLP service attributes... + * Load a cupsd_printer_t structure with the SLP service attributes... */ SLPFindAttrs(BrowseSLPHandle, s->url, "", "", AttrCallback, &p); @@ -2073,10 +2073,10 @@ UpdateSLPBrowse(void) */ if (strstr(uri, "/printers/") != NULL) - ProcessBrowseData(uri, p.type, IPP_PRINTER_IDLE, p.location, + cupsdProcessBrowseData(uri, p.type, IPP_PRINTER_IDLE, p.location, p.info, p.make_model); else if (strstr(uri, "/classes/") != NULL) - ProcessBrowseData(uri, p.type | CUPS_PRINTER_CLASS, IPP_PRINTER_IDLE, + cupsdProcessBrowseData(uri, p.type | CUPS_PRINTER_CLASS, IPP_PRINTER_IDLE, p.location, p.info, p.make_model); } @@ -2087,7 +2087,7 @@ UpdateSLPBrowse(void) free(s); } - LogMessage(L_DEBUG, "UpdateSLPBrowse() End..."); + cupsdLogMessage(L_DEBUG, "cupsdUpdateSLPBrowse() End..."); } #endif /* HAVE_LIBSLP */ diff --git a/scheduler/dirsvc.h b/scheduler/dirsvc.h index 72c63d594..4ba9f1db1 100644 --- a/scheduler/dirsvc.h +++ b/scheduler/dirsvc.h @@ -50,7 +50,7 @@ typedef struct { char iface[32]; /* Destination interface */ http_addr_t to; /* Destination address */ -} dirsvc_addr_t; +} cupsd_dirsvc_addr_t; /* @@ -59,9 +59,9 @@ typedef struct typedef struct { - authmask_t from; /* Source address/name mask */ + cupsd_authmask_t from; /* Source address/name mask */ http_addr_t to; /* Destination address */ -} dirsvc_relay_t; +} cupsd_dirsvc_relay_t; /* @@ -73,7 +73,7 @@ typedef struct char hostname[64]; /* Hostname (actually, IP address) */ int port; /* Port number */ int pid; /* Current poll server PID */ -} dirsvc_poll_t; +} cupsd_dirsvc_poll_t; /* @@ -106,19 +106,19 @@ VAR char *BrowseLocalOptions *BrowseRemoteOptions VALUE(NULL); /* Options to add to remote printer URIs */ -VAR dirsvc_addr_t *Browsers VALUE(NULL); +VAR cupsd_dirsvc_addr_t *Browsers VALUE(NULL); /* Broadcast addresses */ -VAR location_t *BrowseACL VALUE(NULL); +VAR cupsd_location_t *BrowseACL VALUE(NULL); /* Browser access control list */ -VAR 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 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 */ -VAR dirsvc_poll_t *Polled VALUE(NULL); +VAR cupsd_dirsvc_poll_t *Polled VALUE(NULL); /* Polled servers */ VAR int PollPipe VALUE(0); /* Status pipe for pollers */ @@ -137,20 +137,20 @@ VAR time_t BrowseSLPRefresh VALUE(0); * Prototypes... */ -extern void ProcessBrowseData(const char *uri, cups_ptype_t type, +extern void cupsdProcessBrowseData(const char *uri, cups_ptype_t type, ipp_pstate_t state, const char *location, const char *info, const char *make_model); -extern void SendBrowseDelete(printer_t *p); -extern void SendBrowseList(void); -extern void SendCUPSBrowse(printer_t *p); -extern void SendSLPBrowse(printer_t *p); -extern void StartBrowsing(void); -extern void StartPolling(void); -extern void StopBrowsing(void); -extern void StopPolling(void); -extern void UpdateCUPSBrowse(void); -extern void UpdatePolling(void); -extern void UpdateSLPBrowse(void); +extern void cupsdSendBrowseDelete(cupsd_printer_t *p); +extern void cupsdSendBrowseList(void); +extern void cupsdSendCUPSBrowse(cupsd_printer_t *p); +extern void cupsdSendSLPBrowse(cupsd_printer_t *p); +extern void cupsdStartBrowsing(void); +extern void cupsdStartPolling(void); +extern void cupsdStopBrowsing(void); +extern void cupsdStopPolling(void); +extern void cupsdUpdateCUPSBrowse(void); +extern void cupsdUpdatePolling(void); +extern void cupsdUpdateSLPBrowse(void); /* diff --git a/scheduler/env.c b/scheduler/env.c index 62a38f38f..e5277b6b7 100644 --- a/scheduler/env.c +++ b/scheduler/env.c @@ -57,7 +57,7 @@ cupsdClearEnv(void) for (i = 0; i < num_common_env; i ++) - ClearString(common_env + i); + cupsdClearString(common_env + i); num_common_env = 0; } @@ -82,7 +82,7 @@ cupsdInitEnv(void) * to access their bundle resources properly... */ - SetString(common_env, ""); + cupsdSetString(common_env, ""); num_common_env = 1; #endif /* __APPLE__ */ @@ -162,7 +162,7 @@ cupsdSetEnv(const char *name, /* I - Name of variable */ if (num_common_env >= (int)(sizeof(common_env) / sizeof(common_env[0]))) { - LogMessage(L_ERROR, "cupsdSetEnv: Too many environment variables set!"); + cupsdLogMessage(L_ERROR, "cupsdSetEnv: Too many environment variables set!"); return; } @@ -180,9 +180,9 @@ cupsdSetEnv(const char *name, /* I - Name of variable */ * Set the new environment variable... */ - SetStringf(common_env + num_common_env, "%s=%s", name, value); + cupsdSetStringf(common_env + num_common_env, "%s=%s", name, value); - LogMessage(L_DEBUG, "cupsdSetEnv: %s\n", common_env[num_common_env]); + cupsdLogMessage(L_DEBUG, "cupsdSetEnv: %s\n", common_env[num_common_env]); num_common_env ++; } diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 4b5bfa757..5cafcfc02 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -23,15 +23,15 @@ * * Contents: * - * ProcessIPPRequest() - 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_job_state_reasons() - Add the "job-state-reasons" attribute based + * add_cupsd_job_state_reasons() - Add the "job-state-reasons" attribute based * upon the job and printer state... - * add_job_subscriptions() - Add any subcriptions for a job. + * add_cupsd_job_subscriptions() - Add any subcriptions for a job. * add_printer() - Add a printer to the system. - * add_printer_state_reasons() - Add the "printer-state-reasons" attribute + * add_cupsd_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. @@ -67,7 +67,7 @@ * 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_job_ticket() - Reads a job ticket embedded in a PS file. + * read_ps_cupsd_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. @@ -111,73 +111,73 @@ typedef struct * Local functions... */ -static void accept_jobs(client_t *con, ipp_attribute_t *uri); -static void add_class(client_t *con, ipp_attribute_t *uri); -static int add_file(client_t *con, job_t *job, mime_type_t *filetype, +static void accept_jobs(cupsd_client_t *con, ipp_attribute_t *uri); +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_job_state_reasons(client_t *con, job_t *job); -static void add_job_subscriptions(client_t *con, job_t *job); -static void add_printer(client_t *con, ipp_attribute_t *uri); -static void add_printer_state_reasons(client_t *con, printer_t *p); -static void add_queued_job_count(client_t *con, printer_t *p); -static void authenticate_job(client_t *con, ipp_attribute_t *uri); -static void cancel_all_jobs(client_t *con, ipp_attribute_t *uri); -static void cancel_job(client_t *con, ipp_attribute_t *uri); -static void cancel_subscription(client_t *con, int id); -static int check_quotas(client_t *con, printer_t *p); +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_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_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 void cancel_job(cupsd_client_t *con, ipp_attribute_t *uri); +static void cancel_subscription(cupsd_client_t *con, int id); +static int check_quotas(cupsd_client_t *con, cupsd_printer_t *p); static ipp_attribute_t *copy_attribute(ipp_t *to, ipp_attribute_t *attr, int quickcopy); static void copy_attrs(ipp_t *to, ipp_t *from, ipp_attribute_t *req, ipp_tag_t group, int quickcopy); -static int copy_banner(client_t *con, job_t *job, const char *name); +static int copy_banner(cupsd_client_t *con, cupsd_job_t *job, const char *name); static int copy_file(const char *from, const char *to); -static int copy_model(client_t *con, const char *from, const char *to); -static void create_job(client_t *con, ipp_attribute_t *uri); -static void create_subscription(client_t *con, ipp_attribute_t *uri); -static void delete_printer(client_t *con, ipp_attribute_t *uri); -static void get_default(client_t *con); -static void get_devices(client_t *con); -static void get_jobs(client_t *con, ipp_attribute_t *uri); -static void get_job_attrs(client_t *con, ipp_attribute_t *uri); -static void get_notifications(client_t *con, int id); -static void get_ppds(client_t *con); -static void get_printers(client_t *con, int type); -static void get_printer_attrs(client_t *con, ipp_attribute_t *uri); -static void get_subscription_attrs(client_t *con, int sub_id); -static void get_subscriptions(client_t *con, ipp_attribute_t *uri); -static void hold_job(client_t *con, ipp_attribute_t *uri); -static void move_job(client_t *con, ipp_attribute_t *uri); +static int copy_model(cupsd_client_t *con, const char *from, const char *to); +static void create_job(cupsd_client_t *con, ipp_attribute_t *uri); +static void create_subscription(cupsd_client_t *con, ipp_attribute_t *uri); +static void delete_printer(cupsd_client_t *con, ipp_attribute_t *uri); +static void get_default(cupsd_client_t *con); +static void get_devices(cupsd_client_t *con); +static void get_jobs(cupsd_client_t *con, ipp_attribute_t *uri); +static void get_job_attrs(cupsd_client_t *con, ipp_attribute_t *uri); +static void get_notifications(cupsd_client_t *con, int id); +static void get_ppds(cupsd_client_t *con); +static void get_printers(cupsd_client_t *con, int type); +static void get_printer_attrs(cupsd_client_t *con, ipp_attribute_t *uri); +static void get_subscription_attrs(cupsd_client_t *con, int sub_id); +static void get_subscriptions(cupsd_client_t *con, ipp_attribute_t *uri); +static void hold_job(cupsd_client_t *con, ipp_attribute_t *uri); +static void move_job(cupsd_client_t *con, ipp_attribute_t *uri); static int ppd_add_default(const char *option, const char *choice, int num_defaults, ppd_default_t **defaults); static int ppd_parse_line(const char *line, char *option, int olen, char *choice, int clen); -static void print_job(client_t *con, ipp_attribute_t *uri); -static void read_ps_job_ticket(client_t *con); -static void reject_jobs(client_t *con, ipp_attribute_t *uri); -static void release_job(client_t *con, ipp_attribute_t *uri); -static void renew_subscription(client_t *con, int sub_id); -static void restart_job(client_t *con, ipp_attribute_t *uri); -static void save_auth_info(client_t *con, int job_id); -static void send_document(client_t *con, ipp_attribute_t *uri); -static void send_ipp_error(client_t *con, ipp_status_t status); -static void set_default(client_t *con, ipp_attribute_t *uri); -static void set_job_attrs(client_t *con, ipp_attribute_t *uri); -static void start_printer(client_t *con, ipp_attribute_t *uri); -static void stop_printer(client_t *con, ipp_attribute_t *uri); -static int user_allowed(printer_t *p, const char *username); -static void validate_job(client_t *con, ipp_attribute_t *uri); +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 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); +static void restart_job(cupsd_client_t *con, ipp_attribute_t *uri); +static void save_auth_info(cupsd_client_t *con, int job_id); +static void send_document(cupsd_client_t *con, ipp_attribute_t *uri); +static void send_ipp_error(cupsd_client_t *con, ipp_status_t status); +static void set_default(cupsd_client_t *con, ipp_attribute_t *uri); +static void set_job_attrs(cupsd_client_t *con, ipp_attribute_t *uri); +static void start_printer(cupsd_client_t *con, ipp_attribute_t *uri); +static void stop_printer(cupsd_client_t *con, ipp_attribute_t *uri); +static int user_allowed(cupsd_printer_t *p, const char *username); +static void validate_job(cupsd_client_t *con, ipp_attribute_t *uri); static int validate_name(const char *name); -static int validate_user(job_t *job, client_t *con, +static int validate_user(cupsd_job_t *job, cupsd_client_t *con, const char *owner, char *username, int userlen); /* - * 'ProcessIPPRequest()' - Process an incoming IPP request... + * 'cupsdProcessIPPRequest()' - Process an incoming IPP request... */ int /* O - 1 on success, 0 on failure */ -ProcessIPPRequest(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 */ @@ -188,7 +188,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ int sub_id; /* Subscription ID */ - LogMessage(L_DEBUG2, "ProcessIPPRequest(%p[%d]): operation_id = %04x", + cupsdLogMessage(L_DEBUG2, "cupsdProcessIPPRequest(%p[%d]): operation_id = %04x", con, con->http.fd, con->request->request.op.operation_id); /* @@ -211,7 +211,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ * Return an error, since we only support IPP 1.x. */ - LogMessage(L_ERROR, "ProcessIPPRequest: bad request version (%d.%d)!", + cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: bad request version (%d.%d)!", con->request->request.any.version[0], con->request->request.any.version[1]); @@ -225,7 +225,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ } else if (con->request->attrs == NULL) { - LogMessage(L_ERROR, "ProcessIPPRequest: no attributes in request!"); + cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: no attributes in request!"); cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL, "%04X %s No attributes in request", @@ -249,7 +249,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ * Out of order; return an error... */ - LogMessage(L_ERROR, "ProcessIPPRequest: attribute groups are out of order!"); + cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: attribute groups are out of order!"); cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL, "%04X %s Attribute groups are out of order", @@ -325,7 +325,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ if (!charset) { - LogMessage(L_ERROR, "ProcessIPPRequest: missing attributes-charset attribute!"); + cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: missing attributes-charset attribute!"); cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL, "%04X %s Missing attributes-charset attribute", @@ -334,7 +334,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ if (!language) { - LogMessage(L_ERROR, "ProcessIPPRequest: missing attributes-natural-language attribute!"); + cupsdLogMessage(L_ERROR, "cupsdProcessIPPRequest: missing attributes-natural-language attribute!"); cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL, "%04X %s Missing attributes-natural-language attribute", @@ -343,21 +343,21 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ if (!uri) { - LogMessage(L_ERROR, "ProcessIPPRequest: missing printer-uri or job-uri attribute!"); + cupsdLogMessage(L_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); } - LogMessage(L_DEBUG, "Request attributes follow..."); + cupsdLogMessage(L_DEBUG, "Request attributes follow..."); for (attr = con->request->attrs; attr != NULL; attr = attr->next) - LogMessage(L_DEBUG, "attr \"%s\": group_tag = %x, value_tag = %x", + cupsdLogMessage(L_DEBUG, "attr \"%s\": group_tag = %x, value_tag = %x", attr->name ? attr->name : "(null)", attr->group_tag, attr->value_tag); - LogMessage(L_DEBUG, "End of attributes..."); + cupsdLogMessage(L_DEBUG, "End of attributes..."); send_ipp_error(con, IPP_BAD_REQUEST); } @@ -383,7 +383,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ * Remote unauthenticated user masquerading as local root... */ - SetString(&(username->values[0].string.text), RemoteRoot); + cupsdSetString(&(username->values[0].string.text), RemoteRoot); } } @@ -398,7 +398,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ */ if (uri) - LogMessage(L_DEBUG2, "ProcessIPPRequest: URI=\"%s\"", + cupsdLogMessage(L_DEBUG2, "cupsdProcessIPPRequest: URI=\"%s\"", uri->values[0].string.text); switch (con->request->request.op.operation_id) @@ -566,11 +566,11 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ * Sending data from the scheduler... */ - LogMessage(L_DEBUG, "ProcessIPPRequest: %d status_code=%x (%s)", + 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)); - if (SendHeader(con, HTTP_OK, "application/ipp")) + if (cupsdSendHeader(con, HTTP_OK, "application/ipp")) { if (con->http.version == HTTP_1_1) { @@ -587,7 +587,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ con->http.data_remaining); } - LogMessage(L_DEBUG2, "ProcessIPPRequest: Adding fd %d to OutputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdProcessIPPRequest: Adding fd %d to OutputSet...", con->http.fd); FD_SET(con->http.fd, OutputSet); @@ -624,7 +624,7 @@ ProcessIPPRequest(client_t *con) /* I - Client connection */ */ static void -accept_jobs(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) */ @@ -634,10 +634,10 @@ accept_jobs(client_t *con, /* I - Client connection */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ const char *name; /* Printer name */ - printer_t *printer; /* Printer data */ + cupsd_printer_t *printer; /* Printer data */ - LogMessage(L_DEBUG2, "accept_jobs(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "accept_jobs(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -646,7 +646,7 @@ accept_jobs(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/admin/", 7) != 0) { - LogMessage(L_ERROR, "accept_jobs: admin request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "accept_jobs: admin request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -658,13 +658,13 @@ accept_jobs(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((name = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "accept_jobs: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "accept_jobs: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -675,7 +675,7 @@ accept_jobs(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) { - LogMessage(L_ERROR, "accept_jobs: not authorized!"); + cupsdLogMessage(L_ERROR, "accept_jobs: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -687,14 +687,14 @@ accept_jobs(client_t *con, /* I - Client connection */ printer->accepting = 1; printer->state_message[0] = '\0'; - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); if (dtype & CUPS_PRINTER_CLASS) - SaveAllClasses(); + cupsdSaveAllClasses(); else - SaveAllPrinters(); + cupsdSaveAllPrinters(); - LogMessage(L_INFO, "Printer \'%s\' now accepting jobs (\'%s\').", name, + cupsdLogMessage(L_INFO, "Printer \'%s\' now accepting jobs (\'%s\').", name, con->username); /* @@ -710,7 +710,7 @@ accept_jobs(client_t *con, /* I - Client connection */ */ static void -add_class(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 */ @@ -719,7 +719,7 @@ add_class(client_t *con, /* I - Client connection */ host[HTTP_MAX_URI], /* Host portion of URI */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - 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 */ @@ -727,7 +727,7 @@ add_class(client_t *con, /* I - Client connection */ int modify; /* Non-zero if we just modified */ - LogMessage(L_DEBUG2, "add_class(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "add_class(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -736,7 +736,7 @@ add_class(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/admin/", 7) != 0) { - LogMessage(L_ERROR, "add_class: admin request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "add_class: admin request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -778,7 +778,7 @@ add_class(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "add_class: not authorized!"); + cupsdLogMessage(L_ERROR, "add_class: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -787,13 +787,13 @@ add_class(client_t *con, /* I - Client connection */ * See if the class already exists; if not, create a new class... */ - if ((pclass = FindClass(resource + 9)) == NULL) + if ((pclass = cupsdFindClass(resource + 9)) == NULL) { /* * Class doesn't exist; see if we have a printer of the same name... */ - if ((pclass = FindPrinter(resource + 9)) != NULL && + if ((pclass = cupsdFindPrinter(resource + 9)) != NULL && !(pclass->type & CUPS_PRINTER_REMOTE)) { /* @@ -808,7 +808,7 @@ add_class(client_t *con, /* I - Client connection */ * No, add the pclass... */ - pclass = AddClass(resource + 9); + pclass = cupsdAddClass(resource + 9); modify = 0; } else if (pclass->type & CUPS_PRINTER_IMPLICIT) @@ -820,17 +820,17 @@ add_class(client_t *con, /* I - Client connection */ if (ImplicitAnyClasses) { cupsArrayRemove(Printers, pclass); - SetStringf(&pclass->name, "Any%s", resource + 9); + cupsdSetStringf(&pclass->name, "Any%s", resource + 9); cupsArrayAdd(Printers, pclass); } else - DeletePrinter(pclass, 1); + cupsdDeletePrinter(pclass, 1); /* * Add the class as a new local class... */ - pclass = AddClass(resource + 9); + pclass = cupsdAddClass(resource + 9); modify = 0; } else if (pclass->type & CUPS_PRINTER_REMOTE) @@ -839,17 +839,17 @@ add_class(client_t *con, /* I - Client connection */ * Rename the remote class to "Class"... */ - DeletePrinterFilters(pclass); + cupsdDeletePrinterFilters(pclass); cupsArrayRemove(Printers, pclass); - SetStringf(&pclass->name, "%s@%s", resource + 9, pclass->hostname); - SetPrinterAttrs(pclass); + cupsdSetStringf(&pclass->name, "%s@%s", resource + 9, pclass->hostname); + cupsdSetPrinterAttrs(pclass); cupsArrayAdd(Printers, pclass); /* * Add the class as a new local class... */ - pclass = AddClass(resource + 9); + pclass = cupsdAddClass(resource + 9); modify = 0; } else @@ -860,23 +860,23 @@ add_class(client_t *con, /* I - Client connection */ */ if ((attr = ippFindAttribute(con->request, "printer-location", IPP_TAG_TEXT)) != NULL) - SetString(&pclass->location, attr->values[0].string.text); + cupsdSetString(&pclass->location, attr->values[0].string.text); if ((attr = ippFindAttribute(con->request, "printer-info", IPP_TAG_TEXT)) != NULL) - SetString(&pclass->info, attr->values[0].string.text); + cupsdSetString(&pclass->info, attr->values[0].string.text); if ((attr = ippFindAttribute(con->request, "printer-is-accepting-jobs", IPP_TAG_BOOLEAN)) != NULL) { - LogMessage(L_INFO, "Setting %s printer-is-accepting-jobs to %d (was %d.)", + cupsdLogMessage(L_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; - AddPrinterHistory(pclass); + cupsdAddPrinterHistory(pclass); } if ((attr = ippFindAttribute(con->request, "printer-is-shared", IPP_TAG_BOOLEAN)) != NULL) { - LogMessage(L_INFO, "Setting %s printer-is-shared to %d (was %d.)", + cupsdLogMessage(L_INFO, "Setting %s printer-is-shared to %d (was %d.)", pclass->name, attr->values[0].boolean, pclass->shared); pclass->shared = attr->values[0].boolean; @@ -887,78 +887,78 @@ add_class(client_t *con, /* I - Client connection */ if (attr->values[0].integer != IPP_PRINTER_IDLE && attr->values[0].integer == IPP_PRINTER_STOPPED) { - LogMessage(L_ERROR, "Attempt to set %s printer-state to bad value %d!", + cupsdLogMessage(L_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; } - LogMessage(L_INFO, "Setting %s printer-state to %d (was %d.)", pclass->name, + cupsdLogMessage(L_INFO, "Setting %s printer-state to %d (was %d.)", pclass->name, attr->values[0].integer, pclass->state); - SetPrinterState(pclass, (ipp_pstate_t)(attr->values[0].integer), 0); + cupsdSetPrinterState(pclass, (ipp_pstate_t)(attr->values[0].integer), 0); } if ((attr = ippFindAttribute(con->request, "printer-state-message", IPP_TAG_TEXT)) != NULL) { strlcpy(pclass->state_message, attr->values[0].string.text, sizeof(pclass->state_message)); - AddPrinterHistory(pclass); + cupsdAddPrinterHistory(pclass); } if ((attr = ippFindAttribute(con->request, "job-sheets-default", IPP_TAG_ZERO)) != NULL && !Classification) { - SetString(&pclass->job_sheets[0], attr->values[0].string.text); + cupsdSetString(&pclass->cupsd_job_sheets[0], attr->values[0].string.text); if (attr->num_values > 1) - SetString(&pclass->job_sheets[1], attr->values[1].string.text); + cupsdSetString(&pclass->cupsd_job_sheets[1], attr->values[1].string.text); else - SetString(&pclass->job_sheets[1], "none"); + cupsdSetString(&pclass->cupsd_job_sheets[1], "none"); } if ((attr = ippFindAttribute(con->request, "requesting-user-name-allowed", IPP_TAG_ZERO)) != NULL) { - FreePrinterUsers(pclass); + cupsdFreePrinterUsers(pclass); pclass->deny_users = 0; if (attr->value_tag == IPP_TAG_NAME && (attr->num_values > 1 || strcmp(attr->values[0].string.text, "all") != 0)) for (i = 0; i < attr->num_values; i ++) - AddPrinterUser(pclass, attr->values[i].string.text); + cupsdAddPrinterUser(pclass, attr->values[i].string.text); } else if ((attr = ippFindAttribute(con->request, "requesting-user-name-denied", IPP_TAG_ZERO)) != NULL) { - FreePrinterUsers(pclass); + cupsdFreePrinterUsers(pclass); pclass->deny_users = 1; if (attr->value_tag == IPP_TAG_NAME && (attr->num_values > 1 || strcmp(attr->values[0].string.text, "none") != 0)) for (i = 0; i < attr->num_values; i ++) - AddPrinterUser(pclass, attr->values[i].string.text); + cupsdAddPrinterUser(pclass, attr->values[i].string.text); } if ((attr = ippFindAttribute(con->request, "job-quota-period", IPP_TAG_INTEGER)) != NULL) { - LogMessage(L_DEBUG, "add_class: Setting job-quota-period to %d...", + cupsdLogMessage(L_DEBUG, "add_class: Setting job-quota-period to %d...", attr->values[0].integer); - FreeQuotas(pclass); + cupsdFreeQuotas(pclass); pclass->quota_period = attr->values[0].integer; } if ((attr = ippFindAttribute(con->request, "job-k-limit", IPP_TAG_INTEGER)) != NULL) { - LogMessage(L_DEBUG, "add_class: Setting job-k-limit to %d...", + cupsdLogMessage(L_DEBUG, "add_class: Setting job-k-limit to %d...", attr->values[0].integer); - FreeQuotas(pclass); + cupsdFreeQuotas(pclass); pclass->k_limit = attr->values[0].integer; } if ((attr = ippFindAttribute(con->request, "job-page-limit", IPP_TAG_INTEGER)) != NULL) { - LogMessage(L_DEBUG, "add_class: Setting job-page-limit to %d...", + cupsdLogMessage(L_DEBUG, "add_class: Setting job-page-limit to %d...", attr->values[0].integer); - FreeQuotas(pclass); + cupsdFreeQuotas(pclass); pclass->page_limit = attr->values[0].integer; } if ((attr = ippFindAttribute(con->request, "printer-op-policy", IPP_TAG_TEXT)) != NULL) @@ -968,14 +968,14 @@ add_class(client_t *con, /* I - Client connection */ if ((p = cupsdFindPolicy(attr->values[0].string.text)) != NULL) { - LogMessage(L_DEBUG, "add_class: Setting printer-op-policy to \"%s\"...", + cupsdLogMessage(L_DEBUG, "add_class: Setting printer-op-policy to \"%s\"...", attr->values[0].string.text); - SetString(&pclass->op_policy, attr->values[0].string.text); + cupsdSetString(&pclass->op_policy, attr->values[0].string.text); pclass->op_policy_ptr = p; } else { - LogMessage(L_ERROR, "add_class: Unknown printer-op-policy \"%s\"...", + cupsdLogMessage(L_ERROR, "add_class: Unknown printer-op-policy \"%s\"...", attr->values[0].string.text); send_ipp_error(con, IPP_NOT_POSSIBLE); return; @@ -987,15 +987,15 @@ add_class(client_t *con, /* I - Client connection */ strcmp(attr->values[0].string.text, "retry-job") && strcmp(attr->values[0].string.text, "stop-printer")) { - LogMessage(L_ERROR, "add_class: Unknown printer-error-policy \"%s\"...", + cupsdLogMessage(L_ERROR, "add_class: Unknown printer-error-policy \"%s\"...", attr->values[0].string.text); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } - LogMessage(L_DEBUG, "add_class: Setting printer-error-policy to \"%s\"...", + cupsdLogMessage(L_DEBUG, "add_class: Setting printer-error-policy to \"%s\"...", attr->values[0].string.text); - SetString(&pclass->error_policy, 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) { @@ -1022,13 +1022,13 @@ add_class(client_t *con, /* I - Client connection */ httpSeparate(attr->values[i].string.text, method, username, host, &port, resource); - if ((dest = ValidateDest(host, resource, &dtype, &member)) == NULL) + if ((dest = cupsdValidateDest(host, resource, &dtype, &member)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "add_class: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "add_class: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -1037,7 +1037,7 @@ add_class(client_t *con, /* I - Client connection */ * Add it to the class... */ - AddPrinterToClass(pclass, member); + cupsdAddPrinterToClass(pclass, member); } } @@ -1045,11 +1045,11 @@ add_class(client_t *con, /* I - Client connection */ * Update the printer class attributes and return... */ - SetPrinterAttrs(pclass); - SaveAllClasses(); - CheckJobs(); + cupsdSetPrinterAttrs(pclass); + cupsdSaveAllClasses(); + cupsdCheckJobs(); - WritePrintcap(); + cupsdWritePrintcap(); if (modify) { @@ -1057,18 +1057,18 @@ add_class(client_t *con, /* I - Client connection */ "Class \'%s\' modified by \'%s\'.", pclass->name, con->username); - LogMessage(L_INFO, "Class \'%s\' modified by \'%s\'.", pclass->name, + cupsdLogMessage(L_INFO, "Class \'%s\' modified by \'%s\'.", pclass->name, con->username); } else { - AddPrinterHistory(pclass); + cupsdAddPrinterHistory(pclass); cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, pclass, NULL, "New class \'%s\' added by \'%s\'.", pclass->name, con->username); - LogMessage(L_INFO, "New class \'%s\' added by \'%s\'.", pclass->name, + cupsdLogMessage(L_INFO, "New class \'%s\' added by \'%s\'.", pclass->name, con->username); } @@ -1081,8 +1081,8 @@ add_class(client_t *con, /* I - Client connection */ */ static int /* O - 0 on success, -1 on error */ -add_file(client_t *con, /* I - Connection to client */ - job_t *job, /* I - Job to add to */ +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 */ { @@ -1090,7 +1090,7 @@ add_file(client_t *con, /* I - Connection to client */ int *compressions; /* New compressions array... */ - LogMessage(L_DEBUG2, "add_file(con=%p[%d], job=%d, filetype=%s/%s, compression=%d)\n", + 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); @@ -1114,8 +1114,8 @@ add_file(client_t *con, /* I - Connection to client */ if (compressions == NULL || filetypes == NULL) { - CancelJob(job->id, 1); - LogMessage(L_ERROR, "add_file: unable to allocate memory for file types!"); + cupsdCancelJob(job->id, 1); + cupsdLogMessage(L_ERROR, "add_file: unable to allocate memory for file types!"); send_ipp_error(con, IPP_INTERNAL_ERROR); return (-1); } @@ -1132,27 +1132,27 @@ add_file(client_t *con, /* I - Connection to client */ /* - * 'add_job_state_reasons()' - Add the "job-state-reasons" attribute based + * 'add_cupsd_job_state_reasons()' - Add the "job-state-reasons" attribute based * upon the job and printer state... */ static void -add_job_state_reasons(client_t *con, /* I - Client connection */ - job_t *job) /* I - Job info */ +add_cupsd_job_state_reasons(cupsd_client_t *con, /* I - Client connection */ + cupsd_job_t *job) /* I - Job info */ { - printer_t *dest; /* Destination printer */ + cupsd_printer_t *dest; /* Destination printer */ - LogMessage(L_DEBUG2, "add_job_state_reasons(%p[%d], %d)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "add_cupsd_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) { case IPP_JOB_PENDING : if (job->dtype & CUPS_PRINTER_CLASS) - dest = FindClass(job->dest); + dest = cupsdFindClass(job->dest); else - dest = FindPrinter(job->dest); + dest = cupsdFindPrinter(job->dest); if (dest != NULL && dest->state == IPP_PRINTER_STOPPED) ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, @@ -1201,12 +1201,12 @@ add_job_state_reasons(client_t *con, /* I - Client connection */ /* - * 'add_job_subscriptions()' - Add any subcriptions for a job. + * 'add_cupsd_job_subscriptions()' - Add any subcriptions for a job. */ static void -add_job_subscriptions(client_t *con, /* I - Client connection */ - job_t *job) /* I - Newly created job */ +add_cupsd_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 */ @@ -1301,11 +1301,11 @@ add_job_subscriptions(client_t *con, /* I - Client connection */ if (mask == CUPSD_EVENT_NONE) mask = CUPSD_EVENT_JOB_COMPLETED; - sub = cupsdAddSubscription(mask, FindDest(job->dest), job, recipient); + sub = cupsdAddSubscription(mask, cupsdFindDest(job->dest), job, recipient); sub->interval = interval; - SetString(&sub->owner, job->username); + cupsdSetString(&sub->owner, job->username); if (user_data) { @@ -1354,7 +1354,7 @@ add_job_subscriptions(client_t *con, /* I - Client connection */ */ static void -add_printer(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 */ @@ -1363,7 +1363,7 @@ add_printer(client_t *con, /* I - Client connection */ host[HTTP_MAX_URI], /* Host portion of URI */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - 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... */ @@ -1372,7 +1372,7 @@ add_printer(client_t *con, /* I - Client connection */ int modify; /* Non-zero if we are modifying */ - LogMessage(L_DEBUG2, "add_printer(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "add_printer(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -1381,7 +1381,7 @@ add_printer(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/admin/", 7) != 0) { - LogMessage(L_ERROR, "add_printer: admin request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "add_printer: admin request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -1399,7 +1399,7 @@ add_printer(client_t *con, /* I - Client connection */ * No, return an error... */ - LogMessage(L_ERROR, "add_printer: bad printer URI \"%s\"!", + cupsdLogMessage(L_ERROR, "add_printer: bad printer URI \"%s\"!", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -1425,7 +1425,7 @@ add_printer(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "add_printer: not authorized!"); + cupsdLogMessage(L_ERROR, "add_printer: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -1434,20 +1434,20 @@ add_printer(client_t *con, /* I - Client connection */ * See if the printer already exists; if not, create a new printer... */ - if ((printer = FindPrinter(resource + 10)) == NULL) + if ((printer = cupsdFindPrinter(resource + 10)) == NULL) { /* * Printer doesn't exist; see if we have a class of the same name... */ - if ((printer = FindClass(resource + 10)) != NULL && + if ((printer = cupsdFindClass(resource + 10)) != NULL && !(printer->type & CUPS_PRINTER_REMOTE)) { /* * Yes, return an error... */ - LogMessage(L_ERROR, "add_printer: \"%s\" already exists as a class!", + cupsdLogMessage(L_ERROR, "add_printer: \"%s\" already exists as a class!", resource + 10); send_ipp_error(con, IPP_NOT_POSSIBLE); return; @@ -1457,7 +1457,7 @@ add_printer(client_t *con, /* I - Client connection */ * No, add the printer... */ - printer = AddPrinter(resource + 10); + printer = cupsdAddPrinter(resource + 10); modify = 0; } else if (printer->type & CUPS_PRINTER_IMPLICIT) @@ -1469,17 +1469,17 @@ add_printer(client_t *con, /* I - Client connection */ if (ImplicitAnyClasses) { cupsArrayRemove(Printers, printer); - SetStringf(&printer->name, "Any%s", resource + 10); + cupsdSetStringf(&printer->name, "Any%s", resource + 10); cupsArrayAdd(Printers, printer); } else - DeletePrinter(printer, 1); + cupsdDeletePrinter(printer, 1); /* * Add the printer as a new local printer... */ - printer = AddPrinter(resource + 10); + printer = cupsdAddPrinter(resource + 10); modify = 0; } else if (printer->type & CUPS_PRINTER_REMOTE) @@ -1488,17 +1488,17 @@ add_printer(client_t *con, /* I - Client connection */ * Rename the remote printer to "Printer@server"... */ - DeletePrinterFilters(printer); + cupsdDeletePrinterFilters(printer); cupsArrayRemove(Printers, printer); - SetStringf(&printer->name, "%s@%s", resource + 10, printer->hostname); - SetPrinterAttrs(printer); + cupsdSetStringf(&printer->name, "%s@%s", resource + 10, printer->hostname); + cupsdSetPrinterAttrs(printer); cupsArrayAdd(Printers, printer); /* * Add the printer as a new local printer... */ - printer = AddPrinter(resource + 10); + printer = cupsdAddPrinter(resource + 10); modify = 0; } else @@ -1509,10 +1509,10 @@ add_printer(client_t *con, /* I - Client connection */ */ if ((attr = ippFindAttribute(con->request, "printer-location", IPP_TAG_TEXT)) != NULL) - SetString(&printer->location, attr->values[0].string.text); + cupsdSetString(&printer->location, attr->values[0].string.text); if ((attr = ippFindAttribute(con->request, "printer-info", IPP_TAG_TEXT)) != NULL) - SetString(&printer->info, attr->values[0].string.text); + cupsdSetString(&printer->info, attr->values[0].string.text); if ((attr = ippFindAttribute(con->request, "device-uri", IPP_TAG_URI)) != NULL) { @@ -1535,7 +1535,7 @@ add_printer(client_t *con, /* I - Client connection */ * File devices are disabled and the URL is not file:/dev/null... */ - LogMessage(L_ERROR, "add_printer: File device URIs have been disabled! " + cupsdLogMessage(L_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; @@ -1554,19 +1554,19 @@ add_printer(client_t *con, /* I - Client connection */ * Could not find device in list! */ - LogMessage(L_ERROR, "add_printer: bad device-uri attribute \'%s\'!", + cupsdLogMessage(L_ERROR, "add_printer: bad device-uri attribute \'%s\'!", attr->values[0].string.text); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } } - LogMessage(L_INFO, "Setting %s device-uri to \"%s\" (was \"%s\".)", + 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))); - SetString(&printer->device_uri, attr->values[0].string.text); + cupsdSetString(&printer->device_uri, attr->values[0].string.text); } if ((attr = ippFindAttribute(con->request, "port-monitor", IPP_TAG_KEYWORD)) != NULL) @@ -1583,34 +1583,34 @@ add_printer(client_t *con, /* I - Client connection */ if (i >= supported->num_values) { - LogMessage(L_ERROR, "add_printer: bad port-monitor attribute \'%s\'!", + cupsdLogMessage(L_ERROR, "add_printer: bad port-monitor attribute \'%s\'!", attr->values[0].string.text); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } - LogMessage(L_INFO, "Setting %s port-monitor to \"%s\" (was \"%s\".)", + cupsdLogMessage(L_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")) - SetString(&printer->port_monitor, attr->values[0].string.text); + cupsdSetString(&printer->port_monitor, attr->values[0].string.text); else - ClearString(&printer->port_monitor); + cupsdClearString(&printer->port_monitor); } if ((attr = ippFindAttribute(con->request, "printer-is-accepting-jobs", IPP_TAG_BOOLEAN)) != NULL) { - LogMessage(L_INFO, "Setting %s printer-is-accepting-jobs to %d (was %d.)", + cupsdLogMessage(L_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; - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); } if ((attr = ippFindAttribute(con->request, "printer-is-shared", IPP_TAG_BOOLEAN)) != NULL) { - LogMessage(L_INFO, "Setting %s printer-is-shared to %d (was %d.)", + cupsdLogMessage(L_INFO, "Setting %s printer-is-shared to %d (was %d.)", printer->name, attr->values[0].boolean, printer->shared); printer->shared = attr->values[0].boolean; @@ -1621,78 +1621,78 @@ add_printer(client_t *con, /* I - Client connection */ if (attr->values[0].integer != IPP_PRINTER_IDLE && attr->values[0].integer == IPP_PRINTER_STOPPED) { - LogMessage(L_ERROR, "Attempt to set %s printer-state to bad value %d!", + cupsdLogMessage(L_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; } - LogMessage(L_INFO, "Setting %s printer-state to %d (was %d.)", printer->name, + cupsdLogMessage(L_INFO, "Setting %s printer-state to %d (was %d.)", printer->name, attr->values[0].integer, printer->state); - SetPrinterState(printer, (ipp_pstate_t)(attr->values[0].integer), 0); + cupsdSetPrinterState(printer, (ipp_pstate_t)(attr->values[0].integer), 0); } if ((attr = ippFindAttribute(con->request, "printer-state-message", IPP_TAG_TEXT)) != NULL) { strlcpy(printer->state_message, attr->values[0].string.text, sizeof(printer->state_message)); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); } if ((attr = ippFindAttribute(con->request, "job-sheets-default", IPP_TAG_ZERO)) != NULL && !Classification) { - SetString(&printer->job_sheets[0], attr->values[0].string.text); + cupsdSetString(&printer->cupsd_job_sheets[0], attr->values[0].string.text); if (attr->num_values > 1) - SetString(&printer->job_sheets[1], attr->values[1].string.text); + cupsdSetString(&printer->cupsd_job_sheets[1], attr->values[1].string.text); else - SetString(&printer->job_sheets[1], "none"); + cupsdSetString(&printer->cupsd_job_sheets[1], "none"); } if ((attr = ippFindAttribute(con->request, "requesting-user-name-allowed", IPP_TAG_ZERO)) != NULL) { - FreePrinterUsers(printer); + cupsdFreePrinterUsers(printer); printer->deny_users = 0; if (attr->value_tag == IPP_TAG_NAME && (attr->num_values > 1 || strcmp(attr->values[0].string.text, "all") != 0)) for (i = 0; i < attr->num_values; i ++) - AddPrinterUser(printer, attr->values[i].string.text); + cupsdAddPrinterUser(printer, attr->values[i].string.text); } else if ((attr = ippFindAttribute(con->request, "requesting-user-name-denied", IPP_TAG_ZERO)) != NULL) { - FreePrinterUsers(printer); + cupsdFreePrinterUsers(printer); printer->deny_users = 1; if (attr->value_tag == IPP_TAG_NAME && (attr->num_values > 1 || strcmp(attr->values[0].string.text, "none") != 0)) for (i = 0; i < attr->num_values; i ++) - AddPrinterUser(printer, attr->values[i].string.text); + cupsdAddPrinterUser(printer, attr->values[i].string.text); } if ((attr = ippFindAttribute(con->request, "job-quota-period", IPP_TAG_INTEGER)) != NULL) { - LogMessage(L_DEBUG, "add_printer: Setting job-quota-period to %d...", + cupsdLogMessage(L_DEBUG, "add_printer: Setting job-quota-period to %d...", attr->values[0].integer); - FreeQuotas(printer); + cupsdFreeQuotas(printer); printer->quota_period = attr->values[0].integer; } if ((attr = ippFindAttribute(con->request, "job-k-limit", IPP_TAG_INTEGER)) != NULL) { - LogMessage(L_DEBUG, "add_printer: Setting job-k-limit to %d...", + cupsdLogMessage(L_DEBUG, "add_printer: Setting job-k-limit to %d...", attr->values[0].integer); - FreeQuotas(printer); + cupsdFreeQuotas(printer); printer->k_limit = attr->values[0].integer; } if ((attr = ippFindAttribute(con->request, "job-page-limit", IPP_TAG_INTEGER)) != NULL) { - LogMessage(L_DEBUG, "add_printer: Setting job-page-limit to %d...", + cupsdLogMessage(L_DEBUG, "add_printer: Setting job-page-limit to %d...", attr->values[0].integer); - FreeQuotas(printer); + cupsdFreeQuotas(printer); printer->page_limit = attr->values[0].integer; } if ((attr = ippFindAttribute(con->request, "printer-op-policy", IPP_TAG_TEXT)) != NULL) @@ -1702,14 +1702,14 @@ add_printer(client_t *con, /* I - Client connection */ if ((p = cupsdFindPolicy(attr->values[0].string.text)) != NULL) { - LogMessage(L_DEBUG, "add_printer: Setting printer-op-policy to \"%s\"...", + cupsdLogMessage(L_DEBUG, "add_printer: Setting printer-op-policy to \"%s\"...", attr->values[0].string.text); - SetString(&printer->op_policy, attr->values[0].string.text); + cupsdSetString(&printer->op_policy, attr->values[0].string.text); printer->op_policy_ptr = p; } else { - LogMessage(L_ERROR, "add_printer: Unknown printer-op-policy \"%s\"...", + cupsdLogMessage(L_ERROR, "add_printer: Unknown printer-op-policy \"%s\"...", attr->values[0].string.text); send_ipp_error(con, IPP_NOT_POSSIBLE); return; @@ -1721,15 +1721,15 @@ add_printer(client_t *con, /* I - Client connection */ strcmp(attr->values[0].string.text, "retry-job") && strcmp(attr->values[0].string.text, "stop-printer")) { - LogMessage(L_ERROR, "add_printer: Unknown printer-error-policy \"%s\"...", + cupsdLogMessage(L_ERROR, "add_printer: Unknown printer-error-policy \"%s\"...", attr->values[0].string.text); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } - LogMessage(L_DEBUG, "add_printer: Setting printer-error-policy to \"%s\"...", + cupsdLogMessage(L_DEBUG, "add_printer: Setting printer-error-policy to \"%s\"...", attr->values[0].string.text); - SetString(&printer->error_policy, attr->values[0].string.text); + cupsdSetString(&printer->error_policy, attr->values[0].string.text); } /* @@ -1737,7 +1737,7 @@ add_printer(client_t *con, /* I - Client connection */ */ if (!printer->device_uri) - SetString(&printer->device_uri, "file:/dev/null"); + cupsdSetString(&printer->device_uri, "file:/dev/null"); /* * See if we have an interface script or PPD file attached to the request... @@ -1782,14 +1782,14 @@ add_printer(client_t *con, /* I - Client connection */ if (copy_file(srcfile, dstfile)) { - LogMessage(L_ERROR, "add_printer: Unable to copy interface script from %s to %s - %s!", + cupsdLogMessage(L_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 { - LogMessage(L_DEBUG, "add_printer: Copied interface script successfully!"); + cupsdLogMessage(L_DEBUG, "add_printer: Copied interface script successfully!"); chmod(dstfile, 0755); } } @@ -1806,14 +1806,14 @@ add_printer(client_t *con, /* I - Client connection */ if (copy_file(srcfile, dstfile)) { - LogMessage(L_ERROR, "add_printer: Unable to copy PPD file from %s to %s - %s!", + cupsdLogMessage(L_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 { - LogMessage(L_DEBUG, "add_printer: Copied PPD file successfully!"); + cupsdLogMessage(L_DEBUG, "add_printer: Copied PPD file successfully!"); chmod(dstfile, 0644); } } @@ -1859,14 +1859,14 @@ add_printer(client_t *con, /* I - Client connection */ if (copy_model(con, attr->values[0].string.text, dstfile)) { - LogMessage(L_ERROR, "add_printer: Unable to copy PPD file from %s to %s - %s!", + cupsdLogMessage(L_ERROR, "add_printer: Unable to copy PPD file from %s to %s - %s!", attr->values[0].string.text, dstfile, strerror(errno)); send_ipp_error(con, IPP_INTERNAL_ERROR); return; } else { - LogMessage(L_DEBUG, "add_printer: Copied PPD file successfully!"); + cupsdLogMessage(L_DEBUG, "add_printer: Copied PPD file successfully!"); chmod(dstfile, 0644); } } @@ -1883,26 +1883,26 @@ add_printer(client_t *con, /* I - Client connection */ * Update the printer attributes and return... */ - SetPrinterAttrs(printer); - SaveAllPrinters(); + cupsdSetPrinterAttrs(printer); + cupsdSaveAllPrinters(); if (printer->job != NULL) { - job_t *job; + cupsd_job_t *job; /* * Stop the current job and then restart it below... */ - job = (job_t *)printer->job; + job = (cupsd_job_t *)printer->job; - StopJob(job->id, 1); + cupsdStopJob(job->id, 1); job->state->values[0].integer = IPP_JOB_PENDING; } - CheckJobs(); + cupsdCheckJobs(); - WritePrintcap(); + cupsdWritePrintcap(); if (modify) { @@ -1910,18 +1910,18 @@ add_printer(client_t *con, /* I - Client connection */ "Printer \'%s\' modified by \'%s\'.", printer->name, con->username); - LogMessage(L_INFO, "Printer \'%s\' modified by \'%s\'.", printer->name, + cupsdLogMessage(L_INFO, "Printer \'%s\' modified by \'%s\'.", printer->name, con->username); } else { - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, printer, NULL, "New printer \'%s\' added by \'%s\'.", printer->name, con->username); - LogMessage(L_INFO, "New printer \'%s\' added by \'%s\'.", printer->name, + cupsdLogMessage(L_INFO, "New printer \'%s\' added by \'%s\'.", printer->name, con->username); } @@ -1930,16 +1930,16 @@ add_printer(client_t *con, /* I - Client connection */ /* - * 'add_printer_state_reasons()' - Add the "printer-state-reasons" attribute + * 'add_cupsd_printer_state_reasons()' - Add the "printer-state-reasons" attribute * based upon the printer state... */ static void -add_printer_state_reasons( - client_t *con, /* I - Client connection */ - printer_t *p) /* I - Printer info */ +add_cupsd_printer_state_reasons( + cupsd_client_t *con, /* I - Client connection */ + cupsd_printer_t *p) /* I - Printer info */ { - LogMessage(L_DEBUG2, "add_printer_state_reasons(%p[%d], %p[%s])\n", + cupsdLogMessage(L_DEBUG2, "add_cupsd_printer_state_reasons(%p[%d], %p[%s])\n", con, con->http.fd, p, p->name); if (p->num_reasons == 0) @@ -1959,16 +1959,16 @@ add_printer_state_reasons( */ static void -add_queued_job_count(client_t *con, /* I - Client connection */ - 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 */ - LogMessage(L_DEBUG2, "add_queued_job_count(%p[%d], %p[%s])\n", + cupsdLogMessage(L_DEBUG2, "add_queued_job_count(%p[%d], %p[%s])\n", con, con->http.fd, p, p->name); - count = GetPrinterJobCount(p->name); + count = cupsdGetPrinterJobCount(p->name); ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "queued-job-count", count); @@ -1980,12 +1980,12 @@ add_queued_job_count(client_t *con, /* I - Client connection */ */ static void -authenticate_job(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 */ - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ char method[HTTP_MAX_URI], /* Method portion of URI */ username[HTTP_MAX_URI], @@ -1997,7 +1997,7 @@ authenticate_job(client_t *con, /* I - Client connection */ int port; /* Port portion of URI */ - LogMessage(L_DEBUG2, "authenticate_job(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "authenticate_job(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -2018,7 +2018,7 @@ authenticate_job(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "authenticate_job: got a printer-uri attribute but no job-id!"); + cupsdLogMessage(L_ERROR, "authenticate_job: got a printer-uri attribute but no job-id!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -2039,7 +2039,7 @@ authenticate_job(client_t *con, /* I - Client connection */ * Not a valid URI! */ - LogMessage(L_ERROR, "authenticate_job: bad job-uri attribute \'%s\'!\n", + cupsdLogMessage(L_ERROR, "authenticate_job: bad job-uri attribute \'%s\'!\n", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -2052,13 +2052,13 @@ authenticate_job(client_t *con, /* I - Client connection */ * See if the job exists... */ - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { /* * Nope - return a "not found" error... */ - LogMessage(L_ERROR, "authenticate_job: job #%d doesn't exist!", jobid); + cupsdLogMessage(L_ERROR, "authenticate_job: job #%d doesn't exist!", jobid); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -2073,7 +2073,7 @@ authenticate_job(client_t *con, /* I - Client connection */ * Return a "not-possible" error... */ - LogMessage(L_ERROR, "authenticate_job: job #%d is not held for authentication!", jobid); + cupsdLogMessage(L_ERROR, "authenticate_job: job #%d is not held for authentication!", jobid); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } @@ -2094,7 +2094,7 @@ authenticate_job(client_t *con, /* I - Client connection */ if (!validate_user(job, con, job->username, username, sizeof(username))) { - LogMessage(L_ERROR, "authenticate_job: \"%s\" not authorized to authenticate job id %d owned by \"%s\"!", + cupsdLogMessage(L_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; @@ -2116,16 +2116,16 @@ authenticate_job(client_t *con, /* I - Client connection */ if (attr != NULL) { attr->value_tag = IPP_TAG_KEYWORD; - SetString(&(attr->values[0].string.text), "no-hold"); + cupsdSetString(&(attr->values[0].string.text), "no-hold"); } /* * Release the job and return... */ - ReleaseJob(jobid); + cupsdReleaseJob(jobid); - LogMessage(L_INFO, "Job %d was authenticated by \'%s\'.", jobid, + cupsdLogMessage(L_INFO, "Job %d was authenticated by \'%s\'.", jobid, con->username); } @@ -2135,7 +2135,7 @@ authenticate_job(client_t *con, /* I - Client connection */ */ static void -cancel_all_jobs(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 */ @@ -2148,10 +2148,10 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ ipp_attribute_t *attr; /* Attribute in request */ const char *username; /* Username */ int purge; /* Purge? */ - printer_t *printer; /* Printer */ + cupsd_printer_t *printer; /* Printer */ - LogMessage(L_DEBUG2, "cancel_all_jobs(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "cancel_all_jobs(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -2161,7 +2161,7 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/admin/", 7) && strncmp(con->uri, "/jobs/", 7)) { - LogMessage(L_ERROR, "cancel_all_jobs: admin request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "cancel_all_jobs: admin request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -2173,7 +2173,7 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ if (strcmp(uri->name, "printer-uri")) { - LogMessage(L_ERROR, "cancel_all_jobs: bad %s attribute \'%s\'!", + cupsdLogMessage(L_ERROR, "cancel_all_jobs: bad %s attribute \'%s\'!", uri->name, uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -2191,7 +2191,7 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ username = attr->values[0].string.text; else { - LogMessage(L_ERROR, "cancel_all_jobs: missing requesting-user-name attribute!"); + cupsdLogMessage(L_ERROR, "cancel_all_jobs: missing requesting-user-name attribute!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -2203,7 +2203,7 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ (username && con->username[0] && strcmp(username, con->username))) && strncmp(con->uri, "/admin/", 7)) { - LogMessage(L_ERROR, "cancel_all_jobs: only administrators can cancel " + cupsdLogMessage(L_ERROR, "cancel_all_jobs: only administrators can cancel " "other users\' jobs!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -2225,7 +2225,7 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, userpass, host, &port, resource); - if ((dest = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI? @@ -2233,7 +2233,7 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ if (strcmp(resource, "/printers/") != 0) { - LogMessage(L_ERROR, "cancel_all_jobs: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "cancel_all_jobs: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -2244,7 +2244,7 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "cancel_all_jobs: not authorized!"); + cupsdLogMessage(L_ERROR, "cancel_all_jobs: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -2253,9 +2253,9 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ * Cancel all jobs on all printers... */ - CancelJobs(NULL, username, purge); + cupsdCancelJobs(NULL, username, purge); - LogMessage(L_INFO, "All jobs were %s by \'%s\'.", + cupsdLogMessage(L_INFO, "All jobs were %s by \'%s\'.", purge ? "purged" : "cancelled", con->username); } else @@ -2266,7 +2266,7 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) { - LogMessage(L_ERROR, "cancel_all_jobs: not authorized!"); + cupsdLogMessage(L_ERROR, "cancel_all_jobs: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -2275,9 +2275,9 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ * Cancel all of the jobs on the named printer... */ - CancelJobs(dest, username, purge); + cupsdCancelJobs(dest, username, purge); - LogMessage(L_INFO, "All jobs on \'%s\' were %s by \'%s\'.", dest, + cupsdLogMessage(L_INFO, "All jobs on \'%s\' were %s by \'%s\'.", dest, purge ? "purged" : "cancelled", con->username); } @@ -2290,7 +2290,7 @@ cancel_all_jobs(client_t *con, /* I - Client connection */ */ static void -cancel_job(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 */ @@ -2300,13 +2300,13 @@ cancel_job(client_t *con, /* I - Client connection */ host[HTTP_MAX_URI], /* Host portion of URI */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - job_t *job; /* Job information */ + cupsd_job_t *job; /* Job information */ const char *dest; /* Destination */ cups_ptype_t dtype; /* Destination type (printer or class) */ - printer_t *printer; /* Printer data */ + cupsd_printer_t *printer; /* Printer data */ - LogMessage(L_DEBUG2, "cancel_job(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "cancel_job(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -2317,7 +2317,7 @@ cancel_job(client_t *con, /* I - Client connection */ strncmp(con->uri, "/jobs/", 5) != 0 && strncmp(con->uri, "/printers/", 10) != 0) { - LogMessage(L_ERROR, "cancel_job: cancel request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "cancel_job: cancel request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -2335,7 +2335,7 @@ cancel_job(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "cancel_job: got a printer-uri attribute but no job-id!"); + cupsdLogMessage(L_ERROR, "cancel_job: got a printer-uri attribute but no job-id!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -2348,13 +2348,13 @@ cancel_job(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((dest = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "cancel_job: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "cancel_job: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -2364,16 +2364,16 @@ cancel_job(client_t *con, /* I - Client connection */ */ if (printer->job) - jobid = ((job_t *)printer->job)->id; + jobid = ((cupsd_job_t *)printer->job)->id; else { /* * No, see if there are any pending jobs... */ - for (job = (job_t *)cupsArrayFirst(ActiveJobs); + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; - job = (job_t *)cupsArrayNext(ActiveJobs)) + job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (job->state->values[0].integer <= IPP_JOB_PROCESSING && !strcasecmp(job->dest, dest)) break; @@ -2382,7 +2382,7 @@ cancel_job(client_t *con, /* I - Client connection */ jobid = job->id; else { - LogMessage(L_ERROR, "cancel_job: No active jobs on %s!", dest); + cupsdLogMessage(L_ERROR, "cancel_job: No active jobs on %s!", dest); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } @@ -2403,7 +2403,7 @@ cancel_job(client_t *con, /* I - Client connection */ * Not a valid URI! */ - LogMessage(L_ERROR, "cancel_job: bad job-uri attribute \'%s\'!", + cupsdLogMessage(L_ERROR, "cancel_job: bad job-uri attribute \'%s\'!", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -2416,13 +2416,13 @@ cancel_job(client_t *con, /* I - Client connection */ * See if the job exists... */ - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { /* * Nope - return a "not found" error... */ - LogMessage(L_ERROR, "cancel_job: job #%d doesn't exist!", jobid); + cupsdLogMessage(L_ERROR, "cancel_job: job #%d doesn't exist!", jobid); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -2433,7 +2433,7 @@ cancel_job(client_t *con, /* I - Client connection */ if (!validate_user(job, con, job->username, username, sizeof(username))) { - LogMessage(L_ERROR, "cancel_job: \"%s\" not authorized to delete job id %d owned by \"%s\"!", + cupsdLogMessage(L_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; @@ -2446,7 +2446,7 @@ cancel_job(client_t *con, /* I - Client connection */ if (job->state->values[0].integer >= IPP_JOB_CANCELLED) { - LogMessage(L_ERROR, "cancel_job: job id %d is %s - can't cancel!", + 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" : @@ -2462,10 +2462,10 @@ cancel_job(client_t *con, /* I - Client connection */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled by \'%s\'.", username); - CancelJob(jobid, 0); - CheckJobs(); + cupsdCancelJob(jobid, 0); + cupsdCheckJobs(); - LogMessage(L_INFO, "Job %d was cancelled by \'%s\'.", jobid, username); + cupsdLogMessage(L_INFO, "Job %d was cancelled by \'%s\'.", jobid, username); con->response->request.status.status_code = IPP_OK; } @@ -2476,7 +2476,7 @@ cancel_job(client_t *con, /* I - Client connection */ */ static void -cancel_subscription(client_t *con, /* I - Client connection */ +cancel_subscription(cupsd_client_t *con, /* I - Client connection */ int sub_id) /* I - Subscription ID */ { } @@ -2487,17 +2487,17 @@ cancel_subscription(client_t *con, /* I - Client connection */ */ static int /* O - 1 if OK, 0 if not */ -check_quotas(client_t *con, /* I - Client connection */ - 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 */ char username[33]; /* Username */ - quota_t *q; /* Quota data */ + cupsd_quota_t *q; /* Quota data */ struct passwd *pw; /* User password data */ - LogMessage(L_DEBUG2, "check_quotas(%p[%d], %p[%s])\n", + cupsdLogMessage(L_DEBUG2, "check_quotas(%p[%d], %p[%s])\n", con, con->http.fd, p, p->name); /* @@ -2517,7 +2517,7 @@ check_quotas(client_t *con, /* I - Client connection */ strlcpy(username, con->username, sizeof(username)); else if (attr != NULL) { - LogMessage(L_DEBUG, "check_quotas: requesting-user-name = \'%s\'", + cupsdLogMessage(L_DEBUG, "check_quotas: requesting-user-name = \'%s\'", attr->values[0].string.text); strlcpy(username, attr->values[0].string.text, sizeof(username)); @@ -2535,9 +2535,9 @@ check_quotas(client_t *con, /* I - Client connection */ * Check if there are too many pending jobs on this printer... */ - if (GetPrinterJobCount(p->name) >= MaxJobsPerPrinter) + if (cupsdGetPrinterJobCount(p->name) >= MaxJobsPerPrinter) { - LogMessage(L_INFO, "Too many jobs for printer \"%s\"...", p->name); + cupsdLogMessage(L_INFO, "Too many jobs for printer \"%s\"...", p->name); return (0); } } @@ -2548,9 +2548,9 @@ check_quotas(client_t *con, /* I - Client connection */ * Check if there are too many pending jobs for this user... */ - if (GetUserJobCount(username) >= MaxJobsPerUser) + if (cupsdGetUserJobCount(username) >= MaxJobsPerUser) { - LogMessage(L_INFO, "Too many jobs for user \"%s\"...", username); + cupsdLogMessage(L_INFO, "Too many jobs for user \"%s\"...", username); return (0); } } @@ -2582,7 +2582,7 @@ check_quotas(client_t *con, /* I - Client connection */ if ((i < p->num_users) == p->deny_users) { - LogMessage(L_INFO, "Denying user \"%s\" access to printer \"%s\"...", + cupsdLogMessage(L_INFO, "Denying user \"%s\" access to printer \"%s\"...", username, p->name); return (0); } @@ -2594,9 +2594,9 @@ check_quotas(client_t *con, /* I - Client connection */ if (p->k_limit || p->page_limit) { - if ((q = UpdateQuota(p, username, 0, 0)) == NULL) + if ((q = cupsdUpdateQuota(p, username, 0, 0)) == NULL) { - LogMessage(L_ERROR, "Unable to allocate quota data for user \"%s\"!", + cupsdLogMessage(L_ERROR, "Unable to allocate quota data for user \"%s\"!", username); return (0); } @@ -2604,7 +2604,7 @@ check_quotas(client_t *con, /* I - Client connection */ if ((q->k_count >= p->k_limit && p->k_limit) || (q->page_count >= p->page_limit && p->page_limit)) { - LogMessage(L_INFO, "User \"%s\" is over the quota limit...", + cupsdLogMessage(L_INFO, "User \"%s\" is over the quota limit...", username); return (0); } @@ -2632,7 +2632,7 @@ copy_attribute( ipp_attribute_t *toattr; /* Destination attribute */ - LogMessage(L_DEBUG2, "copy_attribute(%p, %p[%s,%x,%x])\n", to, attr, + cupsdLogMessage(L_DEBUG2, "copy_attribute(%p, %p[%s,%x,%x])\n", to, attr, attr->name ? attr->name : "(null)", attr->group_tag, attr->value_tag); @@ -2795,7 +2795,7 @@ copy_attrs(ipp_t *to, /* I - Destination request */ ipp_attribute_t *fromattr; /* Source attribute */ - LogMessage(L_DEBUG2, "copy_attrs(%p, %p, %p, %x)\n", to, from, req, group); + cupsdLogMessage(L_DEBUG2, "copy_attrs(%p, %p, %p, %x)\n", to, from, req, group); if (to == NULL || from == NULL) return; @@ -2834,14 +2834,14 @@ copy_attrs(ipp_t *to, /* I - Destination request */ */ static int /* O - Size of banner file in kbytes */ -copy_banner(client_t *con, /* I - Client connection */ - job_t *job, /* I - Job information */ +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 */ - 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 */ @@ -2850,7 +2850,7 @@ copy_banner(client_t *con, /* I - Client connection */ ipp_attribute_t *attr; /* Attribute */ - LogMessage(L_DEBUG2, "copy_banner(%p[%d], %p[%d], %s)", + cupsdLogMessage(L_DEBUG2, "copy_banner(%p[%d], %p[%d], %s)", con, con->http.fd, job, job->id, name ? name : "(null)"); /* @@ -2859,7 +2859,7 @@ copy_banner(client_t *con, /* I - Client connection */ if (name == NULL || strcmp(name, "none") == 0 || - (banner = FindBanner(name)) == NULL) + (banner = cupsdFindBanner(name)) == NULL) return (0); /* @@ -2873,7 +2873,7 @@ copy_banner(client_t *con, /* I - Client connection */ job->num_files); if ((out = cupsFileOpen(filename, "w")) == NULL) { - LogMessage(L_ERROR, "copy_banner: Unable to create banner job file %s - %s", + cupsdLogMessage(L_ERROR, "copy_banner: Unable to create banner job file %s - %s", filename, strerror(errno)); job->num_files --; return (0); @@ -2928,7 +2928,7 @@ copy_banner(client_t *con, /* I - Client connection */ { cupsFileClose(out); unlink(filename); - LogMessage(L_ERROR, "copy_banner: Unable to open banner template file %s - %s", + cupsdLogMessage(L_ERROR, "copy_banner: Unable to open banner template file %s - %s", filename, strerror(errno)); job->num_files --; return (0); @@ -3011,7 +3011,7 @@ copy_banner(client_t *con, /* I - Client connection */ case IPP_TAG_INTEGER : case IPP_TAG_ENUM : if (strncmp(s, "time-at-", 8) == 0) - cupsFilePuts(out, GetDateTime(attr->values[i].integer)); + cupsFilePuts(out, cupsdGetDateTime(attr->values[i].integer)); else cupsFilePrintf(out, "%d", attr->values[i].integer); break; @@ -3112,7 +3112,7 @@ copy_file(const char *from, /* I - Source file */ char buffer[2048]; /* Copy buffer */ - LogMessage(L_DEBUG2, "copy_file(\"%s\", \"%s\")\n", from, to); + cupsdLogMessage(L_DEBUG2, "copy_file(\"%s\", \"%s\")\n", from, to); /* * Open the source and destination file for a copy... @@ -3155,7 +3155,7 @@ copy_file(const char *from, /* I - Source file */ */ static int /* O - 0 = success, -1 = error */ -copy_model(client_t *con, /* I - Client connection */ +copy_model(cupsd_client_t *con, /* I - Client connection */ const char *from, /* I - Source file */ const char *to) /* I - Destination file */ { @@ -3189,7 +3189,7 @@ copy_model(client_t *con, /* I - Client connection */ #endif /* HAVE_LIBPAPER */ - LogMessage(L_DEBUG2, "copy_model(con=%p, from=\"%s\", to=\"%s\")\n", + cupsdLogMessage(L_DEBUG2, "copy_model(con=%p, from=\"%s\", to=\"%s\")\n", con, from, to); /* @@ -3216,12 +3216,12 @@ copy_model(client_t *con, /* I - Client connection */ close(tempfd); unlink(tempfile); - LogMessage(L_ERROR, "copy_model: Unable to allocate %d bytes for select()...", + cupsdLogMessage(L_ERROR, "copy_model: Unable to allocate %d bytes for select()...", SetSize); return (-1); } - LogMessage(L_DEBUG, "copy_model: Running \"cups-driverd cat %s\"...", from); + cupsdLogMessage(L_DEBUG, "copy_model: Running \"cups-driverd cat %s\"...", from); if (!cupsdStartProcess(buffer, argv, envp, -1, temppipe[1], CGIPipes[1], -1, 0, &temppid)) @@ -3292,7 +3292,7 @@ copy_model(client_t *con, /* I - Client connection */ } if (FD_ISSET(CGIPipes[0], input)) - UpdateCGI(); + cupsdUpdateCGI(); } close(temppipe[0]); @@ -3304,7 +3304,7 @@ copy_model(client_t *con, /* I - Client connection */ * No data from cups-deviced... */ - LogMessage(L_ERROR, "copy_model: empty PPD file!"); + cupsdLogMessage(L_ERROR, "copy_model: empty PPD file!"); unlink(tempfile); return (-1); } @@ -3525,7 +3525,7 @@ copy_model(client_t *con, /* I - Client connection */ */ static void -create_job(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 */ @@ -3533,20 +3533,20 @@ create_job(client_t *con, /* I - Client connection */ cups_ptype_t dtype; /* Destination type (printer or class) */ int priority; /* Job priority */ char *title; /* Job name/title */ - 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 */ - 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 */ - LogMessage(L_DEBUG2, "create_job(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "create_job(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -3556,7 +3556,7 @@ create_job(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/classes/", 9) != 0 && strncmp(con->uri, "/printers/", 10) != 0) { - LogMessage(L_ERROR, "create_job: cancel request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "create_job: cancel request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -3568,13 +3568,13 @@ create_job(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((dest = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "create_job: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "create_job: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -3587,7 +3587,7 @@ create_job(client_t *con, /* I - Client connection */ strcasecmp(con->http.hostname, "localhost") && strcasecmp(con->http.hostname, ServerName)) { - LogMessage(L_ERROR, "print_job: printer not shared!"); + cupsdLogMessage(L_ERROR, "print_job: printer not shared!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -3599,7 +3599,7 @@ create_job(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL) || ((printer->type & CUPS_PRINTER_AUTHENTICATED) && !con->username[0])) { - LogMessage(L_ERROR, "create_job: not authorized!"); + cupsdLogMessage(L_ERROR, "create_job: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -3610,7 +3610,7 @@ create_job(client_t *con, /* I - Client connection */ if (!printer->accepting) { - LogMessage(L_INFO, "create_job: destination \'%s\' is not accepting jobs.", + cupsdLogMessage(L_INFO, "create_job: destination \'%s\' is not accepting jobs.", dest); send_ipp_error(con, IPP_NOT_ACCEPTING); return; @@ -3624,7 +3624,7 @@ create_job(client_t *con, /* I - Client connection */ { if (attr->values[0].integer < 1 || attr->values[0].integer > MaxCopies) { - LogMessage(L_ERROR, "create_job: Bad copies value %d.", + cupsdLogMessage(L_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, @@ -3640,7 +3640,7 @@ create_job(client_t *con, /* I - Client connection */ if (attr->values[i].range.lower < lowerpagerange || attr->values[i].range.lower > attr->values[i].range.upper) { - LogMessage(L_ERROR, "create_job: bad page-ranges values %d-%d.", + cupsdLogMessage(L_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; @@ -3655,11 +3655,11 @@ create_job(client_t *con, /* I - Client connection */ */ if (cupsArrayCount(Jobs) >= MaxJobs && MaxJobs) - CleanJobs(); + cupsdCleanJobs(); if (cupsArrayCount(Jobs) >= MaxJobs && MaxJobs) { - LogMessage(L_INFO, "create_job: too many jobs."); + cupsdLogMessage(L_INFO, "create_job: too many jobs."); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } @@ -3686,9 +3686,9 @@ create_job(client_t *con, /* I - Client connection */ ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL, title = "Untitled"); - if ((job = AddJob(priority, printer->name)) == NULL) + if ((job = cupsdAddJob(priority, printer->name)) == NULL) { - LogMessage(L_ERROR, "create_job: unable to add job for destination \'%s\'!", + cupsdLogMessage(L_ERROR, "create_job: unable to add job for destination \'%s\'!", dest); send_ipp_error(con, IPP_INTERNAL_ERROR); return; @@ -3702,18 +3702,18 @@ create_job(client_t *con, /* I - Client connection */ if (con->username[0]) { - SetString(&job->username, con->username); + cupsdSetString(&job->username, con->username); save_auth_info(con, job->id); } else if (attr != NULL) { - LogMessage(L_DEBUG, "create_job: requesting-user-name = \'%s\'", + cupsdLogMessage(L_DEBUG, "create_job: requesting-user-name = \'%s\'", attr->values[0].string.text); - SetString(&job->username, attr->values[0].string.text); + cupsdSetString(&job->username, attr->values[0].string.text); } else - SetString(&job->username, "anonymous"); + cupsdSetString(&job->username, "anonymous"); if (attr == NULL) ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-originating-user-name", @@ -3721,7 +3721,7 @@ create_job(client_t *con, /* I - Client connection */ else { attr->group_tag = IPP_TAG_JOB; - SetString(&attr->name, "job-originating-user-name"); + cupsdSetString(&attr->name, "job-originating-user-name"); } if ((attr = ippFindAttribute(job->attrs, "job-originating-host-name", @@ -3835,7 +3835,7 @@ create_job(client_t *con, /* I - Client connection */ * Hold job until specified time... */ - SetJobHoldUntil(job->id, attr->values[0].string.text); + cupsdSetJobHoldUntil(job->id, attr->values[0].string.text); } else job->hold_until = time(NULL) + 60; @@ -3851,16 +3851,16 @@ create_job(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_ZERO)) == NULL) { - LogMessage(L_DEBUG, "Adding default job-sheets values \"%s,%s\"...", - printer->job_sheets[0], printer->job_sheets[1]); + cupsdLogMessage(L_DEBUG, "Adding default job-sheets values \"%s,%s\"...", + printer->cupsd_job_sheets[0], printer->cupsd_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->job_sheets[0]); - attr->values[1].string.text = strdup(printer->job_sheets[1]); + attr->values[0].string.text = strdup(printer->cupsd_job_sheets[0]); + attr->values[1].string.text = strdup(printer->cupsd_job_sheets[1]); } - job->job_sheets = attr; + job->cupsd_job_sheets = attr; /* * Enforce classification level if set... @@ -3868,7 +3868,7 @@ create_job(client_t *con, /* I - Client connection */ if (Classification) { - LogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d", + cupsdLogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d", Classification ? Classification : "(null)", ClassifyOverride); if (ClassifyOverride) @@ -3881,9 +3881,9 @@ create_job(client_t *con, /* I - Client connection */ * Force the leading banner to have the classification on it... */ - SetString(&attr->values[0].string.text, Classification); + cupsdSetString(&attr->values[0].string.text, Classification); - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " "job-sheets=\"%s,none\", " "job-originating-user-name=\"%s\"", job->id, Classification, @@ -3898,9 +3898,9 @@ create_job(client_t *con, /* I - Client connection */ * Can't put two different security markings on the same document! */ - SetString(&attr->values[1].string.text, attr->values[0].string.text); + cupsdSetString(&attr->values[1].string.text, attr->values[0].string.text); - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " "job-sheets=\"%s,%s\", " "job-originating-user-name=\"%s\"", job->id, attr->values[0].string.text, @@ -3914,13 +3914,13 @@ create_job(client_t *con, /* I - Client connection */ strcmp(attr->values[1].string.text, "none")))) { if (attr->num_values == 1) - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN " "job-sheets=\"%s\", " "job-originating-user-name=\"%s\"", job->id, attr->values[0].string.text, job->username); else - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN " "job-sheets=\"%s,%s\",fffff " "job-originating-user-name=\"%s\"", job->id, attr->values[0].string.text, @@ -3939,29 +3939,29 @@ create_job(client_t *con, /* I - Client connection */ if (attr->num_values > 1 && !strcmp(attr->values[0].string.text, attr->values[1].string.text)) { - SetString(&(attr->values[0].string.text), Classification); - SetString(&(attr->values[1].string.text), Classification); + cupsdSetString(&(attr->values[0].string.text), Classification); + cupsdSetString(&(attr->values[1].string.text), Classification); } else { if (attr->num_values == 1 || strcmp(attr->values[0].string.text, "none")) - SetString(&(attr->values[0].string.text), Classification); + cupsdSetString(&(attr->values[0].string.text), Classification); if (attr->num_values > 1 && strcmp(attr->values[1].string.text, "none")) - SetString(&(attr->values[1].string.text), Classification); + cupsdSetString(&(attr->values[1].string.text), Classification); } if (attr->num_values > 1) - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " + 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); else - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " "job-sheets=\"%s\", " "job-originating-user-name=\"%s\"", job->id, Classification, @@ -3975,12 +3975,12 @@ create_job(client_t *con, /* I - Client connection */ if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT))) { - LogMessage(L_INFO, "Adding start banner page \"%s\" to job %d.", + cupsdLogMessage(L_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); - UpdateQuota(printer, job->username, 0, kbytes); + cupsdUpdateQuota(printer, job->username, 0, kbytes); } } else if ((attr = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_ZERO)) != NULL) @@ -3990,7 +3990,7 @@ create_job(client_t *con, /* I - Client connection */ * Add any job subscriptions... */ - add_job_subscriptions(con, job); + add_cupsd_job_subscriptions(con, job); /* * Set all but the first two attributes to the job attributes group... @@ -4003,9 +4003,9 @@ create_job(client_t *con, /* I - Client connection */ * Save and log the job... */ - SaveJob(job->id); + cupsdSaveJob(job->id); - LogMessage(L_INFO, "Job %d created on \'%s\' by \'%s\'.", job->id, + cupsdLogMessage(L_INFO, "Job %d created on \'%s\' by \'%s\'.", job->id, job->dest, job->username); cupsdAddEvent(CUPSD_EVENT_JOB_CREATED, printer, job, "Job created."); @@ -4034,7 +4034,7 @@ create_job(client_t *con, /* I - Client connection */ static void create_subscription( - client_t *con, /* I - Client connection */ + cupsd_client_t *con, /* I - Client connection */ ipp_attribute_t *uri) /* I - Printer URI */ { } @@ -4045,7 +4045,7 @@ create_subscription( */ static void -delete_printer(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 */ @@ -4055,11 +4055,11 @@ delete_printer(client_t *con, /* I - Client connection */ host[HTTP_MAX_URI], /* Host portion of URI */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - printer_t *printer; /* Printer/class */ + cupsd_printer_t *printer; /* Printer/class */ char filename[1024]; /* Script/PPD filename */ - LogMessage(L_DEBUG2, "delete_printer(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "delete_printer(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -4068,7 +4068,7 @@ delete_printer(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/admin/", 7) != 0) { - LogMessage(L_ERROR, "delete_printer: admin request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "delete_printer: admin request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -4080,13 +4080,13 @@ delete_printer(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((dest = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "delete_printer: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "delete_printer: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -4097,7 +4097,7 @@ delete_printer(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "delete_printer: not authorized!"); + cupsdLogMessage(L_ERROR, "delete_printer: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -4106,7 +4106,7 @@ delete_printer(client_t *con, /* I - Client connection */ * Remove old jobs... */ - CancelJobs(dest, NULL, 1); + cupsdCancelJobs(dest, NULL, 1); /* * Remove old subscriptions and send a "deleted printer" event... @@ -4131,19 +4131,19 @@ delete_printer(client_t *con, /* I - Client connection */ if (dtype & CUPS_PRINTER_CLASS) { - LogMessage(L_INFO, "Class \'%s\' deleted by \'%s\'.", dest, + cupsdLogMessage(L_INFO, "Class \'%s\' deleted by \'%s\'.", dest, con->username); - DeletePrinter(printer, 0); - SaveAllClasses(); + cupsdDeletePrinter(printer, 0); + cupsdSaveAllClasses(); } else { - LogMessage(L_INFO, "Printer \'%s\' deleted by \'%s\'.", dest, + cupsdLogMessage(L_INFO, "Printer \'%s\' deleted by \'%s\'.", dest, con->username); - DeletePrinter(printer, 0); - SaveAllPrinters(); + cupsdDeletePrinter(printer, 0); + cupsdSaveAllPrinters(); } /* @@ -4159,7 +4159,7 @@ delete_printer(client_t *con, /* I - Client connection */ */ static void -get_default(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 */ @@ -4170,7 +4170,7 @@ get_default(client_t *con) /* I - Client connection */ time_t curtime; /* Current time */ - LogMessage(L_DEBUG2, "get_default(%p[%d])\n", con, con->http.fd); + cupsdLogMessage(L_DEBUG2, "get_default(%p[%d])\n", con, con->http.fd); /* * Check policy... @@ -4178,7 +4178,7 @@ get_default(client_t *con) /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "get_default: not authorized!"); + cupsdLogMessage(L_ERROR, "get_default: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -4197,13 +4197,13 @@ get_default(client_t *con) /* I - Client connection */ con->servername, con->serverport, DefaultPrinter->name); ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uri-supported", NULL, printer_uri); - LogMessage(L_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri); + cupsdLogMessage(L_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri); } ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", DefaultPrinter->state); - add_printer_state_reasons(con, DefaultPrinter); + add_cupsd_printer_state_reasons(con, DefaultPrinter); ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-state-message", NULL, DefaultPrinter->state_message); @@ -4271,7 +4271,7 @@ get_default(client_t *con) /* I - Client connection */ */ static void -get_devices(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 */ @@ -4283,7 +4283,7 @@ get_devices(client_t *con) /* I - Client connection */ int alen; /* Length of attribute value */ - LogMessage(L_DEBUG2, "get_devices(%p[%d])\n", con, con->http.fd); + cupsdLogMessage(L_DEBUG2, "get_devices(%p[%d])\n", con, con->http.fd); /* * Check policy... @@ -4291,7 +4291,7 @@ get_devices(client_t *con) /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "get_devices: not authorized!"); + cupsdLogMessage(L_ERROR, "get_devices: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -4348,7 +4348,7 @@ get_devices(client_t *con) /* I - Client connection */ limit ? limit->values[0].integer : 0, attrs); - if (SendCommand(con, command, options, 1)) + if (cupsdSendCommand(con, command, options, 1)) { /* * Command started successfully, don't send an IPP response here... @@ -4374,7 +4374,7 @@ get_devices(client_t *con) /* I - Client connection */ */ static void -get_jobs(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 */ @@ -4391,13 +4391,13 @@ get_jobs(client_t *con, /* I - Client connection */ int first; /* First job ID */ int limit; /* Maximum number of jobs to return */ int count; /* Number of jobs that match */ - job_t *job; /* Current job pointer */ + cupsd_job_t *job; /* Current job pointer */ char job_uri[HTTP_MAX_URI]; /* Job URI... */ - printer_t *printer; /* Printer */ + cupsd_printer_t *printer; /* Printer */ cups_array_t *list; /* Which job list... */ - LogMessage(L_DEBUG2, "get_jobs(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "get_jobs(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -4428,13 +4428,13 @@ get_jobs(client_t *con, /* I - Client connection */ dmask = CUPS_PRINTER_CLASS; printer = NULL; } - else if ((dest = ValidateDest(host, resource, &dtype, &printer)) == NULL) + else if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "get_jobs: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "get_jobs: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -4449,14 +4449,14 @@ get_jobs(client_t *con, /* I - Client connection */ { if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) { - LogMessage(L_ERROR, "get_jobs: not authorized!"); + cupsdLogMessage(L_ERROR, "get_jobs: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } } else if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "get_jobs: not authorized!"); + cupsdLogMessage(L_ERROR, "get_jobs: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -4520,15 +4520,15 @@ get_jobs(client_t *con, /* I - Client connection */ * OK, build a list of jobs for this printer... */ - for (count = 0, job = (job_t *)cupsArrayFirst(list); + for (count = 0, job = (cupsd_job_t *)cupsArrayFirst(list); count < limit && job; - job = (job_t *)cupsArrayNext(list)) + job = (cupsd_job_t *)cupsArrayNext(list)) { /* * Filter out jobs that don't match... */ - LogMessage(L_DEBUG2, "get_jobs: job->id = %d", job->id); + cupsdLogMessage(L_DEBUG2, "get_jobs: job->id = %d", job->id); if ((dest != NULL && strcmp(job->dest, dest) != 0) && (job->printer == NULL || dest == NULL || @@ -4548,7 +4548,7 @@ get_jobs(client_t *con, /* I - Client connection */ count ++; - LogMessage(L_DEBUG2, "get_jobs: count = %d", count); + cupsdLogMessage(L_DEBUG2, "get_jobs: count = %d", count); /* * Send the requested attributes for each job... @@ -4573,7 +4573,7 @@ get_jobs(client_t *con, /* I - Client connection */ copy_attrs(con->response, job->attrs, requested, IPP_TAG_JOB, 0); - add_job_state_reasons(con, job); + add_cupsd_job_state_reasons(con, job); ippAddSeparator(con->response); } @@ -4590,13 +4590,13 @@ get_jobs(client_t *con, /* I - Client connection */ */ static void -get_job_attrs(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 */ - 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 */ @@ -4605,7 +4605,7 @@ get_job_attrs(client_t *con, /* I - Client connection */ char job_uri[HTTP_MAX_URI]; /* Job URI... */ - LogMessage(L_DEBUG2, "get_job_attrs(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "get_job_attrs(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -4620,7 +4620,7 @@ get_job_attrs(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "get_job_attrs: got a printer-uri attribute but no job-id!"); + cupsdLogMessage(L_ERROR, "get_job_attrs: got a printer-uri attribute but no job-id!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -4641,7 +4641,7 @@ get_job_attrs(client_t *con, /* I - Client connection */ * Not a valid URI! */ - LogMessage(L_ERROR, "get_job_attrs: bad job-uri attribute \'%s\'!\n", + cupsdLogMessage(L_ERROR, "get_job_attrs: bad job-uri attribute \'%s\'!\n", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -4654,13 +4654,13 @@ get_job_attrs(client_t *con, /* I - Client connection */ * See if the job exists... */ - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { /* * Nope - return a "not found" error... */ - LogMessage(L_ERROR, "get_job_attrs: job #%d doesn't exist!", jobid); + cupsdLogMessage(L_ERROR, "get_job_attrs: job #%d doesn't exist!", jobid); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -4671,7 +4671,7 @@ get_job_attrs(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "get_job_attrs: not authorized!"); + cupsdLogMessage(L_ERROR, "get_job_attrs: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -4704,7 +4704,7 @@ get_job_attrs(client_t *con, /* I - Client connection */ copy_attrs(con->response, job->attrs, requested, IPP_TAG_JOB, 0); - add_job_state_reasons(con, job); + add_cupsd_job_state_reasons(con, job); if (requested != NULL) con->response->request.status.status_code = IPP_OK_SUBST; @@ -4718,7 +4718,7 @@ get_job_attrs(client_t *con, /* I - Client connection */ */ static void -get_notifications(client_t *con, /* I - Client connection */ +get_notifications(cupsd_client_t *con, /* I - Client connection */ int id) /* I - Subscription ID */ { } @@ -4729,7 +4729,7 @@ get_notifications(client_t *con, /* I - Client connection */ */ static void -get_ppds(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 */ @@ -4742,7 +4742,7 @@ get_ppds(client_t *con) /* I - Client connection */ int alen; /* Length of attribute value */ - LogMessage(L_DEBUG2, "get_ppds(%p[%d])\n", con, con->http.fd); + cupsdLogMessage(L_DEBUG2, "get_ppds(%p[%d])\n", con, con->http.fd); /* * Check policy... @@ -4750,7 +4750,7 @@ get_ppds(client_t *con) /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "get_ppds: not authorized!"); + cupsdLogMessage(L_ERROR, "get_ppds: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -4810,7 +4810,7 @@ get_ppds(client_t *con) /* I - Client connection */ make ? "%20ppd-make=" : "", make ? make->values[0].string.text : ""); - if (SendCommand(con, command, options, 0)) + if (cupsdSendCommand(con, command, options, 0)) { /* * Command started successfully, don't send an IPP response here... @@ -4836,7 +4836,7 @@ get_ppds(client_t *con) /* I - Client connection */ */ static void -get_printer_attrs(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 */ @@ -4850,7 +4850,7 @@ get_printer_attrs(client_t *con, /* I - Client connection */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - printer_t *printer; /* Printer/class */ + cupsd_printer_t *printer; /* Printer/class */ char printer_uri[HTTP_MAX_URI]; /* Printer URI */ time_t curtime; /* Current time */ @@ -4860,7 +4860,7 @@ get_printer_attrs(client_t *con, /* I - Client connection */ int need_history; /* Need to send history collection? */ - LogMessage(L_DEBUG2, "get_printer_attrs(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "get_printer_attrs(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -4869,13 +4869,13 @@ get_printer_attrs(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((dest = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "get_printer_attrs: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "get_printer_attrs: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -4886,7 +4886,7 @@ get_printer_attrs(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) { - LogMessage(L_ERROR, "get_printer_attrs: not authorized!"); + cupsdLogMessage(L_ERROR, "get_printer_attrs: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -4905,13 +4905,13 @@ get_printer_attrs(client_t *con, /* I - Client connection */ con->servername, con->serverport, printer->name); ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uri-supported", NULL, printer_uri); - LogMessage(L_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri); + cupsdLogMessage(L_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri); } ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", printer->state); - add_printer_state_reasons(con, printer); + add_cupsd_printer_state_reasons(con, printer); ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-state-message", NULL, printer->state_message); @@ -4974,7 +4974,7 @@ get_printer_attrs(client_t *con, /* I - Client connection */ */ static void -get_printers(client_t *con, /* I - Client connection */ +get_printers(cupsd_client_t *con, /* I - Client connection */ int type) /* I - 0 or CUPS_PRINTER_CLASS */ { int i; /* Looping var */ @@ -4984,20 +4984,20 @@ get_printers(client_t *con, /* I - Client connection */ int need_history; /* Need to send history collection? */ int limit; /* Maximum number of printers to return */ int count; /* Number of printers that match */ - printer_t *printer; /* Current printer pointer */ + cupsd_printer_t *printer; /* Current printer pointer */ time_t curtime; /* Current time */ - int printer_type, /* printer-type attribute */ + int cupsd_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 */ - printer_t *iclass; /* Implicit class */ + cupsd_printer_t *iclass; /* Implicit class */ const char *username; /* Current user */ char printer_uri[HTTP_MAX_URI]; /* Printer URI */ - LogMessage(L_DEBUG2, "get_printers(%p[%d], %x)\n", con, con->http.fd, type); + cupsdLogMessage(L_DEBUG2, "get_printers(%p[%d], %x)\n", con, con->http.fd, type); if (!Printers || !cupsArrayCount(Printers)) { @@ -5011,7 +5011,7 @@ get_printers(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "get_printers: not authorized!"); + cupsdLogMessage(L_ERROR, "get_printers: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -5030,9 +5030,9 @@ get_printers(client_t *con, /* I - Client connection */ */ if ((attr = ippFindAttribute(con->request, "printer-type", IPP_TAG_ENUM)) != NULL) - printer_type = attr->values[0].integer; + cupsd_printer_type = attr->values[0].integer; else - printer_type = 0; + cupsd_printer_type = 0; if ((attr = ippFindAttribute(con->request, "printer-type-mask", IPP_TAG_ENUM)) != NULL) printer_mask = attr->values[0].integer; @@ -5073,11 +5073,11 @@ get_printers(client_t *con, /* I - Client connection */ curtime = time(NULL); - for (count = 0, printer = (printer_t *)cupsArrayFirst(Printers); + for (count = 0, printer = (cupsd_printer_t *)cupsArrayFirst(Printers); count < limit && printer != NULL; - printer = (printer_t *)cupsArrayNext(Printers)) + printer = (cupsd_printer_t *)cupsArrayNext(Printers)) if ((!type || (printer->type & CUPS_PRINTER_CLASS) == type) && - (printer->type & printer_mask) == printer_type && + (printer->type & printer_mask) == cupsd_printer_type && (location == NULL || printer->location == NULL || !strcasecmp(printer->location, location))) { @@ -5107,7 +5107,7 @@ get_printers(client_t *con, /* I - Client connection */ * Find the core printer, if any... */ - if ((iclass = FindPrinter(name)) != NULL && + if ((iclass = cupsdFindPrinter(name)) != NULL && (iclass->type & CUPS_PRINTER_IMPLICIT)) continue; } @@ -5149,13 +5149,13 @@ get_printers(client_t *con, /* I - Client connection */ con->servername, con->serverport, printer->name); ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uri-supported", NULL, printer_uri); - LogMessage(L_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri); + cupsdLogMessage(L_DEBUG2, "printer-uri-supported=\"%s\"", printer_uri); } ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", printer->state); - add_printer_state_reasons(con, printer); + add_cupsd_printer_state_reasons(con, printer); ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-state-message", NULL, printer->state_message); @@ -5205,7 +5205,7 @@ get_printers(client_t *con, /* I - Client connection */ */ static void -get_subscription_attrs(client_t *con, /* I - Client connection */ +get_subscription_attrs(cupsd_client_t *con, /* I - Client connection */ int sub_id) /* I - Subscription ID */ { } @@ -5216,7 +5216,7 @@ get_subscription_attrs(client_t *con, /* I - Client connection */ */ static void -get_subscriptions(client_t *con, /* I - Client connection */ +get_subscriptions(cupsd_client_t *con, /* I - Client connection */ ipp_attribute_t *uri) /* I - Printer URI */ { } @@ -5227,7 +5227,7 @@ get_subscriptions(client_t *con, /* I - Client connection */ */ static void -hold_job(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 */ @@ -5238,10 +5238,10 @@ hold_job(client_t *con, /* I - Client connection */ host[HTTP_MAX_URI], /* Host portion of URI */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - job_t *job; /* Job information */ + cupsd_job_t *job; /* Job information */ - LogMessage(L_DEBUG2, "hold_job(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "hold_job(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -5252,7 +5252,7 @@ hold_job(client_t *con, /* I - Client connection */ strncmp(con->uri, "/jobs/", 5) != 0 && strncmp(con->uri, "/printers/", 10) != 0) { - LogMessage(L_ERROR, "hold_job: hold request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "hold_job: hold request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -5270,7 +5270,7 @@ hold_job(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "hold_job: got a printer-uri attribute but no job-id!"); + cupsdLogMessage(L_ERROR, "hold_job: got a printer-uri attribute but no job-id!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -5291,7 +5291,7 @@ hold_job(client_t *con, /* I - Client connection */ * Not a valid URI! */ - LogMessage(L_ERROR, "hold_job: bad job-uri attribute \'%s\'!", + cupsdLogMessage(L_ERROR, "hold_job: bad job-uri attribute \'%s\'!", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -5304,13 +5304,13 @@ hold_job(client_t *con, /* I - Client connection */ * See if the job exists... */ - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { /* * Nope - return a "not found" error... */ - LogMessage(L_ERROR, "hold_job: job #%d doesn't exist!", jobid); + cupsdLogMessage(L_ERROR, "hold_job: job #%d doesn't exist!", jobid); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -5321,7 +5321,7 @@ hold_job(client_t *con, /* I - Client connection */ if (!validate_user(job, con, job->username, username, sizeof(username))) { - LogMessage(L_ERROR, "hold_job: \"%s\" not authorized to hold job id %d owned by \"%s\"!", + cupsdLogMessage(L_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; @@ -5331,7 +5331,7 @@ hold_job(client_t *con, /* I - Client connection */ * Hold the job and return... */ - HoldJob(jobid); + cupsdHoldJob(jobid); if ((newattr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_KEYWORD)) == NULL) newattr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_NAME); @@ -5362,10 +5362,10 @@ hold_job(client_t *con, /* I - Client connection */ * Hold job until specified time... */ - SetJobHoldUntil(job->id, attr->values[0].string.text); + cupsdSetJobHoldUntil(job->id, attr->values[0].string.text); } - LogMessage(L_INFO, "Job %d was held by \'%s\'.", jobid, username); + cupsdLogMessage(L_INFO, "Job %d was held by \'%s\'.", jobid, username); con->response->request.status.status_code = IPP_OK; } @@ -5376,12 +5376,12 @@ hold_job(client_t *con, /* I - Client connection */ */ static void -move_job(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 */ - 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 */ @@ -5389,10 +5389,10 @@ move_job(client_t *con, /* I - Client connection */ host[HTTP_MAX_URI], /* Host portion of URI */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - printer_t *printer; /* Printer */ + cupsd_printer_t *printer; /* Printer */ - LogMessage(L_DEBUG2, "move_job(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "move_job(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -5407,7 +5407,7 @@ move_job(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "move_job: got a printer-uri attribute but no job-id!"); + cupsdLogMessage(L_ERROR, "move_job: got a printer-uri attribute but no job-id!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -5428,7 +5428,7 @@ move_job(client_t *con, /* I - Client connection */ * Not a valid URI! */ - LogMessage(L_ERROR, "move_job: bad job-uri attribute \'%s\'!\n", + cupsdLogMessage(L_ERROR, "move_job: bad job-uri attribute \'%s\'!\n", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -5441,13 +5441,13 @@ move_job(client_t *con, /* I - Client connection */ * See if the job exists... */ - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { /* * Nope - return a "not found" error... */ - LogMessage(L_ERROR, "move_job: job #%d doesn't exist!", jobid); + cupsdLogMessage(L_ERROR, "move_job: job #%d doesn't exist!", jobid); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -5462,7 +5462,7 @@ move_job(client_t *con, /* I - Client connection */ * Return a "not-possible" error... */ - LogMessage(L_ERROR, "move_job: job #%d is finished and cannot be altered!", jobid); + cupsdLogMessage(L_ERROR, "move_job: job #%d is finished and cannot be altered!", jobid); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } @@ -5473,7 +5473,7 @@ move_job(client_t *con, /* I - Client connection */ if (!validate_user(job, con, job->username, username, sizeof(username))) { - LogMessage(L_ERROR, "move_job: \"%s\" not authorized to move job id %d owned by \"%s\"!", + cupsdLogMessage(L_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; @@ -5485,7 +5485,7 @@ move_job(client_t *con, /* I - Client connection */ * Need job-printer-uri... */ - LogMessage(L_ERROR, "move_job: job-printer-uri attribute missing!"); + cupsdLogMessage(L_ERROR, "move_job: job-printer-uri attribute missing!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -5496,13 +5496,13 @@ move_job(client_t *con, /* I - Client connection */ httpSeparate(attr->values[0].string.text, method, username, host, &port, resource); - if ((dest = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "move_job: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "move_job: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -5513,7 +5513,7 @@ move_job(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) { - LogMessage(L_ERROR, "move_job: not authorized!"); + cupsdLogMessage(L_ERROR, "move_job: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -5522,13 +5522,13 @@ move_job(client_t *con, /* I - Client connection */ * Move the job to a different printer or class... */ - MoveJob(jobid, dest); + cupsdMoveJob(jobid, dest); /* * Start jobs if possible... */ - CheckJobs(); + cupsdCheckJobs(); /* * Return with "everything is OK" status... @@ -5573,7 +5573,7 @@ ppd_add_default( if (!temp) { - LogMessage(L_ERROR, "ppd_add_default: Unable to add default value for \"%s\" - %s", + cupsdLogMessage(L_ERROR, "ppd_add_default: Unable to add default value for \"%s\" - %s", option, strerror(errno)); return (num_defaults); } @@ -5660,7 +5660,7 @@ ppd_parse_line(const char *line, /* I - Line */ */ static void -print_job(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 */ @@ -5669,7 +5669,7 @@ print_job(client_t *con, /* I - Client connection */ cups_ptype_t dtype; /* Destination type (printer or class) */ int priority; /* Job priority */ char *title; /* Job name/title */ - 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 */ @@ -5683,7 +5683,7 @@ print_job(client_t *con, /* I - Client connection */ type[MIME_MAX_TYPE], /* Subtype of file */ mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE + 2]; /* Textual name of mime type */ - 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 */ @@ -5691,7 +5691,7 @@ print_job(client_t *con, /* I - Client connection */ int compression; /* Document compression */ - LogMessage(L_DEBUG2, "print_job(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "print_job(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -5701,7 +5701,7 @@ print_job(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/classes/", 9) != 0 && strncmp(con->uri, "/printers/", 10) != 0) { - LogMessage(L_ERROR, "print_job: cancel request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "print_job: cancel request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -5715,7 +5715,7 @@ print_job(client_t *con, /* I - Client connection */ { if (attr->values[0].integer < 1 || attr->values[0].integer > MaxCopies) { - LogMessage(L_ERROR, "print_job: Bad copies value %d.", + cupsdLogMessage(L_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, @@ -5731,7 +5731,7 @@ print_job(client_t *con, /* I - Client connection */ if (attr->values[i].range.lower < lowerpagerange || attr->values[i].range.lower > attr->values[i].range.upper) { - LogMessage(L_ERROR, "print_job: bad page-ranges values %d-%d.", + cupsdLogMessage(L_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; @@ -5756,7 +5756,7 @@ print_job(client_t *con, /* I - Client connection */ #endif /* HAVE_LIBZ */ ) { - LogMessage(L_ERROR, "print_job: Unsupported compression \"%s\"!", + cupsdLogMessage(L_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, @@ -5776,7 +5776,7 @@ print_job(client_t *con, /* I - Client connection */ if (!con->filename) { - LogMessage(L_ERROR, "print_job: No file!?!"); + cupsdLogMessage(L_ERROR, "print_job: No file!?!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -5793,7 +5793,7 @@ print_job(client_t *con, /* I - Client connection */ if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super, type) != 2) { - LogMessage(L_ERROR, "print_job: could not scan type \'%s\'!", + cupsdLogMessage(L_ERROR, "print_job: could not scan type \'%s\'!", format->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -5815,7 +5815,7 @@ print_job(client_t *con, /* I - Client connection */ * Auto-type the file... */ - LogMessage(L_DEBUG, "print_job: auto-typing file..."); + cupsdLogMessage(L_DEBUG, "print_job: auto-typing file..."); filetype = mimeFileType(MimeDatabase, con->filename, &compression); @@ -5845,9 +5845,9 @@ print_job(client_t *con, /* I - Client connection */ if (filetype == NULL) { - LogMessage(L_ERROR, "print_job: Unsupported format \'%s/%s\'!", + cupsdLogMessage(L_ERROR, "print_job: Unsupported format \'%s/%s\'!", super, type); - LogMessage(L_INFO, "Hint: Do you have the raw file printing rules enabled?"); + cupsdLogMessage(L_INFO, "Hint: Do you have the raw file printing rules enabled?"); send_ipp_error(con, IPP_DOCUMENT_FORMAT); if (format) @@ -5857,7 +5857,7 @@ print_job(client_t *con, /* I - Client connection */ return; } - LogMessage(L_DEBUG, "print_job: request file type is %s/%s.", + cupsdLogMessage(L_DEBUG, "print_job: request file type is %s/%s.", filetype->super, filetype->type); /* @@ -5866,7 +5866,7 @@ print_job(client_t *con, /* I - Client connection */ if (!strcasecmp(filetype->super, "application") && !strcasecmp(filetype->type, "postscript")) - read_ps_job_ticket(con); + read_ps_cupsd_job_ticket(con); /* * Is the destination valid? @@ -5874,13 +5874,13 @@ print_job(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((dest = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "print_job: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "print_job: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -5893,7 +5893,7 @@ print_job(client_t *con, /* I - Client connection */ strcasecmp(con->http.hostname, "localhost") && strcasecmp(con->http.hostname, ServerName)) { - LogMessage(L_ERROR, "print_job: printer not shared!"); + cupsdLogMessage(L_ERROR, "print_job: printer not shared!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -5905,7 +5905,7 @@ print_job(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL) || ((printer->type & CUPS_PRINTER_AUTHENTICATED) && !con->username[0])) { - LogMessage(L_ERROR, "print_job: not authorized!"); + cupsdLogMessage(L_ERROR, "print_job: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -5916,7 +5916,7 @@ print_job(client_t *con, /* I - Client connection */ if (!printer->accepting) { - LogMessage(L_INFO, "print_job: destination \'%s\' is not accepting jobs.", + cupsdLogMessage(L_INFO, "print_job: destination \'%s\' is not accepting jobs.", dest); send_ipp_error(con, IPP_NOT_ACCEPTING); return; @@ -5927,11 +5927,11 @@ print_job(client_t *con, /* I - Client connection */ */ if (cupsArrayCount(Jobs) >= MaxJobs && MaxJobs) - CleanJobs(); + cupsdCleanJobs(); if (cupsArrayCount(Jobs) >= MaxJobs && MaxJobs) { - LogMessage(L_INFO, "print_job: too many jobs - %d jobs, max jobs is %d.", + cupsdLogMessage(L_INFO, "print_job: too many jobs - %d jobs, max jobs is %d.", cupsArrayCount(Jobs), MaxJobs); send_ipp_error(con, IPP_NOT_POSSIBLE); return; @@ -5959,9 +5959,9 @@ print_job(client_t *con, /* I - Client connection */ ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL, title = "Untitled"); - if ((job = AddJob(priority, printer->name)) == NULL) + if ((job = cupsdAddJob(priority, printer->name)) == NULL) { - LogMessage(L_ERROR, "print_job: unable to add job for destination \'%s\'!", + cupsdLogMessage(L_ERROR, "print_job: unable to add job for destination \'%s\'!", dest); send_ipp_error(con, IPP_INTERNAL_ERROR); return; @@ -5979,18 +5979,18 @@ print_job(client_t *con, /* I - Client connection */ if (con->username[0]) { - SetString(&job->username, con->username); + cupsdSetString(&job->username, con->username); save_auth_info(con, job->id); } else if (attr != NULL) { - LogMessage(L_DEBUG, "print_job: requesting-user-name = \'%s\'", + cupsdLogMessage(L_DEBUG, "print_job: requesting-user-name = \'%s\'", attr->values[0].string.text); - SetString(&job->username, attr->values[0].string.text); + cupsdSetString(&job->username, attr->values[0].string.text); } else - SetString(&job->username, "anonymous"); + cupsdSetString(&job->username, "anonymous"); if (attr == NULL) ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-originating-user-name", @@ -5998,7 +5998,7 @@ print_job(client_t *con, /* I - Client connection */ else { attr->group_tag = IPP_TAG_JOB; - SetString(&attr->name, "job-originating-user-name"); + cupsdSetString(&attr->name, "job-originating-user-name"); } /* @@ -6094,7 +6094,7 @@ print_job(client_t *con, /* I - Client connection */ else kbytes = (fileinfo.st_size + 1023) / 1024; - UpdateQuota(printer, job->username, 0, kbytes); + cupsdUpdateQuota(printer, job->username, 0, kbytes); attr->values[0].integer += kbytes; ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "time-at-creation", @@ -6120,7 +6120,7 @@ print_job(client_t *con, /* I - Client connection */ */ job->state->values[0].integer = IPP_JOB_HELD; - SetJobHoldUntil(job->id, attr->values[0].string.text); + cupsdSetJobHoldUntil(job->id, attr->values[0].string.text); } if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) || @@ -6132,16 +6132,16 @@ print_job(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_ZERO)) == NULL) { - LogMessage(L_DEBUG, "Adding default job-sheets values \"%s,%s\"...", - printer->job_sheets[0], printer->job_sheets[1]); + cupsdLogMessage(L_DEBUG, "Adding default job-sheets values \"%s,%s\"...", + printer->cupsd_job_sheets[0], printer->cupsd_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->job_sheets[0]); - attr->values[1].string.text = strdup(printer->job_sheets[1]); + attr->values[0].string.text = strdup(printer->cupsd_job_sheets[0]); + attr->values[1].string.text = strdup(printer->cupsd_job_sheets[1]); } - job->job_sheets = attr; + job->cupsd_job_sheets = attr; /* * Enforce classification level if set... @@ -6149,7 +6149,7 @@ print_job(client_t *con, /* I - Client connection */ if (Classification) { - LogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d", + cupsdLogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d", Classification ? Classification : "(null)", ClassifyOverride); if (ClassifyOverride) @@ -6162,9 +6162,9 @@ print_job(client_t *con, /* I - Client connection */ * Force the leading banner to have the classification on it... */ - SetString(&attr->values[0].string.text, Classification); + cupsdSetString(&attr->values[0].string.text, Classification); - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " "job-sheets=\"%s,none\", " "job-originating-user-name=\"%s\"", job->id, Classification, @@ -6179,9 +6179,9 @@ print_job(client_t *con, /* I - Client connection */ * Can't put two different security markings on the same document! */ - SetString(&attr->values[1].string.text, attr->values[0].string.text); + cupsdSetString(&attr->values[1].string.text, attr->values[0].string.text); - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " "job-sheets=\"%s,%s\", " "job-originating-user-name=\"%s\"", job->id, attr->values[0].string.text, @@ -6195,13 +6195,13 @@ print_job(client_t *con, /* I - Client connection */ strcmp(attr->values[1].string.text, "none")))) { if (attr->num_values == 1) - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN " "job-sheets=\"%s\", " "job-originating-user-name=\"%s\"", job->id, attr->values[0].string.text, job->username); else - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION OVERRIDDEN " "job-sheets=\"%s,%s\", " "job-originating-user-name=\"%s\"", job->id, attr->values[0].string.text, @@ -6220,29 +6220,29 @@ print_job(client_t *con, /* I - Client connection */ if (attr->num_values > 1 && !strcmp(attr->values[0].string.text, attr->values[1].string.text)) { - SetString(&(attr->values[0].string.text), Classification); - SetString(&(attr->values[1].string.text), Classification); + cupsdSetString(&(attr->values[0].string.text), Classification); + cupsdSetString(&(attr->values[1].string.text), Classification); } else { if (attr->num_values == 1 || strcmp(attr->values[0].string.text, "none")) - SetString(&(attr->values[0].string.text), Classification); + cupsdSetString(&(attr->values[0].string.text), Classification); if (attr->num_values > 1 && strcmp(attr->values[1].string.text, "none")) - SetString(&(attr->values[1].string.text), Classification); + cupsdSetString(&(attr->values[1].string.text), Classification); } if (attr->num_values > 1) - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " + 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); else - LogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " + cupsdLogMessage(L_NOTICE, "[Job %d] CLASSIFICATION FORCED " "job-sheets=\"%s\", " "job-originating-user-name=\"%s\"", job->id, Classification, @@ -6256,12 +6256,12 @@ print_job(client_t *con, /* I - Client connection */ if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT))) { - LogMessage(L_INFO, "Adding start banner page \"%s\" to job %d.", + cupsdLogMessage(L_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); - UpdateQuota(printer, job->username, 0, kbytes); + cupsdUpdateQuota(printer, job->username, 0, kbytes); } } else if ((attr = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_ZERO)) != NULL) @@ -6277,7 +6277,7 @@ print_job(client_t *con, /* I - Client connection */ snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id, job->num_files); rename(con->filename, filename); - ClearString(&con->filename); + cupsdClearString(&con->filename); /* * See if we need to add the ending sheet... @@ -6290,19 +6290,19 @@ print_job(client_t *con, /* I - Client connection */ * Yes... */ - LogMessage(L_INFO, "Adding end banner page \"%s\" to job %d.", + cupsdLogMessage(L_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); - UpdateQuota(printer, job->username, 0, kbytes); + cupsdUpdateQuota(printer, job->username, 0, kbytes); } /* * Add any job subscriptions... */ - add_job_subscriptions(con, job); + add_cupsd_job_subscriptions(con, job); /* * Set all but the first two attributes to the job attributes group... @@ -6315,24 +6315,24 @@ print_job(client_t *con, /* I - Client connection */ * Log and save the job... */ - LogMessage(L_INFO, "Job %d queued on \'%s\' by \'%s\'.", job->id, + cupsdLogMessage(L_INFO, "Job %d queued on \'%s\' by \'%s\'.", job->id, job->dest, job->username); - LogMessage(L_DEBUG, "Job %d hold_until = %d", job->id, (int)job->hold_until); + cupsdLogMessage(L_DEBUG, "Job %d hold_until = %d", job->id, (int)job->hold_until); - SaveJob(job->id); + cupsdSaveJob(job->id); cupsdAddEvent(CUPSD_EVENT_JOB_CREATED, printer, job, "Job created."); /* - * Start the job if possible... Since CheckJobs() can cancel a job if it + * 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; - CheckJobs(); + cupsdCheckJobs(); - job = FindJob(jobid); + job = cupsdFindJob(jobid); /* * Fill in the response info... @@ -6347,14 +6347,14 @@ print_job(client_t *con, /* I - Client connection */ ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", job ? job->state->values[0].integer : IPP_JOB_CANCELLED); - add_job_state_reasons(con, job); + add_cupsd_job_state_reasons(con, job); con->response->request.status.status_code = IPP_OK; } /* - * 'read_ps_job_ticket()' - Reads a job ticket embedded in a PS file. + * 'read_ps_cupsd_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 + @@ -6387,7 +6387,7 @@ print_job(client_t *con, /* I - Client connection */ */ static void -read_ps_job_ticket(client_t *con) /* I - Client connection */ +read_ps_cupsd_job_ticket(cupsd_client_t *con) /* I - Client connection */ { cups_file_t *fp; /* File to read from */ char line[256]; /* Line data */ @@ -6405,7 +6405,7 @@ read_ps_job_ticket(client_t *con) /* I - Client connection */ if ((fp = cupsFileOpen(con->filename, "rb")) == NULL) { - LogMessage(L_ERROR, "read_ps_job_ticket: Unable to open PostScript print file - %s", + cupsdLogMessage(L_ERROR, "read_ps_cupsd_job_ticket: Unable to open PostScript print file - %s", strerror(errno)); return; } @@ -6416,7 +6416,7 @@ read_ps_job_ticket(client_t *con) /* I - Client connection */ if (cupsFileGets(fp, line, sizeof(line)) == NULL) { - LogMessage(L_ERROR, "read_ps_job_ticket: Unable to read from PostScript print file - %s", + cupsdLogMessage(L_ERROR, "read_ps_cupsd_job_ticket: Unable to read from PostScript print file - %s", strerror(errno)); cupsFileClose(fp); return; @@ -6538,7 +6538,7 @@ read_ps_job_ticket(client_t *con) /* I - Client connection */ */ static void -reject_jobs(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) */ @@ -6548,11 +6548,11 @@ reject_jobs(client_t *con, /* I - Client connection */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ const char *name; /* Printer name */ - printer_t *printer; /* Printer data */ + cupsd_printer_t *printer; /* Printer data */ ipp_attribute_t *attr; /* printer-state-message text */ - LogMessage(L_DEBUG2, "reject_jobs(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "reject_jobs(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -6561,7 +6561,7 @@ reject_jobs(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/admin/", 7) != 0) { - LogMessage(L_ERROR, "reject_jobs: admin request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "reject_jobs: admin request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -6573,13 +6573,13 @@ reject_jobs(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((name = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "reject_jobs: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "reject_jobs: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -6590,7 +6590,7 @@ reject_jobs(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) { - LogMessage(L_ERROR, "reject_jobs: not authorized!"); + cupsdLogMessage(L_ERROR, "reject_jobs: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -6608,20 +6608,20 @@ reject_jobs(client_t *con, /* I - Client connection */ strlcpy(printer->state_message, attr->values[0].string.text, sizeof(printer->state_message)); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); if (dtype & CUPS_PRINTER_CLASS) { - SaveAllClasses(); + cupsdSaveAllClasses(); - LogMessage(L_INFO, "Class \'%s\' rejecting jobs (\'%s\').", name, + cupsdLogMessage(L_INFO, "Class \'%s\' rejecting jobs (\'%s\').", name, con->username); } else { - SaveAllPrinters(); + cupsdSaveAllPrinters(); - LogMessage(L_INFO, "Printer \'%s\' rejecting jobs (\'%s\').", name, + cupsdLogMessage(L_INFO, "Printer \'%s\' rejecting jobs (\'%s\').", name, con->username); } @@ -6638,7 +6638,7 @@ reject_jobs(client_t *con, /* I - Client connection */ */ static void -release_job(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 */ @@ -6648,10 +6648,10 @@ release_job(client_t *con, /* I - Client connection */ host[HTTP_MAX_URI], /* Host portion of URI */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - job_t *job; /* Job information */ + cupsd_job_t *job; /* Job information */ - LogMessage(L_DEBUG2, "release_job(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "release_job(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -6662,7 +6662,7 @@ release_job(client_t *con, /* I - Client connection */ strncmp(con->uri, "/jobs/", 5) != 0 && strncmp(con->uri, "/printers/", 10) != 0) { - LogMessage(L_ERROR, "release_job: release request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "release_job: release request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -6680,7 +6680,7 @@ release_job(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "release_job: got a printer-uri attribute but no job-id!"); + cupsdLogMessage(L_ERROR, "release_job: got a printer-uri attribute but no job-id!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -6701,7 +6701,7 @@ release_job(client_t *con, /* I - Client connection */ * Not a valid URI! */ - LogMessage(L_ERROR, "release_job: bad job-uri attribute \'%s\'!", + cupsdLogMessage(L_ERROR, "release_job: bad job-uri attribute \'%s\'!", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -6714,13 +6714,13 @@ release_job(client_t *con, /* I - Client connection */ * See if the job exists... */ - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { /* * Nope - return a "not found" error... */ - LogMessage(L_ERROR, "release_job: job #%d doesn't exist!", jobid); + cupsdLogMessage(L_ERROR, "release_job: job #%d doesn't exist!", jobid); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -6735,7 +6735,7 @@ release_job(client_t *con, /* I - Client connection */ * Nope - return a "not possible" error... */ - LogMessage(L_ERROR, "release_job: job #%d is not held!", jobid); + cupsdLogMessage(L_ERROR, "release_job: job #%d is not held!", jobid); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } @@ -6746,7 +6746,7 @@ release_job(client_t *con, /* I - Client connection */ if (!validate_user(job, con, job->username, username, sizeof(username))) { - LogMessage(L_ERROR, "release_job: \"%s\" not authorized to release job id %d owned by \"%s\"!", + cupsdLogMessage(L_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; @@ -6770,9 +6770,9 @@ release_job(client_t *con, /* I - Client connection */ * Release the job and return... */ - ReleaseJob(jobid); + cupsdReleaseJob(jobid); - LogMessage(L_INFO, "Job %d was released by \'%s\'.", jobid, username); + cupsdLogMessage(L_INFO, "Job %d was released by \'%s\'.", jobid, username); con->response->request.status.status_code = IPP_OK; } @@ -6783,7 +6783,7 @@ release_job(client_t *con, /* I - Client connection */ */ static void -renew_subscription(client_t *con, /* I - Client connection */ +renew_subscription(cupsd_client_t *con, /* I - Client connection */ int sub_id) /* I - Subscription ID */ { } @@ -6794,7 +6794,7 @@ renew_subscription(client_t *con, /* I - Client connection */ */ static void -restart_job(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 */ @@ -6804,10 +6804,10 @@ restart_job(client_t *con, /* I - Client connection */ host[HTTP_MAX_URI], /* Host portion of URI */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - job_t *job; /* Job information */ + cupsd_job_t *job; /* Job information */ - LogMessage(L_DEBUG2, "restart_job(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "restart_job(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -6818,7 +6818,7 @@ restart_job(client_t *con, /* I - Client connection */ strncmp(con->uri, "/jobs/", 5) != 0 && strncmp(con->uri, "/printers/", 10) != 0) { - LogMessage(L_ERROR, "restart_job: restart request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "restart_job: restart request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -6836,7 +6836,7 @@ restart_job(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "restart_job: got a printer-uri attribute but no job-id!"); + cupsdLogMessage(L_ERROR, "restart_job: got a printer-uri attribute but no job-id!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -6857,7 +6857,7 @@ restart_job(client_t *con, /* I - Client connection */ * Not a valid URI! */ - LogMessage(L_ERROR, "restart_job: bad job-uri attribute \'%s\'!", + cupsdLogMessage(L_ERROR, "restart_job: bad job-uri attribute \'%s\'!", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -6870,13 +6870,13 @@ restart_job(client_t *con, /* I - Client connection */ * See if the job exists... */ - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { /* * Nope - return a "not found" error... */ - LogMessage(L_ERROR, "restart_job: job #%d doesn't exist!", jobid); + cupsdLogMessage(L_ERROR, "restart_job: job #%d doesn't exist!", jobid); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -6891,7 +6891,7 @@ restart_job(client_t *con, /* I - Client connection */ * Nope - return a "not possible" error... */ - LogMessage(L_ERROR, "restart_job: job #%d is not complete!", jobid); + cupsdLogMessage(L_ERROR, "restart_job: job #%d is not complete!", jobid); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } @@ -6906,7 +6906,7 @@ restart_job(client_t *con, /* I - Client connection */ * Nope - return a "not possible" error... */ - LogMessage(L_ERROR, "restart_job: job #%d cannot be restarted - no files!", jobid); + cupsdLogMessage(L_ERROR, "restart_job: job #%d cannot be restarted - no files!", jobid); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } @@ -6917,7 +6917,7 @@ restart_job(client_t *con, /* I - Client connection */ if (!validate_user(job, con, job->username, username, sizeof(username))) { - LogMessage(L_ERROR, "restart_job: \"%s\" not authorized to restart job id %d owned by \"%s\"!", + cupsdLogMessage(L_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; @@ -6927,9 +6927,9 @@ restart_job(client_t *con, /* I - Client connection */ * Restart the job and return... */ - RestartJob(jobid); + cupsdRestartJob(jobid); - LogMessage(L_INFO, "Job %d was restarted by \'%s\'.", jobid, username); + cupsdLogMessage(L_INFO, "Job %d was restarted by \'%s\'.", jobid, username); con->response->request.status.status_code = IPP_OK; } @@ -6940,7 +6940,7 @@ restart_job(client_t *con, /* I - Client connection */ */ static void -save_auth_info(client_t *con, /* I - Client connection */ +save_auth_info(cupsd_client_t *con, /* I - Client connection */ int job_id) /* I - Job ID */ { int i; /* Looping var */ @@ -6982,7 +6982,7 @@ save_auth_info(client_t *con, /* I - Client connection */ snprintf(filename, sizeof(filename), "%s/a%05d", RequestRoot, job_id); if ((fp = cupsFileOpen(filename, "w")) == NULL) { - LogMessage(L_ERROR, "Unable to save authentication info to \"%s\" - %s", + cupsdLogMessage(L_ERROR, "Unable to save authentication info to \"%s\" - %s", filename, strerror(errno)); return; } @@ -7024,13 +7024,13 @@ save_auth_info(client_t *con, /* I - Client connection */ */ static void -send_document(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 */ - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ char job_uri[HTTP_MAX_URI], /* Job URI */ method[HTTP_MAX_URI], @@ -7050,13 +7050,13 @@ send_document(client_t *con, /* I - Client connection */ mimetype[MIME_MAX_SUPER + MIME_MAX_TYPE + 2]; /* Textual name of mime type */ char filename[1024]; /* Job filename */ - 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 */ - LogMessage(L_DEBUG2, "send_document(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "send_document(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -7067,7 +7067,7 @@ send_document(client_t *con, /* I - Client connection */ strncmp(con->uri, "/jobs/", 6) != 0 && strncmp(con->uri, "/printers/", 10) != 0) { - LogMessage(L_ERROR, "send_document: print request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "send_document: print request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -7085,7 +7085,7 @@ send_document(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "send_document: got a printer-uri attribute but no job-id!"); + cupsdLogMessage(L_ERROR, "send_document: got a printer-uri attribute but no job-id!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -7106,7 +7106,7 @@ send_document(client_t *con, /* I - Client connection */ * Not a valid URI! */ - LogMessage(L_ERROR, "send_document: bad job-uri attribute \'%s\'!", + cupsdLogMessage(L_ERROR, "send_document: bad job-uri attribute \'%s\'!", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -7119,13 +7119,13 @@ send_document(client_t *con, /* I - Client connection */ * See if the job exists... */ - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { /* * Nope - return a "not found" error... */ - LogMessage(L_ERROR, "send_document: job #%d doesn't exist!", jobid); + cupsdLogMessage(L_ERROR, "send_document: job #%d doesn't exist!", jobid); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -7136,7 +7136,7 @@ send_document(client_t *con, /* I - Client connection */ if (!validate_user(job, con, job->username, username, sizeof(username))) { - LogMessage(L_ERROR, "send_document: \"%s\" not authorized to send document for job id %d owned by \"%s\"!", + cupsdLogMessage(L_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; @@ -7157,7 +7157,7 @@ send_document(client_t *con, /* I - Client connection */ #endif /* HAVE_LIBZ */ ) { - LogMessage(L_ERROR, "print_job: Unsupported compression \"%s\"!", + cupsdLogMessage(L_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, @@ -7177,7 +7177,7 @@ send_document(client_t *con, /* I - Client connection */ if (!con->filename) { - LogMessage(L_ERROR, "send_document: No file!?!"); + cupsdLogMessage(L_ERROR, "send_document: No file!?!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -7194,7 +7194,7 @@ send_document(client_t *con, /* I - Client connection */ if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super, type) != 2) { - LogMessage(L_ERROR, "send_document: could not scan type \'%s\'!", + cupsdLogMessage(L_ERROR, "send_document: could not scan type \'%s\'!", format->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -7217,7 +7217,7 @@ send_document(client_t *con, /* I - Client connection */ * Auto-type the file... */ - LogMessage(L_DEBUG, "send_document: auto-typing file..."); + cupsdLogMessage(L_DEBUG, "send_document: auto-typing file..."); filetype = mimeFileType(MimeDatabase, con->filename, &compression); @@ -7247,9 +7247,9 @@ send_document(client_t *con, /* I - Client connection */ if (filetype == NULL) { - LogMessage(L_ERROR, "send_document: Unsupported format \'%s/%s\'!", + cupsdLogMessage(L_ERROR, "send_document: Unsupported format \'%s/%s\'!", super, type); - LogMessage(L_INFO, "Hint: Do you have the raw file printing rules enabled?"); + cupsdLogMessage(L_INFO, "Hint: Do you have the raw file printing rules enabled?"); send_ipp_error(con, IPP_DOCUMENT_FORMAT); if (format) @@ -7259,7 +7259,7 @@ send_document(client_t *con, /* I - Client connection */ return; } - LogMessage(L_DEBUG, "send_document: request file type is %s/%s.", + cupsdLogMessage(L_DEBUG, "send_document: request file type is %s/%s.", filetype->super, filetype->type); /* @@ -7270,16 +7270,16 @@ send_document(client_t *con, /* I - Client connection */ return; if (job->dtype & CUPS_PRINTER_CLASS) - printer = FindClass(job->dest); + printer = cupsdFindClass(job->dest); else - printer = FindPrinter(job->dest); + printer = cupsdFindPrinter(job->dest); if (stat(con->filename, &fileinfo)) kbytes = 0; else kbytes = (fileinfo.st_size + 1023) / 1024; - UpdateQuota(printer, job->username, 0, kbytes); + cupsdUpdateQuota(printer, job->username, 0, kbytes); if ((attr = ippFindAttribute(job->attrs, "job-k-octets", IPP_TAG_INTEGER)) != NULL) attr->values[0].integer += kbytes; @@ -7288,9 +7288,9 @@ send_document(client_t *con, /* I - Client connection */ job->num_files); rename(con->filename, filename); - ClearString(&con->filename); + cupsdClearString(&con->filename); - LogMessage(L_INFO, "File of type %s/%s queued in job #%d by \'%s\'.", + cupsdLogMessage(L_INFO, "File of type %s/%s queued in job #%d by \'%s\'.", filetype->super, filetype->type, job->id, job->username); /* @@ -7313,12 +7313,12 @@ send_document(client_t *con, /* I - Client connection */ * Yes... */ - LogMessage(L_INFO, "Adding end banner page \"%s\" to job %d.", + cupsdLogMessage(L_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); - UpdateQuota(printer, job->username, 0, kbytes); + cupsdUpdateQuota(printer, job->username, 0, kbytes); } if (job->state->values[0].integer == IPP_JOB_STOPPED) @@ -7332,18 +7332,18 @@ send_document(client_t *con, /* I - Client connection */ job->state->values[0].integer = IPP_JOB_PENDING; } - SaveJob(job->id); + cupsdSaveJob(job->id); /* - * Start the job if possible... Since CheckJobs() can cancel a job if it + * 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; - CheckJobs(); + cupsdCheckJobs(); - job = FindJob(jobid); + job = cupsdFindJob(jobid); } else { @@ -7354,7 +7354,7 @@ send_document(client_t *con, /* I - Client connection */ { job->state->values[0].integer = IPP_JOB_HELD; job->hold_until = time(NULL) + 60; - SaveJob(job->id); + cupsdSaveJob(job->id); } } @@ -7372,7 +7372,7 @@ send_document(client_t *con, /* I - Client connection */ ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", job ? job->state->values[0].integer : IPP_JOB_CANCELLED); - add_job_state_reasons(con, job); + add_cupsd_job_state_reasons(con, job); con->response->request.status.status_code = IPP_OK; } @@ -7383,13 +7383,13 @@ send_document(client_t *con, /* I - Client connection */ */ static void -send_ipp_error(client_t *con, /* I - Client connection */ +send_ipp_error(cupsd_client_t *con, /* I - Client connection */ ipp_status_t status) /* I - IPP status code */ { - LogMessage(L_DEBUG2, "send_ipp_error(%p[%d], %x)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "send_ipp_error(%p[%d], %x)\n", con, con->http.fd, status); - LogMessage(L_DEBUG, "Sending error: %s", ippErrorString(status)); + cupsdLogMessage(L_DEBUG, "Sending error: %s", ippErrorString(status)); if (status == IPP_NOT_AUTHORIZED) { @@ -7398,7 +7398,7 @@ send_ipp_error(client_t *con, /* I - Client connection */ * the client will properly authenticate the request... */ - SendError(con, HTTP_UNAUTHORIZED); + cupsdSendError(con, HTTP_UNAUTHORIZED); ippDelete(con->response); con->response = NULL; @@ -7424,7 +7424,7 @@ send_ipp_error(client_t *con, /* I - Client connection */ */ static void -set_default(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) */ @@ -7438,10 +7438,10 @@ set_default(client_t *con, /* I - Client connection */ /* Resource portion of URI */ int port; /* Port portion of URI */ const char *name; /* Printer name */ - printer_t *printer; /* Printer */ + cupsd_printer_t *printer; /* Printer */ - LogMessage(L_DEBUG2, "set_default(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "set_default(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -7450,7 +7450,7 @@ set_default(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/admin/", 7) != 0) { - LogMessage(L_ERROR, "set_default: admin request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "set_default: admin request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -7462,13 +7462,13 @@ set_default(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((name = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "set_default: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "set_default: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -7479,7 +7479,7 @@ set_default(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) { - LogMessage(L_ERROR, "set_default: not authorized!"); + cupsdLogMessage(L_ERROR, "set_default: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -7490,10 +7490,10 @@ set_default(client_t *con, /* I - Client connection */ DefaultPrinter = printer; - SaveAllPrinters(); - SaveAllClasses(); + cupsdSaveAllPrinters(); + cupsdSaveAllClasses(); - LogMessage(L_INFO, "Default destination set to \'%s\' by \'%s\'.", name, + cupsdLogMessage(L_INFO, "Default destination set to \'%s\' by \'%s\'.", name, con->username); /* @@ -7509,14 +7509,14 @@ set_default(client_t *con, /* I - Client connection */ */ static void -set_job_attrs(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 */ - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ char method[HTTP_MAX_URI], /* Method portion of URI */ username[HTTP_MAX_URI], @@ -7528,7 +7528,7 @@ set_job_attrs(client_t *con, /* I - Client connection */ int port; /* Port portion of URI */ - LogMessage(L_DEBUG2, "set_job_attrs(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "set_job_attrs(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -7549,7 +7549,7 @@ set_job_attrs(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "job-id", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "set_job_attrs: got a printer-uri attribute but no job-id!"); + cupsdLogMessage(L_ERROR, "set_job_attrs: got a printer-uri attribute but no job-id!"); send_ipp_error(con, IPP_BAD_REQUEST); return; } @@ -7570,7 +7570,7 @@ set_job_attrs(client_t *con, /* I - Client connection */ * Not a valid URI! */ - LogMessage(L_ERROR, "set_job_attrs: bad job-uri attribute \'%s\'!\n", + cupsdLogMessage(L_ERROR, "set_job_attrs: bad job-uri attribute \'%s\'!\n", uri->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -7583,13 +7583,13 @@ set_job_attrs(client_t *con, /* I - Client connection */ * See if the job exists... */ - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { /* * Nope - return a "not found" error... */ - LogMessage(L_ERROR, "set_job_attrs: job #%d doesn't exist!", jobid); + cupsdLogMessage(L_ERROR, "set_job_attrs: job #%d doesn't exist!", jobid); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -7604,7 +7604,7 @@ set_job_attrs(client_t *con, /* I - Client connection */ * Return a "not-possible" error... */ - LogMessage(L_ERROR, "set_job_attrs: job #%d is finished and cannot be altered!", jobid); + cupsdLogMessage(L_ERROR, "set_job_attrs: job #%d is finished and cannot be altered!", jobid); send_ipp_error(con, IPP_NOT_POSSIBLE); return; } @@ -7615,7 +7615,7 @@ set_job_attrs(client_t *con, /* I - Client connection */ if (!validate_user(job, con, job->username, username, sizeof(username))) { - LogMessage(L_ERROR, "set_job_attrs: \"%s\" not authorized to alter job id %d owned by \"%s\"!", + cupsdLogMessage(L_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; @@ -7686,7 +7686,7 @@ set_job_attrs(client_t *con, /* I - Client connection */ return; } else if (con->response->request.status.status_code == IPP_OK) - SetJobPriority(jobid, attr->values[0].integer); + cupsdSetJobPriority(jobid, attr->values[0].integer); } else if (!strcmp(attr->name, "job-state")) { @@ -7735,12 +7735,12 @@ set_job_attrs(client_t *con, /* I - Client connection */ } else if (con->response->request.status.status_code == IPP_OK) { - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); if (JobHistory) { job->state->values[0].integer = attr->values[0].integer; - SaveJob(job->id); + cupsdSaveJob(job->id); } } break; @@ -7787,12 +7787,12 @@ set_job_attrs(client_t *con, /* I - Client connection */ if (strcmp(attr->name, "job-hold-until") == 0) { - SetJobHoldUntil(job->id, attr->values[0].string.text); + cupsdSetJobHoldUntil(job->id, attr->values[0].string.text); if (strcmp(attr->values[0].string.text, "no-hold") == 0) - ReleaseJob(job->id); + cupsdReleaseJob(job->id); else - HoldJob(job->id); + cupsdHoldJob(job->id); } } else if (attr->value_tag == IPP_TAG_DELETEATTR) @@ -7834,13 +7834,13 @@ set_job_attrs(client_t *con, /* I - Client connection */ * Save the job... */ - SaveJob(job->id); + cupsdSaveJob(job->id); /* * Start jobs if possible... */ - CheckJobs(); + cupsdCheckJobs(); } @@ -7849,7 +7849,7 @@ set_job_attrs(client_t *con, /* I - Client connection */ */ static void -start_printer(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) */ @@ -7863,10 +7863,10 @@ start_printer(client_t *con, /* I - Client connection */ /* Resource portion of URI */ int port; /* Port portion of URI */ const char *name; /* Printer name */ - printer_t *printer; /* Printer data */ + cupsd_printer_t *printer; /* Printer data */ - LogMessage(L_DEBUG2, "start_printer(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "start_printer(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -7875,7 +7875,7 @@ start_printer(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/admin/", 7) != 0) { - LogMessage(L_ERROR, "start_printer: admin request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "start_printer: admin request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -7887,13 +7887,13 @@ start_printer(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((name = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "start_printer: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "start_printer: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -7904,7 +7904,7 @@ start_printer(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) { - LogMessage(L_ERROR, "start_printer: not authorized!"); + cupsdLogMessage(L_ERROR, "start_printer: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -7915,15 +7915,15 @@ start_printer(client_t *con, /* I - Client connection */ printer->state_message[0] = '\0'; - StartPrinter(printer, 1); + cupsdStartPrinter(printer, 1); if (dtype & CUPS_PRINTER_CLASS) - LogMessage(L_INFO, "Class \'%s\' started by \'%s\'.", name, + cupsdLogMessage(L_INFO, "Class \'%s\' started by \'%s\'.", name, con->username); - LogMessage(L_INFO, "Printer \'%s\' started by \'%s\'.", name, + cupsdLogMessage(L_INFO, "Printer \'%s\' started by \'%s\'.", name, con->username); - CheckJobs(); + cupsdCheckJobs(); /* * Everything was ok, so return OK status... @@ -7938,7 +7938,7 @@ start_printer(client_t *con, /* I - Client connection */ */ static void -stop_printer(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) */ @@ -7952,11 +7952,11 @@ stop_printer(client_t *con, /* I - Client connection */ /* Resource portion of URI */ int port; /* Port portion of URI */ const char *name; /* Printer name */ - printer_t *printer; /* Printer data */ + cupsd_printer_t *printer; /* Printer data */ ipp_attribute_t *attr; /* printer-state-message attribute */ - LogMessage(L_DEBUG2, "stop_printer(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "stop_printer(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -7965,7 +7965,7 @@ stop_printer(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/admin/", 7) != 0) { - LogMessage(L_ERROR, "stop_printer: admin request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "stop_printer: admin request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -7977,13 +7977,13 @@ stop_printer(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if ((name = ValidateDest(host, resource, &dtype, &printer)) == NULL) + if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "stop_printer: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "stop_printer: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -7994,7 +7994,7 @@ stop_printer(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) { - LogMessage(L_ERROR, "stop_printer: not authorized!"); + cupsdLogMessage(L_ERROR, "stop_printer: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -8012,13 +8012,13 @@ stop_printer(client_t *con, /* I - Client connection */ sizeof(printer->state_message)); } - StopPrinter(printer, 1); + cupsdStopPrinter(printer, 1); if (dtype & CUPS_PRINTER_CLASS) - LogMessage(L_INFO, "Class \'%s\' stopped by \'%s\'.", name, + cupsdLogMessage(L_INFO, "Class \'%s\' stopped by \'%s\'.", name, con->username); else - LogMessage(L_INFO, "Printer \'%s\' stopped by \'%s\'.", name, + cupsdLogMessage(L_INFO, "Printer \'%s\' stopped by \'%s\'.", name, con->username); /* @@ -8034,7 +8034,7 @@ stop_printer(client_t *con, /* I - Client connection */ */ static int /* O - 0 if not allowed, 1 if allowed */ -user_allowed(printer_t *p, /* I - Printer or class */ +user_allowed(cupsd_printer_t *p, /* I - Printer or class */ const char *username) /* I - Username */ { int i; /* Looping var */ @@ -8074,7 +8074,7 @@ user_allowed(printer_t *p, /* I - Printer or class */ */ static void -validate_job(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 */ @@ -8093,10 +8093,10 @@ validate_job(client_t *con, /* I - Client connection */ /* Supertype of file */ type[MIME_MAX_TYPE]; /* Subtype of file */ - printer_t *printer; /* Printer */ + cupsd_printer_t *printer; /* Printer */ - LogMessage(L_DEBUG2, "validate_job(%p[%d], %s)\n", con, con->http.fd, + cupsdLogMessage(L_DEBUG2, "validate_job(%p[%d], %s)\n", con, con->http.fd, uri->values[0].string.text); /* @@ -8106,7 +8106,7 @@ validate_job(client_t *con, /* I - Client connection */ if (strncmp(con->uri, "/classes/", 9) != 0 && strncmp(con->uri, "/printers/", 10) != 0) { - LogMessage(L_ERROR, "validate_job: request on bad resource \'%s\'!", + cupsdLogMessage(L_ERROR, "validate_job: request on bad resource \'%s\'!", con->uri); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; @@ -8120,7 +8120,7 @@ validate_job(client_t *con, /* I - Client connection */ if ((attr = ippFindAttribute(con->request, "compression", IPP_TAG_KEYWORD)) != NULL && strcmp(attr->values[0].string.text, "none") == 0) { - LogMessage(L_ERROR, "validate_job: Unsupported compression attribute %s!", + cupsdLogMessage(L_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, @@ -8136,7 +8136,7 @@ validate_job(client_t *con, /* I - Client connection */ { if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super, type) != 2) { - LogMessage(L_ERROR, "validate_job: could not scan type \'%s\'!\n", + cupsdLogMessage(L_ERROR, "validate_job: could not scan type \'%s\'!\n", format->values[0].string.text); send_ipp_error(con, IPP_BAD_REQUEST); return; @@ -8146,9 +8146,9 @@ validate_job(client_t *con, /* I - Client connection */ strcmp(type, "octet-stream") != 0) && mimeType(MimeDatabase, super, type) == NULL) { - LogMessage(L_ERROR, "validate_job: Unsupported format \'%s\'!\n", + cupsdLogMessage(L_ERROR, "validate_job: Unsupported format \'%s\'!\n", format->values[0].string.text); - LogMessage(L_INFO, "Hint: Do you have the raw file printing rules enabled?"); + cupsdLogMessage(L_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); @@ -8162,13 +8162,13 @@ validate_job(client_t *con, /* I - Client connection */ httpSeparate(uri->values[0].string.text, method, username, host, &port, resource); - if (ValidateDest(host, resource, &dtype, &printer) == NULL) + if (cupsdValidateDest(host, resource, &dtype, &printer) == NULL) { /* * Bad URI... */ - LogMessage(L_ERROR, "validate_job: resource name \'%s\' no good!", resource); + cupsdLogMessage(L_ERROR, "validate_job: resource name \'%s\' no good!", resource); send_ipp_error(con, IPP_NOT_FOUND); return; } @@ -8179,7 +8179,7 @@ validate_job(client_t *con, /* I - Client connection */ if (!cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) { - LogMessage(L_ERROR, "validate_job: not authorized!"); + cupsdLogMessage(L_ERROR, "validate_job: not authorized!"); send_ipp_error(con, IPP_NOT_AUTHORIZED); return; } @@ -8223,17 +8223,17 @@ validate_name(const char *name) /* I - Name to check */ */ static int /* O - 1 if permitted, 0 otherwise */ -validate_user(job_t *job, /* I - Job */ - client_t *con, /* I - Client connection */ +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 */ - printer_t *printer; /* Printer for job */ + cupsd_printer_t *printer; /* Printer for job */ - LogMessage(L_DEBUG2, "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, userlen=%d)\n", + 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); @@ -8260,9 +8260,9 @@ validate_user(job_t *job, /* I - Job */ */ if (job->dtype & CUPS_PRINTER_CLASS) - printer = FindClass(job->dest); + printer = cupsdFindClass(job->dest); else - printer = FindPrinter(job->dest); + printer = cupsdFindPrinter(job->dest); if (printer) return (cupsdCheckPolicy(printer->op_policy_ptr, con, owner)); diff --git a/scheduler/job.c b/scheduler/job.c index 235b0c95a..5fd2e00a5 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -23,32 +23,32 @@ * * Contents: * - * AddJob() - Add a new job to the job queue... - * CancelJob() - Cancel the specified print job. - * CancelJobs() - Cancel all jobs for the given destination/user... - * CheckJobs() - Check the pending jobs and start any if the + * cupsdAddJob() - Add a new job to the job queue... + * 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. - * CleanJobs() - Clean out old jobs. - * FreeAllJobs() - Free all jobs from memory. - * FindJob() - Find the specified job. - * GetPrinterJobCount() - Get the number of pending, processing, + * 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. - * GetUserJobCount() - Get the number of pending, processing, + * cupsdGetUserJobCount() - Get the number of pending, processing, * or held jobs for a user. - * HoldJob() - Hold the specified job. - * LoadAllJobs() - Load all jobs from disk. - * MoveJob() - Move the specified job to a different + * cupsdHoldJob() - Hold the specified job. + * cupsdLoadAllJobs() - Load all jobs from disk. + * cupsdMoveJob() - Move the specified job to a different * destination. - * ReleaseJob() - Release the specified job. - * RestartJob() - Restart the specified job. - * SaveJob() - Save a job to disk. - * SetJobHoldUntil() - Set the hold time for a job... - * SetJobPriority() - Set the priority of a job, moving it up/down + * 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. - * StartJob() - Start a print job. - * StopAllJobs() - Stop all print jobs. - * StopJob() - Stop a print job. - * UpdateJob() - Read a status update from a job's filters. + * 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 @@ -86,22 +86,22 @@ static mime_filter_t gziptoany_filter = static int compare_active_jobs(void *first, void *second, void *data); static int compare_jobs(void *first, void *second, void *data); static int ipp_length(ipp_t *ipp); -static void set_time(job_t *job, const char *name); -static void set_hold_until(job_t *job, time_t holdtime); +static void set_time(cupsd_job_t *job, const char *name); +static void set_hold_until(cupsd_job_t *job, time_t holdtime); /* - * 'AddJob()' - Add a new job to the job queue... + * 'cupsdAddJob()' - Add a new job to the job queue... */ -job_t * /* O - New job record */ -AddJob(int priority, /* I - Job priority */ +cupsd_job_t * /* O - New job record */ +cupsdAddJob(int priority, /* I - Job priority */ const char *dest) /* I - Job destination */ { - job_t *job; /* New job record */ + cupsd_job_t *job; /* New job record */ - job = calloc(sizeof(job_t), 1); + job = calloc(sizeof(cupsd_job_t), 1); job->id = NextJobId ++; job->priority = priority; @@ -110,7 +110,7 @@ AddJob(int priority, /* I - Job priority */ job->print_pipes[0] = -1; job->print_pipes[1] = -1; - SetString(&job->dest, dest); + cupsdSetString(&job->dest, dest); /* * Add the new job to the "all jobs" and "active jobs" lists... @@ -124,25 +124,25 @@ AddJob(int priority, /* I - Job priority */ /* - * 'CancelJob()' - Cancel the specified print job. + * 'cupsdCancelJob()' - Cancel the specified print job. */ void -CancelJob(int id, /* I - Job to cancel */ +cupsdCancelJob(int id, /* I - Job to cancel */ int purge) /* I - Purge jobs? */ { int i; /* Looping var */ - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ char filename[1024]; /* Job filename */ - LogMessage(L_DEBUG, "CancelJob: id = %d", id); + cupsdLogMessage(L_DEBUG, "cupsdCancelJob: id = %d", id); /* * Find the job... */ - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; /* @@ -155,10 +155,10 @@ CancelJob(int id, /* I - Job to cancel */ * Stop any processes that are working on the current job... */ - DEBUG_puts("CancelJob: found job in list."); + DEBUG_puts("cupsdCancelJob: found job in list."); if (job->state->values[0].integer == IPP_JOB_PROCESSING) - StopJob(job->id, 0); + cupsdStopJob(job->id, 0); cupsArrayRemove(ActiveJobs, job); @@ -198,7 +198,7 @@ CancelJob(int id, /* I - Job to cancel */ * Save job state info... */ - SaveJob(job->id); + cupsdSaveJob(job->id); } else { @@ -229,8 +229,8 @@ CancelJob(int id, /* I - Job to cancel */ free(job->filetypes); } - ClearString(&job->username); - ClearString(&job->dest); + cupsdClearString(&job->username); + cupsdClearString(&job->dest); free(job); } @@ -238,20 +238,20 @@ CancelJob(int id, /* I - Job to cancel */ /* - * 'CancelJobs()' - Cancel all jobs for the given destination/user... + * 'cupsdCancelJobs()' - Cancel all jobs for the given destination/user... */ void -CancelJobs(const char *dest, /* I - Destination to cancel */ +cupsdCancelJobs(const char *dest, /* I - Destination to cancel */ const char *username, /* I - Username or NULL */ int purge) /* I - Purge jobs? */ { - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ - for (job = (job_t *)cupsArrayFirst(Jobs); + for (job = (cupsd_job_t *)cupsArrayFirst(Jobs); job; - job = (job_t *)cupsArrayNext(Jobs)) + job = (cupsd_job_t *)cupsArrayNext(Jobs)) if ((dest == NULL || !strcmp(job->dest, dest)) && (username == NULL || !strcmp(job->username, username))) { @@ -262,31 +262,31 @@ CancelJobs(const char *dest, /* I - Destination to cancel */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, purge ? "Job purged." : "Job canceled."); - CancelJob(job->id, purge); + cupsdCancelJob(job->id, purge); } - CheckJobs(); + cupsdCheckJobs(); } /* - * 'CheckJobs()' - Check the pending jobs and start any if the destination + * 'cupsdCheckJobs()' - Check the pending jobs and start any if the destination * is available. */ void -CheckJobs(void) +cupsdCheckJobs(void) { - job_t *job; /* Current job in queue */ - printer_t *printer, /* Printer destination */ + cupsd_job_t *job; /* Current job in queue */ + cupsd_printer_t *printer, /* Printer destination */ *pclass; /* Printer class destination */ - DEBUG_puts("CheckJobs()"); + DEBUG_puts("cupsdCheckJobs()"); - for (job = (job_t *)cupsArrayFirst(ActiveJobs); + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; - job = (job_t *)cupsArrayNext(ActiveJobs)) + job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) { /* * Start held jobs if they are ready... @@ -303,7 +303,7 @@ CheckJobs(void) if (job->state->values[0].integer == IPP_JOB_PENDING && !NeedReload) { - printer = FindDest(job->dest); + printer = cupsdFindDest(job->dest); while (printer && (printer->type & (CUPS_PRINTER_IMPLICIT | CUPS_PRINTER_CLASS))) @@ -317,7 +317,7 @@ CheckJobs(void) if (!(pclass->type & CUPS_PRINTER_REMOTE)) { if (pclass->state != IPP_PRINTER_STOPPED) - printer = FindAvailablePrinter(job->dest); + printer = cupsdFindAvailablePrinter(job->dest); else printer = NULL; } @@ -330,13 +330,13 @@ CheckJobs(void) * cancel the job... */ - LogMessage(L_WARN, "Printer/class %s has gone away; cancelling job %d!", + cupsdLogMessage(L_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."); - CancelJob(job->id, 1); + cupsdCancelJob(job->id, 1); } else if (printer) { @@ -348,7 +348,7 @@ CheckJobs(void) if (printer->state == IPP_PRINTER_IDLE || /* Printer is idle */ ((printer->type & CUPS_PRINTER_REMOTE) && /* Printer is remote */ !printer->job)) /* and not printing a job */ - StartJob(job->id, printer); + cupsdStartJob(job->id, printer); } } } @@ -356,41 +356,41 @@ CheckJobs(void) /* - * 'CleanJobs()' - Clean out old jobs. + * 'cupsdCleanJobs()' - Clean out old jobs. */ void -CleanJobs(void) +cupsdCleanJobs(void) { - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ if (!MaxJobs) return; - for (job = (job_t *)cupsArrayFirst(Jobs); + for (job = (cupsd_job_t *)cupsArrayFirst(Jobs); job && cupsArrayCount(Jobs) >= MaxJobs; - job = (job_t *)cupsArrayNext(Jobs)) + job = (cupsd_job_t *)cupsArrayNext(Jobs)) if (job->state->values[0].integer >= IPP_JOB_CANCELLED) - CancelJob(job->id, 1); + cupsdCancelJob(job->id, 1); } /* - * 'FinishJob()' - Finish a job. + * 'cupsdFinishJob()' - Finish a job. */ void -FinishJob(job_t *job) /* I - Job */ +cupsdFinishJob(cupsd_job_t *job) /* I - Job */ { - int job_history; /* Did CancelJob() keep the job? */ - printer_t *printer; /* Current printer */ + int job_history; /* Did cupsdCancelJob() keep the job? */ + cupsd_printer_t *printer; /* Current printer */ - LogMessage(L_DEBUG, "FinishJob: job %d, file %d is complete.", + cupsdLogMessage(L_DEBUG, "cupsdFinishJob: job %d, file %d is complete.", job->id, job->current_file - 1); - LogMessage(L_DEBUG2, "FinishJob: job->status is %d", job->status); + cupsdLogMessage(L_DEBUG2, "cupsdFinishJob: job->status is %d", job->status); if (job->status_buffer && job->current_file >= job->num_files) { @@ -398,12 +398,12 @@ FinishJob(job_t *job) /* I - Job */ * Close the pipe and clear the input bit. */ - LogMessage(L_DEBUG2, "FinishJob: Removing fd %d from InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdFinishJob: Removing fd %d from InputSet...", job->status_buffer->fd); FD_CLR(job->status_buffer->fd, InputSet); - LogMessage(L_DEBUG2, "FinishJob: Closing status input pipe %d...", + cupsdLogMessage(L_DEBUG2, "cupsdFinishJob: Closing status input pipe %d...", job->status_buffer->fd); cupsdStatBufDelete(job->status_buffer); @@ -428,9 +428,9 @@ FinishJob(job_t *job) /* I - Job */ * act... */ - StopJob(job->id, 0); + cupsdStopJob(job->id, 0); job->state->values[0].integer = IPP_JOB_PENDING; - SaveJob(job->id); + cupsdSaveJob(job->id); /* * If the job was queued to a class, try requeuing it... For @@ -438,7 +438,7 @@ FinishJob(job_t *job) /* I - Job */ */ if (job->dtype & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)) - CheckJobs(); + cupsdCheckJobs(); else if ((printer->type & CUPS_PRINTER_FAX) || !strcmp(printer->error_policy, "retry-job")) { @@ -455,14 +455,14 @@ FinishJob(job_t *job) /* I - Job */ * Too many tries... */ - LogMessage(L_ERROR, "Canceling job %d since it could not be sent after %d tries.", + cupsdLogMessage(L_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.", FaxRetryLimit); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); } else { @@ -474,7 +474,7 @@ FinishJob(job_t *job) /* I - Job */ } } else if (!strcmp(printer->error_policy, "abort-job")) - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); break; case CUPS_BACKEND_CANCEL : @@ -482,7 +482,7 @@ FinishJob(job_t *job) /* I - Job */ * Cancel the job... */ - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); break; case CUPS_BACKEND_HOLD : @@ -490,9 +490,9 @@ FinishJob(job_t *job) /* I - Job */ * Hold the job... */ - StopJob(job->id, 0); - SetJobHoldUntil(job->id, "indefinite"); - SaveJob(job->id); + cupsdStopJob(job->id, 0); + cupsdSetJobHoldUntil(job->id, "indefinite"); + cupsdSaveJob(job->id); break; case CUPS_BACKEND_STOP : @@ -500,17 +500,17 @@ FinishJob(job_t *job) /* I - Job */ * Stop the printer... */ - StopJob(job->id, 0); - SaveJob(job->id); - SetPrinterState(printer, IPP_PRINTER_STOPPED, 1); + cupsdStopJob(job->id, 0); + cupsdSaveJob(job->id); + cupsdSetPrinterState(printer, IPP_PRINTER_STOPPED, 1); break; case CUPS_BACKEND_AUTH_REQUIRED : - StopJob(job->id, 0); - SetJobHoldUntil(job->id, "indefinite"); + cupsdStopJob(job->id, 0); + cupsdSetJobHoldUntil(job->id, "indefinite"); /**** TODO ****/ /* cupsdSetJobStateReasons(job->id, "authentication-required"); */ - SaveJob(job->id); + cupsdSaveJob(job->id); cupsdAddEvent(CUPSD_EVENT_JOB_STOPPED, printer, job, "Authentication is required for job %d.", job->id); @@ -521,7 +521,7 @@ FinishJob(job_t *job) /* I - Job */ * Try printing another job... */ - CheckJobs(); + cupsdCheckJobs(); } else if (job->status > 0) { @@ -530,7 +530,7 @@ FinishJob(job_t *job) /* I - Job */ */ if (job->current_file < job->num_files) - StartJob(job->id, job->printer); + cupsdStartJob(job->id, job->printer); else { cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, @@ -539,15 +539,15 @@ FinishJob(job_t *job) /* I - Job */ job_history = JobHistory && !(job->dtype & CUPS_PRINTER_REMOTE); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); if (job_history) { job->state->values[0].integer = IPP_JOB_ABORTED; - SaveJob(job->id); + cupsdSaveJob(job->id); } - CheckJobs(); + cupsdCheckJobs(); } } else @@ -559,7 +559,7 @@ FinishJob(job_t *job) /* I - Job */ if (job->current_file < job->num_files) { FilterLevel -= job->cost; - StartJob(job->id, job->printer); + cupsdStartJob(job->id, job->printer); } else { @@ -568,37 +568,37 @@ FinishJob(job_t *job) /* I - Job */ job_history = JobHistory && !(job->dtype & CUPS_PRINTER_REMOTE); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); if (job_history) { job->state->values[0].integer = IPP_JOB_COMPLETED; - SaveJob(job->id); + cupsdSaveJob(job->id); } - CheckJobs(); + cupsdCheckJobs(); } } } /* - * 'FreeAllJobs()' - Free all jobs from memory. + * 'cupsdFreeAllJobs()' - Free all jobs from memory. */ void -FreeAllJobs(void) +cupsdFreeAllJobs(void) { - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ - HoldSignals(); + cupsdHoldSignals(); - StopAllJobs(); + cupsdStopAllJobs(); - for (job = (job_t *)cupsArrayFirst(Jobs); + for (job = (cupsd_job_t *)cupsArrayFirst(Jobs); job; - job = (job_t *)cupsArrayNext(Jobs)) + job = (cupsd_job_t *)cupsArrayNext(Jobs)) { cupsArrayRemove(Jobs, job); cupsArrayRemove(ActiveJobs, job); @@ -614,41 +614,41 @@ FreeAllJobs(void) free(job); } - ReleaseSignals(); + cupsdReleaseSignals(); } /* - * 'FindJob()' - Find the specified job. + * 'cupsdFindJob()' - Find the specified job. */ -job_t * /* O - Job data */ -FindJob(int id) /* I - Job ID */ +cupsd_job_t * /* O - Job data */ +cupsdFindJob(int id) /* I - Job ID */ { - job_t key; /* Search key */ + cupsd_job_t key; /* Search key */ key.id = id; - return ((job_t *)cupsArrayFind(Jobs, &key)); + return ((cupsd_job_t *)cupsArrayFind(Jobs, &key)); } /* - * 'GetPrinterJobCount()' - Get the number of pending, processing, + * 'cupsdGetPrinterJobCount()' - Get the number of pending, processing, * or held jobs in a printer or class. */ int /* O - Job count */ -GetPrinterJobCount(const char *dest) /* I - Printer or class name */ +cupsdGetPrinterJobCount(const char *dest) /* I - Printer or class name */ { int count; /* Job count */ - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ - for (job = (job_t *)cupsArrayFirst(ActiveJobs), count = 0; + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs), count = 0; job; - job = (job_t *)cupsArrayNext(ActiveJobs)) + job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (!strcasecmp(job->dest, dest)) count ++; @@ -657,20 +657,20 @@ GetPrinterJobCount(const char *dest) /* I - Printer or class name */ /* - * 'GetUserJobCount()' - Get the number of pending, processing, + * 'cupsdGetUserJobCount()' - Get the number of pending, processing, * or held jobs for a user. */ int /* O - Job count */ -GetUserJobCount(const char *username) /* I - Username */ +cupsdGetUserJobCount(const char *username) /* I - Username */ { int count; /* Job count */ - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ - for (job = (job_t *)cupsArrayFirst(ActiveJobs), count = 0; + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs), count = 0; job; - job = (job_t *)cupsArrayNext(ActiveJobs)) + job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (!strcasecmp(job->username, username)) count ++; @@ -679,45 +679,45 @@ GetUserJobCount(const char *username) /* I - Username */ /* - * 'HoldJob()' - Hold the specified job. + * 'cupsdHoldJob()' - Hold the specified job. */ void -HoldJob(int id) /* I - Job ID */ +cupsdHoldJob(int id) /* I - Job ID */ { - job_t *job; /* Job data */ + cupsd_job_t *job; /* Job data */ - LogMessage(L_DEBUG, "HoldJob: id = %d", id); + cupsdLogMessage(L_DEBUG, "cupsdHoldJob: id = %d", id); - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; if (job->state->values[0].integer == IPP_JOB_PROCESSING) - StopJob(id, 0); + cupsdStopJob(id, 0); - DEBUG_puts("HoldJob: setting state to held..."); + DEBUG_puts("cupsdHoldJob: setting state to held..."); job->state->values[0].integer = IPP_JOB_HELD; - SaveJob(id); + cupsdSaveJob(id); - CheckJobs(); + cupsdCheckJobs(); } /* - * 'LoadAllJobs()' - Load all jobs from disk. + * 'cupsdLoadAllJobs()' - Load all jobs from disk. */ void -LoadAllJobs(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 */ - job_t *job; /* New job */ + cupsd_job_t *job; /* New job */ int jobid, /* Current job ID */ fileid; /* Current file ID */ ipp_attribute_t *attr; /* Job attribute */ @@ -726,7 +726,7 @@ LoadAllJobs(void) host[HTTP_MAX_URI], /* Host portion of URI */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ - printer_t *p; /* Printer or class */ + cupsd_printer_t *p; /* Printer or class */ const char *dest; /* Destination */ mime_type_t **filetypes; /* New filetypes array */ int *compressions; /* New compressions array */ @@ -746,11 +746,11 @@ LoadAllJobs(void) * Then open the requests directory... */ - LogMessage(L_DEBUG, "LoadAllJobs: Scanning %s...", RequestRoot); + cupsdLogMessage(L_DEBUG, "cupsdLoadAllJobs: Scanning %s...", RequestRoot); if ((dir = cupsDirOpen(RequestRoot)) == NULL) { - LogMessage(L_ERROR, "LoadAllJobs: Unable to open spool directory %s: %s", + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Unable to open spool directory %s: %s", RequestRoot, strerror(errno)); return; } @@ -766,9 +766,9 @@ LoadAllJobs(void) * Allocate memory for the job... */ - if ((job = calloc(sizeof(job_t), 1)) == NULL) + if ((job = calloc(sizeof(cupsd_job_t), 1)) == NULL) { - LogMessage(L_ERROR, "LoadAllJobs: Ran out of memory for jobs!"); + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Ran out of memory for jobs!"); cupsDirClose(dir); return; } @@ -776,7 +776,7 @@ LoadAllJobs(void) if ((job->attrs = ippNew()) == NULL) { free(job); - LogMessage(L_ERROR, "LoadAllJobs: Ran out of memory for job attributes!"); + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Ran out of memory for job attributes!"); cupsDirClose(dir); return; } @@ -791,7 +791,7 @@ LoadAllJobs(void) job->print_pipes[0] = -1; job->print_pipes[1] = -1; - LogMessage(L_DEBUG, "LoadAllJobs: Loading attributes for job %d...\n", + cupsdLogMessage(L_DEBUG, "cupsdLoadAllJobs: Loading attributes for job %d...\n", job->id); if (job->id >= NextJobId) @@ -804,7 +804,7 @@ LoadAllJobs(void) snprintf(filename, sizeof(filename), "%s/%s", RequestRoot, dent->filename); if ((fd = open(filename, O_RDONLY)) < 0) { - LogMessage(L_ERROR, "LoadAllJobs: Unable to open job control file \"%s\" - %s!", + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Unable to open job control file \"%s\" - %s!", filename, strerror(errno)); ippDelete(job->attrs); free(job); @@ -815,7 +815,7 @@ LoadAllJobs(void) { if (ippReadFile(fd, job->attrs) != IPP_DATA) { - LogMessage(L_ERROR, "LoadAllJobs: Unable to read job control file \"%s\"!", + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Unable to read job control file \"%s\"!", filename); close(fd); ippDelete(job->attrs); @@ -829,7 +829,7 @@ LoadAllJobs(void) if ((job->state = ippFindAttribute(job->attrs, "job-state", IPP_TAG_ENUM)) == NULL) { - LogMessage(L_ERROR, "LoadAllJobs: Missing or bad job-state attribute in control file \"%s\"!", + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Missing or bad job-state attribute in control file \"%s\"!", filename); ippDelete(job->attrs); free(job); @@ -839,7 +839,7 @@ LoadAllJobs(void) if ((attr = ippFindAttribute(job->attrs, "job-printer-uri", IPP_TAG_URI)) == NULL) { - LogMessage(L_ERROR, "LoadAllJobs: No job-printer-uri attribute in control file \"%s\"!", + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: No job-printer-uri attribute in control file \"%s\"!", filename); ippDelete(job->attrs); free(job); @@ -850,7 +850,7 @@ LoadAllJobs(void) httpSeparate(attr->values[0].string.text, method, username, host, &port, resource); - if ((dest = ValidateDest(host, resource, &(job->dtype), NULL)) == NULL && + if ((dest = cupsdValidateDest(host, resource, &(job->dtype), NULL)) == NULL && job->state != NULL && job->state->values[0].integer <= IPP_JOB_PROCESSING) { @@ -860,30 +860,30 @@ LoadAllJobs(void) if (strncmp(resource, "/classes/", 9) == 0) { - p = AddClass(resource + 9); - SetString(&p->make_model, "Remote Class on unknown"); + p = cupsdAddClass(resource + 9); + cupsdSetString(&p->make_model, "Remote Class on unknown"); } else { - p = AddPrinter(resource + 10); - SetString(&p->make_model, "Remote Printer on unknown"); + p = cupsdAddPrinter(resource + 10); + cupsdSetString(&p->make_model, "Remote Printer on unknown"); } p->state = IPP_PRINTER_STOPPED; p->type |= CUPS_PRINTER_REMOTE; p->browse_time = 2147483647; - SetString(&p->location, "Location Unknown"); - SetString(&p->info, "No Information Available"); + cupsdSetString(&p->location, "Location Unknown"); + cupsdSetString(&p->info, "No Information Available"); p->hostname[0] = '\0'; - SetPrinterAttrs(p); + cupsdSetPrinterAttrs(p); dest = p->name; } if (dest == NULL) { - LogMessage(L_ERROR, "LoadAllJobs: Unable to queue job for destination \"%s\"!", + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Unable to queue job for destination \"%s\"!", attr->values[0].string.text); ippDelete(job->attrs); free(job); @@ -891,15 +891,15 @@ LoadAllJobs(void) continue; } - SetString(&job->dest, dest); + cupsdSetString(&job->dest, dest); job->sheets = ippFindAttribute(job->attrs, "job-media-sheets-completed", IPP_TAG_INTEGER); - job->job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME); + job->cupsd_job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME); if ((attr = ippFindAttribute(job->attrs, "job-priority", IPP_TAG_INTEGER)) == NULL) { - LogMessage(L_ERROR, "LoadAllJobs: Missing or bad job-priority attribute in control file \"%s\"!", + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Missing or bad job-priority attribute in control file \"%s\"!", filename); ippDelete(job->attrs); free(job); @@ -910,14 +910,14 @@ LoadAllJobs(void) if ((attr = ippFindAttribute(job->attrs, "job-originating-user-name", IPP_TAG_NAME)) == NULL) { - LogMessage(L_ERROR, "LoadAllJobs: Missing or bad job-originating-user-name attribute in control file \"%s\"!", + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Missing or bad job-originating-user-name attribute in control file \"%s\"!", filename); ippDelete(job->attrs); free(job); unlink(filename); continue; } - SetString(&job->username, attr->values[0].string.text); + cupsdSetString(&job->username, attr->values[0].string.text); /* * Insert the job into the array, sorting by job priority and ID... @@ -939,7 +939,7 @@ LoadAllJobs(void) if (attr == NULL) job->state->values[0].integer = IPP_JOB_PENDING; else - SetJobHoldUntil(job->id, attr->values[0].string.text); + cupsdSetJobHoldUntil(job->id, attr->values[0].string.text); } else if (job->state->values[0].integer == IPP_JOB_PROCESSING) job->state->values[0].integer = IPP_JOB_PENDING; @@ -962,14 +962,14 @@ LoadAllJobs(void) jobid = atoi(dent->filename + 1); fileid = atoi(strchr(dent->filename, '-') + 1); - LogMessage(L_DEBUG, "LoadAllJobs: Auto-typing document file %s...", + cupsdLogMessage(L_DEBUG, "cupsdLoadAllJobs: Auto-typing document file %s...", dent->filename); snprintf(filename, sizeof(filename), "%s/%s", RequestRoot, dent->filename); - if ((job = FindJob(jobid)) == NULL) + if ((job = cupsdFindJob(jobid)) == NULL) { - LogMessage(L_ERROR, "LoadAllJobs: Orphaned print file \"%s\"!", + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Orphaned print file \"%s\"!", filename); unlink(filename); continue; @@ -992,7 +992,7 @@ LoadAllJobs(void) if (compressions == NULL || filetypes == NULL) { - LogMessage(L_ERROR, "LoadAllJobs: Ran out of memory for job file types!"); + cupsdLogMessage(L_ERROR, "cupsdLoadAllJobs: Ran out of memory for job file types!"); continue; } @@ -1015,31 +1015,31 @@ LoadAllJobs(void) * Clean out old jobs as needed... */ - CleanJobs(); + cupsdCleanJobs(); } /* - * 'MoveJob()' - Move the specified job to a different destination. + * 'cupsdMoveJob()' - Move the specified job to a different destination. */ void -MoveJob(int id, /* I - Job ID */ +cupsdMoveJob(int id, /* I - Job ID */ const char *dest) /* I - Destination */ { - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ ipp_attribute_t *attr; /* job-printer-uri attribute */ - printer_t *p; /* Destination printer or class */ + cupsd_printer_t *p; /* Destination printer or class */ /* * Find the printer and job... */ - if ((p = FindDest(dest)) == NULL) + if ((p = cupsdFindDest(dest)) == NULL) return; - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; /* @@ -1053,86 +1053,86 @@ MoveJob(int id, /* I - Job ID */ * Change the destination information... */ - SetString(&job->dest, dest); + cupsdSetString(&job->dest, dest); job->dtype = p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT); if ((attr = ippFindAttribute(job->attrs, "job-printer-uri", IPP_TAG_URI)) != NULL) - SetString(&(attr->values[0].string.text), p->uri); + cupsdSetString(&(attr->values[0].string.text), p->uri); - SaveJob(job->id); + cupsdSaveJob(job->id); } /* - * 'ReleaseJob()' - Release the specified job. + * 'cupsdReleaseJob()' - Release the specified job. */ void -ReleaseJob(int id) /* I - Job ID */ +cupsdReleaseJob(int id) /* I - Job ID */ { - job_t *job; /* Job data */ + cupsd_job_t *job; /* Job data */ - LogMessage(L_DEBUG, "ReleaseJob: id = %d", id); + cupsdLogMessage(L_DEBUG, "cupsdReleaseJob: id = %d", id); - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; if (job->state->values[0].integer == IPP_JOB_HELD) { - DEBUG_puts("ReleaseJob: setting state to pending..."); + DEBUG_puts("cupsdReleaseJob: setting state to pending..."); job->state->values[0].integer = IPP_JOB_PENDING; - SaveJob(id); - CheckJobs(); + cupsdSaveJob(id); + cupsdCheckJobs(); } } /* - * 'RestartJob()' - Restart the specified job. + * 'cupsdRestartJob()' - Restart the specified job. */ void -RestartJob(int id) /* I - Job ID */ +cupsdRestartJob(int id) /* I - Job ID */ { - job_t *job; /* Job data */ + cupsd_job_t *job; /* Job data */ - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; if (job->state->values[0].integer == IPP_JOB_STOPPED || JobFiles) { job->tries = 0; job->state->values[0].integer = IPP_JOB_PENDING; - SaveJob(id); - CheckJobs(); + cupsdSaveJob(id); + cupsdCheckJobs(); } } /* - * 'SaveJob()' - Save a job to disk. + * 'cupsdSaveJob()' - Save a job to disk. */ void -SaveJob(int id) /* I - Job ID */ +cupsdSaveJob(int id) /* I - Job ID */ { - job_t *job; /* Pointer to job */ + cupsd_job_t *job; /* Pointer to job */ char filename[1024]; /* Job control filename */ int fd; /* File descriptor */ - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; snprintf(filename, sizeof(filename), "%s/c%05d", RequestRoot, id); if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) { - LogMessage(L_ERROR, "SaveJob: Unable to create job control file \"%s\" - %s.", + cupsdLogMessage(L_ERROR, "cupsdSaveJob: Unable to create job control file \"%s\" - %s.", filename, strerror(errno)); return; } @@ -1142,21 +1142,21 @@ SaveJob(int id) /* I - Job ID */ ippWriteFile(fd, job->attrs); - LogMessage(L_DEBUG2, "SaveJob: Closing file %d...", fd); + cupsdLogMessage(L_DEBUG2, "cupsdSaveJob: Closing file %d...", fd); close(fd); } /* - * 'SetJobHoldUntil()' - Set the hold time for a job... + * 'cupsdSetJobHoldUntil()' - Set the hold time for a job... */ void -SetJobHoldUntil(int id, /* I - Job ID */ +cupsdSetJobHoldUntil(int id, /* I - Job ID */ const char *when) /* I - When to resume */ { - 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 */ @@ -1164,9 +1164,9 @@ SetJobHoldUntil(int id, /* I - Job ID */ int second; /* Hold second */ - LogMessage(L_DEBUG, "SetJobHoldUntil(%d, \"%s\")", id, when); + cupsdLogMessage(L_DEBUG, "cupsdSetJobHoldUntil(%d, \"%s\")", id, when); - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; second = 0; @@ -1281,20 +1281,20 @@ SetJobHoldUntil(int id, /* I - Job ID */ job->hold_until += 24 * 60 * 60 * 60; } - LogMessage(L_DEBUG, "SetJobHoldUntil: hold_until = %d", (int)job->hold_until); + cupsdLogMessage(L_DEBUG, "cupsdSetJobHoldUntil: hold_until = %d", (int)job->hold_until); } /* - * 'SetJobPriority()' - Set the priority of a job, moving it up/down in the + * 'cupsdSetJobPriority()' - Set the priority of a job, moving it up/down in the * list as needed. */ void -SetJobPriority(int id, /* I - Job ID */ +cupsdSetJobPriority(int id, /* I - Job ID */ int priority) /* I - New priority (0 to 100) */ { - job_t *job; /* Job to change */ + cupsd_job_t *job; /* Job to change */ ipp_attribute_t *attr; /* Job attribute */ @@ -1302,7 +1302,7 @@ SetJobPriority(int id, /* I - Job ID */ * Find the job... */ - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; /* @@ -1328,19 +1328,19 @@ SetJobPriority(int id, /* I - Job ID */ cupsArrayAdd(ActiveJobs, job); - SaveJob(job->id); + cupsdSaveJob(job->id); } /* - * 'StartJob()' - Start a print job. + * 'cupsdStartJob()' - Start a print job. */ void -StartJob(int id, /* I - Job ID */ - printer_t *printer) /* I - Printer to print job */ +cupsdStartJob(int id, /* I - Job ID */ + cupsd_printer_t *printer) /* I - Printer to print job */ { - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ int i; /* Looping var */ int slot; /* Pipe slot */ int num_filters; /* Number of filters for job */ @@ -1375,22 +1375,22 @@ StartJob(int id, /* I - Job ID */ static int optlength = 0; /* Length of option buffer */ - LogMessage(L_DEBUG, "StartJob(%d, %p)", id, printer); + cupsdLogMessage(L_DEBUG, "cupsdStartJob(%d, %p)", id, printer); - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; - LogMessage(L_DEBUG, "StartJob() id = %d, file = %d/%d", id, + cupsdLogMessage(L_DEBUG, "cupsdStartJob() id = %d, file = %d/%d", id, job->current_file, job->num_files); if (job->num_files == 0) { - LogMessage(L_ERROR, "Job ID %d has no files! Cancelling it!", id); + cupsdLogMessage(L_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."); - CancelJob(id, 0); + cupsdCancelJob(id, 0); return; } @@ -1409,7 +1409,7 @@ StartJob(int id, /* I - Job ID */ * filtering... */ - LogMessage(L_DEBUG, "StartJob: Sending job to queue tagged as raw..."); + cupsdLogMessage(L_DEBUG, "cupsdStartJob: Sending job to queue tagged as raw..."); filters = NULL; } @@ -1424,12 +1424,12 @@ StartJob(int id, /* I - Job ID */ if (num_filters == 0) { - LogMessage(L_ERROR, "Unable to convert file %d to printable format for job %d!", + cupsdLogMessage(L_ERROR, "Unable to convert file %d to printable format for job %d!", job->current_file, job->id); - LogMessage(L_INFO, "Hint: Do you have ESP Ghostscript installed?"); + cupsdLogMessage(L_INFO, "Hint: Do you have ESP Ghostscript installed?"); if (LogLevel < L_DEBUG) - LogMessage(L_INFO, "Hint: Try setting the LogLevel to \"debug\"."); + cupsdLogMessage(L_INFO, "Hint: Try setting the LogLevel to \"debug\"."); job->current_file ++; @@ -1438,7 +1438,7 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because it has no files that can be printed."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); } return; @@ -1489,9 +1489,9 @@ StartJob(int id, /* I - Job ID */ if (filters != NULL) free(filters); - LogMessage(L_INFO, "Holding job %d because filter limit has been reached.", + cupsdLogMessage(L_INFO, "Holding job %d because filter limit has been reached.", id); - LogMessage(L_DEBUG, "StartJob: id = %d, file = %d, " + cupsdLogMessage(L_DEBUG, "cupsdStartJob: id = %d, file = %d, " "cost = %d, level = %d, limit = %d", id, job->current_file, job->cost, FilterLevel, FilterLimit); @@ -1520,7 +1520,7 @@ StartJob(int id, /* I - Job ID */ if (temp_filters == NULL) { - LogMessage(L_ERROR, "Unable to add decompression filter - %s", + cupsdLogMessage(L_ERROR, "Unable to add decompression filter - %s", strerror(errno)); if (filters != NULL) @@ -1533,7 +1533,7 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the print file could not be decompressed."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); } return; @@ -1565,7 +1565,7 @@ StartJob(int id, /* I - Job ID */ if (temp_filters == NULL) { - LogMessage(L_ERROR, "Unable to add port monitor - %s", + cupsdLogMessage(L_ERROR, "Unable to add port monitor - %s", strerror(errno)); if (filters != NULL) @@ -1578,7 +1578,7 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the port monitor could not be added."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); } return; @@ -1599,7 +1599,7 @@ StartJob(int id, /* I - Job ID */ job->status = 0; job->printer = printer; printer->job = job; - SetPrinterState(printer, IPP_PRINTER_PROCESSING, 0); + cupsdSetPrinterState(printer, IPP_PRINTER_PROCESSING, 0); if (job->current_file == 0) { @@ -1611,36 +1611,36 @@ StartJob(int id, /* I - Job ID */ * Determine if we are printing a banner page or not... */ - if (job->job_sheets == NULL) + if (job->cupsd_job_sheets == NULL) { - LogMessage(L_DEBUG, "No job-sheets attribute."); - if ((job->job_sheets = + cupsdLogMessage(L_DEBUG, "No job-sheets attribute."); + if ((job->cupsd_job_sheets = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_ZERO)) != NULL) - LogMessage(L_DEBUG, "... but someone added one without setting job_sheets!"); + cupsdLogMessage(L_DEBUG, "... but someone added one without setting cupsd_job_sheets!"); } - else if (job->job_sheets->num_values == 1) - LogMessage(L_DEBUG, "job-sheets=%s", - job->job_sheets->values[0].string.text); + else if (job->cupsd_job_sheets->num_values == 1) + cupsdLogMessage(L_DEBUG, "job-sheets=%s", + job->cupsd_job_sheets->values[0].string.text); else - LogMessage(L_DEBUG, "job-sheets=%s,%s", - job->job_sheets->values[0].string.text, - job->job_sheets->values[1].string.text); + cupsdLogMessage(L_DEBUG, "job-sheets=%s,%s", + job->cupsd_job_sheets->values[0].string.text, + job->cupsd_job_sheets->values[1].string.text); if (printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) banner_page = 0; - else if (job->job_sheets == NULL) + else if (job->cupsd_job_sheets == NULL) banner_page = 0; - else if (strcasecmp(job->job_sheets->values[0].string.text, "none") != 0 && + else if (strcasecmp(job->cupsd_job_sheets->values[0].string.text, "none") != 0 && job->current_file == 0) banner_page = 1; - else if (job->job_sheets->num_values > 1 && - strcasecmp(job->job_sheets->values[1].string.text, "none") != 0 && + else if (job->cupsd_job_sheets->num_values > 1 && + strcasecmp(job->cupsd_job_sheets->values[1].string.text, "none") != 0 && job->current_file == (job->num_files - 1)) banner_page = 1; else banner_page = 0; - LogMessage(L_DEBUG, "banner_page = %d", banner_page); + cupsdLogMessage(L_DEBUG, "banner_page = %d", banner_page); /* * Building the options string is harder than it needs to be, but @@ -1661,7 +1661,7 @@ StartJob(int id, /* I - Job ID */ if (optptr == NULL) { - LogMessage(L_CRIT, "StartJob: Unable to allocate %d bytes for option buffer for job %d!", + cupsdLogMessage(L_CRIT, "cupsdStartJob: Unable to allocate %d bytes for option buffer for job %d!", i, id); if (filters != NULL) @@ -1672,7 +1672,7 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the server ran out of memory."); - CancelJob(id, 0); + cupsdCancelJob(id, 0); return; } @@ -1851,7 +1851,7 @@ StartJob(int id, /* I - Job ID */ argv[6] = filename; argv[7] = NULL; - LogMessage(L_DEBUG, "StartJob: argv = \"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"", + 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]); /* @@ -1953,9 +1953,9 @@ StartJob(int id, /* I - Job ID */ for (i = 0; i < envc; i ++) if (strncmp(envp[i], "DEVICE_URI=", 11)) - LogMessage(L_DEBUG, "StartJob: envp[%d]=\"%s\"", i, envp[i]); + cupsdLogMessage(L_DEBUG, "cupsdStartJob: envp[%d]=\"%s\"", i, envp[i]); else - LogMessage(L_DEBUG, "StartJob: envp[%d]=\"DEVICE_URI=%s\"", i, sani_uri); + cupsdLogMessage(L_DEBUG, "cupsdStartJob: envp[%d]=\"DEVICE_URI=%s\"", i, sani_uri); job->current_file ++; @@ -1965,12 +1965,12 @@ StartJob(int id, /* I - Job ID */ if (cupsdOpenPipe(statusfds)) { - LogMessage(L_ERROR, "Unable to create job status pipes - %s.", + cupsdLogMessage(L_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)); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); if (filters != NULL) free(filters); @@ -1978,11 +1978,11 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the server could not create the job status pipes."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); return; } - LogMessage(L_DEBUG, "StartJob: statusfds = [ %d %d ]", + cupsdLogMessage(L_DEBUG, "cupsdStartJob: statusfds = [ %d %d ]", statusfds[0], statusfds[1]); #ifdef FD_CLOEXEC @@ -2000,23 +2000,23 @@ StartJob(int id, /* I - Job ID */ if (filterfds[1][0] < 0) { - LogMessage(L_ERROR, "Unable to open \"/dev/null\" - %s.", strerror(errno)); + cupsdLogMessage(L_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)); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); if (filters != NULL) free(filters); cupsdClosePipe(statusfds); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); return; } fcntl(filterfds[1][0], F_SETFD, fcntl(filterfds[1][0], F_GETFD) | FD_CLOEXEC); - LogMessage(L_DEBUG, "StartJob: filterfds[%d] = [ %d %d ]", 1, filterfds[1][0], + cupsdLogMessage(L_DEBUG, "cupsdStartJob: filterfds[%d] = [ %d %d ]", 1, filterfds[1][0], filterfds[1][1]); for (i = 0, slot = 0; i < num_filters; i ++) @@ -2031,11 +2031,11 @@ StartJob(int id, /* I - Job ID */ { if (cupsdOpenPipe(filterfds[slot])) { - LogMessage(L_ERROR, "Unable to create job filter pipes - %s.", + cupsdLogMessage(L_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)); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); if (filters != NULL) free(filters); @@ -2046,7 +2046,7 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the server could not create the filter pipes."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); return; } } @@ -2058,11 +2058,11 @@ StartJob(int id, /* I - Job ID */ { if (cupsdOpenPipe(job->print_pipes)) { - LogMessage(L_ERROR, "Unable to create job backend pipes - %s.", + cupsdLogMessage(L_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)); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); if (filters != NULL) free(filters); @@ -2073,7 +2073,7 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the server could not create the backend pipes."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); return; } } @@ -2094,13 +2094,13 @@ StartJob(int id, /* I - Job ID */ if (job->print_pipes[1] < 0) { - LogMessage(L_ERROR, "Unable to open output file \"%s\" - %s.", + cupsdLogMessage(L_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)); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); if (filters != NULL) free(filters); @@ -2111,7 +2111,7 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the server could not open the output file."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); return; } @@ -2119,7 +2119,7 @@ StartJob(int id, /* I - Job ID */ fcntl(job->print_pipes[1], F_GETFD) | FD_CLOEXEC); } - LogMessage(L_DEBUG2, "StartJob: print_pipes = [ %d %d ]", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: print_pipes = [ %d %d ]", job->print_pipes[0], job->print_pipes[1]); } @@ -2127,42 +2127,42 @@ StartJob(int id, /* I - Job ID */ filterfds[slot][1] = job->print_pipes[1]; } - LogMessage(L_DEBUG, "StartJob: filter = \"%s\"", command); - LogMessage(L_DEBUG, "StartJob: filterfds[%d] = [ %d %d ]", + cupsdLogMessage(L_DEBUG, "cupsdStartJob: filter = \"%s\"", command); + cupsdLogMessage(L_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); - LogMessage(L_DEBUG2, "StartJob: Closing filter pipes for slot %d [ %d %d ]...", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing filter pipes for slot %d [ %d %d ]...", !slot, filterfds[!slot][0], filterfds[!slot][1]); cupsdClosePipe(filterfds[!slot]); if (pid == 0) { - LogMessage(L_ERROR, "Unable to start filter \"%s\" - %s.", + cupsdLogMessage(L_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)); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); if (filters != NULL) free(filters); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the server could not execute a filter."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); return; } - LogMessage(L_INFO, "Started filter %s (PID %d) for job %d.", + cupsdLogMessage(L_INFO, "Started filter %s (PID %d) for job %d.", command, pid, job->id); argv[6] = NULL; @@ -2190,11 +2190,11 @@ StartJob(int id, /* I - Job ID */ if (filterfds[slot][1] < 0) { - LogMessage(L_ERROR, "Unable to open \"/dev/null\" - %s.", strerror(errno)); + cupsdLogMessage(L_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)); - AddPrinterHistory(printer); + cupsdAddPrinterHistory(printer); if (filters != NULL) free(filters); @@ -2204,15 +2204,15 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the server could not open a file."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); return; } fcntl(filterfds[slot][1], F_SETFD, fcntl(filterfds[slot][1], F_GETFD) | FD_CLOEXEC); - LogMessage(L_DEBUG, "StartJob: backend = \"%s\"", command); - LogMessage(L_DEBUG, "StartJob: filterfds[%d] = [ %d %d ]", + cupsdLogMessage(L_DEBUG, "cupsdStartJob: backend = \"%s\"", command); + cupsdLogMessage(L_DEBUG, "cupsdStartJob: filterfds[%d] = [ %d %d ]", slot, filterfds[slot][0], filterfds[slot][1]); pid = cupsdStartProcess(command, argv, envp, filterfds[!slot][0], @@ -2222,17 +2222,17 @@ StartJob(int id, /* I - Job ID */ if (pid == 0) { - LogMessage(L_ERROR, "Unable to start backend \"%s\" - %s.", + cupsdLogMessage(L_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)); - LogMessage(L_DEBUG2, "StartJob: Closing print pipes [ %d %d ]...", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing print pipes [ %d %d ]...", job->print_pipes[0], job->print_pipes[1]); cupsdClosePipe(job->print_pipes); - LogMessage(L_DEBUG2, "StartJob: Closing back pipes [ %d %d ]...", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing back pipes [ %d %d ]...", job->back_pipes[0], job->back_pipes[1]); cupsdClosePipe(job->back_pipes); @@ -2240,24 +2240,24 @@ StartJob(int id, /* I - Job ID */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "Job cancelled because the server could not execute the backend."); - CancelJob(job->id, 0); + cupsdCancelJob(job->id, 0); return; } else { - LogMessage(L_INFO, "Started backend %s (PID %d) for job %d.", + cupsdLogMessage(L_INFO, "Started backend %s (PID %d) for job %d.", command, pid, job->id); } } if (job->current_file == job->num_files) { - LogMessage(L_DEBUG2, "StartJob: Closing print pipes [ %d %d ]...", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing print pipes [ %d %d ]...", job->print_pipes[0], job->print_pipes[1]); cupsdClosePipe(job->print_pipes); - LogMessage(L_DEBUG2, "StartJob: Closing back pipes [ %d %d ]...", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing back pipes [ %d %d ]...", job->back_pipes[0], job->back_pipes[1]); cupsdClosePipe(job->back_pipes); @@ -2270,24 +2270,24 @@ StartJob(int id, /* I - Job ID */ if (job->current_file == job->num_files) { - LogMessage(L_DEBUG2, "StartJob: Closing print pipes [ %d %d ]...", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing print pipes [ %d %d ]...", job->print_pipes[0], job->print_pipes[1]); cupsdClosePipe(job->print_pipes); } } - LogMessage(L_DEBUG2, "StartJob: Closing filter pipes for slot %d [ %d %d ]...", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing filter pipes for slot %d [ %d %d ]...", slot, filterfds[slot][0], filterfds[slot][1]); cupsdClosePipe(filterfds[slot]); - LogMessage(L_DEBUG2, "StartJob: Closing status output pipe %d...", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Closing status output pipe %d...", statusfds[1]); close(statusfds[1]); - LogMessage(L_DEBUG2, "StartJob: Adding fd %d to InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdStartJob: Adding fd %d to InputSet...", job->status_buffer->fd); FD_SET(job->status_buffer->fd, InputSet); @@ -2295,43 +2295,43 @@ StartJob(int id, /* I - Job ID */ /* - * 'StopAllJobs()' - Stop all print jobs. + * 'cupsdStopAllJobs()' - Stop all print jobs. */ void -StopAllJobs(void) +cupsdStopAllJobs(void) { - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ - DEBUG_puts("StopAllJobs()"); + DEBUG_puts("cupsdStopAllJobs()"); - for (job = (job_t *)cupsArrayFirst(ActiveJobs); + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; - job = (job_t *)cupsArrayNext(ActiveJobs)) + job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (job->state->values[0].integer == IPP_JOB_PROCESSING) { - StopJob(job->id, 1); + cupsdStopJob(job->id, 1); job->state->values[0].integer = IPP_JOB_PENDING; } } /* - * 'StopJob()' - Stop a print job. + * 'cupsdStopJob()' - Stop a print job. */ void -StopJob(int id, /* I - Job ID */ +cupsdStopJob(int id, /* I - Job ID */ int force) /* I - 1 = Force all filters to stop */ { int i; /* Looping var */ - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ - LogMessage(L_DEBUG, "StopJob: id = %d, force = %d", id, force); + cupsdLogMessage(L_DEBUG, "cupsdStopJob: id = %d, force = %d", id, force); - if ((job = FindJob(id)) == NULL) + if ((job = cupsdFindJob(id)) == NULL) return; if (job->state->values[0].integer != IPP_JOB_PROCESSING) @@ -2343,11 +2343,11 @@ StopJob(int id, /* I - Job ID */ !(job->dtype & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)) && !(job->printer->type & CUPS_PRINTER_FAX) && !strcmp(job->printer->error_policy, "stop-printer")) - SetPrinterState(job->printer, IPP_PRINTER_STOPPED, 1); + cupsdSetPrinterState(job->printer, IPP_PRINTER_STOPPED, 1); else if (job->printer->state != IPP_PRINTER_STOPPED) - SetPrinterState(job->printer, IPP_PRINTER_IDLE, 0); + cupsdSetPrinterState(job->printer, IPP_PRINTER_IDLE, 0); - LogMessage(L_DEBUG, "StopJob: printer state is %d", job->printer->state); + cupsdLogMessage(L_DEBUG, "cupsdStopJob: printer state is %d", job->printer->state); job->state->values[0].integer = IPP_JOB_STOPPED; job->printer->job = NULL; @@ -2368,12 +2368,12 @@ StopJob(int id, /* I - Job ID */ job->backend = 0; } - LogMessage(L_DEBUG2, "StopJob: Closing print pipes [ %d %d ]...", + cupsdLogMessage(L_DEBUG2, "cupsdStopJob: Closing print pipes [ %d %d ]...", job->print_pipes[0], job->print_pipes[1]); cupsdClosePipe(job->print_pipes); - LogMessage(L_DEBUG2, "StopJob: Closing back pipes [ %d %d ]...", + cupsdLogMessage(L_DEBUG2, "cupsdStopJob: Closing back pipes [ %d %d ]...", job->back_pipes[0], job->back_pipes[1]); cupsdClosePipe(job->back_pipes); @@ -2384,12 +2384,12 @@ StopJob(int id, /* I - Job ID */ * Close the pipe and clear the input bit. */ - LogMessage(L_DEBUG2, "StopJob: Removing fd %d from InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdStopJob: Removing fd %d from InputSet...", job->status_buffer->fd); FD_CLR(job->status_buffer->fd, InputSet); - LogMessage(L_DEBUG2, "StopJob: Closing status input pipe %d...", + cupsdLogMessage(L_DEBUG2, "cupsdStopJob: Closing status input pipe %d...", job->status_buffer->fd); cupsdStatBufDelete(job->status_buffer); @@ -2400,11 +2400,11 @@ StopJob(int id, /* I - Job ID */ /* - * 'UpdateJob()' - Read a status update from a job's filters. + * 'cupsdUpdateJob()' - Read a status update from a job's filters. */ void -UpdateJob(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 */ @@ -2444,16 +2444,16 @@ UpdateJob(job_t *job) /* I - Job to check */ job->sheets->values[0].integer += copies; if (job->printer->page_limit) - UpdateQuota(job->printer, job->username, copies, 0); + cupsdUpdateQuota(job->printer, job->username, copies, 0); } - LogPage(job, message); + cupsdLogPage(job, message); cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job, "Printed %d page(s).", job->sheets->values[0].integer); } else if (loglevel == L_STATE) - SetPrinterReasons(job->printer, message); + cupsdSetPrinterReasons(job->printer, message); else if (loglevel == L_ATTR) { /* @@ -2486,7 +2486,7 @@ UpdateJob(job_t *job) /* I - Job to check */ * Handle the end of job stuff... */ - FinishJob(job); + cupsdFinishJob(job); } } @@ -2503,10 +2503,10 @@ compare_active_jobs(void *first, /* I - First job */ int diff; /* Difference */ - if ((diff = ((job_t *)first)->priority - ((job_t *)second)->priority) != 0) + if ((diff = ((cupsd_job_t *)first)->priority - ((cupsd_job_t *)second)->priority) != 0) return (diff); else - return (((job_t *)first)->id - ((job_t *)second)->id); + return (((cupsd_job_t *)first)->id - ((cupsd_job_t *)second)->id); } @@ -2519,7 +2519,7 @@ compare_jobs(void *first, /* I - First job */ void *second, /* I - Second job */ void *data) /* I - App data (not used) */ { - return (((job_t *)first)->id - ((job_t *)second)->id); + return (((cupsd_job_t *)first)->id - ((cupsd_job_t *)second)->id); } @@ -2650,7 +2650,7 @@ ipp_length(ipp_t *ipp) /* I - IPP request */ */ static void -set_time(job_t *job, /* I - Job to update */ +set_time(cupsd_job_t *job, /* I - Job to update */ const char *name) /* I - Name of attribute */ { ipp_attribute_t *attr; /* Time attribute */ @@ -2669,7 +2669,7 @@ set_time(job_t *job, /* I - Job to update */ */ static void -set_hold_until(job_t *job, /* I - Job to update */ +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 */ @@ -2681,7 +2681,7 @@ set_hold_until(job_t *job, /* I - Job to update */ * Set the hold_until value and hold the job... */ - LogMessage(L_DEBUG, "set_hold_until: hold_until = %d", (int)holdtime); + cupsdLogMessage(L_DEBUG, "set_hold_until: hold_until = %d", (int)holdtime); job->state->values[0].integer = IPP_JOB_HELD; job->hold_until = holdtime; @@ -2706,9 +2706,9 @@ set_hold_until(job_t *job, /* I - Job to update */ attr = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-hold-until", NULL, holdstr); else - SetString(&attr->values[0].string.text, holdstr); + cupsdSetString(&attr->values[0].string.text, holdstr); - SaveJob(job->id); + cupsdSaveJob(job->id); } diff --git a/scheduler/job.h b/scheduler/job.h index 422419c59..0cf92cfd4 100644 --- a/scheduler/job.h +++ b/scheduler/job.h @@ -33,7 +33,7 @@ * Job request structure... */ -typedef struct job_s +typedef struct cupsd_job_s { int id, /* Job ID */ priority; /* Job priority */ @@ -43,7 +43,7 @@ typedef struct job_s 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) */ + 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 */ @@ -56,9 +56,9 @@ typedef struct job_s int filters[MAX_FILTERS + 1];/* Filter process IDs, 0 terminated */ int backend; /* Backend process ID */ int status; /* Status code from filters */ - printer_t *printer; /* Printer this job is assigned to */ + cupsd_printer_t *printer; /* Printer this job is assigned to */ int tries; /* Number of tries for this job */ -} job_t; +} cupsd_job_t; /* @@ -95,29 +95,29 @@ VAR int FaxRetryLimit VALUE(5), * Prototypes... */ -extern job_t *AddJob(int priority, const char *dest); -extern void CancelJob(int id, int purge); -extern void CancelJobs(const char *dest, const char *username, int purge); -extern void CheckJobs(void); -extern void CleanJobs(void); -extern void DeleteJob(int id); -extern job_t *FindJob(int id); -extern void FinishJob(job_t *job); -extern void FreeAllJobs(void); -extern int GetPrinterJobCount(const char *dest); -extern int GetUserJobCount(const char *username); -extern void HoldJob(int id); -extern void LoadAllJobs(void); -extern void MoveJob(int id, const char *dest); -extern void ReleaseJob(int id); -extern void RestartJob(int id); -extern void SaveJob(int id); -extern void SetJobHoldUntil(int id, const char *when); -extern void SetJobPriority(int id, int priority); -extern void StartJob(int id, printer_t *printer); -extern void StopAllJobs(void); -extern void StopJob(int id, int force); -extern void UpdateJob(job_t *job); +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 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); /* diff --git a/scheduler/listen.c b/scheduler/listen.c index e67da7b1d..08813c3c0 100644 --- a/scheduler/listen.c +++ b/scheduler/listen.c @@ -24,10 +24,10 @@ * * Contents: * - * PauseListening() - Clear input polling on all listening sockets... - * ResumeListening() - Set input polling on all listening sockets... - * StartListening() - Create all listening sockets... - * StopListening() - Close all listening sockets... + * cupsdPauseListening() - Clear input polling on all listening sockets... + * cupsdResumeListening() - Set input polling on all listening sockets... + * cupsdStartListening() - Create all listening sockets... + * cupsdStopListening() - Close all listening sockets... */ /* @@ -38,27 +38,27 @@ /* - * 'PauseListening()' - Clear input polling on all listening sockets... + * 'cupsdPauseListening()' - Clear input polling on all listening sockets... */ void -PauseListening(void) +cupsdPauseListening(void) { int i; /* Looping var */ - listener_t *lis; /* Current listening socket */ + cupsd_listener_t *lis; /* Current listening socket */ if (NumListeners < 1 || !FD_ISSET(Listeners[0].fd, InputSet)) return; if (NumClients == MaxClients) - LogMessage(L_WARN, "Max clients reached, holding new connections..."); + cupsdLogMessage(L_WARN, "Max clients reached, holding new connections..."); - LogMessage(L_DEBUG, "PauseListening: Clearing input bits..."); + cupsdLogMessage(L_DEBUG, "cupsdPauseListening: Clearing input bits..."); for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++) { - LogMessage(L_DEBUG2, "PauseListening: Removing fd %d from InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdPauseListening: Removing fd %d from InputSet...", lis->fd); FD_CLR(lis->fd, InputSet); @@ -67,27 +67,27 @@ PauseListening(void) /* - * 'ResumeListening()' - Set input polling on all listening sockets... + * 'cupsdResumeListening()' - Set input polling on all listening sockets... */ void -ResumeListening(void) +cupsdResumeListening(void) { int i; /* Looping var */ - listener_t *lis; /* Current listening socket */ + cupsd_listener_t *lis; /* Current listening socket */ if (NumListeners < 1 || FD_ISSET(Listeners[0].fd, InputSet)) return; if (NumClients >= (MaxClients - 1)) - LogMessage(L_WARN, "Resuming new connection processing..."); + cupsdLogMessage(L_WARN, "Resuming new connection processing..."); - LogMessage(L_DEBUG, "ResumeListening: Setting input bits..."); + cupsdLogMessage(L_DEBUG, "cupsdResumeListening: Setting input bits..."); for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++) { - LogMessage(L_DEBUG2, "ResumeListening: Adding fd %d to InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdResumeListening: Adding fd %d to InputSet...", lis->fd); FD_SET(lis->fd, InputSet); } @@ -95,17 +95,17 @@ ResumeListening(void) /* - * 'StartListening()' - Create all listening sockets... + * 'cupsdStartListening()' - Create all listening sockets... */ void -StartListening(void) +cupsdStartListening(void) { int status; /* Bind result */ int i, /* Looping var */ p, /* Port number */ val; /* Parameter value */ - listener_t *lis; /* Current listening socket */ + 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? */ @@ -118,7 +118,7 @@ StartListening(void) }; - LogMessage(L_DEBUG, "StartListening: NumListeners=%d", NumListeners); + cupsdLogMessage(L_DEBUG, "cupsdStartListening: NumListeners=%d", NumListeners); /* * Get the server's IP address... @@ -140,7 +140,7 @@ StartListening(void) * Didn't find it! Use an address of 0... */ - LogMessage(L_ERROR, "StartListening: Unable to find IP address for server name \"%s\" - %s\n", + cupsdLogMessage(L_ERROR, "cupsdStartListening: Unable to find IP address for server name \"%s\" - %s\n", ServerName, hstrerror(h_errno)); ServerAddr.ipv4.sin_family = AF_INET; @@ -197,7 +197,7 @@ StartListening(void) * Try binding to an IPv4 address instead... */ - LogMessage(L_NOTICE, "StartListening: Unable to use IPv6 address, trying IPv4..."); + cupsdLogMessage(L_NOTICE, "cupsdStartListening: Unable to use IPv6 address, trying IPv4..."); p = ntohs(lis->address.ipv6.sin6_port); @@ -215,7 +215,7 @@ StartListening(void) if (lis->fd == -1) { - LogMessage(L_ERROR, "StartListening: Unable to open listen socket for address %s:%d - %s.", + cupsdLogMessage(L_ERROR, "cupsdStartListening: Unable to open listen socket for address %s:%d - %s.", s, p, strerror(errno)); exit(errno); } @@ -305,7 +305,7 @@ StartListening(void) if (status < 0) { - LogMessage(L_ERROR, "StartListening: Unable to bind socket for address %s:%d - %s.", + cupsdLogMessage(L_ERROR, "cupsdStartListening: Unable to bind socket for address %s:%d - %s.", s, p, strerror(errno)); exit(errno); } @@ -316,16 +316,16 @@ StartListening(void) if (listen(lis->fd, ListenBackLog) < 0) { - LogMessage(L_ERROR, "StartListening: Unable to listen for clients on address %s:%d - %s.", + cupsdLogMessage(L_ERROR, "cupsdStartListening: Unable to listen for clients on address %s:%d - %s.", s, p, strerror(errno)); exit(errno); } if (p) - LogMessage(L_INFO, "StartListening: Listening to %s:%d on fd %d...", + cupsdLogMessage(L_INFO, "cupsdStartListening: Listening to %s:%d on fd %d...", s, p, lis->fd); else - LogMessage(L_INFO, "StartListening: Listening to %s on fd %d...", + cupsdLogMessage(L_INFO, "cupsdStartListening: Listening to %s on fd %d...", s, lis->fd); } @@ -335,7 +335,7 @@ StartListening(void) if (!LocalPort && !have_domain) { - LogMessage(L_EMERG, "No Listen or Port lines were found to allow access via localhost!"); + cupsdLogMessage(L_EMERG, "No Listen or Port lines were found to allow access via localhost!"); /* * Commit suicide... @@ -371,24 +371,24 @@ StartListening(void) * Resume listening for connections... */ - ResumeListening(); + cupsdResumeListening(); } /* - * 'StopListening()' - Close all listening sockets... + * 'cupsdStopListening()' - Close all listening sockets... */ void -StopListening(void) +cupsdStopListening(void) { int i; /* Looping var */ - listener_t *lis; /* Current listening socket */ + cupsd_listener_t *lis; /* Current listening socket */ - LogMessage(L_DEBUG, "StopListening: closing all listen sockets."); + cupsdLogMessage(L_DEBUG, "cupsdStopListening: closing all listen sockets."); - PauseListening(); + cupsdPauseListening(); for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++) { diff --git a/scheduler/log.c b/scheduler/log.c index 5ff15e5e2..9ca80365d 100644 --- a/scheduler/log.c +++ b/scheduler/log.c @@ -23,10 +23,10 @@ * * Contents: * - * GetDateTime() - Returns a pointer to a date/time string. - * LogMessage() - Log a message to the error log file. - * LogPage() - Log a page to the page log file. - * LogRequest() - Log an HTTP request in Common Log Format. + * cupsdGetDateTime() - Returns a pointer to a date/time string. + * cupsdLogMessage() - Log a message to the error log file. + * cupsdLogPage() - Log a page to the page log file. + * cupsdLogRequest() - Log an HTTP request in Common Log Format. * check_log_file() - Open/rotate a log file if it needs it. */ @@ -50,11 +50,11 @@ static int check_log_file(cups_file_t **, const char *); /* - * 'GetDateTime()' - Returns a pointer to a date/time string. + * 'cupsdGetDateTime()' - Returns a pointer to a date/time string. */ char * /* O - Date/time string */ -GetDateTime(time_t t) /* I - Time value */ +cupsdGetDateTime(time_t t) /* I - Time value */ { struct tm *date; /* Date/time value */ static time_t last_time = -1; /* Last time value */ @@ -111,11 +111,11 @@ GetDateTime(time_t t) /* I - Time value */ /* - * 'LogMessage()' - Log a message to the error log file. + * 'cupsdLogMessage()' - Log a message to the error log file. */ int /* O - 1 on success, 0 on error */ -LogMessage(int level, /* I - Log level */ +cupsdLogMessage(int level, /* I - Log level */ const char *message, /* I - printf-style message string */ ...) /* I - Additional args as needed */ { @@ -186,7 +186,7 @@ LogMessage(int level, /* I - Log level */ * Print the log level and date/time... */ - cupsFilePrintf(ErrorFile, "%c %s ", levels[level], GetDateTime(time(NULL))); + cupsFilePrintf(ErrorFile, "%c %s ", levels[level], cupsdGetDateTime(time(NULL))); /* * Allocate the line buffer as needed... @@ -275,11 +275,11 @@ LogMessage(int level, /* I - Log level */ /* - * 'LogPage()' - Log a page to the page log file. + * 'cupsdLogPage()' - Log a page to the page log file. */ int /* O - 1 on success, 0 on error */ -LogPage(job_t *job, /* I - Job being printed */ +cupsdLogPage(cupsd_job_t *job, /* I - Job being printed */ const char *page) /* I - Page being printed */ { ipp_attribute_t *billing, /* job-billing attribute */ @@ -322,7 +322,7 @@ LogPage(job_t *job, /* I - Job being printed */ cupsFilePrintf(PageFile, "%s %s %d %s %s %s %s\n", job->printer->name, job->username ? job->username : "-", - job->id, GetDateTime(time(NULL)), page, + job->id, cupsdGetDateTime(time(NULL)), page, billing ? billing->values[0].string.text : "-", hostname->values[0].string.text); cupsFileFlush(PageFile); @@ -332,11 +332,11 @@ LogPage(job_t *job, /* I - Job being printed */ /* - * 'LogRequest()' - Log an HTTP request in Common Log Format. + * 'cupsdLogRequest()' - Log an HTTP request in Common Log Format. */ int /* O - 1 on success, 0 on error */ -LogRequest(client_t *con, /* I - Request to log */ +cupsdLogRequest(cupsd_client_t *con, /* I - Request to log */ http_status_t code) /* I - Response code */ { static const char * const states[] = @@ -388,7 +388,7 @@ LogRequest(client_t *con, /* I - Request to log */ cupsFilePrintf(AccessFile, "%s - %s %s \"%s %s HTTP/%d.%d\" %d %d\n", con->http.hostname, con->username[0] != '\0' ? con->username : "-", - GetDateTime(con->start), states[con->operation], con->uri, + cupsdGetDateTime(con->start), states[con->operation], con->uri, con->http.version / 100, con->http.version % 100, code, con->bytes); cupsFileFlush(AccessFile); diff --git a/scheduler/main.c b/scheduler/main.c index 70f601df8..30a7fe4dc 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -26,12 +26,12 @@ * main() - Main entry for the CUPS scheduler. * cupsdClosePipe() - Close a pipe as necessary. * cupsdOpenPipe() - Create a pipe which is closed on exec. - * CatchChildSignals() - Catch SIGCHLD signals... - * HoldSignals() - Hold child and termination signals. - * IgnoreChildSignals() - Ignore SIGCHLD signals... - * ReleaseSignals() - Release signals for delivery. - * SetString() - Set a string value. - * SetStringf() - Set a formatted string value. + * 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. @@ -96,9 +96,9 @@ main(int argc, /* I - Number of command-line arguments */ int fds; /* Number of ready descriptors select returns */ fd_set *input, /* Input set for select() */ *output; /* Output set for select() */ - client_t *con; /* Current client */ - job_t *job; /* Current job */ - 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 */ @@ -138,7 +138,7 @@ main(int argc, /* I - Number of command-line arguments */ * Absolute directory... */ - SetString(&ConfigurationFile, argv[i]); + cupsdSetString(&ConfigurationFile, argv[i]); } else { @@ -150,7 +150,7 @@ main(int argc, /* I - Number of command-line arguments */ getcwd(current, sizeof(current)); - SetStringf(&ConfigurationFile, "%s/%s", current, argv[i]); + cupsdSetStringf(&ConfigurationFile, "%s/%s", current, argv[i]); } break; @@ -174,7 +174,7 @@ main(int argc, /* I - Number of command-line arguments */ } if (!ConfigurationFile) - SetString(&ConfigurationFile, CUPS_SERVERROOT "/cupsd.conf"); + cupsdSetString(&ConfigurationFile, CUPS_SERVERROOT "/cupsd.conf"); /* * If the user hasn't specified "-f", run in the background... @@ -323,7 +323,7 @@ main(int argc, /* I - Number of command-line arguments */ * Read configuration... */ - if (!ReadConfiguration()) + if (!cupsdReadConfiguration()) { syslog(LOG_LPR, "Unable to read configuration file \'%s\' - exiting!", ConfigurationFile); @@ -400,7 +400,7 @@ main(int argc, /* I - Number of command-line arguments */ * Initialize authentication certificates... */ - InitCerts(); + cupsdInitCerts(); /* * If we are running in the background, signal the parent process that @@ -437,13 +437,13 @@ main(int argc, /* I - Number of command-line arguments */ * Catch signals... */ - CatchChildSignals(); + cupsdCatchChildSignals(); /* * Start any pending print jobs... */ - CheckJobs(); + cupsdCheckJobs(); /* * Loop forever... @@ -459,7 +459,7 @@ main(int argc, /* I - Number of command-line arguments */ while (!stop_scheduler) { #ifdef DEBUG - LogMessage(L_DEBUG2, "main: Top of loop, dead_children=%d, NeedReload=%d", + cupsdLogMessage(L_DEBUG2, "main: Top of loop, dead_children=%d, NeedReload=%d", dead_children, NeedReload); #endif /* DEBUG */ @@ -485,22 +485,22 @@ main(int argc, /* I - Number of command-line arguments */ for (i = NumClients, con = Clients; i > 0; i --, con ++) if (con->http.state == HTTP_WAITING) { - CloseClient(con); + cupsdCloseClient(con); con --; } else con->http.keep_alive = HTTP_KEEPALIVE_OFF; - PauseListening(); + cupsdPauseListening(); } /* * Check for any active jobs... */ - for (job = (job_t *)cupsArrayFirst(ActiveJobs); + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; - job = (job_t *)cupsArrayNext(ActiveJobs)) + job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (job->state->values[0].integer == IPP_JOB_PROCESSING) break; @@ -512,7 +512,7 @@ main(int argc, /* I - Number of command-line arguments */ if ((NumClients == 0 && (!job || NeedReload != RELOAD_ALL)) || (time(NULL) - ReloadTime) >= ReloadTimeout) { - if (!ReadConfiguration()) + if (!cupsdReadConfiguration()) { syslog(LOG_LPR, "Unable to read configuration file \'%s\' - exiting!", ConfigurationFile); @@ -553,7 +553,7 @@ main(int argc, /* I - Number of command-line arguments */ * Log all sorts of debug info to help track down the problem. */ - LogMessage(L_EMERG, "select() failed - %s!", strerror(errno)); + cupsdLogMessage(L_EMERG, "select() failed - %s!", strerror(errno)); strcpy(s, "InputSet ="); slen = 10; @@ -567,7 +567,7 @@ main(int argc, /* I - Number of command-line arguments */ sptr += strlen(sptr); } - LogMessage(L_EMERG, s); + cupsdLogMessage(L_EMERG, s); strcpy(s, "OutputSet ="); slen = 11; @@ -581,21 +581,21 @@ main(int argc, /* I - Number of command-line arguments */ sptr += strlen(sptr); } - LogMessage(L_EMERG, s); + cupsdLogMessage(L_EMERG, s); for (i = 0, con = Clients; i < NumClients; i ++, con ++) - LogMessage(L_EMERG, "Clients[%d] = %d, file = %d, state = %d", + cupsdLogMessage(L_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 ++) - LogMessage(L_EMERG, "Listeners[%d] = %d", i, lis->fd); + cupsdLogMessage(L_EMERG, "Listeners[%d] = %d", i, lis->fd); - LogMessage(L_EMERG, "BrowseSocket = %d", BrowseSocket); + cupsdLogMessage(L_EMERG, "BrowseSocket = %d", BrowseSocket); - for (job = (job_t *)cupsArrayFirst(ActiveJobs); + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; - job = (job_t *)cupsArrayNext(ActiveJobs)) - LogMessage(L_EMERG, "Jobs[%d] = %d < [%d %d] > [%d %d]", + 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]); @@ -606,9 +606,9 @@ main(int argc, /* I - Number of command-line arguments */ * Check for status info from job filters... */ - for (job = (job_t *)cupsArrayFirst(ActiveJobs); + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; - job = (job_t *)cupsArrayNext(ActiveJobs)) + job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (job->status_buffer && FD_ISSET(job->status_buffer->fd, input)) { /* @@ -622,7 +622,7 @@ main(int argc, /* I - Number of command-line arguments */ * Read any status messages from the filters... */ - UpdateJob(job); + cupsdUpdateJob(job); } /* @@ -630,7 +630,7 @@ main(int argc, /* I - Number of command-line arguments */ */ if (CGIPipes[0] >= 0 && FD_ISSET(CGIPipes[0], input)) - UpdateCGI(); + cupsdUpdateCGI(); /* * Update the browse list as needed... @@ -639,20 +639,20 @@ main(int argc, /* I - Number of command-line arguments */ if (Browsing && (BrowseLocalProtocols | BrowseRemoteProtocols)) { if (BrowseSocket >= 0 && FD_ISSET(BrowseSocket, input)) - UpdateCUPSBrowse(); + cupsdUpdateCUPSBrowse(); if (PollPipe >= 0 && FD_ISSET(PollPipe, input)) - UpdatePolling(); + cupsdUpdatePolling(); #ifdef HAVE_LIBSLP if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP) && BrowseSLPRefresh <= time(NULL)) - UpdateSLPBrowse(); + cupsdUpdateSLPBrowse(); #endif /* HAVE_LIBSLP */ if (time(NULL) > browse_time) { - SendBrowseList(); + cupsdSendBrowseList(); browse_time = time(NULL); } } @@ -665,7 +665,7 @@ main(int argc, /* I - Number of command-line arguments */ if (FD_ISSET(lis->fd, input)) { FD_CLR(lis->fd, input); - AcceptClient(lis); + cupsdAcceptClient(lis); } /* @@ -682,7 +682,7 @@ main(int argc, /* I - Number of command-line arguments */ { FD_CLR(con->http.fd, input); - if (!ReadClient(con)) + if (!cupsdReadClient(con)) { if (con->pipe_pid) FD_CLR(con->file, input); @@ -708,12 +708,12 @@ main(int argc, /* I - Number of command-line arguments */ con->file_ready = 1; #ifdef DEBUG - LogMessage(L_DEBUG2, "main: Data ready file %d!", con->file); + cupsdLogMessage(L_DEBUG2, "main: Data ready file %d!", con->file); #endif /* DEBUG */ if (!FD_ISSET(con->http.fd, output)) { - LogMessage(L_DEBUG2, "main: Removing fd %d from InputSet...", con->file); + cupsdLogMessage(L_DEBUG2, "main: Removing fd %d from InputSet...", con->file); FD_CLR(con->file, InputSet); } } @@ -723,7 +723,7 @@ main(int argc, /* I - Number of command-line arguments */ FD_CLR(con->http.fd, output); if (!con->pipe_pid || con->file_ready) - if (!WriteClient(con)) + if (!cupsdWriteClient(con)) { con --; continue; @@ -737,10 +737,10 @@ main(int argc, /* I - Number of command-line arguments */ activity = time(NULL) - Timeout; if (con->http.activity < activity && !con->pipe_pid) { - LogMessage(L_DEBUG, "Closing client %d after %d seconds of inactivity...", + cupsdLogMessage(L_DEBUG, "Closing client %d after %d seconds of inactivity...", con->http.fd, Timeout); - CloseClient(con); + cupsdCloseClient(con); con --; continue; } @@ -752,7 +752,7 @@ main(int argc, /* I - Number of command-line arguments */ if ((time(NULL) - senddoc_time) >= 10) { - CheckJobs(); + cupsdCheckJobs(); senddoc_time = time(NULL); } @@ -767,7 +767,7 @@ main(int argc, /* I - Number of command-line arguments */ mem = mallinfo(); - LogMessage(L_DEBUG, "mallinfo: arena = %d, used = %d, free = %d\n", + cupsdLogMessage(L_DEBUG, "mallinfo: arena = %d, used = %d, free = %d\n", mem.arena, mem.usmblks + mem.uordblks, mem.fsmblks + mem.fordblks); mallinfo_time = time(NULL); @@ -785,8 +785,8 @@ main(int argc, /* I - Number of command-line arguments */ * Update the root certificate... */ - DeleteCert(0); - AddCert(0, "root"); + cupsdDeleteCert(0); + cupsdAddCert(0, "root"); } } @@ -795,17 +795,17 @@ main(int argc, /* I - Number of command-line arguments */ */ if (stop_scheduler) - LogMessage(L_INFO, "Scheduler shutting down normally."); + cupsdLogMessage(L_INFO, "Scheduler shutting down normally."); else - LogMessage(L_ERROR, "Scheduler shutting down due to program error."); + cupsdLogMessage(L_ERROR, "Scheduler shutting down due to program error."); /* * Close all network clients and stop all jobs... */ - StopServer(); + cupsdStopServer(); - StopAllJobs(); + cupsdStopAllJobs(); #ifdef __sgi /* @@ -898,11 +898,11 @@ cupsdOpenPipe(int *fds) /* O - Pipe file descriptors (2) */ /* - * 'CatchChildSignals()' - Catch SIGCHLD signals... + * 'cupsdCatchChildSignals()' - Catch SIGCHLD signals... */ void -CatchChildSignals(void) +cupsdCatchChildSignals(void) { #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* Actions for POSIX signals */ @@ -926,11 +926,11 @@ CatchChildSignals(void) /* - * 'ClearString()' - Clear a string. + * 'cupsdClearString()' - Clear a string. */ void -ClearString(char **s) /* O - String value */ +cupsdClearString(char **s) /* O - String value */ { if (s && *s) { @@ -941,11 +941,11 @@ ClearString(char **s) /* O - String value */ /* - * 'HoldSignals()' - Hold child and termination signals. + * 'cupsdHoldSignals()' - Hold child and termination signals. */ void -HoldSignals(void) +cupsdHoldSignals(void) { #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) sigset_t newmask; /* New POSIX signal mask */ @@ -969,14 +969,14 @@ HoldSignals(void) /* - * 'IgnoreChildSignals()' - Ignore SIGCHLD signals... + * 'cupsdIgnoreChildSignals()' - Ignore SIGCHLD signals... * * We don't really ignore them, we set the signal handler to SIG_DFL, * since some OS's rely on signals for the wait4() function to work. */ void -IgnoreChildSignals(void) +cupsdIgnoreChildSignals(void) { #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* Actions for POSIX signals */ @@ -999,11 +999,11 @@ IgnoreChildSignals(void) /* - * 'ReleaseSignals()' - Release signals for delivery. + * 'cupsdReleaseSignals()' - Release signals for delivery. */ void -ReleaseSignals(void) +cupsdReleaseSignals(void) { holdcount --; if (holdcount > 0) @@ -1019,11 +1019,11 @@ ReleaseSignals(void) /* - * 'SetString()' - Set a string value. + * 'cupsdSetString()' - Set a string value. */ void -SetString(char **s, /* O - New string */ +cupsdSetString(char **s, /* O - New string */ const char *v) /* I - String value */ { if (!s || *s == v) @@ -1040,11 +1040,11 @@ SetString(char **s, /* O - New string */ /* - * 'SetStringf()' - Set a formatted string value. + * 'cupsdSetStringf()' - Set a formatted string value. */ void -SetStringf(char **s, /* O - New string */ +cupsdSetStringf(char **s, /* O - New string */ const char *f, /* I - Printf-style format string */ ...) /* I - Additional args as needed */ { @@ -1098,11 +1098,11 @@ process_children(void) { int status; /* Exit status of child */ int pid; /* Process ID of child */ - job_t *job; /* Current job */ + cupsd_job_t *job; /* Current job */ int i; /* Looping var */ - LogMessage(L_DEBUG2, "process_children()"); + cupsdLogMessage(L_DEBUG2, "process_children()"); /* * Reset the dead_children flag... @@ -1122,7 +1122,7 @@ process_children(void) if ((pid = wait(&status)) > 0) #endif /* HAVE_WAITPID */ { - LogMessage(L_DEBUG2, "process_children: pid = %d, status = %d\n", pid, status); + cupsdLogMessage(L_DEBUG2, "process_children: pid = %d, status = %d\n", pid, status); /* * Ignore SIGTERM errors - that comes when a job is cancelled... @@ -1134,32 +1134,32 @@ process_children(void) if (status) { if (WIFEXITED(status)) - LogMessage(L_ERROR, "PID %d stopped with status %d!", pid, + cupsdLogMessage(L_ERROR, "PID %d stopped with status %d!", pid, WEXITSTATUS(status)); else - LogMessage(L_ERROR, "PID %d crashed on signal %d!", pid, + cupsdLogMessage(L_ERROR, "PID %d crashed on signal %d!", pid, WTERMSIG(status)); if (LogLevel < L_DEBUG) - LogMessage(L_INFO, "Hint: Try setting the LogLevel to \"debug\" to find out more."); + cupsdLogMessage(L_INFO, "Hint: Try setting the LogLevel to \"debug\" to find out more."); } else - LogMessage(L_DEBUG2, "PID %d exited with no errors.", pid); + cupsdLogMessage(L_DEBUG2, "PID %d exited with no errors.", pid); /* * Delete certificates for CGI processes... */ if (pid) - DeleteCert(pid); + cupsdDeleteCert(pid); /* * Lookup the PID in the jobs list... */ - for (job = (job_t *)cupsArrayFirst(ActiveJobs); + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; - job = (job_t *)cupsArrayNext(ActiveJobs)) + job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (job->state != NULL && job->state->values[0].integer == IPP_JOB_PROCESSING) { @@ -1209,7 +1209,7 @@ process_children(void) * Process the next file... */ - FinishJob(job); + cupsdFinishJob(job); } } break; @@ -1290,9 +1290,9 @@ select_timeout(int fds) /* I - Number of ready descriptors select returned */ int i; /* Looping var */ long timeout; /* Timeout for select */ time_t now; /* Current time */ - client_t *con; /* Client information */ - printer_t *p; /* Printer information */ - 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 */ @@ -1349,9 +1349,9 @@ select_timeout(int fds) /* I - Number of ready descriptors select returned */ if (BrowseLocalProtocols & BROWSE_CUPS) { - for (p = (printer_t *)cupsArrayFirst(Printers); + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) { if (p->type & CUPS_PRINTER_REMOTE) { @@ -1379,9 +1379,9 @@ select_timeout(int fds) /* I - Number of ready descriptors select returned */ if (timeout > (now + 10) && ActiveJobs) { - for (job = (job_t *)cupsArrayFirst(ActiveJobs); + for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; - job = (job_t *)cupsArrayNext(ActiveJobs)) + job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (job->state->values[0].integer <= IPP_JOB_PROCESSING) { timeout = now + 10; @@ -1433,7 +1433,7 @@ select_timeout(int fds) /* I - Number of ready descriptors select returned */ * Log and return the timeout value... */ - LogMessage(L_DEBUG2, "select_timeout: %ld seconds to %s", timeout, why); + cupsdLogMessage(L_DEBUG2, "select_timeout: %ld seconds to %s", timeout, why); return (timeout); } diff --git a/scheduler/network.c b/scheduler/network.c index 638c47e50..69a7c1c72 100644 --- a/scheduler/network.c +++ b/scheduler/network.c @@ -73,17 +73,17 @@ void freeifaddrs(struct ifaddrs *addrs); * 'NetIFFind()' - Find a network interface. */ -cups_netif_t * /* O - Network interface data */ +cupsd_netif_t * /* O - Network interface data */ NetIFFind(const char *name) /* I - Name of interface */ { - cups_netif_t *temp; /* Current network interface */ + cupsd_netif_t *temp; /* Current network interface */ /* * Update the interface list as needed... */ - NetIFUpdate(); + cupsdNetIFUpdate(); /* * Search for the named interface... @@ -98,13 +98,13 @@ NetIFFind(const char *name) /* I - Name of interface */ /* - * 'NetIFFree()' - Free the current network interface list. + * 'cupsdNetIFFree()' - Free the current network interface list. */ void -NetIFFree(void) +cupsdNetIFFree(void) { - cups_netif_t *next; /* Next interface in list */ + cupsd_netif_t *next; /* Next interface in list */ /* @@ -123,16 +123,16 @@ NetIFFree(void) /* - * 'NetIFUpdate()' - Update the network interface list as needed... + * 'cupsdNetIFUpdate()' - Update the network interface list as needed... */ void -NetIFUpdate(void) +cupsdNetIFUpdate(void) { int i, /* Looping var */ match; /* Matching address? */ - listener_t *lis; /* Listen address */ - cups_netif_t *temp; /* Current interface */ + cupsd_listener_t *lis; /* Listen address */ + cupsd_netif_t *temp; /* Current interface */ struct ifaddrs *addrs, /* Interface address list */ *addr; /* Current interface address */ @@ -151,7 +151,7 @@ NetIFUpdate(void) * Free the old interfaces... */ - NetIFFree(); + cupsdNetIFFree(); /* * Grab a new list of interfaces... @@ -179,7 +179,7 @@ NetIFUpdate(void) * OK, we have an IPv4/6 address, so create a new list node... */ - if ((temp = calloc(1, sizeof(cups_netif_t))) == NULL) + if ((temp = calloc(1, sizeof(cupsd_netif_t))) == NULL) break; temp->next = NetIFList; diff --git a/scheduler/network.h b/scheduler/network.h index 46f144158..ef19510d6 100644 --- a/scheduler/network.h +++ b/scheduler/network.h @@ -27,9 +27,9 @@ * Structures... */ -typedef struct cups_netif_str /**** Network interface data ****/ +typedef struct cupsd_netif_s /**** Network interface data ****/ { - struct cups_netif_str *next; /* Next interface in list */ + struct cupsd_netif_s *next; /* Next interface in list */ char name[32], /* Network interface name */ hostname[HTTP_MAX_HOST]; /* Hostname associated with interface */ @@ -38,7 +38,7 @@ typedef struct cups_netif_str /**** Network interface data ****/ http_addr_t address, /* Network address */ mask, /* Network mask */ broadcast; /* Broadcast address */ -} cups_netif_t; +} cupsd_netif_t; /* @@ -47,16 +47,16 @@ typedef struct cups_netif_str /**** Network interface data ****/ VAR time_t NetIFTime VALUE(0); /* Network interface list time */ -VAR cups_netif_t *NetIFList VALUE(NULL); +VAR cupsd_netif_t *NetIFList VALUE(NULL); /* List of network interfaces */ /* * Prototypes... */ -extern cups_netif_t *NetIFFind(const char *name); -extern void NetIFFree(void); -extern void NetIFUpdate(void); +extern cupsd_netif_t *NetIFFind(const char *name); +extern void cupsdNetIFFree(void); +extern void cupsdNetIFUpdate(void); /* diff --git a/scheduler/policy.c b/scheduler/policy.c index c5847fb06..c7e7dae5e 100644 --- a/scheduler/policy.c +++ b/scheduler/policy.c @@ -80,34 +80,34 @@ cupsdAddPolicy(const char *policy) /* I - Name of policy */ * 'cupsdAddPolicyOp()' - Add an operation to a policy. */ -location_t * /* O - New policy operation */ +cupsd_location_t * /* O - New policy operation */ cupsdAddPolicyOp(cupsd_policy_t *p, /* I - Policy */ - location_t *po, /* I - Policy operation to copy */ + cupsd_location_t *po, /* I - Policy operation to copy */ ipp_op_t op) /* I - IPP operation code */ { int i; /* Looping var */ - location_t *temp, /* New policy operation */ + cupsd_location_t *temp, /* New policy operation */ **tempa; /* New policy operation array */ char name[1024]; /* Interface name */ - LogMessage(L_DEBUG2, "cupsdAddPolicyOp(p=%p, po=%p, op=%x(%s))", + cupsdLogMessage(L_DEBUG2, "cupsdAddPolicyOp(p=%p, po=%p, op=%x(%s))", p, po, op, ippOpString(op)); if (p == NULL) return (NULL); if (p->num_ops == 0) - tempa = malloc(sizeof(location_t *)); + tempa = malloc(sizeof(cupsd_location_t *)); else - tempa = realloc(p->ops, sizeof(location_t *) * (p->num_ops + 1)); + tempa = realloc(p->ops, sizeof(cupsd_location_t *) * (p->num_ops + 1)); if (tempa == NULL) return (NULL); p->ops = tempa; - if ((temp = calloc(1, sizeof(location_t))) != NULL) + if ((temp = calloc(1, sizeof(cupsd_location_t))) != NULL) { p->ops = tempa; tempa[p->num_ops] = temp; @@ -129,24 +129,24 @@ cupsdAddPolicyOp(cupsd_policy_t *p, /* I - Policy */ temp->encryption = po->encryption; for (i = 0; i < po->num_names; i ++) - AddName(temp, po->names[i]); + cupsdAddName(temp, po->names[i]); for (i = 0; i < po->num_allow; i ++) switch (po->allow[i].type) { case AUTH_IP : - AllowIP(temp, po->allow[i].mask.ip.address, + cupsdAllowIP(temp, po->allow[i].mask.ip.address, po->allow[i].mask.ip.netmask); break; case AUTH_INTERFACE : snprintf(name, sizeof(name), "@IF(%s)", po->allow[i].mask.name.name); - AllowHost(temp, name); + cupsdAllowHost(temp, name); break; default : - AllowHost(temp, po->allow[i].mask.name.name); + cupsdAllowHost(temp, po->allow[i].mask.name.name); break; } @@ -154,18 +154,18 @@ cupsdAddPolicyOp(cupsd_policy_t *p, /* I - Policy */ switch (po->deny[i].type) { case AUTH_IP : - DenyIP(temp, po->deny[i].mask.ip.address, + cupsdDenyIP(temp, po->deny[i].mask.ip.address, po->deny[i].mask.ip.netmask); break; case AUTH_INTERFACE : snprintf(name, sizeof(name), "@IF(%s)", po->deny[i].mask.name.name); - DenyHost(temp, name); + cupsdDenyHost(temp, name); break; default : - DenyHost(temp, po->deny[i].mask.name.name); + cupsdDenyHost(temp, po->deny[i].mask.name.name); break; } } @@ -181,10 +181,10 @@ cupsdAddPolicyOp(cupsd_policy_t *p, /* I - Policy */ int /* I - 1 if OK, 0 otherwise */ cupsdCheckPolicy(cupsd_policy_t *p, /* I - Policy */ - client_t *con, /* I - Client connection */ + cupsd_client_t *con, /* I - Client connection */ const char *owner) /* I - Owner of object */ { - location_t *po; /* Current policy operation */ + cupsd_location_t *po; /* Current policy operation */ /* @@ -193,7 +193,7 @@ cupsdCheckPolicy(cupsd_policy_t *p, /* I - Policy */ if (!p || !con) { - LogMessage(L_CRIT, "cupsdCheckPolicy: p=%p, con=%p!", p, con); + cupsdLogMessage(L_CRIT, "cupsdCheckPolicy: p=%p, con=%p!", p, con); return (0); } @@ -204,7 +204,7 @@ cupsdCheckPolicy(cupsd_policy_t *p, /* I - Policy */ if ((po = cupsdFindPolicyOp(p, con->request->request.op.operation_id)) == NULL) { - LogMessage(L_DEBUG2, "cupsdCheckPolicy: No matching operation, returning 0!"); + cupsdLogMessage(L_DEBUG2, "cupsdCheckPolicy: No matching operation, returning 0!"); return (0); } @@ -227,7 +227,7 @@ cupsdDeleteAllPolicies(void) { int i, j; /* Looping vars */ cupsd_policy_t **p; /* Current policy */ - location_t **po; /* Current policy op */ + cupsd_location_t **po; /* Current policy op */ if (NumPolicies == 0) @@ -288,15 +288,15 @@ cupsdFindPolicy(const char *policy) /* I - Name of policy */ * 'cupsdFindPolicyOp()' - Find a policy operation. */ -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 */ - location_t **po; /* Current policy operation */ + cupsd_location_t **po; /* Current policy operation */ - LogMessage(L_DEBUG2, "cupsdFindPolicyOp(p=%p, op=%x(%s))\n", + cupsdLogMessage(L_DEBUG2, "cupsdFindPolicyOp(p=%p, op=%x(%s))\n", p, op, ippOpString(op)); /* @@ -313,18 +313,18 @@ cupsdFindPolicyOp(cupsd_policy_t *p, /* I - Policy */ for (i = p->num_ops, po = p->ops; i > 0; i --, po ++) if ((*po)->op == op) { - LogMessage(L_DEBUG2, "cupsdFindPolicyOp: Found exact match..."); + cupsdLogMessage(L_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) { - LogMessage(L_DEBUG2, "cupsdFindPolicyOp: Found wildcard match..."); + cupsdLogMessage(L_DEBUG2, "cupsdFindPolicyOp: Found wildcard match..."); return (*po); } - LogMessage(L_DEBUG2, "cupsdFindPolicyOp: No match found!"); + cupsdLogMessage(L_DEBUG2, "cupsdFindPolicyOp: No match found!"); return (NULL); } diff --git a/scheduler/policy.h b/scheduler/policy.h index 28aa6aab2..9a2ff7da5 100644 --- a/scheduler/policy.h +++ b/scheduler/policy.h @@ -32,7 +32,7 @@ typedef struct { char *name; /* Policy name */ int num_ops; /* Number of operations */ - location_t **ops; /* Operations */ + cupsd_location_t **ops; /* Operations */ } cupsd_policy_t; @@ -51,13 +51,13 @@ VAR cupsd_policy_t **Policies VALUE(NULL); */ extern cupsd_policy_t *cupsdAddPolicy(const char *policy); -extern location_t *cupsdAddPolicyOp(cupsd_policy_t *p, 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, client_t *con, +extern int cupsdCheckPolicy(cupsd_policy_t *p, cupsd_client_t *con, const char *owner); extern void cupsdDeleteAllPolicies(void); extern cupsd_policy_t *cupsdFindPolicy(const char *policy); -extern location_t *cupsdFindPolicyOp(cupsd_policy_t *p, ipp_op_t op); +extern cupsd_location_t *cupsdFindPolicyOp(cupsd_policy_t *p, ipp_op_t op); /* diff --git a/scheduler/ppds.c b/scheduler/ppds.c index 715c8e68b..e31af3c39 100644 --- a/scheduler/ppds.c +++ b/scheduler/ppds.c @@ -116,7 +116,7 @@ LoadPPDs(const char *d) /* I - Directory to scan... */ if ((ppds = malloc(sizeof(ppd_info_t) * num_ppds)) == NULL) { - LogMessage(L_ERROR, "LoadPPDs: Unable to allocate memory for %d PPD files!", + cupsdLogMessage(L_ERROR, "LoadPPDs: Unable to allocate memory for %d PPD files!", num_ppds); num_ppds = 0; alloc_ppds = 0; @@ -131,7 +131,7 @@ LoadPPDs(const char *d) /* I - Directory to scan... */ cupsFileClose(fp); - LogMessage(L_INFO, "LoadPPDs: Read \"%s\", %d PPDs...", filename, + cupsdLogMessage(L_INFO, "LoadPPDs: Read \"%s\", %d PPDs...", filename, num_ppds); /* @@ -146,7 +146,7 @@ LoadPPDs(const char *d) /* I - Directory to scan... */ } else { - LogMessage(L_ERROR, "LoadPPDs: Unable to read \"%s\" - %s", filename, + cupsdLogMessage(L_ERROR, "LoadPPDs: Unable to read \"%s\" - %s", filename, strerror(errno)); num_ppds = 0; } @@ -199,15 +199,15 @@ LoadPPDs(const char *d) /* I - Directory to scan... */ cupsFileClose(fp); - LogMessage(L_INFO, "LoadPPDs: Wrote \"%s\", %d PPDs...", filename, + cupsdLogMessage(L_INFO, "LoadPPDs: Wrote \"%s\", %d PPDs...", filename, num_ppds); } else - LogMessage(L_ERROR, "LoadPPDs: Unable to write \"%s\" - %s", filename, + cupsdLogMessage(L_ERROR, "LoadPPDs: Unable to write \"%s\" - %s", filename, strerror(errno)); } else - LogMessage(L_INFO, "LoadPPDs: No new or changed PPDs..."); + cupsdLogMessage(L_INFO, "LoadPPDs: No new or changed PPDs..."); /* * Create the list of PPDs... @@ -453,7 +453,7 @@ load_ppds(const char *d, /* I - Actual directory */ if ((dir = opendir(d)) == NULL) { - LogMessage(L_ERROR, "LoadPPDs: Unable to open PPD directory \"%s\": %s", + cupsdLogMessage(L_ERROR, "LoadPPDs: Unable to open PPD directory \"%s\": %s", d, strerror(errno)); return; } @@ -719,7 +719,7 @@ load_ppds(const char *d, /* I - Actual directory */ * Allocate memory for the new PPD file... */ - LogMessage(L_DEBUG, "LoadPPDs: Adding ppd \"%s\"...", name); + cupsdLogMessage(L_DEBUG, "LoadPPDs: Adding ppd \"%s\"...", name); if (num_ppds >= alloc_ppds) { @@ -734,7 +734,7 @@ load_ppds(const char *d, /* I - Actual directory */ if (ppd == NULL) { - LogMessage(L_ERROR, "load_ppds: Ran out of memory for %d PPD files!", + cupsdLogMessage(L_ERROR, "load_ppds: Ran out of memory for %d PPD files!", alloc_ppds + 32); closedir(dir); return; @@ -748,7 +748,7 @@ load_ppds(const char *d, /* I - Actual directory */ num_ppds ++; } else - LogMessage(L_DEBUG, "LoadPPDs: Updating ppd \"%s\"...", name); + cupsdLogMessage(L_DEBUG, "LoadPPDs: Updating ppd \"%s\"...", name); /* * Zero the PPD record and copy the info over... diff --git a/scheduler/printers.c b/scheduler/printers.c index 3e7c73489..7bb07d4f7 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -23,25 +23,25 @@ * * Contents: * - * AddPrinter() - Add a printer to the system. - * AddPrinterFilter() - Add a MIME filter for a printer. - * AddPrinterHistory() - Add the current printer state to the history. - * AddPrinterUser() - Add a user to the ACL. - * DeleteAllPrinters() - Delete all printers from the system. - * DeletePrinter() - Delete a printer from the system. - * DeletePrinterFilters() - Delete all MIME filters for a printer. - * FindPrinter() - Find a printer in the list. - * FreePrinterUsers() - Free allow/deny users. - * LoadAllPrinters() - Load printers from the printers.conf file. - * SaveAllPrinters() - Save all printer definitions to the printers.conf - * SetPrinterAttrs() - Set printer attributes based upon the PPD file. - * SetPrinterReasons() - Set/update the reasons strings. - * SetPrinterState() - Update the current state of a printer. + * cupsdAddPrinter() - Add a printer to the system. + * cupsdAddPrinterFilter() - Add a MIME filter for a printer. + * cupsdAddPrinterHistory() - Add the current printer state to the history. + * cupsdAddPrinterUser() - Add a user to the ACL. + * cupsdDeleteAllPrinters() - Delete all printers from the system. + * cupsdDeletePrinter() - Delete a printer from the system. + * cupsdDeletePrinterFilters() - Delete all MIME filters for a printer. + * cupsdFindPrinter() - Find a printer in the list. + * cupsdFreePrinterUsers() - Free allow/deny users. + * cupsdLoadAllPrinters() - Load printers from the printers.conf file. + * cupsdSaveAllPrinters() - Save all printer definitions to the printers.conf + * 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. - * StopPrinter() - Stop a printer from printing any jobs... - * ValidateDest() - Validate a printer/class destination. - * WritePrintcap() - Write a pseudo-printcap file for older + * 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 @@ -63,26 +63,26 @@ static int compare_printers(void *first, void *second, void *data); #ifdef __sgi -static void write_irix_config(printer_t *p); -static void write_irix_state(printer_t *p); +static void write_irix_config(cupsd_printer_t *p); +static void write_irix_state(cupsd_printer_t *p); #endif /* __sgi */ /* - * 'AddPrinter()' - Add a printer to the system. + * 'cupsdAddPrinter()' - Add a printer to the system. */ -printer_t * /* O - New printer */ -AddPrinter(const char *name) /* I - Name of printer */ +cupsd_printer_t * /* O - New printer */ +cupsdAddPrinter(const char *name) /* I - Name of printer */ { - printer_t *p; /* New printer */ + cupsd_printer_t *p; /* New printer */ /* * Range check input... */ - LogMessage(L_DEBUG2, "AddPrinter(\"%s\")", name ? name : "(null)"); + cupsdLogMessage(L_DEBUG2, "cupsdAddPrinter(\"%s\")", name ? name : "(null)"); if (name == NULL) return (NULL); @@ -91,30 +91,30 @@ AddPrinter(const char *name) /* I - Name of printer */ * Create a new printer entity... */ - if ((p = calloc(1, sizeof(printer_t))) == NULL) + if ((p = calloc(1, sizeof(cupsd_printer_t))) == NULL) { - LogMessage(L_CRIT, "Unable to allocate memory for printer - %s", + cupsdLogMessage(L_CRIT, "Unable to allocate memory for printer - %s", strerror(errno)); return (NULL); } - SetString(&p->name, name); - SetString(&p->info, name); - SetString(&p->hostname, ServerName); + cupsdSetString(&p->name, name); + cupsdSetString(&p->info, name); + cupsdSetString(&p->hostname, ServerName); - SetStringf(&p->uri, "ipp://%s:%d/printers/%s", ServerName, LocalPort, name); - SetStringf(&p->device_uri, "file:/dev/null"); + cupsdSetStringf(&p->uri, "ipp://%s:%d/printers/%s", ServerName, LocalPort, name); + cupsdSetStringf(&p->device_uri, "file:/dev/null"); p->state = IPP_PRINTER_STOPPED; p->accepting = 0; p->shared = 1; p->filetype = mimeAddType(MimeDatabase, "printer", name); - SetString(&p->job_sheets[0], "none"); - SetString(&p->job_sheets[1], "none"); + cupsdSetString(&p->cupsd_job_sheets[0], "none"); + cupsdSetString(&p->cupsd_job_sheets[1], "none"); - SetString(&p->error_policy, "stop-printer"); - SetString(&p->op_policy, DefaultPolicy); + cupsdSetString(&p->error_policy, "stop-printer"); + cupsdSetString(&p->op_policy, DefaultPolicy); p->op_policy_ptr = DefaultPolicyPtr; @@ -134,7 +134,7 @@ AddPrinter(const char *name) /* I - Name of printer */ * Write a new /etc/printcap or /var/spool/lp/pstatus file. */ - WritePrintcap(); + cupsdWritePrintcap(); /* * Return the new printer... @@ -145,11 +145,11 @@ AddPrinter(const char *name) /* I - Name of printer */ /* - * 'AddPrinterFilter()' - Add a MIME filter for a printer. + * 'cupsdAddPrinterFilter()' - Add a MIME filter for a printer. */ void -AddPrinterFilter(printer_t *p, /* I - Printer to add to */ +cupsdAddPrinterFilter(cupsd_printer_t *p, /* I - Printer to add to */ const char *filter) /* I - Filter to add */ { int i; /* Looping var */ @@ -175,7 +175,7 @@ AddPrinterFilter(printer_t *p, /* I - Printer to add to */ if (sscanf(filter, "%15[^/]/%31s%d%1023s", super, type, &cost, program) != 4) { - LogMessage(L_ERROR, "AddPrinterFilter: Invalid filter string \"%s\"!", + cupsdLogMessage(L_ERROR, "cupsdAddPrinterFilter: Invalid filter string \"%s\"!", filter); return; } @@ -191,7 +191,7 @@ AddPrinterFilter(printer_t *p, /* I - Printer to add to */ !strcasecmp((*temptype)->super, super)) && (type[0] == '*' || !strcasecmp((*temptype)->type, type))) { - LogMessage(L_DEBUG2, "Adding filter %s/%s %s/%s %d %s", + cupsdLogMessage(L_DEBUG2, "Adding filter %s/%s %s/%s %d %s", (*temptype)->super, (*temptype)->type, p->filetype->super, p->filetype->type, cost, program); @@ -201,11 +201,11 @@ AddPrinterFilter(printer_t *p, /* I - Printer to add to */ /* - * 'AddPrinterHistory()' - Add the current printer state to the history. + * 'cupsdAddPrinterHistory()' - Add the current printer state to the history. */ void -AddPrinterHistory(printer_t *p) /* I - Printer */ +cupsdAddPrinterHistory(cupsd_printer_t *p) /* I - Printer */ { ipp_t *history; /* History collection */ @@ -261,11 +261,11 @@ AddPrinterHistory(printer_t *p) /* I - Printer */ /* - * 'AddPrinterUser()' - Add a user to the ACL. + * 'cupsdAddPrinterUser()' - Add a user to the ACL. */ void -AddPrinterUser(printer_t *p, /* I - Printer */ +cupsdAddPrinterUser(cupsd_printer_t *p, /* I - Printer */ const char *username) /* I - User */ { const char **temp; /* Temporary array pointer */ @@ -291,15 +291,15 @@ AddPrinterUser(printer_t *p, /* I - Printer */ /* - * 'CreateCommonData()' - Create the common printer data. + * 'cupsdCreateCommonData()' - Create the common printer data. */ void -CreateCommonData(void) +cupsdCreateCommonData(void) { int i; /* Looping var */ ipp_attribute_t *attr; /* Attribute data */ - printer_t *p; /* Current printer */ + 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 */ @@ -474,7 +474,7 @@ CreateCommonData(void) "job-sheets-supported", NumBanners + 1, NULL, NULL); if (attr == NULL) - LogMessage(L_EMERG, "SetPrinterAttrs: Unable to allocate memory for " + cupsdLogMessage(L_EMERG, "cupsdSetPrinterAttrs: Unable to allocate memory for " "job-sheets-supported attribute: %s!", strerror(errno)); else if (!Classification || ClassifyOverride) @@ -492,9 +492,9 @@ CreateCommonData(void) * Loop through the printers and update the op_policy_ptr values... */ - for (p = (printer_t *)cupsArrayFirst(Printers); + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) if ((p->op_policy_ptr = cupsdFindPolicy(p->op_policy)) == NULL) p->op_policy_ptr = DefaultPolicyPtr; } @@ -502,29 +502,29 @@ CreateCommonData(void) /* - * 'DeleteAllPrinters()' - Delete all printers from the system. + * 'cupsdDeleteAllPrinters()' - Delete all printers from the system. */ void -DeleteAllPrinters(void) +cupsdDeleteAllPrinters(void) { - printer_t *p; /* Pointer to current printer/class */ + cupsd_printer_t *p; /* Pointer to current printer/class */ - for (p = (printer_t *)cupsArrayFirst(Printers); + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) if (!(p->type & CUPS_PRINTER_CLASS)) - DeletePrinter(p, 0); + cupsdDeletePrinter(p, 0); } /* - * 'DeletePrinter()' - Delete a printer from the system. + * 'cupsdDeletePrinter()' - Delete a printer from the system. */ void -DeletePrinter(printer_t *p, /* I - Printer to delete */ +cupsdDeletePrinter(cupsd_printer_t *p, /* I - Printer to delete */ int update) /* I - Update printers.conf? */ { int i; /* Looping var */ @@ -533,7 +533,7 @@ DeletePrinter(printer_t *p, /* I - Printer to delete */ #endif /* __sgi */ - DEBUG_printf(("DeletePrinter(%08x): p->name = \"%s\"...\n", p, p->name)); + DEBUG_printf(("cupsdDeletePrinter(%08x): p->name = \"%s\"...\n", p, p->name)); /* * If this printer is the next for browsing, point to the next one... @@ -542,7 +542,7 @@ DeletePrinter(printer_t *p, /* I - Printer to delete */ if (p == BrowseNext) { cupsArrayFind(Printers, p); - BrowseNext = (printer_t *)cupsArrayNext(Printers); + BrowseNext = (cupsd_printer_t *)cupsArrayNext(Printers); } /* @@ -555,7 +555,7 @@ DeletePrinter(printer_t *p, /* I - Printer to delete */ * Stop printing on this printer... */ - StopPrinter(p, update); + cupsdStopPrinter(p, update); /* * Remove the dummy interface/icon/option files under IRIX... @@ -588,9 +588,9 @@ DeletePrinter(printer_t *p, /* I - Printer to delete */ if (p == DefaultPrinter) { - DefaultPrinter = (printer_t *)cupsArrayFirst(Printers); + DefaultPrinter = (cupsd_printer_t *)cupsArrayFirst(Printers); - WritePrintcap(); + cupsdWritePrintcap(); } /* @@ -599,8 +599,8 @@ DeletePrinter(printer_t *p, /* I - Printer to delete */ if (!(p->type & CUPS_PRINTER_IMPLICIT)) { - DeletePrinterFromClasses(p); - SendBrowseDelete(p); + cupsdDeletePrinterFromClasses(p); + cupsdSendBrowseDelete(p); } /* @@ -623,23 +623,23 @@ DeletePrinter(printer_t *p, /* I - Printer to delete */ ippDelete(p->attrs); - DeletePrinterFilters(p); + cupsdDeletePrinterFilters(p); - FreePrinterUsers(p); - FreeQuotas(p); + cupsdFreePrinterUsers(p); + cupsdFreeQuotas(p); - ClearString(&p->uri); - ClearString(&p->hostname); - ClearString(&p->name); - ClearString(&p->location); - ClearString(&p->make_model); - ClearString(&p->info); - ClearString(&p->job_sheets[0]); - ClearString(&p->job_sheets[1]); - ClearString(&p->device_uri); - ClearString(&p->port_monitor); - ClearString(&p->op_policy); - ClearString(&p->error_policy); + cupsdClearString(&p->uri); + cupsdClearString(&p->hostname); + cupsdClearString(&p->name); + cupsdClearString(&p->location); + cupsdClearString(&p->make_model); + cupsdClearString(&p->info); + cupsdClearString(&p->cupsd_job_sheets[0]); + cupsdClearString(&p->cupsd_job_sheets[1]); + cupsdClearString(&p->device_uri); + cupsdClearString(&p->port_monitor); + cupsdClearString(&p->op_policy); + cupsdClearString(&p->error_policy); free(p); @@ -647,16 +647,16 @@ DeletePrinter(printer_t *p, /* I - Printer to delete */ * Write a new /etc/printcap file... */ - WritePrintcap(); + cupsdWritePrintcap(); } /* - * 'DeletePrinterFilters()' - Delete all MIME filters for a printer. + * 'cupsdDeletePrinterFilters()' - Delete all MIME filters for a printer. */ void -DeletePrinterFilters(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 */ @@ -694,31 +694,31 @@ DeletePrinterFilters(printer_t *p) /* I - Printer to remove from */ /* - * 'FindDest()' - Find a destination in the list. + * 'cupsdFindDest()' - Find a destination in the list. */ -printer_t * /* O - Destination in list */ -FindDest(const char *name) /* I - Name of printer or class to find */ +cupsd_printer_t * /* O - Destination in list */ +cupsdFindDest(const char *name) /* I - Name of printer or class to find */ { - printer_t key; /* Search key */ + cupsd_printer_t key; /* Search key */ key.name = (char *)name; - return ((printer_t *)cupsArrayFind(Printers, &key)); + return ((cupsd_printer_t *)cupsArrayFind(Printers, &key)); } /* - * 'FindPrinter()' - Find a printer in the list. + * 'cupsdFindPrinter()' - Find a printer in the list. */ -printer_t * /* O - Printer in list */ -FindPrinter(const char *name) /* I - Name of printer to find */ +cupsd_printer_t * /* O - Printer in list */ +cupsdFindPrinter(const char *name) /* I - Name of printer to find */ { - printer_t *p; /* Printer in list */ + cupsd_printer_t *p; /* Printer in list */ - if ((p = FindDest(name)) != NULL && (p->type & CUPS_PRINTER_CLASS)) + if ((p = cupsdFindDest(name)) != NULL && (p->type & CUPS_PRINTER_CLASS)) return (NULL); else return (p); @@ -726,11 +726,11 @@ FindPrinter(const char *name) /* I - Name of printer to find */ /* - * 'FreePrinterUsers()' - Free allow/deny users. + * 'cupsdFreePrinterUsers()' - Free allow/deny users. */ void -FreePrinterUsers(printer_t *p) /* I - Printer */ +cupsdFreePrinterUsers(cupsd_printer_t *p) /* I - Printer */ { int i; /* Looping var */ @@ -749,18 +749,18 @@ FreePrinterUsers(printer_t *p) /* I - Printer */ /* - * 'LoadAllPrinters()' - Load printers from the printers.conf file. + * 'cupsdLoadAllPrinters()' - Load printers from the printers.conf file. */ void -LoadAllPrinters(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 */ - printer_t *p; /* Current printer */ + cupsd_printer_t *p; /* Current printer */ /* @@ -770,7 +770,7 @@ LoadAllPrinters(void) snprintf(line, sizeof(line), "%s/printers.conf", ServerRoot); if ((fp = cupsFileOpen(line, "r")) == NULL) { - LogMessage(L_ERROR, "LoadAllPrinters: Unable to open %s - %s", line, + cupsdLogMessage(L_ERROR, "cupsdLoadAllPrinters: Unable to open %s - %s", line, strerror(errno)); return; } @@ -801,9 +801,9 @@ LoadAllPrinters(void) * Add the printer and a base file type... */ - LogMessage(L_DEBUG, "LoadAllPrinters: Loading printer %s...", value); + cupsdLogMessage(L_DEBUG, "cupsdLoadAllPrinters: Loading printer %s...", value); - p = AddPrinter(value); + p = cupsdAddPrinter(value); p->accepting = 1; p->state = IPP_PRINTER_IDLE; @@ -816,7 +816,7 @@ LoadAllPrinters(void) } else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -829,8 +829,8 @@ LoadAllPrinters(void) * Close out the current printer... */ - SetPrinterAttrs(p); - AddPrinterHistory(p); + cupsdSetPrinterAttrs(p); + cupsdAddPrinterHistory(p); if (p->device_uri && strncmp(p->device_uri, "file:", 5) && p->state != IPP_PRINTER_STOPPED) @@ -861,34 +861,34 @@ LoadAllPrinters(void) } else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } } else if (!p) { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } else if (!strcasecmp(line, "Info")) { if (value) - SetString(&p->info, value); + cupsdSetString(&p->info, value); } else if (!strcasecmp(line, "Location")) { if (value) - SetString(&p->location, value); + cupsdSetString(&p->location, value); } else if (!strcasecmp(line, "DeviceURI")) { if (value) - SetString(&p->device_uri, value); + cupsdSetString(&p->device_uri, value); else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -896,12 +896,12 @@ LoadAllPrinters(void) else if (!strcasecmp(line, "PortMonitor")) { if (value && strcmp(value, "none")) - SetString(&p->port_monitor, value); + cupsdSetString(&p->port_monitor, value); else if (value) - ClearString(&p->port_monitor); + cupsdClearString(&p->port_monitor); else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -918,7 +918,7 @@ LoadAllPrinters(void) p->state = IPP_PRINTER_STOPPED; else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -950,7 +950,7 @@ LoadAllPrinters(void) p->accepting = 0; else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -973,7 +973,7 @@ LoadAllPrinters(void) p->shared = 0; else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -991,7 +991,7 @@ LoadAllPrinters(void) if (*valueptr) *valueptr++ = '\0'; - SetString(&p->job_sheets[0], value); + cupsdSetString(&p->cupsd_job_sheets[0], value); while (isspace(*valueptr & 255)) valueptr ++; @@ -1003,12 +1003,12 @@ LoadAllPrinters(void) if (*valueptr) *valueptr++ = '\0'; - SetString(&p->job_sheets[1], value); + cupsdSetString(&p->cupsd_job_sheets[1], value); } } else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -1018,11 +1018,11 @@ LoadAllPrinters(void) if (value) { p->deny_users = 0; - AddPrinterUser(p, value); + cupsdAddPrinterUser(p, value); } else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -1032,11 +1032,11 @@ LoadAllPrinters(void) if (value) { p->deny_users = 1; - AddPrinterUser(p, value); + cupsdAddPrinterUser(p, value); } else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -1047,7 +1047,7 @@ LoadAllPrinters(void) p->quota_period = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -1058,7 +1058,7 @@ LoadAllPrinters(void) p->page_limit = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -1069,7 +1069,7 @@ LoadAllPrinters(void) p->k_limit = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -1077,10 +1077,10 @@ LoadAllPrinters(void) else if (!strcasecmp(line, "OpPolicy")) { if (value) - SetString(&p->op_policy, value); + cupsdSetString(&p->op_policy, value); else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -1088,10 +1088,10 @@ LoadAllPrinters(void) else if (!strcasecmp(line, "ErrorPolicy")) { if (value) - SetString(&p->error_policy, value); + cupsdSetString(&p->error_policy, value); else { - LogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of printers.conf.", linenum); return; } @@ -1102,7 +1102,7 @@ LoadAllPrinters(void) * Something else we don't understand... */ - LogMessage(L_ERROR, "Unknown configuration directive %s on line %d of printers.conf.", + cupsdLogMessage(L_ERROR, "Unknown configuration directive %s on line %d of printers.conf.", line, linenum); } } @@ -1112,18 +1112,18 @@ LoadAllPrinters(void) /* - * 'SaveAllPrinters()' - Save all printer definitions to the printers.conf + * 'cupsdSaveAllPrinters()' - Save all printer definitions to the printers.conf * file. */ void -SaveAllPrinters(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 */ - printer_t *printer; /* Current printer class */ + cupsd_printer_t *printer; /* Current printer class */ time_t curtime; /* Current time */ struct tm *curdate; /* Current date */ @@ -1136,18 +1136,18 @@ SaveAllPrinters(void) snprintf(backup, sizeof(backup), "%s/printers.conf.O", ServerRoot); if (rename(temp, backup)) - LogMessage(L_ERROR, "Unable to backup printers.conf - %s", strerror(errno)); + cupsdLogMessage(L_ERROR, "Unable to backup printers.conf - %s", strerror(errno)); if ((fp = cupsFileOpen(temp, "w")) == NULL) { - LogMessage(L_ERROR, "Unable to save printers.conf - %s", strerror(errno)); + cupsdLogMessage(L_ERROR, "Unable to save printers.conf - %s", strerror(errno)); if (rename(backup, temp)) - LogMessage(L_ERROR, "Unable to restore printers.conf - %s", strerror(errno)); + cupsdLogMessage(L_ERROR, "Unable to restore printers.conf - %s", strerror(errno)); return; } else - LogMessage(L_INFO, "Saving printers.conf..."); + cupsdLogMessage(L_INFO, "Saving printers.conf..."); /* * Restrict access to the file... @@ -1171,9 +1171,9 @@ SaveAllPrinters(void) * Write each local printer known to the system... */ - for (printer = (printer_t *)cupsArrayFirst(Printers); + for (printer = (cupsd_printer_t *)cupsArrayFirst(Printers); printer; - printer = (printer_t *)cupsArrayNext(Printers)) + printer = (cupsd_printer_t *)cupsArrayNext(Printers)) { /* * Skip remote destinations and printer classes... @@ -1223,8 +1223,8 @@ SaveAllPrinters(void) else cupsFilePuts(fp, "Shared No\n"); - cupsFilePrintf(fp, "JobSheets %s %s\n", printer->job_sheets[0], - printer->job_sheets[1]); + cupsFilePrintf(fp, "JobSheets %s %s\n", printer->cupsd_job_sheets[0], + printer->cupsd_job_sheets[1]); cupsFilePrintf(fp, "QuotaPeriod %d\n", printer->quota_period); cupsFilePrintf(fp, "PageLimit %d\n", printer->page_limit); @@ -1255,20 +1255,20 @@ SaveAllPrinters(void) /* - * 'SetPrinterAttrs()' - Set printer attributes based upon the PPD file. + * 'cupsdSetPrinterAttrs()' - Set printer attributes based upon the PPD file. */ void -SetPrinterAttrs(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 */ - location_t *auth; /* Pointer to authentication element */ + cupsd_location_t *auth; /* Pointer to authentication element */ const char *auth_supported; /* Authentication supported */ - cups_ptype_t printer_type; /* Printer type data */ + 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 */ @@ -1288,7 +1288,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ }; - DEBUG_printf(("SetPrinterAttrs: entering name = %s, type = %x\n", p->name, + DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name, p->type)); /* @@ -1296,13 +1296,13 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ */ if (!CommonData) - CreateCommonData(); + cupsdCreateCommonData(); /* * Clear out old filters, if any... */ - DeletePrinterFilters(p); + cupsdDeletePrinterFilters(p); /* * Figure out the authentication that is required for the printer. @@ -1316,7 +1316,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ else snprintf(resource, sizeof(resource), "/printers/%s", p->name); - if ((auth = FindBest(resource, HTTP_POST)) == NULL) + if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL) auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB); if (auth) @@ -1388,13 +1388,13 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ if (attr != NULL) { attr->values[0].string.text = strdup(Classification ? - Classification : p->job_sheets[0]); + Classification : p->cupsd_job_sheets[0]); attr->values[1].string.text = strdup(Classification ? - Classification : p->job_sheets[1]); + Classification : p->cupsd_job_sheets[1]); } } - printer_type = p->type; + cupsd_printer_type = p->type; p->raw = 0; @@ -1526,11 +1526,11 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ "pages-per-minute", ppd->throughput); if (ppd->nickname) - SetString(&p->make_model, ppd->nickname); + cupsdSetString(&p->make_model, ppd->nickname); else if (ppd->modelname) - SetString(&p->make_model, ppd->modelname); + cupsdSetString(&p->make_model, ppd->modelname); else - SetString(&p->make_model, "Bad PPD File"); + cupsdSetString(&p->make_model, "Bad PPD File"); ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-make-and-model", NULL, p->make_model); @@ -1555,7 +1555,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ if (num_media == 0) { - LogMessage(L_CRIT, "SetPrinterAttrs: The PPD file for printer %s " + cupsdLogMessage(L_CRIT, "cupsdSetPrinterAttrs: The PPD file for printer %s " "contains no media options and is therefore " "invalid!", p->name); } @@ -1663,7 +1663,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ * handle "raw" printing by users. */ - AddPrinterFilter(p, "application/vnd.cups-raw 0 -"); + cupsdAddPrinterFilter(p, "application/vnd.cups-raw 0 -"); /* * Add any filters in the PPD file... @@ -1673,7 +1673,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ for (i = 0; i < ppd->num_filters; i ++) { DEBUG_printf(("ppd->filters[%d] = \"%s\"\n", i, ppd->filters[i])); - AddPrinterFilter(p, ppd->filters[i]); + cupsdAddPrinterFilter(p, ppd->filters[i]); } if (ppd->num_filters == 0) @@ -1682,7 +1682,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ * If there are no filters, add a PostScript printing filter. */ - AddPrinterFilter(p, "application/vnd.cups-postscript 0 -"); + cupsdAddPrinterFilter(p, "application/vnd.cups-postscript 0 -"); } /* @@ -1729,7 +1729,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ ppdClose(ppd); - printer_type = p->type; + cupsd_printer_type = p->type; } else if (!access(filename, 0)) { @@ -1739,15 +1739,15 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ pstatus = ppdLastError(&pline); - LogMessage(L_ERROR, "PPD file for %s cannot be loaded!", p->name); + cupsdLogMessage(L_ERROR, "PPD file for %s cannot be loaded!", p->name); if (pstatus <= PPD_ALLOC_ERROR) - LogMessage(L_ERROR, "%s", strerror(errno)); + cupsdLogMessage(L_ERROR, "%s", strerror(errno)); else - LogMessage(L_ERROR, "%s on line %d.", ppdErrorString(pstatus), + cupsdLogMessage(L_ERROR, "%s on line %d.", ppdErrorString(pstatus), pline); - LogMessage(L_INFO, "Hint: Run \"cupstestppd %s\" and fix any errors.", + cupsdLogMessage(L_INFO, "Hint: Run \"cupstestppd %s\" and fix any errors.", filename); /* @@ -1755,13 +1755,13 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ * handle "raw" printing by users. */ - AddPrinterFilter(p, "application/vnd.cups-raw 0 -"); + cupsdAddPrinterFilter(p, "application/vnd.cups-raw 0 -"); /* * Add a PostScript filter, since this is still possibly PS printer. */ - AddPrinterFilter(p, "application/vnd.cups-postscript 0 -"); + cupsdAddPrinterFilter(p, "application/vnd.cups-postscript 0 -"); } else { @@ -1782,7 +1782,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ snprintf(filename, sizeof(filename), "*/* 0 %s/interfaces/%s", ServerRoot, p->name); - AddPrinterFilter(p, filename); + cupsdAddPrinterFilter(p, filename); } else if (p->device_uri && !strncmp(p->device_uri, "ipp://", 6) && @@ -1793,7 +1793,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ * Tell the client this is really a hard-wired remote printer. */ - printer_type |= CUPS_PRINTER_REMOTE; + cupsd_printer_type |= CUPS_PRINTER_REMOTE; /* * Point the printer-uri-supported attribute to the @@ -1847,9 +1847,9 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ p->type &= ~CUPS_PRINTER_NOT_SHARED; ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-type", - printer_type); + cupsd_printer_type); - DEBUG_printf(("SetPrinterAttrs: leaving name = %s, type = %x\n", p->name, + DEBUG_printf(("cupsdSetPrinterAttrs: leaving name = %s, type = %x\n", p->name, p->type)); #ifdef __sgi @@ -1864,11 +1864,11 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ /* - * 'SetPrinterReasons()' - Set/update the reasons strings. + * 'cupsdSetPrinterReasons()' - Set/update the reasons strings. */ void -SetPrinterReasons(printer_t *p, /* I - Printer */ +cupsdSetPrinterReasons(cupsd_printer_t *p, /* I - Printer */ const char *s) /* I - Reasons strings */ { int i; /* Looping var */ @@ -1965,11 +1965,11 @@ SetPrinterReasons(printer_t *p, /* I - Printer */ /* - * 'SetPrinterState()' - Update the current state of a printer. + * 'cupsdSetPrinterState()' - Update the current state of a printer. */ void -SetPrinterState(printer_t *p, /* I - Printer to change */ +cupsdSetPrinterState(cupsd_printer_t *p, /* I - Printer to change */ ipp_pstate_t s, /* I - New state */ int update) /* I - Update printers.conf? */ { @@ -2005,7 +2005,7 @@ SetPrinterState(printer_t *p, /* I - Printer to change */ #endif /* __sgi */ } - AddPrinterHistory(p); + cupsdAddPrinterHistory(p); /* * Save the printer configuration if a printer goes from idle or processing @@ -2016,29 +2016,29 @@ SetPrinterState(printer_t *p, /* I - Printer to change */ update) { if (p->type & CUPS_PRINTER_CLASS) - SaveAllClasses(); + cupsdSaveAllClasses(); else - SaveAllPrinters(); + cupsdSaveAllPrinters(); } } /* - * 'StopPrinter()' - Stop a printer from printing any jobs... + * 'cupsdStopPrinter()' - Stop a printer from printing any jobs... */ void -StopPrinter(printer_t *p, /* I - Printer to stop */ +cupsdStopPrinter(cupsd_printer_t *p, /* I - Printer to stop */ int update) /* I - Update printers.conf? */ { - job_t *job; /* Active print job */ + cupsd_job_t *job; /* Active print job */ /* * Set the printer state... */ - SetPrinterState(p, IPP_PRINTER_STOPPED, update); + cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, update); /* * See if we have a job printing on this printer... @@ -2050,13 +2050,13 @@ StopPrinter(printer_t *p, /* I - Printer to stop */ * Get pointer to job... */ - job = (job_t *)p->job; + job = (cupsd_job_t *)p->job; /* * Stop it... */ - StopJob(job->id, 0); + cupsdStopJob(job->id, 0); /* * Reset the state to pending... @@ -2064,28 +2064,28 @@ StopPrinter(printer_t *p, /* I - Printer to stop */ job->state->values[0].integer = IPP_JOB_PENDING; - SaveJob(job->id); + cupsdSaveJob(job->id); } } /* - * 'ValidateDest()' - Validate a printer/class destination. + * 'cupsdValidateDest()' - Validate a printer/class destination. */ const char * /* O - Printer or class name */ -ValidateDest(const char *hostname, /* I - Host name */ +cupsdValidateDest(const char *hostname, /* I - Host name */ const char *resource, /* I - Resource name */ cups_ptype_t *dtype, /* O - Type (printer or class) */ - printer_t **printer) /* O - Printer pointer */ + cupsd_printer_t **printer) /* O - Printer pointer */ { - printer_t *p; /* Current printer */ + cupsd_printer_t *p; /* Current printer */ char localname[1024], /* Localized hostname */ *lptr, /* Pointer into localized hostname */ *sptr; /* Pointer into server name */ - DEBUG_printf(("ValidateDest(\"%s\", \"%s\", %p, %p)\n", hostname, resource, + DEBUG_printf(("cupsdValidateDest(\"%s\", \"%s\", %p, %p)\n", hostname, resource, dtype, printer)); /* @@ -2130,7 +2130,7 @@ ValidateDest(const char *hostname, /* I - Host name */ * See if the printer or class name exists... */ - p = FindDest(resource); + p = cupsdFindDest(resource); if (p == NULL && strchr(resource, '@') == NULL) return (NULL); @@ -2187,9 +2187,9 @@ ValidateDest(const char *hostname, /* I - Host name */ * Find a matching printer or class... */ - for (p = (printer_t *)cupsArrayFirst(Printers); + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) if (!strcasecmp(p->hostname, localname) && !strcasecmp(p->name, resource)) { @@ -2206,15 +2206,15 @@ ValidateDest(const char *hostname, /* I - Host name */ /* - * 'WritePrintcap()' - Write a pseudo-printcap file for older applications + * 'cupsdWritePrintcap()' - Write a pseudo-printcap file for older applications * that need it... */ void -WritePrintcap(void) +cupsdWritePrintcap(void) { cups_file_t *fp; /* printcap file */ - printer_t *p; /* Current printer */ + cupsd_printer_t *p; /* Current printer */ #ifdef __sgi @@ -2274,9 +2274,9 @@ WritePrintcap(void) cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", DefaultPrinter->name, DefaultPrinter->info, ServerName, DefaultPrinter->name); - for (p = (printer_t *)cupsArrayFirst(Printers); + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) if (p != DefaultPrinter) cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info, ServerName, p->name); @@ -2304,18 +2304,18 @@ WritePrintcap(void) */ cupsFilePuts(fp, "_all:all="); - for (p = (printer_t *)cupsArrayFirst(Printers); + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; - p = (printer_t *)cupsArrayCurrent(Printers)) + p = (cupsd_printer_t *)cupsArrayCurrent(Printers)) cupsFilePrintf(fp, "%s%c", p->name, cupsArrayNext(Printers) ? ',' : '\n'); if (DefaultPrinter) cupsFilePrintf(fp, "_default:use=%s\n", DefaultPrinter->name); - for (p = (printer_t *)cupsArrayFirst(Printers); + for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; - p = (printer_t *)cupsArrayNext(Printers)) + p = (cupsd_printer_t *)cupsArrayNext(Printers)) cupsFilePrintf(fp, "%s:\\\n" "\t:bsdaddr=%s,%s:\\\n" "\t:description=%s:\n", @@ -2409,8 +2409,8 @@ compare_printers(void *first, /* I - First printer */ void *second, /* I - Second printer */ void *data) /* I - App data (not used) */ { - return (strcasecmp(((printer_t *)first)->name, - ((printer_t *)second)->name)); + return (strcasecmp(((cupsd_printer_t *)first)->name, + ((cupsd_printer_t *)second)->name)); } @@ -2421,7 +2421,7 @@ compare_printers(void *first, /* I - First printer */ */ static void -write_irix_config(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 */ @@ -2547,7 +2547,7 @@ write_irix_config(printer_t *p) /* I - Printer to update */ */ static void -write_irix_state(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 */ diff --git a/scheduler/printers.h b/scheduler/printers.h index 3159293d1..cc2eb00ec 100644 --- a/scheduler/printers.h +++ b/scheduler/printers.h @@ -32,14 +32,14 @@ typedef struct time_t next_update; /* Next update time */ int page_count, /* Count of pages */ k_count; /* Count of kilobytes */ -} quota_t; +} cupsd_quota_t; /* * Printer/class information structure... */ -typedef struct printer_s +typedef struct cupsd_printer_s { char *uri, /* Printer URI */ *hostname, /* Host printer resides on */ @@ -57,7 +57,7 @@ typedef struct printer_s int num_reasons; /* Number of printer-state-reasons */ char *reasons[16]; /* printer-state-reasons strings */ time_t state_time; /* Time at this state */ - char *job_sheets[2]; /* Banners/job sheets */ + char *cupsd_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 */ @@ -68,19 +68,19 @@ typedef struct printer_s 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 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 */ num_quotas; /* Number of quota records */ - quota_t *quotas; /* Quota records */ + cupsd_quota_t *quotas; /* Quota records */ int deny_users, /* 1 = deny, 0 = allow */ num_users; /* Number of allowed/denied users */ const char **users; /* Allowed/denied users */ int num_history; /* Number of history collections */ ipp_t **history; /* History data */ int sequence_number; /* Increasing sequence number */ -} printer_t; +} cupsd_printer_t; /* @@ -91,7 +91,7 @@ VAR ipp_t *CommonData VALUE(NULL); /* Common printer object attrs */ VAR cups_array_t *Printers VALUE(NULL); /* Printer list */ -VAR printer_t *DefaultPrinter VALUE(NULL); +VAR cupsd_printer_t *DefaultPrinter VALUE(NULL); /* Default printer */ VAR char *DefaultPolicy VALUE(NULL); /* Default policy name */ @@ -104,34 +104,34 @@ VAR cupsd_policy_t *DefaultPolicyPtr * Prototypes... */ -extern printer_t *AddPrinter(const char *name); -extern void AddPrinterFilter(printer_t *p, const char *filter); -extern void AddPrinterHistory(printer_t *p); -extern void AddPrinterUser(printer_t *p, const char *username); -extern quota_t *AddQuota(printer_t *p, const char *username); -extern void CreateCommonData(void); -extern void DeleteAllPrinters(void); -extern void DeletePrinter(printer_t *p, int update); -extern void DeletePrinterFilters(printer_t *p); -extern printer_t *FindDest(const char *name); -extern printer_t *FindPrinter(const char *name); -extern quota_t *FindQuota(printer_t *p, const char *username); -extern void FreePrinterUsers(printer_t *p); -extern void FreeQuotas(printer_t *p); -extern void LoadAllPrinters(void); -extern void SaveAllPrinters(void); -extern void SetPrinterAttrs(printer_t *p); -extern void SetPrinterReasons(printer_t *p, const char *s); -extern void SetPrinterState(printer_t *p, ipp_pstate_t s, int update); -#define StartPrinter(p,u) SetPrinterState((p), IPP_PRINTER_IDLE, (u)) -extern void StopPrinter(printer_t *p, int update); -extern quota_t *UpdateQuota(printer_t *p, const char *username, +extern cupsd_printer_t *cupsdAddPrinter(const char *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 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 void cupsdFreePrinterUsers(cupsd_printer_t *p); +extern void cupsdFreeQuotas(cupsd_printer_t *p); +extern void cupsdLoadAllPrinters(void); +extern void cupsdSaveAllPrinters(void); +extern void cupsdSetPrinterAttrs(cupsd_printer_t *p); +extern void cupsdSetPrinterReasons(cupsd_printer_t *p, const char *s); +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 const char *ValidateDest(const char *hostname, +extern const char *cupsdValidateDest(const char *hostname, const char *resource, cups_ptype_t *dtype, - printer_t **printer); -extern void WritePrintcap(void); + cupsd_printer_t **printer); +extern void cupsdWritePrintcap(void); extern char *cupsdSanitizeURI(const char *uri, char *buffer, int buflen); diff --git a/scheduler/process.c b/scheduler/process.c index 2b50818cf..38f6a41f9 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -71,14 +71,14 @@ cupsdStartProcess( #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ - LogMessage(L_DEBUG2, "cupsdStartProcess(\"%s\", %p, %p, %d, %d, %d)", + cupsdLogMessage(L_DEBUG2, "cupsdStartProcess(\"%s\", %p, %p, %d, %d, %d)", command, argv, envp, infd, outfd, errfd); /* * Block signals before forking... */ - HoldSignals(); + cupsdHoldSignals(); if ((*pid = fork()) == 0) { @@ -184,7 +184,7 @@ cupsdStartProcess( signal(SIGCHLD, SIG_DFL); #endif /* HAVE_SIGSET */ - ReleaseSignals(); + cupsdReleaseSignals(); /* * Execute the command; if for some reason this doesn't work, @@ -206,12 +206,12 @@ cupsdStartProcess( * Error - couldn't fork a new process! */ - LogMessage(L_ERROR, "Unable to fork %s - %s.", command, strerror(errno)); + cupsdLogMessage(L_ERROR, "Unable to fork %s - %s.", command, strerror(errno)); *pid = 0; } - ReleaseSignals(); + cupsdReleaseSignals(); return (*pid); } diff --git a/scheduler/quotas.c b/scheduler/quotas.c index 200a9d910..ffb457ce8 100644 --- a/scheduler/quotas.c +++ b/scheduler/quotas.c @@ -23,10 +23,10 @@ * * Contents: * - * AddQuota() - Add a quota record for this printer and user. - * FindQuota() - Find a quota record. - * FreeQuotas() - Free quotas for a printer. - * UpdateQuota() - Update quota data for the specified printer and user. + * cupsdAddQuota() - Add a quota record for this printer and user. + * 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... */ @@ -41,27 +41,27 @@ * Local functions... */ -static int compare(const quota_t *q1, const quota_t *q2); +static int compare(const cupsd_quota_t *q1, const cupsd_quota_t *q2); /* - * 'AddQuota()' - Add a quota record for this printer and user. + * 'cupsdAddQuota()' - Add a quota record for this printer and user. */ -quota_t * /* O - Quota data */ -AddQuota(printer_t *p, /* I - Printer */ +cupsd_quota_t * /* O - Quota data */ +cupsdAddQuota(cupsd_printer_t *p, /* I - Printer */ const char *username) /* I - User */ { - quota_t *q; /* New quota data */ + cupsd_quota_t *q; /* New quota data */ if (!p || !username) return (NULL); if (p->num_quotas == 0) - q = malloc(sizeof(quota_t)); + q = malloc(sizeof(cupsd_quota_t)); else - q = realloc(p->quotas, sizeof(quota_t) * (p->num_quotas + 1)); + q = realloc(p->quotas, sizeof(cupsd_quota_t) * (p->num_quotas + 1)); if (!q) return (NULL); @@ -70,26 +70,26 @@ AddQuota(printer_t *p, /* I - Printer */ q += p->num_quotas; p->num_quotas ++; - memset(q, 0, sizeof(quota_t)); + memset(q, 0, sizeof(cupsd_quota_t)); strlcpy(q->username, username, sizeof(q->username)); if (p->num_quotas > 1) - qsort(p->quotas, p->num_quotas, sizeof(quota_t), + qsort(p->quotas, p->num_quotas, sizeof(cupsd_quota_t), (int (*)(const void *, const void *))compare); - return (FindQuota(p, username)); + return (cupsdFindQuota(p, username)); } /* - * 'FindQuota()' - Find a quota record. + * 'cupsdFindQuota()' - Find a quota record. */ -quota_t * /* O - Quota data */ -FindQuota(printer_t *p, /* I - Printer */ +cupsd_quota_t * /* O - Quota data */ +cupsdFindQuota(cupsd_printer_t *p, /* I - Printer */ const char *username) /* I - User */ { - quota_t *q, /* Quota data pointer */ + cupsd_quota_t *q, /* Quota data pointer */ match; /* Search data */ @@ -102,23 +102,23 @@ FindQuota(printer_t *p, /* I - Printer */ { strlcpy(match.username, username, sizeof(match.username)); - q = bsearch(&match, p->quotas, p->num_quotas, sizeof(quota_t), + q = bsearch(&match, p->quotas, p->num_quotas, sizeof(cupsd_quota_t), (int(*)(const void *, const void *))compare); } if (q) return (q); else - return (AddQuota(p, username)); + return (cupsdAddQuota(p, username)); } /* - * 'FreeQuotas()' - Free quotas for a printer. + * 'cupsdFreeQuotas()' - Free quotas for a printer. */ void -FreeQuotas(printer_t *p) /* I - Printer */ +cupsdFreeQuotas(cupsd_printer_t *p) /* I - Printer */ { if (!p) return; @@ -132,17 +132,17 @@ FreeQuotas(printer_t *p) /* I - Printer */ /* - * 'UpdateQuota()' - Update quota data for the specified printer and user. + * 'cupsdUpdateQuota()' - Update quota data for the specified printer and user. */ -quota_t * /* O - Quota data */ -UpdateQuota(printer_t *p, /* I - Printer */ +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 */ { - quota_t *q; /* Quota data */ - job_t *job; /* Current job */ + cupsd_quota_t *q; /* Quota data */ + cupsd_job_t *job; /* Current job */ time_t curtime; /* Current time */ ipp_attribute_t *attr; /* Job attribute */ @@ -153,10 +153,10 @@ UpdateQuota(printer_t *p, /* I - Printer */ if (!p->k_limit && !p->page_limit) return (NULL); - if ((q = FindQuota(p, username)) == NULL) + if ((q = cupsdFindQuota(p, username)) == NULL) return (NULL); - LogMessage(L_DEBUG, "UpdateQuota: p=%s username=%s pages=%d k=%d", + cupsdLogMessage(L_DEBUG, "cupsdUpdateQuota: p=%s username=%s pages=%d k=%d", p->name, username, pages, k); curtime = time(NULL); @@ -178,9 +178,9 @@ UpdateQuota(printer_t *p, /* I - Printer */ q->page_count = 0; q->k_count = 0; - for (job = (job_t *)cupsArrayFirst(Jobs); + for (job = (cupsd_job_t *)cupsArrayFirst(Jobs); job; - job = (job_t *)cupsArrayNext(Jobs)) + job = (cupsd_job_t *)cupsArrayNext(Jobs)) { if (strcasecmp(job->dest, p->name) != 0 || strcasecmp(job->username, q->username) != 0) @@ -199,7 +199,7 @@ UpdateQuota(printer_t *p, /* I - Printer */ if (attr->values[0].integer < curtime) { if (JobAutoPurge) - CancelJob(job->id, 1); + cupsdCancelJob(job->id, 1); continue; } @@ -225,8 +225,8 @@ UpdateQuota(printer_t *p, /* I - Printer */ */ static int /* O - Result of comparison */ -compare(const quota_t *q1, /* I - First quota record */ - const 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)); } diff --git a/scheduler/server.c b/scheduler/server.c index 654403c7a..0465a031c 100644 --- a/scheduler/server.c +++ b/scheduler/server.c @@ -23,8 +23,8 @@ * * Contents: * - * StartServer() - Start the server. - * StopServer() - Stop the server. + * cupsdStartServer() - Start the server. + * cupsdStopServer() - Stop the server. */ /* @@ -38,11 +38,11 @@ /* - * 'StartServer()' - Start the server. + * 'cupsdStartServer()' - Start the server. */ void -StartServer(void) +cupsdStartServer(void) { #ifdef HAVE_LIBSSL int i; /* Looping var */ @@ -85,41 +85,41 @@ StartServer(void) * Startup all the networking stuff... */ - StartListening(); - StartBrowsing(); - StartPolling(); + cupsdStartListening(); + cupsdStartBrowsing(); + cupsdStartPolling(); /* * Create a pipe for CGI processes... */ if (cupsdOpenPipe(CGIPipes)) - LogMessage(L_ERROR, "StartServer: Unable to create pipes for CGI status!"); + cupsdLogMessage(L_ERROR, "cupsdStartServer: Unable to create pipes for CGI status!"); else { CGIStatusBuffer = cupsdStatBufNew(CGIPipes[0], "[CGI]"); - LogMessage(L_DEBUG2, "StartServer: Adding fd %d to InputSet...", CGIPipes[0]); + cupsdLogMessage(L_DEBUG2, "cupsdStartServer: Adding fd %d to InputSet...", CGIPipes[0]); FD_SET(CGIPipes[0], InputSet); } } /* - * 'StopServer()' - Stop the server. + * 'cupsdStopServer()' - Stop the server. */ void -StopServer(void) +cupsdStopServer(void) { /* * Close all network clients and stop all jobs... */ - CloseAllClients(); - StopListening(); - StopPolling(); - StopBrowsing(); + cupsdCloseAllClients(); + cupsdStopListening(); + cupsdStopPolling(); + cupsdStopBrowsing(); if (Clients != NULL) { @@ -145,7 +145,7 @@ StopServer(void) if (CGIPipes[0] >= 0) { - LogMessage(L_DEBUG2, "StopServer: Removing fd %d from InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdStopServer: Removing fd %d from InputSet...", CGIPipes[0]); FD_CLR(CGIPipes[0], InputSet); diff --git a/scheduler/statbuf.c b/scheduler/statbuf.c index c66aaf570..d14a8cd09 100644 --- a/scheduler/statbuf.c +++ b/scheduler/statbuf.c @@ -299,9 +299,9 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb, /* I - Status buffer */ */ if (message[0] == '[') - LogMessage(*loglevel, "%s", message); + cupsdLogMessage(*loglevel, "%s", message); else - LogMessage(*loglevel, "%s %s", sb->prefix, message); + cupsdLogMessage(*loglevel, "%s %s", sb->prefix, message); } /* diff --git a/scheduler/subscriptions.c b/scheduler/subscriptions.c index 6eae9f9ff..a61b857d6 100644 --- a/scheduler/subscriptions.c +++ b/scheduler/subscriptions.c @@ -59,8 +59,8 @@ static void cupsd_delete_event(cupsd_event_t *event); void cupsdAddEvent( cupsd_eventmask_t event, /* I - Event */ - printer_t *dest, /* I - Printer associated with event */ - 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 */ { @@ -77,7 +77,7 @@ cupsdAddEvent( if (MaxEvents <= 0) { - LogMessage(L_WARN, "cupsdAddEvent: Discarding %s event since MaxEvents is %d!", + cupsdLogMessage(L_WARN, "cupsdAddEvent: Discarding %s event since MaxEvents is %d!", cupsdEventName(event), MaxEvents); return; } @@ -93,7 +93,7 @@ cupsdAddEvent( if (!Events) { - LogMessage(L_CRIT, "Unable to allocate memory for event cache - %s", + cupsdLogMessage(L_CRIT, "Unable to allocate memory for event cache - %s", strerror(errno)); return; } @@ -128,7 +128,7 @@ cupsdAddEvent( if ((temp = (cupsd_event_t *)calloc(1, sizeof(cupsd_event_t))) == NULL) { - LogMessage(L_CRIT, "Unable to allocate memory for event - %s", + cupsdLogMessage(L_CRIT, "Unable to allocate memory for event - %s", strerror(errno)); return; } @@ -296,7 +296,7 @@ cupsdAddEvent( if (temp) cupsdSaveAllSubscriptions(); else - LogMessage(L_DEBUG, "Discarding unused %s event...", + cupsdLogMessage(L_DEBUG, "Discarding unused %s event...", cupsdEventName(event)); } @@ -308,14 +308,14 @@ cupsdAddEvent( cupsd_subscription_t * /* O - New subscription object */ cupsdAddSubscription( unsigned mask, /* I - Event mask */ - printer_t *dest, /* I - Printer, if any */ - job_t *job, /* I - Job, if any */ + cupsd_printer_t *dest, /* I - Printer, if any */ + cupsd_job_t *job, /* I - Job, if any */ const char *uri) /* I - notify-recipient-uri, if any */ { cupsd_subscription_t *temp; /* New subscription object */ - LogMessage(L_DEBUG, "cupsdAddSubscription(mask=%x(%s), dest=%p(%s), job=%p(%d), uri=\"%s\")", + 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); @@ -330,7 +330,7 @@ cupsdAddSubscription( if (!Subscriptions) { - LogMessage(L_CRIT, "Unable to allocate memory for subscriptions - %s", + cupsdLogMessage(L_CRIT, "Unable to allocate memory for subscriptions - %s", strerror(errno)); return (NULL); } @@ -349,7 +349,7 @@ cupsdAddSubscription( if ((temp = calloc(1, sizeof(cupsd_subscription_t))) == NULL) { - LogMessage(L_CRIT, "Unable to allocate memory for subscription object - %s", + cupsdLogMessage(L_CRIT, "Unable to allocate memory for subscription object - %s", strerror(errno)); return (NULL); } @@ -365,7 +365,7 @@ cupsdAddSubscription( temp->first_event_id = 1; temp->next_event_id = 1; - SetString(&(temp->recipient), uri); + cupsdSetString(&(temp->recipient), uri); /* * Add the subscription to the array... @@ -437,8 +437,8 @@ cupsdDeleteSubscription( * Free memory... */ - ClearString(&(sub->owner)); - ClearString(&(sub->recipient)); + cupsdClearString(&(sub->owner)); + cupsdClearString(&(sub->recipient)); if (sub->events) free(sub->events); @@ -617,8 +617,8 @@ cupsdEventValue(const char *name) /* I - Name of event */ void cupsdExpireSubscriptions( - printer_t *dest, /* I - Printer, if any */ - 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 */ @@ -636,7 +636,7 @@ cupsdExpireSubscriptions( (dest && sub->dest == dest) || (job && sub->job == job)) { - LogMessage(L_INFO, "Subscription %d has expired...", sub->id); + cupsdLogMessage(L_INFO, "Subscription %d has expired...", sub->id); cupsdDeleteSubscription(sub, 0); @@ -721,7 +721,7 @@ cupsdLoadAllSubscriptions(void) snprintf(line, sizeof(line), "%s/subscriptions.conf", ServerRoot); if ((fp = cupsFileOpen(line, "r")) == NULL) { - LogMessage(L_ERROR, "LoadAllSubscriptions: Unable to open %s - %s", line, + cupsdLogMessage(L_ERROR, "LoadAllSubscriptions: Unable to open %s - %s", line, strerror(errno)); return; } @@ -749,7 +749,7 @@ cupsdLoadAllSubscriptions(void) } else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -758,7 +758,7 @@ cupsdLoadAllSubscriptions(void) { if (!sub) { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -771,7 +771,7 @@ cupsdLoadAllSubscriptions(void) } else if (!sub) { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -784,7 +784,7 @@ cupsdLoadAllSubscriptions(void) if (!value) { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -806,7 +806,7 @@ cupsdLoadAllSubscriptions(void) if ((sub->mask |= cupsdEventValue(value)) == CUPSD_EVENT_NONE) { - LogMessage(L_ERROR, "Unknown event name \'%s\' on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Unknown event name \'%s\' on line %d of subscriptions.conf.", value, linenum); return; } @@ -821,10 +821,10 @@ cupsdLoadAllSubscriptions(void) */ if (value) - SetString(&sub->owner, value); + cupsdSetString(&sub->owner, value); else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -836,10 +836,10 @@ cupsdLoadAllSubscriptions(void) */ if (value) - SetString(&sub->recipient, value); + cupsdSetString(&sub->recipient, value); else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -852,16 +852,16 @@ cupsdLoadAllSubscriptions(void) if (value && isdigit(*value & 255)) { - if ((sub->job = FindJob(atoi(value))) == NULL) + if ((sub->job = cupsdFindJob(atoi(value))) == NULL) { - LogMessage(L_ERROR, "Job %s not found on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Job %s not found on line %d of subscriptions.conf.", value, linenum); delete_sub = 1; } } else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -874,16 +874,16 @@ cupsdLoadAllSubscriptions(void) if (value) { - if ((sub->dest = FindDest(value)) == NULL) + if ((sub->dest = cupsdFindDest(value)) == NULL) { - LogMessage(L_ERROR, "Printer \'%s\' not found on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Printer \'%s\' not found on line %d of subscriptions.conf.", value, linenum); delete_sub = 1; } } else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -935,7 +935,7 @@ cupsdLoadAllSubscriptions(void) if (*valueptr) { - LogMessage(L_ERROR, "Bad UserData \'%s\' on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Bad UserData \'%s\' on line %d of subscriptions.conf.", value, linenum); } else @@ -943,7 +943,7 @@ cupsdLoadAllSubscriptions(void) } else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -958,7 +958,7 @@ cupsdLoadAllSubscriptions(void) sub->lease = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -973,7 +973,7 @@ cupsdLoadAllSubscriptions(void) sub->interval = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -988,7 +988,7 @@ cupsdLoadAllSubscriptions(void) sub->expire = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -1003,7 +1003,7 @@ cupsdLoadAllSubscriptions(void) sub->next_event_id = sub->first_event_id = atoi(value); else { - LogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Syntax error on line %d of subscriptions.conf.", linenum); return; } @@ -1014,7 +1014,7 @@ cupsdLoadAllSubscriptions(void) * Something else we don't understand... */ - LogMessage(L_ERROR, "Unknown configuration directive %s on line %d of subscriptions.conf.", + cupsdLogMessage(L_ERROR, "Unknown configuration directive %s on line %d of subscriptions.conf.", name, linenum); } } @@ -1050,21 +1050,21 @@ cupsdSaveAllSubscriptions(void) snprintf(backup, sizeof(backup), "%s/subscriptions.conf.O", ServerRoot); if (rename(temp, backup)) - LogMessage(L_ERROR, "Unable to backup subscriptions.conf - %s", + cupsdLogMessage(L_ERROR, "Unable to backup subscriptions.conf - %s", strerror(errno)); if ((fp = cupsFileOpen(temp, "w")) == NULL) { - LogMessage(L_ERROR, "Unable to save subscriptions.conf - %s", + cupsdLogMessage(L_ERROR, "Unable to save subscriptions.conf - %s", strerror(errno)); if (rename(backup, temp)) - LogMessage(L_ERROR, "Unable to restore subscriptions.conf - %s", + cupsdLogMessage(L_ERROR, "Unable to restore subscriptions.conf - %s", strerror(errno)); return; } else - LogMessage(L_INFO, "Saving subscriptions.conf..."); + cupsdLogMessage(L_INFO, "Saving subscriptions.conf..."); /* * Restrict access to the file... @@ -1183,7 +1183,7 @@ cupsdSendNotification( cupsd_subscription_t *sub, /* I - Subscription object */ cupsd_event_t *event) /* I - Event to send */ { - LogMessage(L_DEBUG, "cupsdSendNotification(sub=%p(%d), event=%p(%s))\n", + cupsdLogMessage(L_DEBUG, "cupsdSendNotification(sub=%p(%d), event=%p(%s))\n", sub, sub->id, event, cupsdEventName(event->event)); /* @@ -1196,7 +1196,7 @@ cupsdSendNotification( if (!sub->events) { - LogMessage(L_CRIT, "Unable to allocate memory for subscription #%d!", + cupsdLogMessage(L_CRIT, "Unable to allocate memory for subscription #%d!", sub->id); return; } @@ -1265,7 +1265,7 @@ cupsdStopAllNotifiers(void) * Close the status pipes... */ - LogMessage(L_DEBUG2, "cupsdStopAllNotifiers: Removing fd %d from InputSet...", + cupsdLogMessage(L_DEBUG2, "cupsdStopAllNotifiers: Removing fd %d from InputSet...", NotifierPipes[0]); FD_CLR(NotifierPipes[0], InputSet); @@ -1303,7 +1303,7 @@ cupsdUpdateNotiferStatus(void) * Fatal error on pipe - should never happen! */ - LogMessage(L_CRIT, "cupsdUpdateNotifierStatus: error reading from notifier error pipe - %s", + cupsdLogMessage(L_CRIT, "cupsdUpdateNotifierStatus: error reading from notifier error pipe - %s", strerror(errno)); } } diff --git a/scheduler/subscriptions.h b/scheduler/subscriptions.h index 51d165de8..6419a85ce 100644 --- a/scheduler/subscriptions.h +++ b/scheduler/subscriptions.h @@ -81,8 +81,8 @@ typedef struct cupsd_event_s /**** Event structure ****/ cupsd_eventmask_t event; /* Event */ time_t time; /* Time of event */ ipp_t *attrs; /* Notification message */ - printer_t *dest; /* Associated printer, if any */ - job_t *job; /* Associated job, if any */ + 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 ****/ @@ -95,8 +95,8 @@ typedef struct cupsd_subscription_s /**** Subscription structure ****/ int user_data_len; /* Length of notify-user-data */ int lease; /* notify-lease-time */ int interval; /* notify-interval */ - printer_t *dest; /* notify-printer-uri, if any */ - job_t *job; /* notify-job-id, if any */ + 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 */ @@ -145,12 +145,12 @@ VAR cupsd_statbuf_t *NotifierStatusBuffer VALUE(NULL); * Prototypes... */ -extern void cupsdAddEvent(cupsd_eventmask_t event, printer_t *dest, - job_t *job, const char *text, ...); +extern void cupsdAddEvent(cupsd_eventmask_t event, cupsd_printer_t *dest, + cupsd_job_t *job, const char *text, ...); extern cupsd_subscription_t * cupsdAddSubscription(unsigned mask, - printer_t *dest, - job_t *job, const char *uri); + cupsd_printer_t *dest, + cupsd_job_t *job, const char *uri); extern void cupsdDeleteAllEvents(void); extern void cupsdDeleteAllSubscriptions(void); extern void cupsdDeleteSubscription(cupsd_subscription_t *sub, int update); @@ -161,7 +161,7 @@ extern cupsd_eventmask_t extern cupsd_subscription_t * cupsdFindSubscription(int id); -extern void cupsdExpireSubscriptions(printer_t *dest, 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,