]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - berkeley/lpc.c
Fix source file header text duplication text duplication.
[thirdparty/cups.git] / berkeley / lpc.c
index a18eb0e71a38a7fd094ae0e840a2b9956428ea80..6eb70b4a1d5b3871350b33ccf01465d9bf77f774 100644 (file)
@@ -1,43 +1,28 @@
 /*
- * "$Id: lpc.c 7079 2007-11-30 01:58:31Z mike $"
+ * "lpc" command for CUPS.
  *
- *   "lpc" command for the Common UNIX Printing System (CUPS).
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
  *
- *   Copyright 2007 by Apple Inc.
- *   Copyright 1997-2006 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- *   main()            - Parse options and commands.
- *   compare_strings() - Compare two command-line strings.
- *   do_command()      - Do an lpc command...
- *   show_help()       - Show help messages.
- *   show_status()     - Show printers.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file.  If this file is
+ * missing or damaged, see the license at "http://www.cups.org/".
  */
 
 /*
  * Include necessary headers...
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <cups/cups.h>
-#include <cups/i18n.h>
-#include <cups/debug.h>
-#include <cups/string.h>
+#include <cups/cups-private.h>
 
 
 /*
  * Local functions...
  */
 
-static int     compare_strings(const char *, const char *, int);
+static int     compare_strings(const char *, const char *, size_t);
 static void    do_command(http_t *, const char *, const char *);
 static void    show_help(const char *);
 static void    show_status(http_t *, const char *);
@@ -78,7 +63,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
     * Do the command prompt thing...
     */
 
-    _cupsLangPuts(stdout, _("lpc> "));
+    _cupsLangPuts(stdout, _("lpc> ")); /* TODO: Need no-newline version */
     while (fgets(line, sizeof(line), stdin) != NULL)
     {
      /*
@@ -106,7 +91,7 @@ main(int  argc,                              /* I - Number of command-line arguments */
         * Nothing left, just show a prompt...
        */
 
-       _cupsLangPuts(stdout, _("lpc> "));
+       _cupsLangPuts(stdout, _("lpc> ")); /* TODO: Need no newline version */
        continue;
       }
 
@@ -142,7 +127,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
       * Put another prompt out to the user...
       */
 
-      _cupsLangPuts(stdout, _("lpc> "));
+      _cupsLangPuts(stdout, _("lpc> ")); /* TODO: Need no newline version */
     }
   }
 
@@ -163,9 +148,9 @@ main(int  argc,                             /* I - Number of command-line arguments */
 static int                             /* O - -1 or 1 = no match, 0 = match */
 compare_strings(const char *s,         /* I - Command-line string */
                 const char *t,         /* I - Option string */
-                int        tmin)       /* I - Minimum number of unique chars in option */
+                size_t     tmin)       /* I - Minimum number of unique chars in option */
 {
-  int  slen;                           /* Length of command-line string */
+  size_t       slen;                   /* Length of command-line string */
 
 
   slen = strlen(s);
@@ -191,7 +176,7 @@ do_command(http_t     *http,                /* I - HTTP connection to server */
     show_help(params);
   else
     _cupsLangPrintf(stdout,
-                    _("%s is not implemented by the CUPS version of lpc.\n"),
+                    _("%s is not implemented by the CUPS version of lpc."),
                    command);
 }
 
@@ -208,14 +193,14 @@ show_help(const char *command)            /* I - Command to describe or NULL */
     _cupsLangPrintf(stdout,
                     _("Commands may be abbreviated.  Commands are:\n"
                      "\n"
-                     "exit    help    quit    status  ?\n"));
+                     "exit    help    quit    status  ?"));
   }
   else if (!compare_strings(command, "help", 1) || !strcmp(command, "?"))
-    _cupsLangPrintf(stdout, _("help\t\tget help on commands\n"));
+    _cupsLangPrintf(stdout, _("help\t\tGet help on commands."));
   else if (!compare_strings(command, "status", 4))
-    _cupsLangPrintf(stdout, _("status\t\tshow status of daemon and queue\n"));
+    _cupsLangPrintf(stdout, _("status\t\tShow status of daemon and queue."));
   else
-    _cupsLangPrintf(stdout, _("?Invalid help command unknown\n"));
+    _cupsLangPrintf(stdout, _("?Invalid help command unknown."));
 }
 
 
@@ -369,7 +354,8 @@ show_status(http_t     *http,               /* I - HTTP connection to server */
 
          for (ptr = printer;
               *ptr != '\0' && *dptr != '\0' && *ptr == *dptr;
-              ptr ++, dptr ++);
+              ptr ++, dptr ++)
+           /* do nothing */;
 
           if (*ptr == '\0' && (*dptr == '\0' || *dptr == ',' ||
                               isspace(*dptr & 255)))
@@ -405,7 +391,7 @@ show_status(http_t     *http,               /* I - HTTP connection to server */
         printf("%s:\n", printer);
        if (!strncmp(device, "file:", 5))
          _cupsLangPrintf(stdout,
-                         _("\tprinter is on device \'%s\' speed -1\n"),
+                         _("\tprinter is on device \'%s\' speed -1"),
                          device + 5);
        else
        {
@@ -417,27 +403,27 @@ show_status(http_t     *http,             /* I - HTTP connection to server */
          {
            *delimiter = '\0';
            _cupsLangPrintf(stdout,
-                           _("\tprinter is on device \'%s\' speed -1\n"),
+                           _("\tprinter is on device \'%s\' speed -1"),
                            device);
          }
        }
 
         if (accepting)
-         _cupsLangPuts(stdout, _("\tqueuing is enabled\n"));
+         _cupsLangPuts(stdout, _("\tqueuing is enabled"));
        else
-         _cupsLangPuts(stdout, _("\tqueuing is disabled\n"));
+         _cupsLangPuts(stdout, _("\tqueuing is disabled"));
 
         if (pstate != IPP_PRINTER_STOPPED)
-         _cupsLangPuts(stdout, _("\tprinting is enabled\n"));
+         _cupsLangPuts(stdout, _("\tprinting is enabled"));
        else
-         _cupsLangPuts(stdout, _("\tprinting is disabled\n"));
+         _cupsLangPuts(stdout, _("\tprinting is disabled"));
 
        if (jobcount == 0)
-         _cupsLangPuts(stdout, _("\tno entries\n"));
+         _cupsLangPuts(stdout, _("\tno entries"));
        else
-         _cupsLangPrintf(stdout, _("\t%d entries\n"), jobcount);
+         _cupsLangPrintf(stdout, _("\t%d entries"), jobcount);
 
-       _cupsLangPuts(stdout, _("\tdaemon present\n"));
+       _cupsLangPuts(stdout, _("\tdaemon present"));
       }
 
       if (attr == NULL)
@@ -447,8 +433,3 @@ show_status(http_t     *http,               /* I - HTTP connection to server */
     ippDelete(response);
   }
 }
-
-
-/*
- * End of "$Id: lpc.c 7079 2007-11-30 01:58:31Z mike $".
- */