*
* 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.
* 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 */
*/
#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 */
/*
*/
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);
* 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...
/*
- * '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 *));
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;
}
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;
}
/*
- * '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)
/*
- * '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]);
/*
- * '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 */
* Check against all local interfaces...
*/
- NetIFUpdate();
+ cupsdNetIFUpdate();
for (iface = NetIFList; iface != NULL; iface = iface->next)
{
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);
/*
* file...
*/
- if (GetMD5Passwd(username, groupname, junk) != NULL)
+ if (cupsdGetMD5Passwd(username, groupname, junk) != NULL)
return (1);
/*
/*
- * '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 */
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;
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);
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 --;
* 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);
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);
break;
case AUTH_IP :
memcpy(&(temp->allow[i].mask.ip), &((*loc)->allow[i].mask.ip),
- sizeof(ipmask_t));
+ sizeof(cupsd_ipmask_t));
break;
}
}
* 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);
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);
break;
case AUTH_IP :
memcpy(&(temp->deny[i].mask.ip), &((*loc)->deny[i].mask.ip),
- sizeof(ipmask_t));
+ sizeof(cupsd_ipmask_t));
break;
}
}
/*
- * '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 */
/*
*/
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 --)
/*
- * '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)
/*
- * '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]);
/*
- * '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 */
*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...
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))
* 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 */
/*
- * '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 */
{
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);
}
{
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;
}
* 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);
*/
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 */
};
- 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 : "");
/*
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));
/*
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;
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)
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 */
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));
* 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);
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);
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);
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);
* 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);
}
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);
}
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 */
}
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);
}
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)
{
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)
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);
}
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);
}
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);
}
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);
}
* 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);
* 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)
{
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"))
* 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);
}
* '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 */
/*
*/
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);
* Clear the mask record and return...
*/
- memset(temp, 0, sizeof(authmask_t));
+ memset(temp, 0, sizeof(cupsd_authmask_t));
return (temp);
}
* '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 */
/*
*/
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);
* Clear the mask record and return...
*/
- memset(temp, 0, sizeof(authmask_t));
+ memset(temp, 0, sizeof(cupsd_authmask_t));
return (temp);
}
{
int i; /* Looping var */
struct pam_response *replies; /* Replies */
- client_t *client; /* Pointer client connection */
+ cupsd_client_t *client; /* Pointer client connection */
/*
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 ++)
{
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
{
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;
/*
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 */
* 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);
/*
*
* 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.
*/
* 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 */
/*
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;
}
*/
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;
}
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 */
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;
}
* Must be a valid file; add it!
*/
- AddBanner(dent->filename, filename);
+ cupsdAddBanner(dent->filename, filename);
}
/*
cupsDirClose(dir);
if (NumBanners > 1)
- qsort(Banners, NumBanners, sizeof(banner_t),
+ qsort(Banners, NumBanners, sizeof(cupsd_banner_t),
(int (*)(const void *, const void *))compare);
}
*/
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));
}
{
char name[256]; /* Name of banner */
mime_type_t *filetype; /* Filetype for banner */
-} banner_t;
+} cupsd_banner_t;
/*
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 */
* 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);
/*
*
* 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.
*/
/*
- * '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;
/*
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;
/*
- * '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 */
* 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));
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;
}
/*
- * '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 */
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...
/*
- * '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)
{
/*
- * '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 */
*/
if (!RunUser)
- AddCert(0, "root");
+ cupsdAddCert(0, "root");
}
* 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 */
* 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);
/*
*
* 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.
*/
/*
- * '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...
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);
/*
- * '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 */
/*
*/
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;
}
/*
- * '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 */
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;
* 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 */
/*
* 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);
}
/*
- * '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);
/*
- * '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 */
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;
}
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;
}
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;
}
{
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"))
{
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;
}
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;
}
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;
}
if (*valueptr)
*valueptr++ = '\0';
- SetString(&p->job_sheets[0], value);
+ cupsdSetString(&p->cupsd_job_sheets[0], value);
while (isspace(*valueptr & 255))
valueptr ++;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
* 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);
}
}
/*
- * '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 */
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...
* 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...
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);
/*
- * '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)
{
/*
* 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);
/*
*
* 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.
* 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
/*
- * '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 */
/* 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);
/*
con = Clients + NumClients;
- memset(con, 0, sizeof(client_t));
+ memset(con, 0, sizeof(cupsd_client_t));
con->http.activity = time(NULL);
con->file = -1;
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;
}
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);
}
* 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
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;
}
* with double-lookups enabled...
*/
- LogMessage(L_DEBUG2, "AcceptClient: Closing connection %d...",
+ cupsdLogMessage(L_DEBUG2, "cupsdAcceptClient: Closing connection %d...",
con->http.fd);
#ifdef WIN32
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;
}
#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));
/*
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;
}
}
- 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
* 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);
*/
if (NumClients == MaxClients)
- PauseListening();
+ cupsdPauseListening();
#ifdef HAVE_SSL
/*
con->http.encryption = HTTP_ENCRYPT_ALWAYS;
- EncryptClient(con);
+ cupsdEncryptClient(con);
}
else
con->auto_ssl = 1;
/*
- * '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)
#endif /* HAVE_LIBSSL */
- LogMessage(L_DEBUG, "CloseClient: %d", con->http.fd);
+ cupsdLogMessage(L_DEBUG, "cupsdCloseClient: %d", con->http.fd);
/*
* Flush pending writes before closing...
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;
}
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;
}
* 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);
}
{
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);
* 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);
* 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);
httpClearCookie(HTTP(con));
- ClearString(&con->filename);
- ClearString(&con->command);
- ClearString(&con->options);
+ cupsdClearString(&con->filename);
+ cupsdClearString(&con->command);
+ cupsdClearString(&con->options);
if (con->request)
{
*/
if (NumClients == MaxClients)
- ResumeListening();
+ cupsdResumeListening();
/*
* Compact the list of clients as necessary...
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);
/*
- * '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 */
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;
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);
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);
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;
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;
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;
/*
- * '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 */
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");
if (!type || strcasecmp(type->super, "application"))
{
- LogMessage(L_DEBUG2, "IsCGI: Returning 0...");
+ cupsdLogMessage(L_DEBUG2, "cupsdIsCGI: Returning 0...");
return (0);
}
* "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);
* "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);
* "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);
* "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);
* "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 */
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
* 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);
}
}
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));
}
/*
con->password[0] = '\0';
con->uri[0] = '\0';
- ClearString(&con->command);
- ClearString(&con->options);
+ cupsdClearString(&con->command);
+ cupsdClearString(&con->options);
if (con->language != NULL)
{
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)
}
else
{
- SendError(con, HTTP_NOT_SUPPORTED);
- return (CloseClient(con));
+ cupsdSendError(con, HTTP_NOT_SUPPORTED);
+ return (cupsdCloseClient(con));
}
break;
}
* 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));
}
/*
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);
if (status != HTTP_OK && status != HTTP_CONTINUE)
{
- SendError(con, HTTP_BAD_REQUEST);
- return (CloseClient(con));
+ cupsdSendError(con, HTTP_BAD_REQUEST);
+ return (cupsdCloseClient(con));
}
break;
* 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)
{
* 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") &&
* 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 */
}
/**** 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");
* Protect against malicious users!
*/
- if (!SendError(con, HTTP_FORBIDDEN))
- return (CloseClient(con));
+ if (!cupsdSendError(con, HTTP_FORBIDDEN))
+ return (cupsdCloseClient(con));
}
else
{
* 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)
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;
}
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;
* /admin/conf...
*/
- if (!SendError(con, HTTP_FORBIDDEN))
- return (CloseClient(con));
+ if (!cupsdSendError(con, HTTP_FORBIDDEN))
+ return (cupsdCloseClient(con));
break;
}
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;
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
{
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;
* 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 &&
* Request too large...
*/
- if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
- return (CloseClient(con));
+ if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE))
+ return (cupsdCloseClient(con));
break;
}
* Negative content lengths are invalid!
*/
- if (!SendError(con, HTTP_BAD_REQUEST))
- return (CloseClient(con));
+ if (!cupsdSendError(con, HTTP_BAD_REQUEST))
+ return (cupsdCloseClient(con));
break;
}
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)
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;
* /admin/conf...
*/
- if (!SendError(con, HTTP_FORBIDDEN))
- return (CloseClient(con));
+ if (!cupsdSendError(con, HTTP_FORBIDDEN))
+ return (cupsdCloseClient(con));
break;
}
* 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 &&
* Request too large...
*/
- if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
- return (CloseClient(con));
+ if (!cupsdSendError(con, HTTP_REQUEST_TOO_LARGE))
+ return (cupsdCloseClient(con));
break;
}
* Negative content lengths are invalid!
*/
- if (!SendError(con, HTTP_BAD_REQUEST))
- return (CloseClient(con));
+ if (!cupsdSendError(con, HTTP_BAD_REQUEST))
+ return (cupsdCloseClient(con));
break;
}
* 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);
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) &&
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;
}
* 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, '/') ||
* /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
{
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;
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));
}
}
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);
* 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));
}
/*
* 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);
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;
* 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);
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)
{
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);
* 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)
{
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;
}
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? */
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);
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);
/*
- * '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 */
* 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));
/*
* 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
/*
- * '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,
{
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);
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)
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);
/*
- * '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 */
{
/*
- * '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 */
* 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 */
#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 */
}
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)
bufptr[-1] = '\0';
*bufptr++ = '\0';
- LogMessage(L_DEBUG2, "Script header: %s", buf);
+ cupsdLogMessage(L_DEBUG2, "Script header: %s", buf);
if (!con->sent_header)
{
*/
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)
{
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...
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)
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);
}
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));
{
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);
{
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);
}
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);
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)
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);
}
}
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);
}
}
*/
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 */
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')
}
}
- 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);
*/
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 */
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)
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;
}
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)
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);
}
*/
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 */
#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)
*/
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 */
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.
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);
}
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);
}
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);
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);
*/
unlink(con->filename);
- ClearString(&con->filename);
+ cupsdClearString(&con->filename);
/*
* Unlink the old backup, rename the current config file to the backup
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);
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);
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);
*/
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 */
* 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));
*/
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...
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";
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]);
}
/*
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);
}
* 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);
*/
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);
}
* 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 */
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;
/*
/* 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);
* 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);
/*
*
* 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
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 */
* 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)
{
{
#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);
* 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 */
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"...
* Found the group, use it!
*/
- SetString(&SystemGroups[0], CUPS_DEFAULT_GROUP);
+ cupsdSetString(&SystemGroups[0], CUPS_DEFAULT_GROUP);
SystemGroupIDs[0] = group->gr_gid;
}
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;
}
BrowseTimeout = DEFAULT_TIMEOUT;
Browsing = TRUE;
- ClearString(&BrowseLocalOptions);
- ClearString(&BrowseRemoteOptions);
+ cupsdClearString(&BrowseLocalOptions);
+ cupsdClearString(&BrowseRemoteOptions);
JobHistory = DEFAULT_HISTORY;
JobFiles = DEFAULT_FILES;
MaxJobsPerPrinter = 0;
MaxCopies = 100;
- ClearString(&DefaultPolicy);
+ cupsdClearString(&DefaultPolicy);
/*
* Read the configuration file...
* 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...
* 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,
* 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();
* 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...
* 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);
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)
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));
}
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
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...
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);
/*
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, "<Policy default>");
- LogMessage(L_INFO, "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
+ cupsdLogMessage(L_INFO, "<Policy default>");
+ cupsdLogMessage(L_INFO, "<Limit Send-Document Send-URI Cancel-Job Hold-Job "
"Release-Job Restart-Job Purge-Jobs "
"Set-Job-Attributes Create-Job-Subscription "
"Renew-Subscription Cancel-Subscription "
"Get-Notifications Reprocess-Job Cancel-Current-Job "
"Suspend-Current-Job Resume-Job CUPS-Move-Job "
"CUPS-Authenticate-Job>");
- 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);
cupsdAddPolicyOp(p, po, CUPS_MOVE_JOB);
cupsdAddPolicyOp(p, po, CUPS_AUTHENTICATE_JOB);
- LogMessage(L_INFO, "</Limit>");
+ cupsdLogMessage(L_INFO, "</Limit>");
- LogMessage(L_INFO, "<Limit Pause-Printer Resume-Printer "
+ cupsdLogMessage(L_INFO, "<Limit Pause-Printer Resume-Printer "
"Set-Printer-Attributes Enable-Printer "
"Disable-Printer Pause-Printer-After-Current-Job "
"Hold-New-Jobs Release-Held-New-Jobs "
"Schedule-Job-After CUPS-Add-Printer "
"CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class "
"CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
- 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);
cupsdAddPolicyOp(p, po, CUPS_REJECT_JOBS);
cupsdAddPolicyOp(p, po, CUPS_SET_DEFAULT);
- LogMessage(L_INFO, "</Limit>");
+ cupsdLogMessage(L_INFO, "</Limit>");
- LogMessage(L_INFO, "<Limit All>");
- LogMessage(L_INFO, "Order Deny,Allow");
+ cupsdLogMessage(L_INFO, "<Limit All>");
+ cupsdLogMessage(L_INFO, "Order Deny,Allow");
po = cupsdAddPolicyOp(p, NULL, IPP_ANY_OPERATION);
po->order_type = AUTH_ALLOW;
- LogMessage(L_INFO, "</Limit>");
- LogMessage(L_INFO, "</Policy>");
+ cupsdLogMessage(L_INFO, "</Limit>");
+ cupsdLogMessage(L_INFO, "</Policy>");
}
}
!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;
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);
/*
*/
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.");
}
/*
NeedReload = RELOAD_NONE;
- ClearString(&old_serverroot);
- ClearString(&old_requestroot);
+ cupsdClearString(&old_serverroot);
+ cupsdClearString(&old_requestroot);
/*
* Startup the server and return...
*/
- StartServer();
+ cupsdStartServer();
return (1);
}
if (!*value)
{
- LogMessage(L_ERROR, "Bad (empty) address!");
+ cupsdLogMessage(L_ERROR, "Bad (empty) address!");
return (0);
}
{
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);
}
{
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);
}
{
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);
}
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]);
*/
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 */
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;
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);
}
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);
}
*/
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"))
{
*/
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))
{
value ++;
if (!strcasecmp(line, "Allow"))
- AllowHost(loc, value);
+ cupsdAllowHost(loc, value);
else
- DenyHost(loc, value);
+ cupsdDenyHost(loc, value);
}
else
{
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"))
}
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);
}
{
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"))
{
/*
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);
}
if (*valptr)
*valptr++ = '\0';
- AddName(loc, value);
+ cupsdAddName(loc, value);
for (value = valptr; isspace(*value & 255); value ++);
}
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);
}
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 */
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
{
}
else
{
- LogMessage(L_ERROR, "Syntax error on line %d.",
+ cupsdLogMessage(L_ERROR, "Syntax error on line %d.",
linenum);
return (0);
}
}
else
{
- LogMessage(L_ERROR, "Syntax error on line %d.",
+ cupsdLogMessage(L_ERROR, "Syntax error on line %d.",
linenum);
return (0);
}
* 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;
}
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)))
#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
* 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;
}
#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 */
* 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;
}
Browsers = dira;
dira += NumBrowsers;
- memset(dira, 0, sizeof(dirsvc_addr_t));
+ memset(dira, 0, sizeof(cupsd_dirsvc_addr_t));
if (!strcasecmp(value, "@LOCAL"))
{
#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"))
* "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") ||
}
else
{
- LogMessage(L_ERROR, "Unknown browse protocol \"%s\" on line %d.",
+ cupsdLogMessage(L_ERROR, "Unknown browse protocol \"%s\" on line %d.",
value, linenum);
break;
}
* 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))
*/
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"))
{
*/
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]))
{
value ++;
if (!strcasecmp(line, "BrowseAllow"))
- AllowHost(location, value);
+ cupsdAllowHost(location, value);
else
- DenyHost(location, value);
+ cupsdDenyHost(location, value);
}
else
{
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);
}
}
}
*/
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;
}
Relays = relay;
relay += NumRelays;
- memset(relay, 0, sizeof(dirsvc_relay_t));
+ memset(relay, 0, sizeof(cupsd_dirsvc_relay_t));
if (!strncasecmp(value, "from ", 5))
{
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;
}
#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 ++;
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"))
*/
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;
}
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));
#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"))
{
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);
}
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);
}
}
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);
}
}
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();
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"))
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"))
{
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"))
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
{
* 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;
}
!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;
}
}
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;
{
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;
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 ++);
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);
{
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],
if (!strcasecmp(line, "</Policy>"))
{
if (op)
- LogMessage(L_WARN, "Missing </Limit> before </Policy> on line %d!",
+ cupsdLogMessage(L_WARN, "Missing </Limit> before </Policy> on line %d!",
linenum);
return (linenum);
{
if (!value)
{
- LogMessage(L_ERROR, "Syntax error on line %d.", linenum);
+ cupsdLogMessage(L_ERROR, "Syntax error on line %d.", linenum);
return (0);
}
if (!strcasecmp(value, "All"))
ops[num_ops] = IPP_ANY_OPERATION;
else if ((ops[num_ops] = ippOpValue(value)) == IPP_BAD_OPERATION)
- 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 ++);
}
else if (!op)
{
- LogMessage(L_ERROR, "Missing <Limit ops> directive before %s on line %d.",
+ cupsdLogMessage(L_ERROR, "Missing <Limit ops> 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);
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
{
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
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
{
/*
ca = CFArrayCreate(NULL, (const void **)&identity, 1, NULL);
if (ca == nil)
- LogMessage(L_ERROR, "CFArrayCreate error");
+ cupsdLogMessage(L_ERROR, "CFArrayCreate error");
}
/*CFRelease(identity);*/
* 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);
/*
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 */
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);
* 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);
*
* 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.
*/
/*
#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 */
*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 */
(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;
}
(!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;
}
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))
{
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,
* 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;
}
}
* 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;
}
* 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);
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;
}
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))
{
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,
* 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;
}
}
* 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;
}
* 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...
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;
}
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;
}
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;
}
cupsdExpireSubscriptions(p, NULL);
- DeletePrinter(p, 1);
- UpdateImplicitClasses();
+ cupsdDeletePrinter(p, 1);
+ cupsdUpdateImplicitClasses();
}
else if (update)
{
- SetPrinterAttrs(p);
- UpdateImplicitClasses();
+ cupsdSetPrinterAttrs(p);
+ cupsdUpdateImplicitClasses();
}
/*
if (DefaultPrinter == NULL && Printers != NULL)
{
- DefaultPrinter = (printer_t *)cupsArrayFirst(Printers);
+ DefaultPrinter = (cupsd_printer_t *)cupsArrayFirst(Printers);
- WritePrintcap();
+ cupsdWritePrintcap();
}
/*
* 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...
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)
break;
if (i >= pclass->num_printers)
- AddPrinterToClass(pclass, first);
+ cupsdAddPrinterToClass(pclass, first);
first = NULL;
}
if (i >= pclass->num_printers)
{
- AddPrinterToClass(pclass, p);
+ cupsdAddPrinterToClass(pclass, p);
update = 1;
}
}
name[len] = '\0';
offset = 0;
- if ((first = FindDest(name)) != NULL &&
+ if ((first = cupsdFindDest(name)) != NULL &&
!(first->type & CUPS_PRINTER_IMPLICIT))
{
/*
*/
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...
*/
if (BrowseLocalProtocols & BROWSE_CUPS)
- SendCUPSBrowse(p);
+ cupsdSendCUPSBrowse(p);
#ifdef HAVE_LIBSLP
if (BrowseLocalProtocols & BROWSE_SLP)
SLPDeregPrinter(p);
/*
- * '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 */
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 ++;
* 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;
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 */
}
}
* 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...
(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);
}
}
}
/*
- * '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 */
/*
* Send to all local interfaces...
*/
- NetIFUpdate();
+ cupsdNetIFUpdate();
for (iface = NetIFList; iface != NULL; iface = iface->next)
{
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)
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)
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,
* 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 --;
/*
- * '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 */
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;
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
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
* 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);
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;
}
/*
- * '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 */
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;
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);
}
* 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);
/*
- * 'StopBrowsing()' - Stop sending and receiving broadcast information.
+ * 'cupsdStopBrowsing()' - Stop sending and receiving broadcast information.
*/
void
-StopBrowsing(void)
+cupsdStopBrowsing(void)
{
if (!Browsing || !(BrowseLocalProtocols | BrowseRemoteProtocols))
return;
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);
/*
- * '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)
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);
/*
- * '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 */
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 */
/*
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;
}
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;
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;
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);
/*
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;
}
if (!strcasecmp(host, ServerName) && port == LocalPort)
return;
- NetIFUpdate();
+ cupsdNetIFUpdate();
for (iface = NetIFList; iface != NULL; iface = iface->next)
if (!strcasecmp(host, iface->hostname) && port == LocalPort)
*/
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;
}
* 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 */
* 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();
}
}
/*
- * '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 */
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
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...
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...
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);
}
*/
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)
{
*ptr2; /* ... */
- ClearString(valbuf);
+ cupsdClearString(valbuf);
if ((ptr1 = strstr(attrlist, tag)) != NULL)
{
void *cookie) /* I - Current printer */
{
char *tmp = 0;
- printer_t *p = (printer_t*)cookie;
+ cupsd_printer_t *p = (cupsd_printer_t*)cookie;
/*
* 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;
if (strstr(tmp,"two-sided"))
p->type |= CUPS_PRINTER_DUPLEX;
- ClearString(&tmp);
+ cupsdClearString(&tmp);
return (SLP_TRUE);
}
/*
- * '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 */
int port; /* Port portion of URI */
- LogMessage(L_DEBUG, "UpdateSLPBrowse() Start...");
+ cupsdLogMessage(L_DEBUG, "cupsdUpdateSLPBrowse() Start...");
/*
* Reset the refresh time...
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);
*/
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);
}
free(s);
}
- LogMessage(L_DEBUG, "UpdateSLPBrowse() End...");
+ cupsdLogMessage(L_DEBUG, "cupsdUpdateSLPBrowse() End...");
}
#endif /* HAVE_LIBSLP */
{
char iface[32]; /* Destination interface */
http_addr_t to; /* Destination address */
-} dirsvc_addr_t;
+} cupsd_dirsvc_addr_t;
/*
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;
/*
char hostname[64]; /* Hostname (actually, IP address) */
int port; /* Port number */
int pid; /* Current poll server PID */
-} dirsvc_poll_t;
+} cupsd_dirsvc_poll_t;
/*
*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 */
* 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);
/*
for (i = 0; i < num_common_env; i ++)
- ClearString(common_env + i);
+ cupsdClearString(common_env + i);
num_common_env = 0;
}
* to access their bundle resources properly...
*/
- SetString(common_env, "<CFProcessPath>");
+ cupsdSetString(common_env, "<CFProcessPath>");
num_common_env = 1;
#endif /* __APPLE__ */
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;
}
* 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 ++;
}
*
* 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.
* 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.
* 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 */
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);
/*
* 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]);
}
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",
* 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",
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",
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",
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);
}
* Remote unauthenticated user masquerading as local root...
*/
- SetString(&(username->values[0].string.text), RemoteRoot);
+ cupsdSetString(&(username->values[0].string.text), RemoteRoot);
}
}
*/
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)
* 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)
{
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);
*/
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) */
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);
/*
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;
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;
}
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;
}
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);
/*
*/
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 */
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 */
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);
/*
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;
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;
}
* 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))
{
/*
* No, add the pclass...
*/
- pclass = AddClass(resource + 9);
+ pclass = cupsdAddClass(resource + 9);
modify = 0;
}
else if (pclass->type & CUPS_PRINTER_IMPLICIT)
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)
* 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
*/
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;
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)
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;
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)
{
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;
}
* Add it to the class...
*/
- AddPrinterToClass(pclass, member);
+ cupsdAddPrinterToClass(pclass, member);
}
}
* Update the printer class attributes and return...
*/
- SetPrinterAttrs(pclass);
- SaveAllClasses();
- CheckJobs();
+ cupsdSetPrinterAttrs(pclass);
+ cupsdSaveAllClasses();
+ cupsdCheckJobs();
- WritePrintcap();
+ cupsdWritePrintcap();
if (modify)
{
"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);
}
*/
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 */
{
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);
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);
}
/*
- * '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,
/*
- * '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 */
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)
{
*/
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 */
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... */
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);
/*
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;
* 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;
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;
}
* 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;
* No, add the printer...
*/
- printer = AddPrinter(resource + 10);
+ printer = cupsdAddPrinter(resource + 10);
modify = 0;
}
else if (printer->type & CUPS_PRINTER_IMPLICIT)
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)
* 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
*/
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)
{
* 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;
* 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)
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;
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)
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;
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);
}
/*
*/
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...
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);
}
}
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);
}
}
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);
}
}
* 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)
{
"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);
}
/*
- * '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)
*/
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);
*/
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],
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);
/*
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;
}
* 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;
* 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;
}
* 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;
}
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;
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);
}
*/
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 */
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);
/*
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;
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;
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;
}
(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;
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?
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;
}
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;
}
* 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
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;
}
* 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);
}
*/
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 */
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);
/*
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;
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;
}
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;
}
*/
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;
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;
}
* 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;
* 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;
}
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;
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" :
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;
}
*/
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 */
{
}
*/
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);
/*
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));
* 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);
}
}
* 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);
}
}
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);
}
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);
}
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);
}
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);
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;
*/
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 */
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)");
/*
if (name == NULL ||
strcmp(name, "none") == 0 ||
- (banner = FindBanner(name)) == NULL)
+ (banner = cupsdFindBanner(name)) == NULL)
return (0);
/*
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);
{
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);
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;
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...
*/
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 */
{
#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);
/*
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))
}
if (FD_ISSET(CGIPipes[0], input))
- UpdateCGI();
+ cupsdUpdateCGI();
}
close(temppipe[0]);
* 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);
}
*/
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 */
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);
/*
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;
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;
}
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;
}
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;
}
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;
{
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,
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;
*/
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;
}
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;
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",
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",
* 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;
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...
if (Classification)
{
- LogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d",
+ cupsdLogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d",
Classification ? Classification : "(null)", ClassifyOverride);
if (ClassifyOverride)
* 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,
* 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,
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,
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,
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)
* 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...
* 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.");
static void
create_subscription(
- client_t *con, /* I - Client connection */
+ cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
}
*/
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 */
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);
/*
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;
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;
}
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;
}
* Remove old jobs...
*/
- CancelJobs(dest, NULL, 1);
+ cupsdCancelJobs(dest, NULL, 1);
/*
* Remove old subscriptions and send a "deleted printer" event...
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();
}
/*
*/
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 */
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...
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;
}
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);
*/
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 */
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...
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;
}
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...
*/
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 */
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);
/*
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;
}
{
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;
}
* 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 ||
count ++;
- LogMessage(L_DEBUG2, "get_jobs: count = %d", count);
+ cupsdLogMessage(L_DEBUG2, "get_jobs: count = %d", count);
/*
* Send the requested attributes for each job...
copy_attrs(con->response, job->attrs, requested, IPP_TAG_JOB, 0);
- add_job_state_reasons(con, job);
+ add_cupsd_job_state_reasons(con, job);
ippAddSeparator(con->response);
}
*/
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 */
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);
/*
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;
}
* 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;
* 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;
}
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;
}
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;
*/
static void
-get_notifications(client_t *con, /* I - Client connection */
+get_notifications(cupsd_client_t *con, /* I - Client connection */
int id) /* I - Subscription ID */
{
}
*/
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 */
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...
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;
}
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...
*/
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 */
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 */
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);
/*
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;
}
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;
}
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);
*/
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 */
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))
{
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;
}
*/
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;
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)))
{
* Find the core printer, if any...
*/
- if ((iclass = FindPrinter(name)) != NULL &&
+ if ((iclass = cupsdFindPrinter(name)) != NULL &&
(iclass->type & CUPS_PRINTER_IMPLICIT))
continue;
}
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);
*/
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 */
{
}
*/
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 */
{
}
*/
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 */
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);
/*
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;
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;
}
* 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;
* 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;
}
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;
* 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);
* 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;
}
*/
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 */
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);
/*
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;
}
* 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;
* 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;
}
* 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;
}
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;
* 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;
}
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;
}
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;
}
* 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...
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);
}
*/
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 */
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 */
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 */
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);
/*
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;
{
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,
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;
#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,
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;
}
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;
* 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);
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)
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);
/*
if (!strcasecmp(filetype->super, "application") &&
!strcasecmp(filetype->type, "postscript"))
- read_ps_job_ticket(con);
+ read_ps_cupsd_job_ticket(con);
/*
* Is the destination valid?
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;
}
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;
}
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;
}
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;
*/
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;
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;
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",
else
{
attr->group_tag = IPP_TAG_JOB;
- SetString(&attr->name, "job-originating-user-name");
+ cupsdSetString(&attr->name, "job-originating-user-name");
}
/*
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",
*/
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)) ||
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...
if (Classification)
{
- LogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d",
+ cupsdLogMessage(L_INFO, "Classification=\"%s\", ClassifyOverride=%d",
Classification ? Classification : "(null)", ClassifyOverride);
if (ClassifyOverride)
* 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,
* 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,
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,
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,
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)
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...
* 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...
* 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...
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 +
*/
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 */
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;
}
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;
*/
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) */
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);
/*
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;
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;
}
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;
}
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);
}
*/
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 */
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);
/*
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;
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;
}
* 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;
* 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;
}
* 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;
}
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;
* 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;
}
*/
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 */
{
}
*/
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 */
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);
/*
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;
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;
}
* 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;
* 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;
}
* 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;
}
* 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;
}
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;
* 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;
}
*/
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 */
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;
}
*/
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],
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);
/*
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;
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;
}
* 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;
* 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;
}
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;
#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,
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;
}
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;
* 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);
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)
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);
/*
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;
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);
/*
* 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)
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
{
{
job->state->values[0].integer = IPP_JOB_HELD;
job->hold_until = time(NULL) + 60;
- SaveJob(job->id);
+ cupsdSaveJob(job->id);
}
}
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;
}
*/
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)
{
* the client will properly authenticate the request...
*/
- SendError(con, HTTP_UNAUTHORIZED);
+ cupsdSendError(con, HTTP_UNAUTHORIZED);
ippDelete(con->response);
con->response = NULL;
*/
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) */
/* 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);
/*
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;
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;
}
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;
}
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);
/*
*/
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],
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);
/*
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;
}
* 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;
* 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;
}
* 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;
}
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;
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"))
{
}
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;
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)
* Save the job...
*/
- SaveJob(job->id);
+ cupsdSaveJob(job->id);
/*
* Start jobs if possible...
*/
- CheckJobs();
+ cupsdCheckJobs();
}
*/
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) */
/* 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);
/*
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;
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;
}
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;
}
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...
*/
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) */
/* 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);
/*
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;
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;
}
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;
}
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);
/*
*/
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 */
*/
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 */
/* 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);
/*
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;
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,
{
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;
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);
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;
}
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;
}
*/
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);
*/
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));
*
* 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
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;
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...
/*
- * '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;
/*
* 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);
* Save job state info...
*/
- SaveJob(job->id);
+ cupsdSaveJob(job->id);
}
else
{
free(job->filetypes);
}
- ClearString(&job->username);
- ClearString(&job->dest);
+ cupsdClearString(&job->username);
+ cupsdClearString(&job->dest);
free(job);
}
/*
- * '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)))
{
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...
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)))
if (!(pclass->type & CUPS_PRINTER_REMOTE))
{
if (pclass->state != IPP_PRINTER_STOPPED)
- printer = FindAvailablePrinter(job->dest);
+ printer = cupsdFindAvailablePrinter(job->dest);
else
printer = NULL;
}
* 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)
{
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);
}
}
}
/*
- * '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)
{
* 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);
* 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
*/
if (job->dtype & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
- CheckJobs();
+ cupsdCheckJobs();
else if ((printer->type & CUPS_PRINTER_FAX) ||
!strcmp(printer->error_policy, "retry-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
{
}
}
else if (!strcmp(printer->error_policy, "abort-job"))
- CancelJob(job->id, 0);
+ cupsdCancelJob(job->id, 0);
break;
case CUPS_BACKEND_CANCEL :
* Cancel the job...
*/
- CancelJob(job->id, 0);
+ cupsdCancelJob(job->id, 0);
break;
case CUPS_BACKEND_HOLD :
* 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 :
* 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);
* Try printing another job...
*/
- CheckJobs();
+ cupsdCheckJobs();
}
else if (job->status > 0)
{
*/
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,
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
if (job->current_file < job->num_files)
{
FilterLevel -= job->cost;
- StartJob(job->id, job->printer);
+ cupsdStartJob(job->id, job->printer);
}
else
{
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);
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 ++;
/*
- * '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 ++;
/*
- * '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 */
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 */
* 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;
}
* 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;
}
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;
}
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)
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);
{
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);
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);
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);
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)
{
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);
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);
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...
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;
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;
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;
}
* 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;
/*
* 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;
}
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 */
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;
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 */
* Find the job...
*/
- if ((job = FindJob(id)) == NULL)
+ if ((job = cupsdFindJob(id)) == NULL)
return;
/*
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 */
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;
}
* 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;
}
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 ++;
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;
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);
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)
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;
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)
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;
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)
{
* 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
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)
cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
"Job cancelled because the server ran out of memory.");
- CancelJob(id, 0);
+ cupsdCancelJob(id, 0);
return;
}
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]);
/*
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 ++;
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);
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
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 ++)
{
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);
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;
}
}
{
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);
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;
}
}
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);
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;
}
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]);
}
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;
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);
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],
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);
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);
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);
/*
- * '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)
!(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;
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);
* 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);
/*
- * '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 */
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)
{
/*
* Handle the end of job stuff...
*/
- FinishJob(job);
+ cupsdFinishJob(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);
}
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);
}
*/
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 */
*/
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 */
* 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;
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);
}
* Job request structure...
*/
-typedef struct job_s
+typedef struct cupsd_job_s
{
int id, /* Job ID */
priority; /* Job priority */
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 */
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;
/*
* 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);
/*
*
* 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...
*/
/*
/*
- * '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);
/*
- * '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);
}
/*
- * '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? */
};
- LogMessage(L_DEBUG, "StartListening: NumListeners=%d", NumListeners);
+ cupsdLogMessage(L_DEBUG, "cupsdStartListening: NumListeners=%d", NumListeners);
/*
* Get the server's IP address...
* 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;
* 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);
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);
}
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);
}
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);
}
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...
* 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 ++)
{
*
* 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.
*/
/*
- * '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 */
/*
- * '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 */
{
* 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...
/*
- * '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 */
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);
/*
- * '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[] =
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);
* 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.
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 */
* Absolute directory...
*/
- SetString(&ConfigurationFile, argv[i]);
+ cupsdSetString(&ConfigurationFile, argv[i]);
}
else
{
getcwd(current, sizeof(current));
- SetStringf(&ConfigurationFile, "%s/%s", current, argv[i]);
+ cupsdSetStringf(&ConfigurationFile, "%s/%s", current, argv[i]);
}
break;
}
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...
* Read configuration...
*/
- if (!ReadConfiguration())
+ if (!cupsdReadConfiguration())
{
syslog(LOG_LPR, "Unable to read configuration file \'%s\' - exiting!",
ConfigurationFile);
* Initialize authentication certificates...
*/
- InitCerts();
+ cupsdInitCerts();
/*
* If we are running in the background, signal the parent process that
* Catch signals...
*/
- CatchChildSignals();
+ cupsdCatchChildSignals();
/*
* Start any pending print jobs...
*/
- CheckJobs();
+ cupsdCheckJobs();
/*
* Loop forever...
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 */
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;
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);
* 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;
sptr += strlen(sptr);
}
- LogMessage(L_EMERG, s);
+ cupsdLogMessage(L_EMERG, s);
strcpy(s, "OutputSet =");
slen = 11;
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]);
* 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))
{
/*
* Read any status messages from the filters...
*/
- UpdateJob(job);
+ cupsdUpdateJob(job);
}
/*
*/
if (CGIPipes[0] >= 0 && FD_ISSET(CGIPipes[0], input))
- UpdateCGI();
+ cupsdUpdateCGI();
/*
* Update the browse list as needed...
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);
}
}
if (FD_ISSET(lis->fd, input))
{
FD_CLR(lis->fd, input);
- AcceptClient(lis);
+ cupsdAcceptClient(lis);
}
/*
{
FD_CLR(con->http.fd, input);
- if (!ReadClient(con))
+ if (!cupsdReadClient(con))
{
if (con->pipe_pid)
FD_CLR(con->file, input);
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);
}
}
FD_CLR(con->http.fd, output);
if (!con->pipe_pid || con->file_ready)
- if (!WriteClient(con))
+ if (!cupsdWriteClient(con))
{
con --;
continue;
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;
}
if ((time(NULL) - senddoc_time) >= 10)
{
- CheckJobs();
+ cupsdCheckJobs();
senddoc_time = time(NULL);
}
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);
* Update the root certificate...
*/
- DeleteCert(0);
- AddCert(0, "root");
+ cupsdDeleteCert(0);
+ cupsdAddCert(0, "root");
}
}
*/
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
/*
/*
- * '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 */
/*
- * 'ClearString()' - Clear a string.
+ * 'cupsdClearString()' - Clear a string.
*/
void
-ClearString(char **s) /* O - String value */
+cupsdClearString(char **s) /* O - String value */
{
if (s && *s)
{
/*
- * '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 */
/*
- * '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 */
/*
- * 'ReleaseSignals()' - Release signals for delivery.
+ * 'cupsdReleaseSignals()' - Release signals for delivery.
*/
void
-ReleaseSignals(void)
+cupsdReleaseSignals(void)
{
holdcount --;
if (holdcount > 0)
/*
- * '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)
/*
- * '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 */
{
{
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...
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...
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)
{
* Process the next file...
*/
- FinishJob(job);
+ cupsdFinishJob(job);
}
}
break;
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 */
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)
{
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;
* 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);
}
* '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...
/*
- * '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 */
/*
/*
- * '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 */
* Free the old interfaces...
*/
- NetIFFree();
+ cupsdNetIFFree();
/*
* Grab a new list of interfaces...
* 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;
* 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 */
http_addr_t address, /* Network address */
mask, /* Network mask */
broadcast; /* Broadcast address */
-} cups_netif_t;
+} cupsd_netif_t;
/*
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);
/*
* '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;
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;
}
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;
}
}
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 */
/*
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);
}
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);
}
{
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)
* '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));
/*
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);
}
{
char *name; /* Policy name */
int num_ops; /* Number of operations */
- location_t **ops; /* Operations */
+ cupsd_location_t **ops; /* Operations */
} cupsd_policy_t;
*/
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);
/*
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;
cupsFileClose(fp);
- LogMessage(L_INFO, "LoadPPDs: Read \"%s\", %d PPDs...", filename,
+ cupsdLogMessage(L_INFO, "LoadPPDs: Read \"%s\", %d PPDs...", filename,
num_ppds);
/*
}
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;
}
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...
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;
}
* 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)
{
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;
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...
*
* 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
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);
* 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;
* Write a new /etc/printcap or /var/spool/lp/pstatus file.
*/
- WritePrintcap();
+ cupsdWritePrintcap();
/*
* Return the new 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 */
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;
}
!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);
/*
- * '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 */
/*
- * '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 */
/*
- * '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 */
"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)
* 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;
}
/*
- * '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 */
#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...
if (p == BrowseNext)
{
cupsArrayFind(Printers, p);
- BrowseNext = (printer_t *)cupsArrayNext(Printers);
+ BrowseNext = (cupsd_printer_t *)cupsArrayNext(Printers);
}
/*
* Stop printing on this printer...
*/
- StopPrinter(p, update);
+ cupsdStopPrinter(p, update);
/*
* Remove the dummy interface/icon/option files under IRIX...
if (p == DefaultPrinter)
{
- DefaultPrinter = (printer_t *)cupsArrayFirst(Printers);
+ DefaultPrinter = (cupsd_printer_t *)cupsArrayFirst(Printers);
- WritePrintcap();
+ cupsdWritePrintcap();
}
/*
if (!(p->type & CUPS_PRINTER_IMPLICIT))
{
- DeletePrinterFromClasses(p);
- SendBrowseDelete(p);
+ cupsdDeletePrinterFromClasses(p);
+ cupsdSendBrowseDelete(p);
}
/*
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);
* 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 */
/*
- * '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);
/*
- * '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 */
/*
- * '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 */
/*
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;
}
* 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;
}
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;
}
* 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)
}
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;
}
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;
}
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;
}
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;
}
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;
}
if (*valueptr)
*valueptr++ = '\0';
- SetString(&p->job_sheets[0], value);
+ cupsdSetString(&p->cupsd_job_sheets[0], value);
while (isspace(*valueptr & 255))
valueptr ++;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
* 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);
}
}
/*
- * '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 */
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...
* 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...
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);
/*
- * '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 */
};
- DEBUG_printf(("SetPrinterAttrs: entering name = %s, type = %x\n", p->name,
+ DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name,
p->type));
/*
*/
if (!CommonData)
- CreateCommonData();
+ cupsdCreateCommonData();
/*
* Clear out old filters, if any...
*/
- DeletePrinterFilters(p);
+ cupsdDeletePrinterFilters(p);
/*
* Figure out the authentication that is required for the printer.
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)
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;
"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);
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);
}
* 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...
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)
* If there are no filters, add a PostScript printing filter.
*/
- AddPrinterFilter(p, "application/vnd.cups-postscript 0 -");
+ cupsdAddPrinterFilter(p, "application/vnd.cups-postscript 0 -");
}
/*
ppdClose(ppd);
- printer_type = p->type;
+ cupsd_printer_type = p->type;
}
else if (!access(filename, 0))
{
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);
/*
* 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
{
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) &&
* 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
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
/*
- * '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 */
/*
- * '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? */
{
#endif /* __sgi */
}
- AddPrinterHistory(p);
+ cupsdAddPrinterHistory(p);
/*
* Save the printer configuration if a printer goes from idle or processing
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...
* 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...
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));
/*
* See if the printer or class name exists...
*/
- p = FindDest(resource);
+ p = cupsdFindDest(resource);
if (p == NULL && strchr(resource, '@') == NULL)
return (NULL);
* 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))
{
/*
- * '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
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);
*/
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",
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));
}
*/
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 */
*/
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 */
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 */
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 */
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;
/*
/* 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 */
* 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);
#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)
{
signal(SIGCHLD, SIG_DFL);
#endif /* HAVE_SIGSET */
- ReleaseSignals();
+ cupsdReleaseSignals();
/*
* Execute the command; if for some reason this doesn't work,
* 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);
}
*
* 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...
*/
* 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);
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 */
{
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;
/*
- * '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 */
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);
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)
if (attr->values[0].integer < curtime)
{
if (JobAutoPurge)
- CancelJob(job->id, 1);
+ cupsdCancelJob(job->id, 1);
continue;
}
*/
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));
}
*
* Contents:
*
- * StartServer() - Start the server.
- * StopServer() - Stop the server.
+ * cupsdStartServer() - Start the server.
+ * cupsdStopServer() - Stop the server.
*/
/*
/*
- * 'StartServer()' - Start the server.
+ * 'cupsdStartServer()' - Start the server.
*/
void
-StartServer(void)
+cupsdStartServer(void)
{
#ifdef HAVE_LIBSSL
int i; /* Looping var */
* 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)
{
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);
*/
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);
}
/*
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 */
{
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;
}
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;
}
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;
}
if (temp)
cupsdSaveAllSubscriptions();
else
- LogMessage(L_DEBUG, "Discarding unused %s event...",
+ cupsdLogMessage(L_DEBUG, "Discarding unused %s event...",
cupsdEventName(event));
}
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);
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);
}
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);
}
temp->first_event_id = 1;
temp->next_event_id = 1;
- SetString(&(temp->recipient), uri);
+ cupsdSetString(&(temp->recipient), uri);
/*
* Add the subscription to the array...
* Free memory...
*/
- ClearString(&(sub->owner));
- ClearString(&(sub->recipient));
+ cupsdClearString(&(sub->owner));
+ cupsdClearString(&(sub->recipient));
if (sub->events)
free(sub->events);
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 */
(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);
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;
}
}
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;
}
{
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;
}
}
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;
}
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;
}
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;
}
*/
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;
}
*/
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;
}
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;
}
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;
}
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
}
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;
}
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;
}
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;
}
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;
}
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;
}
* 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);
}
}
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...
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));
/*
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;
}
* 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);
* 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));
}
}
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 ****/
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 */
* 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);
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,