]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Mirror 1.1.x changes.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 13 Mar 2003 03:35:00 +0000 (03:35 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 13 Mar 2003 03:35:00 +0000 (03:35 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3462 7a7537e8-13f0-0310-91df-b6672ffda945

scheduler/client.c
scheduler/client.h
scheduler/ipp.c

index b70e097a5e3230512e81aefcae5a44984873552c..43cb60ce7815a587ed1e9332242f87f81000f3e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$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.
  *
@@ -372,6 +372,10 @@ CloseClient(client_t *con) /* I - Client to close */
   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...
@@ -742,11 +746,13 @@ ReadClient(client_t *con) /* I - Client to read from */
        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);
@@ -1084,31 +1090,27 @@ ReadClient(client_t *con)       /* I - Client to read from */
 
               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))
              {
@@ -1262,31 +1264,27 @@ ReadClient(client_t *con)       /* I - Client to read from */
 
               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);
@@ -1381,8 +1379,7 @@ ReadClient(client_t *con) /* I - Client to read from */
            * 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);
@@ -1578,7 +1575,7 @@ ReadClient(client_t *con) /* I - Client to read from */
            close(con->file);
            con->file = 0;
            unlink(con->filename);
-           con->filename[0] = '\0';
+           ClearString(&con->filename);
 
             if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
            {
@@ -1612,7 +1609,7 @@ ReadClient(client_t *con) /* I - Client to read from */
             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))
            {
@@ -1677,8 +1674,7 @@ ReadClient(client_t *con) /* I - Client to read from */
          * 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);
@@ -1721,7 +1717,7 @@ ReadClient(client_t *con) /* I - Client to read from */
              close(con->file);
              con->file = 0;
              unlink(con->filename);
-             con->filename[0] = '\0';
+             ClearString(&con->filename);
 
               if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
              {
@@ -1759,7 +1755,7 @@ ReadClient(client_t *con) /* I - Client to read from */
               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)
              {
@@ -1778,7 +1774,7 @@ ReadClient(client_t *con) /* I - Client to read from */
              }
            }
 
-           if (con->command[0])
+           if (con->command)
            {
              if (!SendCommand(con, con->command, con->options))
              {
@@ -1824,7 +1820,7 @@ SendCommand(client_t      *con,
   int  fd;
 
 
-  if (con->filename[0])
+  if (con->filename)
     fd = open(con->filename, O_RDONLY);
   else
     fd = open("/dev/null", O_RDONLY);
@@ -2221,12 +2217,12 @@ WriteClient(client_t *con)              /* I - Client connection */
       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)
@@ -2241,6 +2237,9 @@ WriteClient(client_t *con)                /* I - Client connection */
       con->response = NULL;
     }
 
+    ClearString(&con->command);
+    ClearString(&con->options);
+
     if (!con->http.keep_alive)
     {
       CloseClient(con);
@@ -2559,7 +2558,7 @@ install_conf_file(client_t *con)  /* I - Connection */
   */
 
   unlink(con->filename);
-  con->filename[0] = '\0';
+  ClearString(&con->filename);
 
  /*
   * Unlink the old backup, rename the current config file to the backup
@@ -3003,5 +3002,5 @@ CDSAWriteFunc(SSLConnectionRef connection,        /* I  - SSL/TLS connection */
 
 
 /*
- * 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 $".
  */
index 3167e1ce6250f4793682734fdfa8ab465acd6944..3c1c35485a56252ffa7ba1290590e46dd6802924 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: client.h,v 1.17.2.6 2003/03/12 21:51:03 mike Exp $"
+ * "$Id: client.h,v 1.17.2.7 2003/03/13 03:35:00 mike Exp $"
  *
  *   Client definitions for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -37,8 +37,8 @@ typedef struct
   char         username[33],           /* Username from Authorization: line */
                password[33],           /* Password from Authorization: line */
                uri[HTTP_MAX_URI],      /* Localized URL/URI for GET/PUT */
-               filename[HTTP_MAX_URI], /* Filename of output file */
-               command[HTTP_MAX_URI],  /* Command to run */
+               *filename,              /* Filename of output file */
+               *command,               /* Command to run */
                *options;               /* Options for command */
   int          file;                   /* Input/output file */
   int          pipe_pid;               /* Pipe process ID (or 0 if not a pipe) */
@@ -104,5 +104,5 @@ extern int  WriteClient(client_t *con);
 
 
 /*
- * End of "$Id: client.h,v 1.17.2.6 2003/03/12 21:51:03 mike Exp $".
+ * End of "$Id: client.h,v 1.17.2.7 2003/03/13 03:35:00 mike Exp $".
  */
index b13b1e1ee05657f25a490a04c6aff9fc122439e1..502628abe0efa1028d8cf78359b82b21110a7608 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$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.
  *
@@ -1257,7 +1257,7 @@ add_printer(client_t        *con, /* I - Client connection */
   * 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)
   {
@@ -4047,7 +4047,7 @@ print_job(client_t        *con,           /* I - Client connection */
   * 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);
@@ -4480,7 +4480,7 @@ print_job(client_t        *con,           /* I - Client connection */
   snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id,
            job->num_files);
   rename(con->filename, filename);
-  con->filename[0] = '\0';
+  ClearString(&con->filename);
 
  /*
   * See if we need to add the ending sheet...
@@ -5255,7 +5255,7 @@ send_document(client_t        *con,       /* I - Client connection */
   * 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);
@@ -5368,7 +5368,7 @@ send_document(client_t        *con,       /* I - Client connection */
            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);
@@ -6187,5 +6187,5 @@ validate_user(client_t   *con,            /* I - Client connection */
 
 
 /*
- * 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 $".
  */