* "cupsaccept", "cupsdisable", "cupsenable", and "cupsreject" commands for
* CUPS.
*
- * Copyright 2007-2017 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright © 2007-2018 by Apple Inc.
+ * Copyright © 1997-2006 by Easy Software Products.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
#include <cups/cups-private.h>
+/*
+ * Local functions...
+ */
+
+static void usage(const char *command) _CUPS_NORETURN;
+
+
/*
* 'main()' - Parse options and accept/reject jobs or disable/enable printers.
*/
cancel = 0;
- if (!strcmp(command, "cupsaccept") || !strcmp(command, "accept"))
+ if (!strcmp(command, "cupsaccept"))
op = CUPS_ACCEPT_JOBS;
- else if (!strcmp(command, "cupsreject") || !strcmp(command, "reject"))
+ else if (!strcmp(command, "cupsreject"))
op = CUPS_REJECT_JOBS;
- else if (!strcmp(command, "cupsdisable") || !strcmp(command, "disable"))
+ else if (!strcmp(command, "cupsdisable"))
op = IPP_PAUSE_PRINTER;
- else if (!strcmp(command, "cupsenable") || !strcmp(command, "enable"))
+ else if (!strcmp(command, "cupsenable"))
op = IPP_RESUME_PRINTER;
else
{
for (i = 1; i < argc; i ++)
{
- if (!strcmp(argv[i], "--hold"))
+ if (!strcmp(argv[i], "--help"))
+ usage(command);
+ else if (!strcmp(argv[i], "--hold"))
op = IPP_HOLD_NEW_JOBS;
else if (!strcmp(argv[i], "--release"))
op = IPP_RELEASE_HELD_NEW_JOBS;
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected username after \"-U\" option."), command);
- return (1);
+ usage(command);
}
cupsSetUser(argv[i]);
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected hostname after \"-h\" option."), command);
- return (1);
+ usage(command);
}
cupsSetServer(argv[i]);
if (i >= argc)
{
_cupsLangPrintf(stderr, _("%s: Error - expected reason text after \"-r\" option."), command);
- return (1);
+ usage(command);
}
reason = argv[i];
default :
_cupsLangPrintf(stderr, _("%s: Error - unknown option \"%c\"."), command, *opt);
- return (1);
+ usage(command);
}
}
}
return (0);
}
+
+
+/*
+ * 'usage()' - Show program usage and exit.
+ */
+
+static void
+usage(const char *command) /* I - Command name */
+{
+ _cupsLangPrintf(stdout, _("Usage: %s [options] destination(s)"), command);
+ _cupsLangPuts(stdout, _("Options:"));
+ _cupsLangPuts(stdout, _("-E Encrypt the connection to the server"));
+ _cupsLangPuts(stdout, _("-h server[:port] Connect to the named server and port"));
+ _cupsLangPuts(stdout, _("-r reason Specify a reason message that others can see"));
+ _cupsLangPuts(stdout, _("-U username Specify the username to use for authentication"));
+ if (!strcmp(command, "cupsdisable"))
+ _cupsLangPuts(stdout, _("--hold Hold new jobs"));
+ if (!strcmp(command, "cupsenable"))
+ _cupsLangPuts(stdout, _("--release Release previously held jobs"));
+
+ exit(1);
+}