From: Michael Sweet Date: Wed, 25 May 2016 15:55:27 +0000 (-0400) Subject: Add new administrative APis help. X-Git-Tag: v2.2b1~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dffa3c7438d26a8a96c7f4937d85a1467b833e8e;p=thirdparty%2Fcups.git Add new administrative APis help. --- diff --git a/Makefile b/Makefile index 1bc05d4f63..1698bd44a1 100644 --- a/Makefile +++ b/Makefile @@ -271,12 +271,6 @@ apihelp: (cd $$dir; $(MAKE) $(MFLAGS) apihelp) || exit 1;\ done -framedhelp: - for dir in cups filter; do\ - echo Generating framed API help in $$dir... ;\ - (cd $$dir; $(MAKE) $(MFLAGS) framedhelp) || exit 1;\ - done - # # Create an Xcode docset using Mini-XML's mxmldoc (http://www.msweet.org/)... diff --git a/cups/Makefile b/cups/Makefile index 593113abcc..d5c5df71c7 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -1,7 +1,7 @@ # # API library Makefile for CUPS. # -# Copyright 2007-2015 by Apple Inc. +# Copyright 2007-2016 by Apple Inc. # Copyright 1997-2006 by Easy Software Products, all rights reserved. # # These coded instructions, statements, and computer programs are the @@ -564,6 +564,13 @@ apihelp: --css ../doc/cups-printable.css \ --header api-overview.header --intro api-overview.shtml \ >../doc/help/api-overview.html + mxmldoc --section "Programming" --title "Administration APIs" \ + --css ../doc/cups-printable.css \ + --header api-admin.header --intro api-admin.shtml \ + api-admin.xml \ + adminutil.c adminutil.h getdevices.c >../doc/help/api-admin.html + mxmldoc --tokens help/api-admin.html api-admin.xml >../doc/help/api-admin.tokens + $(RM) api-admin.xml mxmldoc --section "Programming" --title "Array API" \ --css ../doc/cups-printable.css \ --header api-array.header --intro api-array.shtml \ @@ -612,50 +619,6 @@ apihelp: mxmldoc --tokens help/api-filter.html api-filter.xml >../doc/help/api-filter.tokens $(RM) api-filter.xml -framedhelp: - echo Generating CUPS API help files... - mxmldoc --framed api-overview \ - --section "Programming" \ - --title "Introduction to CUPS Programming" \ - --css ../doc/cups-printable.css \ - --header api-overview.header --intro api-overview.shtml - mxmldoc --framed api-array \ - --section "Programming" --title "Array API" \ - --css ../doc/cups-printable.css \ - --header api-array.header --intro api-array.shtml \ - array.h array.c - mxmldoc --framed api-cups \ - --section "Programming" --title "CUPS API" \ - --css ../doc/cups-printable.css \ - --header api-cups.header --intro api-cups.shtml \ - cups.h adminutil.c dest*.c language.c notify.c \ - options.c tempfile.c usersys.c \ - util.c - mxmldoc --framed api-filedir \ - --section "Programming" --title "File and Directory APIs" \ - --css ../doc/cups-printable.css \ - --header api-filedir.header --intro api-filedir.shtml \ - file.h file.c dir.h dir.c - mxmldoc --framed api-ppd \ - --section "Programming" --title "PPD API (DEPRECATED)" \ - --css ../doc/cups-printable.css \ - --header api-ppd.header --intro api-ppd.shtml \ - ppd.h attr.c conflicts.c custom.c emit.c localize.c mark.c \ - page.c ppd.c - mxmldoc --framed api-httpipp \ - --section "Programming" --title "HTTP and IPP APIs" \ - --css ../doc/cups-printable.css \ - --header api-httpipp.header --intro api-httpipp.shtml \ - http.h ipp.h auth.c getdevices.c getputfile.c encode.c \ - http.c http-addr.c http-support.c ipp.c ipp-support.c \ - md5passwd.c request.c - mxmldoc --framed api-filter \ - --section "Programming" \ - --title "Filter and Backend Programming" \ - --css ../doc/cups-printable.css \ - --header api-filter.header --intro api-filter.shtml \ - backchannel.c backend.h backend.c sidechannel.c sidechannel.h - # # Lines of code computation... diff --git a/cups/api-admin.header b/cups/api-admin.header new file mode 100644 index 0000000000..a3ce3b1e33 --- /dev/null +++ b/cups/api-admin.header @@ -0,0 +1,34 @@ + + +

