/*
- * "$Id: client.c,v 1.91.2.47 2003/03/12 21:51:02 mike Exp $"
+ * "$Id: client.c,v 1.91.2.48 2003/03/13 03:34:59 mike Exp $"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
if (con->http.input_set)
free(con->http.input_set);
+ ClearString(&con->filename);
+ ClearString(&con->command);
+ ClearString(&con->options);
+
#ifdef HAVE_SSL
/*
* Shutdown encryption as needed...
con->bytes = 0;
con->file = 0;
con->pipe_pid = 0;
- con->command[0] = '\0';
con->username[0] = '\0';
con->password[0] = '\0';
con->uri[0] = '\0';
+ ClearString(&con->command);
+ ClearString(&con->options);
+
if (con->language != NULL)
{
cupsLangFree(con->language);
if (strncmp(con->uri, "/admin", 6) == 0)
{
- snprintf(con->command, sizeof(con->command),
- "%s/cgi-bin/admin.cgi", ServerBin);
- con->options = con->uri + 6;
+ SetStringf(&con->command, "%s/cgi-bin/admin.cgi", ServerBin);
+ SetString(&con->options, con->uri + 6);
}
else if (strncmp(con->uri, "/printers", 9) == 0)
{
- snprintf(con->command, sizeof(con->command),
- "%s/cgi-bin/printers.cgi", ServerBin);
- con->options = con->uri + 9;
+ SetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin);
+ SetString(&con->options, con->uri + 9);
}
else if (strncmp(con->uri, "/classes", 8) == 0)
{
- snprintf(con->command, sizeof(con->command),
- "%s/cgi-bin/classes.cgi", ServerBin);
- con->options = con->uri + 8;
+ SetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin);
+ SetString(&con->options, con->uri + 8);
}
else
{
- snprintf(con->command, sizeof(con->command),
- "%s/cgi-bin/jobs.cgi", ServerBin);
- con->options = con->uri + 5;
+ SetStringf(&con->command, "%s/cgi-bin/jobs.cgi", ServerBin);
+ SetString(&con->options, con->uri + 5);
}
if (con->options[0] == '/')
- con->options ++;
+ strcpy(con->options, con->options + 1);
if (!SendCommand(con, con->command, con->options))
{
if (strncmp(con->uri, "/admin", 6) == 0)
{
- snprintf(con->command, sizeof(con->command),
- "%s/cgi-bin/admin.cgi", ServerBin);
- con->options = con->uri + 6;
+ SetStringf(&con->command, "%s/cgi-bin/admin.cgi", ServerBin);
+ SetString(&con->options, con->uri + 6);
}
else if (strncmp(con->uri, "/printers", 9) == 0)
{
- snprintf(con->command, sizeof(con->command),
- "%s/cgi-bin/printers.cgi", ServerBin);
- con->options = con->uri + 9;
+ SetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin);
+ SetString(&con->options, con->uri + 9);
}
else if (strncmp(con->uri, "/classes", 8) == 0)
{
- snprintf(con->command, sizeof(con->command),
- "%s/cgi-bin/classes.cgi", ServerBin);
- con->options = con->uri + 8;
+ SetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin);
+ SetString(&con->options, con->uri + 8);
}
else
{
- snprintf(con->command, sizeof(con->command),
- "%s/cgi-bin/jobs.cgi", ServerBin);
- con->options = con->uri + 5;
+ SetStringf(&con->command, "%s/cgi-bin/jobs.cgi", ServerBin);
+ SetString(&con->options, con->uri + 5);
}
if (con->options[0] == '/')
- con->options ++;
+ strcpy(con->options, con->options + 1);
LogMessage(L_DEBUG2, "ReadClient() %d command=\"%s\", options = \"%s\"",
con->http.fd, con->command, con->options);
* Open a temporary file to hold the request...
*/
- snprintf(con->filename, sizeof(con->filename), "%s/%08x",
- RequestRoot, request_id ++);
+ SetStringf(&con->filename, "%s/%08x", RequestRoot, request_id ++);
con->file = open(con->filename, O_WRONLY | O_CREAT | O_TRUNC, 0640);
fchmod(con->file, 0640);
fchown(con->file, User, Group);
close(con->file);
con->file = 0;
unlink(con->filename);
- con->filename[0] = '\0';
+ ClearString(&con->filename);
if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
{
LogMessage(L_DEBUG2, "ReadClient() %d Removing temp file %s",
con->http.fd, con->filename);
unlink(con->filename);
- con->filename[0] = '\0';
+ ClearString(&con->filename);
if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
{
* Create a file as needed for the request data...
*/
- snprintf(con->filename, sizeof(con->filename), "%s/%08x",
- RequestRoot, request_id ++);
+ SetStringf(&con->filename, "%s/%08x", RequestRoot, request_id ++);
con->file = open(con->filename, O_WRONLY | O_CREAT | O_TRUNC, 0640);
fchmod(con->file, 0640);
fchown(con->file, User, Group);
close(con->file);
con->file = 0;
unlink(con->filename);
- con->filename[0] = '\0';
+ ClearString(&con->filename);
if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
{
LogMessage(L_DEBUG2, "ReadClient() %d Removing temp file %s",
con->http.fd, con->filename);
unlink(con->filename);
- con->filename[0] = '\0';
+ ClearString(&con->filename);
if (con->request)
{
}
}
- if (con->command[0])
+ if (con->command)
{
if (!SendCommand(con, con->command, con->options))
{
int fd;
- if (con->filename[0])
+ if (con->filename)
fd = open(con->filename, O_RDONLY);
else
fd = open("/dev/null", O_RDONLY);
con->pipe_pid = 0;
}
- if (con->filename[0])
+ if (con->filename)
{
LogMessage(L_DEBUG2, "WriteClient() %d Removing temp file %s",
con->http.fd, con->filename);
unlink(con->filename);
- con->filename[0] = '\0';
+ ClearString(&con->filename);
}
if (con->request != NULL)
con->response = NULL;
}
+ ClearString(&con->command);
+ ClearString(&con->options);
+
if (!con->http.keep_alive)
{
CloseClient(con);
*/
unlink(con->filename);
- con->filename[0] = '\0';
+ ClearString(&con->filename);
/*
* Unlink the old backup, rename the current config file to the backup
/*
- * End of "$Id: client.c,v 1.91.2.47 2003/03/12 21:51:02 mike Exp $".
+ * End of "$Id: client.c,v 1.91.2.48 2003/03/13 03:34:59 mike Exp $".
*/
/*
- * "$Id: ipp.c,v 1.127.2.48 2003/03/12 21:27:34 mike Exp $"
+ * "$Id: ipp.c,v 1.127.2.49 2003/03/13 03:35:00 mike Exp $"
*
* IPP routines for the Common UNIX Printing System (CUPS) scheduler.
*
* See if we have an interface script or PPD file attached to the request...
*/
- if (con->filename[0])
+ if (con->filename)
strlcpy(srcfile, con->filename, sizeof(srcfile));
else if ((attr = ippFindAttribute(con->request, "ppd-name", IPP_TAG_NAME)) != NULL)
{
* Do we have a file to print?
*/
- if (con->filename[0] == '\0')
+ if (!con->filename)
{
LogMessage(L_ERROR, "print_job: No file!?!");
send_ipp_error(con, IPP_BAD_REQUEST);
snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id,
job->num_files);
rename(con->filename, filename);
- con->filename[0] = '\0';
+ ClearString(&con->filename);
/*
* See if we need to add the ending sheet...
* Do we have a file to print?
*/
- if (con->filename[0] == '\0')
+ if (!con->filename)
{
LogMessage(L_ERROR, "send_document: No file!?!");
send_ipp_error(con, IPP_BAD_REQUEST);
job->num_files);
rename(con->filename, filename);
- con->filename[0] = '\0';
+ ClearString(&con->filename);
LogMessage(L_INFO, "File of type %s/%s queued in job #%d by \'%s\'.",
filetype->super, filetype->type, job->id, job->username);
/*
- * End of "$Id: ipp.c,v 1.127.2.48 2003/03/12 21:27:34 mike Exp $".
+ * End of "$Id: ipp.c,v 1.127.2.49 2003/03/13 03:35:00 mike Exp $".
*/