]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - systemv/cupsctl.c
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / systemv / cupsctl.c
index ceaa4195577e5484398637e97b1ca20c38912a95..eedd01344e5e7815ba5ec1489b00b0e6e2612193 100644 (file)
@@ -1,40 +1,25 @@
 /*
- * "$Id$"
+ * Scheduler control program for CUPS.
  *
- *   CUPS control program for the Common UNIX Printing System (CUPS).
+ * Copyright 2007-2012 by Apple Inc.
+ * Copyright 2006-2007 by Easy Software Products.
  *
- *   Copyright 2007-2009 by Apple Inc.
- *   Copyright 2006-2007 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/".
- *
- *   This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- *   main()  - Get/set server settings.
- *   usage() - Show program usage.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
  * Include necessary headers...
  */
 
+#include <cups/cups-private.h>
 #include <cups/adminutil.h>
-#include <cups/string.h>
-#include <cups/i18n.h>
-#include <errno.h>
 
 
 /*
  * Local functions...
  */
 
-static void    usage(const char *opt);
+static void    usage(const char *opt) __attribute__((noreturn));
 
 
 /*
@@ -85,12 +70,6 @@ main(int  argc,                              /* I - Number of command-line args */
         else if (!strcmp(argv[i], "--no-remote-any"))
          num_settings = cupsAddOption(CUPS_SERVER_REMOTE_ANY, "0",
                                       num_settings, &settings);
-        else if (!strcmp(argv[i], "--remote-printers"))
-         num_settings = cupsAddOption(CUPS_SERVER_REMOTE_PRINTERS, "1",
-                                      num_settings, &settings);
-        else if (!strcmp(argv[i], "--no-remote-printers"))
-         num_settings = cupsAddOption(CUPS_SERVER_REMOTE_PRINTERS, "0",
-                                      num_settings, &settings);
         else if (!strcmp(argv[i], "--share-printers"))
          num_settings = cupsAddOption(CUPS_SERVER_SHARE_PRINTERS, "1",
                                       num_settings, &settings);
@@ -143,6 +122,13 @@ 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...
   */
@@ -150,7 +136,7 @@ main(int  argc,                             /* I - Number of command-line args */
   if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
                                  cupsEncryption())) == NULL)
   {
-    _cupsLangPrintf(stderr, _("cupsctl: Unable to connect to server: %s\n"),
+    _cupsLangPrintf(stderr, _("cupsctl: Unable to connect to server: %s"),
                     strerror(errno));
     return (1);
   }
@@ -163,19 +149,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);
@@ -193,34 +179,31 @@ 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                      Encrypt the connection."));
+  _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-]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$".
- */