Administrative APIs

+ +
+ + + + + + + + + + + + + + + + +
Headercups/adminutil.h
Library-lcups
See AlsoProgramming: Introduction to CUPS Programming
+ Programming: CUPS API
+ Programming: HTTP and IPP APIs
diff --git a/cups/api-admin.shtml b/cups/api-admin.shtml new file mode 100644 index 0000000000..8928e4787a --- /dev/null +++ b/cups/api-admin.shtml @@ -0,0 +1,96 @@ + + +

Overview

+ +

The administrative APIs provide convenience functions to perform certain administrative functions with the CUPS scheduler.

+ +
Note: +

Administrative functions normally require administrative privileges to execute and must not be used in ordinary user applications!

+
+ +

Scheduler Settings

+ +

The cupsAdminGetServerSettings and cupsAdminSetServerSettings functions allow you to get and set simple directives and their values, respectively, in the cupsd.conf file for the CUPS scheduler. Settings are stored in CUPS option arrays which provide a simple list of string name/value pairs. While any simple cupsd.conf directive name can be specified, the following convenience names are also defined to control common complex directives:

+ +
    +
  • CUPS_SERVER_DEBUG_LOGGING
  • : For cupsAdminGetServerSettings, a value of "1" means that the LogLevel directive is set to debug or debug2 while a value of "0" means it is set to any other value. For cupsAdminSetServerSettings a value of "1" sets the LogLeveL to debug while a value of "0" sets it to warn. +
  • CUPS_SERVER_REMOTE_ADMIN
  • : A value of "1" specifies that administrative requests are accepted from remote addresses while "0" specifies that requests are only accepted from local addresses (loopback interface and domain sockets). +
  • CUPS_SERVER_REMOTE_ANY
  • : A value of "1" specifies that requests are accepts from any address while "0" specifies that requests are only accepted from the local subnet (when sharing is enabled) or local addresses (loopback interface and domain sockets). +
  • CUPS_SERVER_SHARE_PRINTERS
  • : A value of "1" specifies that printer sharing is enabled for selected printers and remote requests are accepted while a value of "0" specifies that printer sharing is disables and remote requests are not accepted. +
  • CUPS_SERVER_USER_CANCEL_ANY
  • : A value of "1" specifies that the default security policy allows any user to cancel any print job, regardless of the owner. A value of "0" specifies that only administrative users can cancel other user's jobs. +
+ +
Note: +

Changing settings will restart the CUPS scheduler.

+

When printer sharing or the web interface are enabled, the scheduler's launch-on-demand functionality is effectively disabled. This can affect power usage, system performance, and the security profile of a system.

+
+ +

The recommended way to make changes to the cupsd.conf is to first call cupsAdminGetServerSettings, make any changes to the returned option array, and then call cupsAdminSetServerSettings to save those settings. For example, to enable the web interface:

+ +
+#include <cups/cups.h>
+#include <cups/adminutil.h>
+
+void
+enable_web_interface(void)
+{
+  int num_settings = 0;           /* Number of settings */
+  cups_option_t *settings = NULL; /* Settings */
+
+
+  if (!cupsAdminGetServerSettings(CUPS_HTTP_DEFAULT, &num_settings, &settings))
+  {
+    fprintf(stderr, "ERROR: Unable to get server settings: %s\n", cupsLastErrorString());
+    return;
+  }
+
+  num_settings = cupsAddOption("WebInterface", "Yes", num_settings, &settings);
+
+  if (!cupsAdminSetServerSettings(CUPS_HTTP_DEFAULT, num_settings, settings))
+  {
+    fprintf(stderr, "ERROR: Unable to set server settings: %s\n", cupsLastErrorString());
+  }
+
+  cupsFreeOptions(num_settings, settings);
+}
+
+ +

Devices

+ +

Printers can be discovered through the CUPS scheduler using the cupsGetDevices API. Typically this API is used to locate printers to add the the system. Each device that is found will cause a supplied callback function to be executed. For example, to list the available printer devices that can be found within 30 seconds:

