]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - systemv/cupsctl.c
Merge changes from CUPS 1.5svn-r9641
[thirdparty/cups.git] / systemv / cupsctl.c
index bc044a9adf5087cbd437b4b0692eaede4a6d5c05..eabc6e479ef6011d16a039d1c83a5412de6d4356 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: cupsctl.c 6379 2007-03-21 14:57:22Z mike $"
+ * "$Id$"
  *
- *   CUPS control program for the Common UNIX Printing System (CUPS).
+ *   Scheduler control program for CUPS.
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 2006-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -24,9 +24,8 @@
  * Include necessary headers...
  */
 
+#include <cups/cups-private.h>
 #include <cups/adminutil.h>
-#include <cups/string.h>
-#include <cups/i18n.h>
 
 
 /*
@@ -66,7 +65,7 @@ main(int  argc,                               /* I - Number of command-line args */
     {
       if (argv[i][1] == '-')
       {
-        if (!strcmp(argv[i], "--debug_logging"))
+        if (!strcmp(argv[i], "--debug-logging"))
          num_settings = cupsAddOption(CUPS_SERVER_DEBUG_LOGGING, "1",
                                       num_settings, &settings);
         else if (!strcmp(argv[i], "--no-debug-logging"))
@@ -142,11 +141,24 @@ main(int  argc,                           /* I - Number of command-line args */
       usage(argv[i]);
   }
 
+  if (cupsGetOption("Listen", num_settings, settings) ||
+      cupsGetOption("Port", num_settings, settings))
+  {
+    _cupsLangPuts(stderr, _("cupsctl: Cannot set Listen or Port directly."));
+    return (1);
+  }
+
  /*
   * Connect to the server using the defaults...
   */
 
-  http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+  if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
+                                 cupsEncryption())) == NULL)
+  {
+    _cupsLangPrintf(stderr, _("cupsctl: Unable to connect to server: %s"),
+                    strerror(errno));
+    return (1);
+  }
 
  /*
   * Set the current configuration if we have anything on the command-line...
@@ -156,19 +168,19 @@ main(int  argc,                           /* I - Number of command-line args */
   {
     if (!cupsAdminSetServerSettings(http, num_settings, settings))
     {
-      _cupsLangPrintf(stderr, "cupsctl: %s\n", cupsLastErrorString());
+      _cupsLangPrintf(stderr, "cupsctl: %s", cupsLastErrorString());
       return (1);
     }
   }
   else if (!cupsAdminGetServerSettings(http, &num_settings, &settings))
   {
-    _cupsLangPrintf(stderr, "cupsctl: %s\n", cupsLastErrorString());
+    _cupsLangPrintf(stderr, "cupsctl: %s", cupsLastErrorString());
     return (1);
   }
   else
   {
     for (i = 0; i < num_settings; i ++)
-      _cupsLangPrintf(stdout, "%s=%s\n", settings[i].name, settings[i].value);
+      _cupsLangPrintf(stdout, "%s=%s", settings[i].name, settings[i].value);
   }
 
   cupsFreeOptions(num_settings, settings);
@@ -186,34 +198,38 @@ usage(const char *opt)                    /* I - Option character/string */
   if (opt)
   {
     if (*opt == '-')
-      _cupsLangPrintf(stderr, _("cupsctl: Unknown option \"%s\"!\n"), opt);
+      _cupsLangPrintf(stderr, _("cupsctl: Unknown option \"%s\""), opt);
     else
-      _cupsLangPrintf(stderr, _("cupsctl: Unknown option \"-%c\"!\n"), *opt);
+      _cupsLangPrintf(stderr, _("cupsctl: Unknown option \"-%c\""), *opt);
   }
 
-  _cupsLangPuts(stdout,
-                _("Usage: cupsctl [options] [param=value ... paramN=valueN]\n"
-                 "\n"
-                 "Options:\n"
-                 "\n"
-                 "    -E                      Enable encryption\n"
-                 "    -U username             Specify username\n"
-                 "    -h server[:port]        Specify server address\n"
-                 "\n"
-                 "    --[no-]debug-logging    Turn debug logging on/off\n"
-                 "    --[no-]remote-admin     Turn remote administration "
-                 "on/off\n"
-                 "    --[no-]remote-any       Allow/prevent access from the "
-                 "Internet\n"
-                 "    --[no-]remote-printers  Show/hide remote printers\n"
-                 "    --[no-]share-printers   Turn printer sharing on/off\n"
-                 "    --[no-]user-cancel-any  Allow/prevent users to cancel "
-                 "any job\n"));
+  _cupsLangPuts(stdout, _("Usage: cupsctl [options] [param=value ... "
+                          "paramN=valueN]"));
+  _cupsLangPuts(stdout, "");
+  _cupsLangPuts(stdout, _("Options:"));
+  _cupsLangPuts(stdout, "");
+  _cupsLangPuts(stdout, _("  -E                      Enable encryption."));
+  _cupsLangPuts(stdout, _("  -U username             Specify username."));
+  _cupsLangPuts(stdout, _("  -h server[:port]        Specify server "
+                          "address."));
+  _cupsLangPuts(stdout, "");
+  _cupsLangPuts(stdout, _("  --[no-]debug-logging    Turn debug logging "
+                          "on/off."));
+  _cupsLangPuts(stdout, _("  --[no-]remote-admin     Turn remote "
+                          "administration on/off."));
+  _cupsLangPuts(stdout, _("  --[no-]remote-any       Allow/prevent access "
+                          "from the Internet."));
+  _cupsLangPuts(stdout, _("  --[no-]remote-printers  Show/hide remote "
+                          "printers."));
+  _cupsLangPuts(stdout, _("  --[no-]share-printers   Turn printer sharing "
+                          "on/off."));
+  _cupsLangPuts(stdout, _("  --[no-]user-cancel-any  Allow/prevent users to "
+                          "cancel any job."));
 
   exit(1);
 }
 
 
 /*
- * End of "$Id: cupsctl.c 6379 2007-03-21 14:57:22Z mike $".
+ * End of "$Id$".
  */