+ +
+#include <cups/cups.h>
+#include <cups/adminutil.h>
+
+
+void
+get_devices_cb(
+    const char *device_class,           /* I - Class */
+    const char *device_id,              /* I - 1284 device ID */
+    const char *device_info,            /* I - Description */
+    const char *device_make_and_model,  /* I - Make and model */
+    const char *device_uri,             /* I - Device URI */
+    const char *device_location,        /* I - Location */
+    void       *user_data)              /* I - User data */
+{
+  puts(device_uri);
+}
+
+
+void
+show_devices(void)
+{
+  cupsGetDevices(CUPS_HTTP_DEFAULT, 30, NULL, NULL, get_devices_cb, NULL);
+}
+
diff --git a/cups/api-filter.header b/cups/api-filter.header index d2cca7af26..f08bc71b76 100644 --- a/cups/api-filter.header +++ b/cups/api-filter.header @@ -1,7 +1,7 @@ + + Administration APIs + + + + + + +
+ + +

Administrative APIs

+ +
+ + + + + + + + + + + + + + + + +
Headercups/adminutil.h
Library-lcups
See AlsoProgramming: Introduction to CUPS Programming
+ Programming: CUPS API
+ Programming: HTTP and IPP APIs
+

Contents

+ + + +

Overview

+ +

The administrative APIs provide convenience functions to perform certain administrative functions with the CUPS scheduler.

+ +
Note: +

Administrative functions normally require administrative privileges to execute and must not be used in ordinary user applications!

+
+ +

Scheduler Settings

+ +

The cupsAdminGetServerSettings and cupsAdminSetServerSettings functions allow you to get and set simple directives and their values, respectively, in the cupsd.conf file for the CUPS scheduler. Settings are stored in CUPS option arrays which provide a simple list of string name/value pairs. While any simple cupsd.conf directive name can be specified, the following convenience names are also defined to control common complex directives:

+ +
    +
  • CUPS_SERVER_DEBUG_LOGGING
  • : For cupsAdminGetServerSettings, a value of "1" means that the LogLevel directive is set to debug or debug2 while a value of "0" means it is set to any other value. For cupsAdminSetServerSettings a value of "1" sets the LogLeveL to debug while a value of "0" sets it to warn. +
  • CUPS_SERVER_REMOTE_ADMIN
  • : A value of "1" specifies that administrative requests are accepted from remote addresses while "0" specifies that requests are only accepted from local addresses (loopback interface and domain sockets). +
  • CUPS_SERVER_REMOTE_ANY
  • : A value of "1" specifies that requests are accepts from any address while "0" specifies that requests are only accepted from the local subnet (when sharing is enabled) or local addresses (loopback interface and domain sockets). +
  • CUPS_SERVER_SHARE_PRINTERS
  • : A value of "1" specifies that printer sharing is enabled for selected printers and remote requests are accepted while a value of "0" specifies that printer sharing is disables and remote requests are not accepted. +
  • CUPS_SERVER_USER_CANCEL_ANY
  • : A value of "1" specifies that the default security policy allows any user to cancel any print job, regardless of the owner. A value of "0" specifies that only administrative users can cancel other user's jobs. +
+ +
Note: +

Changing settings will restart the CUPS scheduler.

+

When printer sharing or the web interface are enabled, the scheduler's launch-on-demand functionality is effectively disabled. This can affect power usage, system performance, and the security profile of a system.

+
+ +

The recommended way to make changes to the cupsd.conf is to first call cupsAdminGetServerSettings, make any changes to the returned option array, and then call cupsAdminSetServerSettings to save those settings. For example, to enable the web interface:

+ +
+#include <cups/cups.h>
+#include <cups/adminutil.h>
+
+void
+enable_web_interface(void)
+{
+  int num_settings = 0;           /* Number of settings */
+  cups_option_t *settings = NULL; /* Settings */
+
+
+  if (!cupsAdminGetServerSettings(CUPS_HTTP_DEFAULT, &num_settings, &settings))
+  {
+    fprintf(stderr, "ERROR: Unable to get server settings: %s\n", cupsLastErrorString());
+    return;
+  }
+
+  num_settings = cupsAddOption("WebInterface", "Yes", num_settings, &settings);
+
+  if (!cupsAdminSetServerSettings(CUPS_HTTP_DEFAULT, num_settings, settings))
+  {
+    fprintf(stderr, "ERROR: Unable to set server settings: %s\n", cupsLastErrorString());
+  }
+
+  cupsFreeOptions(num_settings, settings);
+}
+
+ +

Devices

+ +

Printers can be discovered through the CUPS scheduler using the cupsGetDevices API. Typically this API is used to locate printers to add the the system. Each device that is found will cause a supplied callback function to be executed. For example, to list the available printer devices that can be found within 30 seconds:

+ +
+#include <cups/cups.h>
+#include <cups/adminutil.h>
+
+
+void
+get_devices_cb(
+    const char *device_class,           /* I - Class */
+    const char *device_id,              /* I - 1284 device ID */
+    const char *device_info,            /* I - Description */
+    const char *device_make_and_model,  /* I - Make and model */
+    const char *device_uri,             /* I - Device URI */
+    const char *device_location,        /* I - Location */
+    void       *user_data)              /* I - User data */
+{
+  puts(device_uri);
+}
+
+
+void
+show_devices(void)
+{
+  cupsGetDevices(CUPS_HTTP_DEFAULT, 30, NULL, NULL, get_devices_cb, NULL);
+}
+
+

Functions

+

 DEPRECATED cupsAdminCreateWindowsPPD

+

Create the Windows PPD file for a printer.

+

+char *cupsAdminCreateWindowsPPD (
+    http_t *http,
+    const char *dest,
+    char *buffer,
+    int bufsize
+);

+

Parameters

+
+
http
+
Connection to server or CUPS_HTTP_DEFAULT
+
dest
+
Printer or class
+
buffer
+
Filename buffer
+
bufsize
+
Size of filename buffer
+
+

Return Value

+

PPD file or NULL

+

 DEPRECATED cupsAdminExportSamba

+

Export a printer to Samba.

+

+int cupsAdminExportSamba (
+    const char *dest,
+    const char *ppd,
+    const char *samba_server,
+    const char *samba_user,
+    const char *samba_password,
+    FILE *logfile
+);

+

Parameters

+
+
dest
+
Destination to export
+
ppd
+
PPD file
+
samba_server
+
Samba server
+
samba_user
+
Samba username
+
samba_password
+
Samba password
+
logfile
+
Log file, if any
+
+

Return Value

+

1 on success, 0 on failure

+

 CUPS 1.3/OS X 10.5 cupsAdminGetServerSettings

+

Get settings from the server.

+

+int cupsAdminGetServerSettings (
+    http_t *http,
+    int *num_settings,
+    cups_option_t **settings
+);

+

Parameters

+
+
http
+
Connection to server or CUPS_HTTP_DEFAULT
+
num_settings
+
Number of settings
+
settings
+
Settings
+
+

Return Value

+

1 on success, 0 on failure

+

Discussion

+

The returned settings should be freed with cupsFreeOptions() when +you are done with them. + +

+

 CUPS 1.3/OS X 10.5 cupsAdminSetServerSettings

+

Set settings on the server.

+

+int cupsAdminSetServerSettings (
+    http_t *http,
+    int num_settings,
+    cups_option_t *settings
+);

+

Parameters

+
+
http
+
Connection to server or CUPS_HTTP_DEFAULT
+
num_settings
+
Number of settings
+
settings
+
Settings
+
+

Return Value

+

1 on success, 0 on failure

+

 CUPS 1.4/OS X 10.6 cupsGetDevices

+

Get available printer devices.

+

+ipp_status_t cupsGetDevices (
+    http_t *http,
+    int timeout,
+    const char *include_schemes,
+    const char *exclude_schemes,
+    cups_device_cb_t callback,
+    void *user_data
+);

+

Parameters

+
+
http
+
Connection to server or CUPS_HTTP_DEFAULT
+
timeout
+
Timeout in seconds or CUPS_TIMEOUT_DEFAULT
+
include_schemes
+
Comma-separated URI schemes to include or CUPS_INCLUDE_ALL
+
exclude_schemes
+
Comma-separated URI schemes to exclude or CUPS_EXCLUDE_NONE
+
callback
+
Callback function
+
user_data
+
User data pointer
+
+

Return Value

+

Request status - IPP_OK on success.

+

Discussion

+

This function sends a CUPS-Get-Devices request and streams the discovered +devices to the specified callback function. The "timeout" parameter controls +how long the request lasts, while the "include_schemes" and "exclude_schemes" +parameters provide comma-delimited lists of backends to include or omit from +the request respectively. + +

+

Data Types

+

 CUPS 1.4/OS X 10.6 cups_device_cb_t

+

Device callback +

+

+typedef void (*cups_device_cb_t)(const char *device_class, const char *device_id, const char *device_info, const char *device_make_and_model, const char *device_uri, const char *device_location, void *user_data); +

+
+ + diff --git a/doc/help/api-filter.html b/doc/help/api-filter.html index 0dfd129b9b..22ea732c23 100644 --- a/doc/help/api-filter.html +++ b/doc/help/api-filter.html @@ -355,7 +355,7 @@ div.contents ul.subcontents li {