]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
First pass at a new PHP API for CUPS with the following PHP functions:
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Sat, 25 Feb 2006 08:44:43 +0000 (08:44 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Sat, 25 Feb 2006 08:44:43 +0000 (08:44 +0000)
    cups_cancel_job()
    cups_get_dests()
    cups_get_jobs()
    cups_last_error()
    cups_last_error_string()
    cups_print_file()
    cups_print_files()

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@5171 7a7537e8-13f0-0310-91df-b6672ffda945

scripting/php/Dependencies
scripting/php/Makefile
scripting/php/README
scripting/php/php_phpcups.h [deleted file]
scripting/php/phpcups.c
scripting/php/phpcups.h [new file with mode: 0644]
scripting/php/phpcups.php [changed mode: 0644->0755]

index c5e45a09ca05f19cf75f20ca3a3c3be7d0927947..f674ca767cbd4018a0e2cf972203a364257ee766 100644 (file)
@@ -1,6 +1,6 @@
 # DO NOT DELETE
 
-phpcups.o: php_phpcups.h ../../cups/cups.h ../../cups/ipp.h ../../cups/http.h
-phpcups.o: ../../cups/md5.h ../../cups/ppd.h ../../cups/ipp.h
-phpcups.o: ../../cups/language.h ../../cups/string.h ../../config.h
-phpcups.o: ../../cups/debug.h
+phpcups.o: phpcups.h ../../cups/cups.h ../../cups/ipp.h ../../cups/http.h
+phpcups.o: ../../cups/md5.h ../../cups/ppd.h ../../cups/array.h
+phpcups.o: ../../cups/file.h ../../cups/language.h ../../cups/language.h
+phpcups.o: ../../cups/string.h ../../config.h ../../cups/debug.h
index c93559e4b6940a6332a4e9e9cb873da9924845f5..69d2202b27a6e1c636b66e4905969e61cb1181fd 100644 (file)
@@ -3,7 +3,7 @@
 #
 #   PHP Makefile for the Common UNIX Printing System (CUPS).
 #
-#   Copyright 1997-2005 by Easy Software Products, all rights reserved.
+#   Copyright 1997-2006 by Easy Software Products, all rights reserved.
 #
 #   These coded instructions, statements, and computer programs are the
 #   property of Easy Software Products and are protected by Federal
 #       Attn: CUPS Licensing Information
 #       Easy Software Products
 #       44141 Airport View Drive, Suite 204
-#       Hollywood, Maryland 20636-3111 USA
+#       Hollywood, Maryland 20636 USA
 #
 #       Voice: (301) 373-9603
 #       EMail: cups-info@cups.org
-#         WWW: http://www.cups.org
+#         WWW: http://www.cups.org/
 #
 
 include ../../Makedefs
index 0cb23f1d59676321a9f6fac36852629a45faaf3b..116230cc62a530ef2a3d7bcea091af301badd7c4 100644 (file)
-README - 04/08/2003
+README - 02/25/2006
 -------------------
 
-This directory contains a dynamically loadable CUPS extension
-module for PHP 4.  To compile it type:
+INTRODUCTION
 
-    make
+    This directory contains a dynamically loadable CUPS extension
+    module for PHP 4 and 5.  The CUPS 1.2 module has been
+    substantially updated to provide an API more consistent with
+    the C API and is NOT compatible with the CUPS 1.1 module.
 
-To install it, type:
 
-    make install
+COMPILING AND INSTALLING
 
-Questions should be reported to the CUPS newsgroups/mailing
-lists at:
+    Run "make" to compile the PHP CUPS extension:
 
-    http://www.cups.org/newsgroups.php
+       make
 
-Bug reports and enhancement requests can be submitted via the
-form at:
+    To install it, type:
+
+       make install
+
+
+RESOURCES AND SUPPORT
+
+    Questions should be reported to the CUPS newsgroups/mailing
+    lists at:
+
+       http://www.cups.org/newsgroups.php
+
+    Bug reports and enhancement requests can be submitted via the
+    form at:
+
+       http://www.cups.org/str.php
+
+
+QUICK REFERENCE DOCUMENTATION
+
+    In lieu of actual documentation, the following definitions
+    can be used as a quick reference to the supported functions:
+
+
+cups_cancel_job()
+
+    Cancels a job on the named destination:
+
+        $status = cups_cancel_job($dest, $id);
+
+    The return value is TRUE on success and FALSE on failure.
+
+
+cups_get_dests()
+
+    Gets a list of available destinations:
+
+        $dests = cups_get_dests();
+
+    The return value is an array of objects with the following
+    properties:
+
+        name        The name of the printer or class
+       instance    The instance of the printer or class
+       is_default  TRUE if the printer or class is the default destination
+       options     Associative array of options and their values
+
+
+cups_get_jobs()
+
+    Gets a list of jobs:
+
+        $jobs = cups_get_jobs("dest", myjobs, completed);
+
+    The "dest" string can be blank for jobs on all destinations.
+    Pass TRUE for "myjobs" to only get jobs for the current user.
+    The "completed" argument can be 0 for pending jobs, 1 for
+    completed jobs, and -1 for all jobs.
+
+    The return value is an array of objects with the following
+    properties:
+
+        id                The job ID
+        dest              Printer or class name
+        title             Title/job name
+        user              User the submitted the job
+        format            Document format
+        state             Job state
+        size              Size in kilobytes
+        priority          Priority (1-100)
+        completed_time    Time the job was completed
+        creation_time     Time the job was created
+        processing_time   Time the job was processed
+
+
+    cups_last_error()
+    
+    Returns the IPP status code for the most recent request:
+
+        $error = cups_last_error();
+
+
+    cups_last_error_string()
+    
+    Returns the IPP status-message string for the most recent request:
+
+        $message = cups_last_error_string();
+
+
+    cups_print_file()
+
+    Prints a single file to a printer or class:
+
+        $options = array("name" => "value", "name2" => "value2");
+       $id      = cups_print_file("dest", "filename", "title", $options);
+
+    The return value is the job ID or 0 if there was an error.
+
+
+    cups_print_files()
+
+    Prints one or more files to a printer or class:
+
+        $files   = array("file1", "file2", "file3");
+        $options = array("name" => "value", "name2" => "value2");
+       $id      = cups_print_file("dest", $files, "title", $options);
+
+    The return value is the job ID or 0 if there was an error.
 
-    http://www.cups.org/str.php
diff --git a/scripting/php/php_phpcups.h b/scripting/php/php_phpcups.h
deleted file mode 100644 (file)
index ad9771b..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * "$Id$"
- *
- *   PHP module include file for the Common UNIX Printing System (CUPS).
- *
- *   Copyright 1997-2003 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products 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 please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636-3111 USA
- *
- *       Voice: (301) 373-9603
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
- */
-
-#ifndef PHP_PHPCUPS_H
-#  define PHP_PHPCUPS_H
-
-extern zend_module_entry phpcups_module_entry;
-#  define phpext_phpcups_ptr &phpcups_module_entry
-
-#  ifdef PHP_WIN32
-#    define PHP_PHPCUPS_API __declspec(dllexport)
-#  else
-#    define PHP_PHPCUPS_API
-#  endif
-
-#  ifdef ZTS
-#    include "TSRM.h"
-#  endif
-
-PHP_MINIT_FUNCTION(phpcups);
-PHP_MSHUTDOWN_FUNCTION(phpcups);
-PHP_RINIT_FUNCTION(phpcups);
-PHP_RSHUTDOWN_FUNCTION(phpcups);
-PHP_MINFO_FUNCTION(phpcups);
-
-PHP_FUNCTION(confirm_phpcups_compiled);        
-PHP_FUNCTION(cups_get_dest_options);   
-PHP_FUNCTION(cups_get_dest_list);      
-PHP_FUNCTION(cups_get_jobs);   
-PHP_FUNCTION(cups_cancel_job); 
-PHP_FUNCTION(cups_print_file); 
-PHP_FUNCTION(cups_last_error); 
-PHP_FUNCTION(cups_get_printer_attributes);     
-
-/* 
-       Declare any global variables you may need between the BEGIN
-       and END macros here:     
-
-ZEND_BEGIN_MODULE_GLOBALS(phpcups)
-       int   global_value;
-       char *global_string;
-ZEND_END_MODULE_GLOBALS(phpcups)
-*/
-
-/* In every utility function you add that needs to use variables 
-   in php_phpcups_globals, call TSRM_FETCH(); after declaring other 
-   variables used by that function, or better yet, pass in TSRMG_CC
-   after the last function argument and declare your utility function
-   with TSRMG_DC after the last declared argument.  Always refer to
-   the globals in your function as PHPCUPS_G(variable).  You are 
-   encouraged to rename these macros something shorter, see
-   examples in any other php module directory.
-*/
-
-#  ifdef ZTS
-#    define PHPCUPS_G(v) TSRMG(phpcups_globals_id, zend_phpcups_globals *, v)
-#  else
-#    define PHPCUPS_G(v) (phpcups_globals.v)
-#  endif
-
-#endif /* !PHP_PHPCUPS_H */
-
-
-/*
- * End of "$Id$".
- */
index 406b01eb59549b4c1a06f88281587003e9e83774..3faf1a1928dfd5cdd6e0c73bd54da16ef8cea567 100644 (file)
@@ -1,28 +1,9 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP version 4.0                                                      |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 2.02 of the PHP license,      |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available at through the world-wide-web at                           |
-   | http://www.php.net/license/2_02.txt.                                 |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Authors:                                                             |
-   |                                                                      |
-   +----------------------------------------------------------------------+
- */
-
 /*
  * "$Id$"
  *
  *   Printing utilities for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1997-2002 by Easy Software Products.
+ *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Easy Software Products and are protected by Federal
  *       Attn: CUPS Licensing Information
  *       Easy Software Products
  *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636-3111 USA
+ *       Hollywood, Maryland 20636 USA
  *
  *       Voice: (301) 373-9603
  *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *         WWW: http://www.cups.org/
+ *
+ * Contents:
+ *
  */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "php_phpcups.h"
-
 /*
  * Include necessary headers...
  */
 
-#include <config.h>
-#include <cups/cups.h>
-#include <cups/ipp.h>
-#include <cups/language.h>
 #include <cups/string.h>
-#include <cups/debug.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#if defined(WIN32) || defined(__EMX__)
-#  include <io.h>
-#else
-#  include <unistd.h>
-#endif /* WIN32 || __EMX__ */
-
-
-static int le_result, le_link, le_plink;
-
-
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "phpcups.h"
 
 
-/*
- * Local globals...
+/* 
+ * PHP function list...
  */
 
-static http_t          *cups_server = NULL;    /* Current server connection */
-static ipp_status_t    last_error = IPP_OK;    /* Last IPP error */
-static char            authstring[HTTP_MAX_VALUE] = "";
-                                               /* Authorization string */
-static char            pwdstring[33] = "";     /* Last password string */
-
-
-
+function_entry phpcups_functions[] =
+{
+  PHP_FE(cups_cancel_job, NULL)
+  PHP_FE(cups_get_dests, NULL)
+  PHP_FE(cups_get_jobs, NULL)
+  PHP_FE(cups_last_error, NULL)
+  PHP_FE(cups_last_error_string, NULL)
+  PHP_FE(cups_print_file, NULL)
+  PHP_FE(cups_print_files, NULL)
+  {NULL, NULL, NULL}
+};
 
 
 /*
- *  *********************************************************************
+ * PHP module info...
  */
 
-
-
-
-/* If you declare any globals in php_phpcups.h uncomment this:
-ZEND_DECLARE_MODULE_GLOBALS(phpcups)
-*/
-
-/* True global resources - no need for thread safety here */
-static int le_phpcups;
-
-/* 
- * Every user visible function must have an entry in phpcups_functions[].
- */
-function_entry phpcups_functions[] = {
-       PHP_FE(confirm_phpcups_compiled,NULL)
-       PHP_FE(cups_get_dest_list,      NULL)           
-       PHP_FE(cups_get_dest_options,   NULL)           
-       PHP_FE(cups_get_jobs,   NULL)           
-       PHP_FE(cups_cancel_job, NULL)           
-       PHP_FE(cups_last_error, NULL)           
-       PHP_FE(cups_print_file, NULL)           
-       PHP_FE(cups_get_printer_attributes,     NULL)           
-       {NULL, NULL, NULL}      
+zend_module_entry phpcups_module_entry =
+{
+  STANDARD_MODULE_HEADER,
+  "phpcups",
+  phpcups_functions,
+  PHP_MINIT(phpcups),
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  CUPS_SVERSION,
+  STANDARD_MODULE_PROPERTIES
 };
 
 
-
-
-zend_module_entry phpcups_module_entry = {
-       STANDARD_MODULE_HEADER,
-       "phpcups",
-       phpcups_functions,
-       PHP_MINIT(phpcups),
-       PHP_MSHUTDOWN(phpcups),
-       PHP_RINIT(phpcups),             /* Replace with NULL if there's nothing to do at request start */
-       PHP_RSHUTDOWN(phpcups), /* Replace with NULL if there's nothing to do at request end */
-       PHP_MINFO(phpcups),
-    "0.1", /* Replace with version number for your extension */
-       STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef COMPILE_DL_PHPCUPS
 ZEND_GET_MODULE(phpcups)
-#endif
-
-
-
-
-/* Remove comments and fill if you need to have entries in php.ini
-PHP_INI_BEGIN()
-    STD_PHP_INI_ENTRY("phpcups.value",      "42", PHP_INI_ALL, OnUpdateInt, global_value, zend_phpcups_globals, phpcups_globals)
-    STD_PHP_INI_ENTRY("phpcups.string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_phpcups_globals, phpcups_globals)
-PHP_INI_END()
-*/
-
 
 
+/*
+ * 'cups_convert_options()' - Convert a PHP options array to a CUPS options array.
+ */
 
-/* Uncomment this function if you have INI entries
-static void php_phpcups_init_globals(zend_phpcups_globals *phpcups_globals)
+static int                             /* O - Number of options */
+cups_convert_options(
+    zval          *optionsobj,         /* I - Options array object */
+    cups_option_t **options)           /* O - Options */
 {
-       phpcups_globals->value = 0;
-       phpcups_globals->string = NULL;
-}
-*/
+  int          num_options;            /* Number of options */
+  HashTable    *ht;                    /* Option array hash table */
+  Bucket       *current;               /* Current element in array */
 
 
+  ht          = Z_ARRVAL_P(optionsobj);
+  num_options = 0;
 
+  for (current = ht->pListHead; current; current = current->pListNext)
+    num_options = cupsAddOption(current->arKey,
+                                Z_STRVAL_P(((zval *)current->pDataPtr)),
+                               num_options, options);
 
-PHP_MINIT_FUNCTION(phpcups)
-{
-       /* If you have INI entries, uncomment these lines 
-       ZEND_INIT_MODULE_GLOBALS(phpcups, php_phpcups_init_globals, NULL);
-       REGISTER_INI_ENTRIES();
-       */
-       return SUCCESS;
+  return (num_options);
 }
 
-PHP_MSHUTDOWN_FUNCTION(phpcups)
-{
-       /* uncomment this line if you have INI entries
-       UNREGISTER_INI_ENTRIES();
-       */
-       return SUCCESS;
-}
 
-/* Remove if there's nothing to do at request start */
-PHP_RINIT_FUNCTION(phpcups)
-{
-       return SUCCESS;
-}
+/*
+ * 'zm_startup_phpcups()' - Initialize the CUPS module.
+ */
 
-/* Remove if there's nothing to do at request end */
-PHP_RSHUTDOWN_FUNCTION(phpcups)
+PHP_MINIT_FUNCTION(phpcups)
 {
-       return SUCCESS;
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_LOCAL", CUPS_PRINTER_LOCAL, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_CLASS", CUPS_PRINTER_CLASS, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_REMOTE", CUPS_PRINTER_REMOTE, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_BW", CUPS_PRINTER_BW, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_COLOR", CUPS_PRINTER_COLOR, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_DUPLEX", CUPS_PRINTER_DUPLEX, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_STAPLE", CUPS_PRINTER_STAPLE, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_COPIES", CUPS_PRINTER_COPIES, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_COLLATE", CUPS_PRINTER_COLLATE, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_PUNCH", CUPS_PRINTER_PUNCH, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_COVER", CUPS_PRINTER_COVER, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_BIND", CUPS_PRINTER_BIND, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_SORT", CUPS_PRINTER_SORT, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_SMALL", CUPS_PRINTER_SMALL, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_MEDIUM", CUPS_PRINTER_MEDIUM, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_LARGE", CUPS_PRINTER_LARGE, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_VARIABLE", CUPS_PRINTER_VARIABLE, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_IMPLICIT", CUPS_PRINTER_IMPLICIT, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_DEFAULT", CUPS_PRINTER_DEFAULT, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_FAX", CUPS_PRINTER_FAX, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_REJECTING", CUPS_PRINTER_REJECTING, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_DELETE", CUPS_PRINTER_DELETE, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_NOT_SHARED", CUPS_PRINTER_NOT_SHARED, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_AUTHENTICATED", CUPS_PRINTER_AUTHENTICATED, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_COMMANDS", CUPS_PRINTER_COMMANDS, CONST_CS);
+  REGISTER_LONG_CONSTANT("CUPS_PRINTER_OPTIONS", CUPS_PRINTER_OPTIONS, CONST_CS);
+
+  REGISTER_LONG_CONSTANT("IPP_OK", IPP_OK, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_OK_SUBST", IPP_OK_SUBST, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_OK_CONFLICT", IPP_OK_CONFLICT, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_OK_IGNORED_SUBSCRIPTIONS", IPP_OK_IGNORED_SUBSCRIPTIONS, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_OK_IGNORED_NOTIFICATIONS", IPP_OK_IGNORED_NOTIFICATIONS, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_OK_TOO_MANY_EVENTS", IPP_OK_TOO_MANY_EVENTS, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_OK_BUT_CANCEL_SUBSCRIPTION", IPP_OK_BUT_CANCEL_SUBSCRIPTION, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_OK_EVENTS_COMPLETE", IPP_OK_EVENTS_COMPLETE, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_REDIRECTION_OTHER_SITE", IPP_REDIRECTION_OTHER_SITE, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_BAD_REQUEST", IPP_BAD_REQUEST, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_FORBIDDEN", IPP_FORBIDDEN, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_NOT_AUTHENTICATED", IPP_NOT_AUTHENTICATED, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_NOT_AUTHORIZED", IPP_NOT_AUTHORIZED, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_NOT_POSSIBLE", IPP_NOT_POSSIBLE, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_TIMEOUT", IPP_TIMEOUT, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_NOT_FOUND", IPP_NOT_FOUND, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_GONE", IPP_GONE, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_REQUEST_ENTITY", IPP_REQUEST_ENTITY, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_REQUEST_VALUE", IPP_REQUEST_VALUE, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_DOCUMENT_FORMAT", IPP_DOCUMENT_FORMAT, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_ATTRIBUTES", IPP_ATTRIBUTES, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_URI_SCHEME", IPP_URI_SCHEME, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_CHARSET", IPP_CHARSET, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_CONFLICT", IPP_CONFLICT, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_COMPRESSION_NOT_SUPPORTED", IPP_COMPRESSION_NOT_SUPPORTED, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_COMPRESSION_ERROR", IPP_COMPRESSION_ERROR, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_DOCUMENT_FORMAT_ERROR", IPP_DOCUMENT_FORMAT_ERROR, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_DOCUMENT_ACCESS_ERROR", IPP_DOCUMENT_ACCESS_ERROR, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_ATTRIBUTES_NOT_SETTABLE", IPP_ATTRIBUTES_NOT_SETTABLE, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_IGNORED_ALL_SUBSCRIPTIONS", IPP_IGNORED_ALL_SUBSCRIPTIONS, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_TOO_MANY_SUBSCRIPTIONS", IPP_TOO_MANY_SUBSCRIPTIONS, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_IGNORED_ALL_NOTIFICATIONS", IPP_IGNORED_ALL_NOTIFICATIONS, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_PRINT_SUPPORT_FILE_NOT_FOUND", IPP_PRINT_SUPPORT_FILE_NOT_FOUND, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_INTERNAL_ERROR", IPP_INTERNAL_ERROR, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_OPERATION_NOT_SUPPORTED", IPP_OPERATION_NOT_SUPPORTED, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_SERVICE_UNAVAILABLE", IPP_SERVICE_UNAVAILABLE, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_VERSION_NOT_SUPPORTED", IPP_VERSION_NOT_SUPPORTED, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_DEVICE_ERROR", IPP_DEVICE_ERROR, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_TEMPORARY_ERROR", IPP_TEMPORARY_ERROR, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_NOT_ACCEPTING", IPP_NOT_ACCEPTING, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_PRINTER_BUSY", IPP_PRINTER_BUSY, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_ERROR_JOB_CANCELLED", IPP_ERROR_JOB_CANCELLED, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_MULTIPLE_JOBS_NOT_SUPPORTED", IPP_MULTIPLE_JOBS_NOT_SUPPORTED, CONST_CS);
+  REGISTER_LONG_CONSTANT("IPP_PRINTER_IS_DEACTIVATED", IPP_PRINTER_IS_DEACTIVATED, CONST_CS);
+
+  return (SUCCESS);
 }
 
+/*
+ * 'zif_cups_cancel_job()' - Cancel a job.
+ */
 
-
-PHP_MINFO_FUNCTION(phpcups)
+PHP_FUNCTION(cups_cancel_job)
 {
-       php_info_print_table_start();
-       php_info_print_table_header(2, "phpcups support", "enabled");
-       php_info_print_table_end();
+  char *dest;                          /* Destination */
+  int  dest_len,                       /* Length of destination */
+       id;                             /* Job ID */
 
-       /* Remove comments if you have entries in php.ini
-       DISPLAY_INI_ENTRIES();
-       */
-}
-
-
-
-
-
-
-
-/* Remove the following function when you have succesfully modified config.m4
-   so that your module can be compiled into PHP, it exists only for testing
-   purposes. */
-
-/* Every user-visible function in PHP should document itself in the source */
-PHP_FUNCTION(confirm_phpcups_compiled)
-{
-       char *arg = NULL;
-       int arg_len, len;
-       char string[256];
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
-               return;
-       }
+  if (ZEND_NUM_ARGS() != 2 ||
+      zend_parse_parameters(2, "sl", &dest, &dest_len, &id))
+  {
+    WRONG_PARAM_COUNT;
+  }
 
-       len = sprintf(string, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "phpcups", arg);
-       RETURN_STRINGL(string, len, 1);
+  RETURN_LONG(cupsCancelJob(dest, id));
 }
-/* The previous line is meant for vim and emacs, so it can correctly fold and 
-   unfold functions in source code. See the corresponding marks just before 
-   function definition, where the functions purpose is also documented. Please 
-   follow this convention for the convenience of others editing your code.
-*/
-
-
-
-
-
-
-
-
-
 
 
 /*
- *  Function:    cups_get_dest_options
- *
- *  Date:        8 April 2002 - TDB
- *
- *  Parameters:  d_name     - String  - Name of destination.
- *               d_instance - String  - Name of instance on destination.
- *
- *  Returns:     Array of option "objects", with each object
- *               containing the members:
- *
- *                 name  - String - Option name
- *                 value - String - Option value
- *
- *  Comments:
- *
+ * 'zif_cups_get_dests()' - .
  */
-PHP_FUNCTION(cups_get_dest_options)
-{
-    char        *arg = NULL;
-    int         arg_len, len;
 
-    zval        *new_object;
-
-    zval        **d_server,
-                **d_name, 
-                **d_instance;
-
-    char       c_server[256],
-                c_name[256], 
-                c_instance[256];
-
-    char       l_server[256],
-                l_name[256], 
-                l_instance[256];
+PHP_FUNCTION(cups_get_dests)
+{
+  int          i, j,                   /* Looping vars */
+               num_dests;              /* Number of destinations */
+  cups_dest_t  *dests,                 /* Destinations */
+               *dest;                  /* Current destination */
+  cups_option_t        *option;                /* Current option */
+  zval         *destobj,               /* Destination object */
+               *optionsobj;            /* Options object */
 
-    cups_dest_t *dests, *dptr;
-    int         num_dests;
-    int         i, j;
 
-    array_init(return_value);
+  if (ZEND_NUM_ARGS() != 0)
+  {
+    WRONG_PARAM_COUNT;
+  }
 
-    if ((ZEND_NUM_ARGS() != 3) ||
-        (zend_get_parameters_ex(3,&d_server,&d_name,&d_instance) != SUCCESS))
-    {
-      WRONG_PARAM_COUNT;
-    }
+  if ((num_dests = cupsGetDests(&dests)) <= 0)
+  {
+    RETURN_NULL();
+  }
 
-    convert_to_string_ex( d_server );
-    convert_to_string_ex( d_name );
-    convert_to_string_ex( d_instance );
-
-    /*
-     *  Find the dest/instance we want options for.
-     */
-    bzero( c_server, 256 );
-    bzero( c_name, 256 );
-    bzero( c_instance, 256 );
-
-    if ( (char *)(*d_server)->value.str.val != NULL )
-      strcpy( c_server,(char *)(*d_server)->value.str.val );
-    if ( (char *)(*d_name)->value.str.val != NULL )
-      strcpy( c_name,(char *)(*d_name)->value.str.val );
-    if ( (char *)(*d_instance)->value.str.val != NULL )
-      strcpy( c_instance,(char *)(*d_instance)->value.str.val );
-      
-
-    if (strlen(c_server))
-      cupsSetServer(c_server);
-
-    num_dests = cupsGetDests(&dests); 
-    for (i=0, j = -1; (i < num_dests) && (j < 0); i++)
+  if (array_init(return_value) == SUCCESS)
+  {
+    for (i = 0, dest = dests; i < num_dests; i ++, dest ++)
     {
-      dptr = &dests[i];
-
-      if (dptr->name == NULL)
-        strcpy( l_name, "" );
-      else
-           strcpy( l_name, dptr->name );
-
-      if (dptr->instance == NULL)
-           strcpy( l_instance, "" );
-      else
-        strcpy( l_instance, dptr->instance );
+      MAKE_STD_ZVAL(destobj);
 
-      if ((!strcmp( l_name, c_name )) &&
-          (!strcmp( l_instance, c_instance )))
+      if (object_init(destobj) == SUCCESS)
       {
+       /*
+        * Add properties to the destination for each of the cups_dest_t
+       * members...
+       */
 
-        for (j=0; j < dptr->num_options; j++ )
-        {
-          if ((dptr->options[j].name != NULL) &&
-              (dptr->options[j].value != NULL))
-         {
-            MAKE_STD_ZVAL(new_object);
-            if (object_init(new_object) == SUCCESS)
-            {
-              add_property_string(new_object,"name",dptr->options[j].name, 1 );
-              add_property_string(new_object,"value",dptr->options[j].value,1);
-              add_next_index_zval( return_value, new_object );
-            }
-          }
-        }
-      }
-    }
-    cupsFreeDests(num_dests,dests); 
-}
-
-
-
-
-/*
- *  Function:    cups_get_dest_list
- *
- *  Date:        8 April 2002 - TDB
- *
- *  Parameters:  cups server (optional)
- *
- *  Returns:     Array of destination "objects", with each object
- *               containing the members:
- *
- *                 name        - String - Name of destination.
- *                 instance    - String - Name of instance on destination.
- *                 is_default  - Long   - 1 if default printer.
- *                 num_options - Long   - Number of options for destination.
- *
- *  Comments:
- *
- */
-PHP_FUNCTION(cups_get_dest_list)
-{
-    char        *arg = NULL;
-    int         arg_len, len;
-
-    zval        **z_server;
-    zval        *new_object;
-
-    char        c_server[256];
-
-    char        string[2560];
-    char        temp[256];
-
-    cups_dest_t *dests, *dptr;
-    int         num_dests;
-    int         i;
-
-    /*
-     *  Initialize the return array.
-     */
-    array_init(return_value);
+        add_property_string(destobj, "name", dest->name, 1);
+        add_property_string(destobj, "instance",
+                           dest->instance ? dest->instance : "", 1);
+        add_property_long(destobj, "is_default", dest->is_default);
 
-    switch (ZEND_NUM_ARGS())
-    {
-      /*
-       *  Change servers if passed.
-       */
-      case 1: if (zend_get_parameters_ex(1,&z_server) != SUCCESS)
-              {
-                WRONG_PARAM_COUNT;
-              }
-              convert_to_string_ex( z_server );
-              if ( (char *)(*z_server)->value.str.val != NULL )
-              {
-                strcpy( c_server,(char *)(*z_server)->value.str.val );
-                cupsSetServer( c_server );
-              }
-              break;
-    }
+       /*
+        * Create an associative array for the options...
+       */
 
+        MAKE_STD_ZVAL(optionsobj);
 
-    /*
-     *  First get the destination list from the cups server.
-     */
-    num_dests = cupsGetDests(&dests); 
+       if (array_init(optionsobj) == SUCCESS)
+       {
+         for (j = 0, option = dest->options;
+              j < dest->num_options;
+              j ++, option ++)
+           add_assoc_string(optionsobj, option->name, option->value, 1);
 
-    /*
-     *  Loop through the list, create and fill in the objects, and
-     *  add them to the array.
-     */
-    string[0] = '\0';
-    for (i=0; i < num_dests; i++)
-    {
-      dptr = &dests[i];
+         add_property_zval(destobj, "options", optionsobj);
+       }
 
-      MAKE_STD_ZVAL(new_object);
-      if (object_init(new_object) == SUCCESS)
-      {
-        if (strlen(c_server))
-          add_property_string( new_object, "server", c_server, 1 );
-        else
-          add_property_string( new_object, "server", "", 1 );
-
-        if (dptr->name != NULL)
-          add_property_string( new_object, "name", dptr->name, 1 );
-        else
-          add_property_string( new_object, "name", "", 1 );
-
-        if (dptr->instance != NULL)
-          add_property_string( new_object, "instance", dptr->instance, 1 );
-        else
-          add_property_string( new_object, "instance", "", 1 );
-
-        add_property_long( new_object, "is_default", dptr->is_default );
-        add_property_long( new_object, "num_options", dptr->num_options );
-        add_next_index_zval( return_value, new_object );
+        add_index_zval(return_value, i, destobj);
       }
     }
+  }
 
-    /*
-     *  free the list .....
-     */
-    cupsFreeDests(num_dests,dests); 
+  cupsFreeDests(num_dests, dests);
 }
 
 
-
 /*
- *  Function:    cups_get_jobs
- *
- *  Date:        8 April 2002 - TDB
- *
- *  Parameters:  server    - String  - Name or IP of cups server.  Blank
- *                                     for localhost.
- *
- *               name      - String  - Name of destination to query.
- *
- *               user      - String  - Username to get job list for.
- *                         * Optional, default all users
- *
- *               my_jobs   - Long    - Show only my jobs
- *                         * Optional, default FALSE
- *
- *               completed - Long    - Show completed jobs
- *                         * Optional, default FALSE
- *
- *  Returns:     Array of print job "objects", with each object
- *               containing the members:
- *
- *               id             - Long    - Job id
- *               dest           - String  - Name of destination.
- *               title          - String  - Title of document.
- *               user           - String  - User who submitted job.
- *               format         - String  - Document format (MIME type)
- *               state          - Long    - Current state of the job.
- *               size           - Long    - Size in bytes of the job.
- *               priority       - Long    - Job priority.
- *               completed_time - Long    - Time job completed (UNIX time).
- *               creation_time  - Long    - Time job created (UNIX time).
- *               processing_time- Long    - Processing time in seconds?
- *
- *  Comments:
- *
+ * 'zif_cups_get_jobs()' - Get a list of jobs.
  */
-PHP_FUNCTION( cups_get_jobs )
-{
-    char        *arg = NULL;
 
-    int         arg_len, 
-                len;
-
-    zval        *new_object;
-
-    zval        **z_server,
-                **z_name, 
-                **z_user,
-                **z_myjobs, 
-                **z_completed;
-
-    char       p_server[256],
-                p_name[256],
-                p_user[256];
+PHP_FUNCTION(cups_get_jobs)
+{
+  char         *dest;                  /* Destination */
+  int          dest_len,               /* Length of destination */
+               myjobs,                 /* Only show my jobs? */
+               completed;              /* Show completed jobs? */
+  int          i,                      /* Looping var */
+               num_jobs;               /* Number of jobs */
+  cups_job_t   *jobs,                  /* Jobs */
+               *job;                   /* Current job */
+  zval         *jobobj;                /* Job object */
 
-    int         p_myjobs, 
-                p_completed;
 
-    cups_job_t  *jobs, 
-                *jptr;
 
-    int         num_jobs;
-    int         i;
 
-    bzero( p_server, 256 );
-    bzero( p_name, 256 );
-    bzero( p_user, 256 );
-    p_myjobs    = 0;
-    p_completed = 0;
+  if (ZEND_NUM_ARGS() != 3 ||
+      zend_parse_parameters(3, "sll", &dest, &dest_len, &myjobs, &completed))
+  {
+    WRONG_PARAM_COUNT;
+  }
 
-    /*
-     *  Initialize return value.
-     */
-    array_init(return_value);
+  if (!*dest)
+    dest = NULL;
 
-    /*
-     *  Parse params.
-     */
-    switch(ZEND_NUM_ARGS())
-    {
-      /*
-       *  server, destination only provided.
-       */
-      case 2: 
-              if (zend_get_parameters_ex( 2, &z_server,&z_name ) == SUCCESS)
-              {
-                convert_to_string_ex( z_server);
-                if ( (char *)(*z_server)->value.str.val != NULL )
-                  strcpy( p_server,(char *)(*z_server)->value.str.val );
-                convert_to_string_ex( z_name );
-                if ( (char *)(*z_name)->value.str.val != NULL )
-                  strcpy( p_name,(char *)(*z_name)->value.str.val );
-              }
-              break;
-
-      /*
-       *  server, destination and user
-       */
-      case 3: 
-              if (zend_get_parameters_ex( 3, &z_server, &z_name, 
-                                             &z_user ) == SUCCESS)
-              {
-                convert_to_string_ex( z_name );
-                convert_to_string_ex( z_user );
-                convert_to_string_ex( z_server);
-                if ( (char *)(*z_server)->value.str.val != NULL )
-                  strcpy( p_server,(char *)(*z_server)->value.str.val );
-                if ( (char *)(*z_name)->value.str.val != NULL )
-                  strcpy( p_name,(char *)(*z_name)->value.str.val );
-                if ( (char *)(*z_user)->value.str.val != NULL )
-                  strcpy( p_user,(char *)(*z_user)->value.str.val );
-              }
-              break;
-
-      /*
-       *  server, destination, user, and myjobs
-       */
-      case 4: 
-              if (zend_get_parameters_ex( 4, &z_server, &z_name, &z_user, 
-                                             &z_myjobs ) == SUCCESS)
-              {
-                convert_to_string_ex( z_name );
-                convert_to_string_ex( z_user );
-                convert_to_string_ex( z_server);
-                if ( (char *)(*z_server)->value.str.val != NULL )
-                  strcpy( p_server,(char *)(*z_server)->value.str.val );
-                if ( (char *)(*z_name)->value.str.val != NULL )
-                  strcpy( p_name,(char *)(*z_name)->value.str.val );
-                if ( (char *)(*z_user)->value.str.val != NULL )
-                  strcpy( p_user,(char *)(*z_user)->value.str.val );
-
-                convert_to_string_ex( z_myjobs );
-                p_myjobs = strtoul((char *)(*z_myjobs)->value.str.val,NULL,10);
-              }
-              break;
-
-      /*
-       *  server, destination, user, myjobs, and completed
-       */
-      case 5: 
-              if (zend_get_parameters_ex( 5, &z_server, &z_name, &z_user, 
-                                          &z_myjobs, &z_completed ) == SUCCESS)
-              {
-                convert_to_string_ex( z_name );
-                convert_to_string_ex( z_user );
-                convert_to_string_ex( z_server);
-                if ( (char *)(*z_server)->value.str.val != NULL )
-                  strcpy( p_server,(char *)(*z_server)->value.str.val );
-                if ( (char *)(*z_name)->value.str.val != NULL )
-                  strcpy( p_name,(char *)(*z_name)->value.str.val );
-                if ( (char *)(*z_user)->value.str.val != NULL )
-                  strcpy( p_user,(char *)(*z_user)->value.str.val );
-
-                convert_to_string_ex( z_myjobs );
-                p_myjobs = strtoul((char *)(*z_myjobs)->value.str.val,NULL,10);
-
-                convert_to_string_ex( z_completed);
-                p_completed = strtoul((char *)(*z_completed)->value.str.val,NULL,10);
-              }
-              break;
-    }
+  if ((num_jobs = cupsGetJobs(&jobs, dest, myjobs, completed)) <= 0)
+  {
+    RETURN_NULL();
+  }
 
-    /*
-     *  Set the cups server if given.
-     */
-    if (strlen(p_server))
-      cupsSetServer(p_server);
-
-    /*
-     *  Set the cups user if given, otherwise get all jobs.
-     */
-    if (strlen(p_user))
-      cupsSetUser(p_user); 
-    else
-      cupsSetUser("root"); 
-
-    /*
-     *  Get the jobs list from the CUPS server.
-     */
-    num_jobs = cupsGetJobs(&jobs,p_name,p_myjobs,p_completed); 
-
-    /*
-     *  Build the array of objects to return.
-     */
-    for (i=0; i < num_jobs; i++)
+  if (array_init(return_value) == SUCCESS)
+  {
+    for (i = 0, job = jobs; i < num_jobs; i ++, job ++)
     {
-      jptr = &jobs[i];
+      MAKE_STD_ZVAL(jobobj);
 
-      MAKE_STD_ZVAL(new_object);
-      if (object_init(new_object) == SUCCESS)
-      {
-        add_property_long(new_object,"id",jptr->id  );
-        add_property_string(new_object,"dest",jptr->dest, 1 );
-        add_property_string(new_object,"title",jptr->title, 1 );
-        add_property_string(new_object,"user",jptr->user, 1 );
-        add_property_string(new_object,"format",jptr->format, 1 );
-        add_property_long(new_object,"state",jptr->state );
-        add_property_long(new_object,"size",jptr->size );
-        add_property_long(new_object,"priority",jptr->priority );
-        add_property_long(new_object,"completed_time",jptr->completed_time);
-        add_property_long(new_object,"creation_time",jptr->creation_time);
-        add_property_long(new_object,"processing_time",jptr->processing_time);
-        add_next_index_zval( return_value, new_object );
-      }
-      else
+      if (object_init(jobobj) == SUCCESS)
       {
-        printf("\nError creating new object\n");
+       /*
+        * Add properties to the job for each of the cups_job_t
+       * members...
+       */
+
+        add_property_long(jobobj, "id", job->id);
+        add_property_string(jobobj, "dest", job->dest, 1);
+        add_property_string(jobobj, "title", job->title, 1);
+        add_property_string(jobobj, "user", job->user, 1);
+        add_property_string(jobobj, "format", job->format, 1);
+        add_property_long(jobobj, "state", job->state);
+        add_property_long(jobobj, "size", job->size);
+        add_property_long(jobobj, "priority", job->priority);
+        add_property_long(jobobj, "completed_time", job->completed_time);
+        add_property_long(jobobj, "creation_time", job->creation_time);
+        add_property_long(jobobj, "processing_time", job->processing_time);
+
+        add_index_zval(return_value, i, jobobj);
       }
     }
-    cupsFreeJobs(num_jobs,jobs); 
-}
-
+  }
 
+  cupsFreeJobs(num_jobs, jobs);
+}
 
 
 /*
- *  Function:    cups_last_error
- *
- *  Date:        8 April 2002 - TDB
- *
- *  Parameters:  none.
- *
- *  Returns:     error number - Long
- *
- *  Comments:
- *
+ * 'zif_cups_last_error()' - Return the last IPP status code.
  */
+
 PHP_FUNCTION(cups_last_error)
 {
-  static char error[1024];
-
-  zval **z_server;
-  char c_server[256];
-
-  bzero( c_server, 256 );
-
-  switch (ZEND_NUM_ARGS())
+  if (ZEND_NUM_ARGS() != 0)
   {
-      /*
-       *  Change servers if passed.
-       */
-      case 1: if (zend_get_parameters_ex(1,&z_server) != SUCCESS)
-              {
-                WRONG_PARAM_COUNT;
-              }
-              convert_to_string_ex( z_server );
-              if ( (char *)(*z_server)->value.str.val != NULL )
-              {
-                strcpy( c_server,(char *)(*z_server)->value.str.val );
-                cupsSetServer( c_server );
-              }
-              break;
+    WRONG_PARAM_COUNT;
   }
-  sprintf( error,"%d", cupsLastError());
 
-  RETURN_STRINGL(error, strlen(error)+1, 1);
+  RETURN_LONG(cupsLastError());
 }
 
 
-
-
-
-
 /*
- *  Function:    cups_cancel_job
- *
- *  Date:        8 April 2002 - TDB
- *
- *  Parameters:  server - String  -  Name or IP of cups server.
- *               name   - String  -  Name of destination.
- *               job    - Long    -  Job ID to cancel.
- *
- *  Returns:     error number - Long?????????
- *
- *  Comments:
- *
+ * 'zif_cups_last_error_string()' - Return the last IPP status-message.
  */
-PHP_FUNCTION(cups_cancel_job)
-{
-    zval        **z_server, **z_name, **z_job;
-
-    char       p_server[256], p_name[256];
-    int         p_job;
-
-    int         ret_val = -1;
-
-    /*
-     *  Get parameters .....
-     */
-    if ((ZEND_NUM_ARGS() != 3) ||
-        (zend_get_parameters_ex( 3, &z_server, &z_name, &z_job ) != SUCCESS))
-    {
-      WRONG_PARAM_COUNT;
-    }
-
-    convert_to_string_ex( z_server);
-    if ( (char *)(*z_name)->value.str.val != NULL )
-    {
-      strcpy( p_server,(char *)(*z_server)->value.str.val );
-      cupsSetServer(p_server);
-    }
-
-    convert_to_string_ex( z_name );
-    if ( (char *)(*z_name)->value.str.val != NULL )
-      strcpy( p_name,(char *)(*z_name)->value.str.val );
-
-    convert_to_string_ex( z_job );
-    p_job = strtoul((char *)(*z_job)->value.str.val,NULL,10);
-
-    if (strlen(p_server))
-      cupsSetServer(p_server);
-    cupsSetUser("root");
-
-    /*
-     *  Errrr ....  Cancel the job ......
-     */
-    ret_val = cupsCancelJob(p_name,p_job);
-
-    RETURN_LONG(ret_val);
-}
-
 
-
-cups_option_t *_phpcups_parse_options( cups_option_t *options, 
-                                       int *num_options, char *param )
+PHP_FUNCTION(cups_last_error_string)
 {
-  char name[1024], value[1024];
-
-  sscanf(param,"%1023[^=]=%1023s", name, value ); 
-
-  if (strlen(name) && strlen(value))
+  if (ZEND_NUM_ARGS() != 0)
   {
-    if (options == NULL)
-    {
-      options = (cups_option_t *)emalloc(sizeof(cups_option_t));
-      options->name = (char *)emalloc(strlen(name)+1);
-      options->value = (char *)emalloc(strlen(value)+1);
-      strcpy( options->name, name );
-      strcpy( options->value, value );
-      *num_options++;
-    }
-    else
-    {
-      options = (cups_option_t *)erealloc(options,
-                                  (*num_options+1) * sizeof(cups_option_t));
-      options[*num_options].name = (char *)emalloc(strlen(name)+1);
-      options[*num_options].value = (char *)emalloc(strlen(value)+1);
-      strcpy( options[*num_options].name, name );
-      strcpy( options[*num_options].value, value );
-      *num_options++;
-    }
+    WRONG_PARAM_COUNT;
   }
-  return(options);
-}
-
-
-/*
- *  Function:    cups_print_file
- *
- *  Date:        8 April 2002 - TDB
- *
- *  Parameters:  printer    - String  -  Name of destination.
- *               filename   - String  -  Name of file to print (full path).
- *               title      - String  -  Title of document.
- *
- *  Returns:     Job ID     - Long
- *
- *  Comments:
- *
- */
-PHP_FUNCTION(cups_print_file)
-{
-    zval        **z_server, **z_printer, **z_filename, **z_title, 
-                **z_options, **keydata;
-
-    HashTable   *param_ht;
 
-    char       p_server[256];
-    char       p_printer[256];
-    char       p_filename[256];
-    char       p_title[256];
-
-    char           temp[4096];
-    cups_option_t  *options = NULL;
-
-    int         count, current;
-    int         ret_val = -1;
-
-    bzero( p_server, 256 );
-    bzero( p_printer, 256 );
-    bzero( p_filename, 256 );
-    bzero( p_title, 256 );
-    bzero( temp, 4096);
-    current = 0;
-
-    int zend_num_args = ZEND_NUM_ARGS();
-    switch (zend_num_args) 
-    {
-      /*
-       *  Server / Destination / filename only.
-       */
-      case 3:
-              if (zend_get_parameters_ex( 3, &z_server, &z_printer, 
-                                             &z_filename) != SUCCESS)
-              {
-                WRONG_PARAM_COUNT;
-              }
-              convert_to_string_ex( z_server);
-              if ( (char *)(*z_server)->value.str.val != NULL )
-              {
-                strcpy( p_server,(char *)(*z_server)->value.str.val );
-                cupsSetServer(p_server);
-              }
-              convert_to_string_ex( z_printer);
-              if ( (char *)(*z_printer)->value.str.val != NULL )
-                strcpy( p_printer,(char *)(*z_printer)->value.str.val );
-              convert_to_string_ex( z_filename );
-              if ( (char *)(*z_filename)->value.str.val != NULL )
-                strcpy( p_filename,(char *)(*z_filename)->value.str.val );
-              strcpy( p_title,"untitled");
-              break;
-
-      /*
-       *  Server, destination, filename and title.
-       */
-      case 4:
-              if (zend_get_parameters_ex( 4, &z_server,
-                                             &z_printer, 
-                                             &z_filename, 
-                                             &z_title) != SUCCESS)
-              {
-                WRONG_PARAM_COUNT;
-              }
-
-              convert_to_string_ex( z_server);
-              if ( (char *)(*z_server)->value.str.val != NULL )
-              {
-                strcpy( p_server,(char *)(*z_server)->value.str.val );
-                cupsSetServer(p_server);
-              }
-
-              convert_to_string_ex( z_printer);
-              if ( (char *)(*z_printer)->value.str.val != NULL )
-                strcpy( p_printer,(char *)(*z_printer)->value.str.val );
-
-              convert_to_string_ex( z_filename );
-              if ( (char *)(*z_filename)->value.str.val != NULL )
-                strcpy( p_filename,(char *)(*z_filename)->value.str.val );
-
-              convert_to_string_ex( z_title );
-              if ( (char *)(*z_title)->value.str.val != NULL )
-                strcpy( p_title,(char *)(*z_title)->value.str.val );
-
-              _zz_internal_log( "cups_print_file", p_server );
-              _zz_internal_log( "cups_print_file", p_printer );
-              _zz_internal_log( "cups_print_file", p_filename );
-              _zz_internal_log( "cups_print_file", p_title );
-              break;
-
-      /*
-       *  Server, destination, filename and title plus printer options.
-       */
-      case 5:
-              if (zend_get_parameters_ex( 5, &z_server,
-                                             &z_printer, 
-                                             &z_filename, 
-                                             &z_title,
-                                             &z_options) != SUCCESS)
-              {
-                WRONG_PARAM_COUNT;
-              }
-              convert_to_string_ex( z_server);
-              if ( (char *)(*z_server)->value.str.val != NULL )
-              {
-                strcpy( p_server,(char *)(*z_server)->value.str.val );
-                cupsSetServer(p_server);
-              }
-              convert_to_string_ex( z_printer);
-              if ( (char *)(*z_printer)->value.str.val != NULL )
-                strcpy( p_printer,(char *)(*z_printer)->value.str.val );
-              convert_to_string_ex( z_filename );
-              if ( (char *)(*z_filename)->value.str.val != NULL )
-                strcpy( p_filename,(char *)(*z_filename)->value.str.val );
-              convert_to_string_ex( z_title );
-              if ( (char *)(*z_title)->value.str.val != NULL )
-                strcpy( p_title,(char *)(*z_title)->value.str.val );
-
-              _zz_internal_log( "cups_print_file(server)", p_server );
-              _zz_internal_log( "cups_print_file(printer)", p_printer );
-              _zz_internal_log( "cups_print_file(filename)", p_filename );
-              _zz_internal_log( "cups_print_file(title)", p_title );
-
-              /*
-               *  Convert options array.
-               */
-              convert_to_array_ex( z_options );
-              param_ht = Z_ARRVAL_PP( z_options );
-              count    = zend_hash_num_elements( param_ht );
-              options  = emalloc(sizeof(zval **) * count);
-
-              current = 0;
-              zend_hash_internal_pointer_reset(param_ht);
-              for (current=0; current < count; current++)
-              {
-                zend_hash_get_current_data(param_ht,(void **)&keydata);   
-                switch(Z_TYPE_PP(keydata))
-                {
-                  case IS_STRING:
-                         convert_to_string_ex(keydata);
-                         strcpy(temp,(char *)(*keydata)->value.str.val );
-              _zz_internal_log( "cups_print_file(option)", temp );
-                         options = _phpcups_parse_options( options, &current,
-                                                           temp );
-                         break;
-                }
-                zend_hash_move_forward(param_ht);
-              }
-              break;
-
-      default: WRONG_PARAM_COUNT;
-    }
-
-    if (current > 0)
-    {
-      
-      bzero(temp,4096);
-      sprintf(temp,"(2) - P: %s F: %s T: %s C: %d", p_printer, p_filename,
-                                              p_title, current );
-      _zz_internal_log( "cups_print_file", temp );
-      ret_val = cupsPrintFile( p_printer,p_filename,p_title,current,options);
-      for (current=0; current < count; current++)
-      {
-        efree( options[current].name );
-        efree( options[current].value );
-      }
-      efree(options);
-    }
-    else
-    {
-      _zz_internal_log( "cups_print_file", "going to print");
-      ret_val = cupsPrintFile( p_printer,p_filename,p_title,0,NULL );
-    }
-
-    RETURN_LONG(ret_val);
+  RETURN_STRING((char *)cupsLastErrorString(), 1);
 }
 
 
-int _phpcups_get_printer_status(char *server, int port, char *name );
-
-typedef struct printer_attrs_type
-{
-  char      *name;
-  char      *value;
-} printer_attrs_t;
-
-
-
-int              num_attrs = 0;
-printer_attrs_t  *printer_attrs = NULL;
-
-void free_attrs_list(void);
-void _phpcups_free_attrs_list(void);
-
 /*
- *  Function:    cups_get_printer_attributes
- *
- *  Date:        8 April 2002 - TDB
- *
- *  Parameters:  name   - String  -  Name of destination.
- *
- *  Returns:     state  - String
- *
- *  Comments:
- *
+ * 'zif_cups_print_file()' - Print a single file.
  */
-PHP_FUNCTION(cups_get_printer_attributes)
-{
-    zval    **z_server, **z_port, **z_name;
-
-    zval    *new_object;
-
-    char    p_server[256], p_name[256];
-    int     p_port = 631;
 
-    int     i, count;
-
-
-    /*
-     *  Initialize return value.
-     */
-    array_init(return_value);
-
-    /*
-     *  Get parameters .....
-     */
-    switch(ZEND_NUM_ARGS())
-    {
-      //
-      //  Destination name only, assume localhost
-      //
-      case 1: 
-              if (zend_get_parameters_ex( 1, &z_name ) != SUCCESS)
-              {
-                WRONG_PARAM_COUNT;
-              }
-              strcpy( p_server,"localhost" );
-              convert_to_string_ex( z_name );
-              if ( (char *)(*z_name)->value.str.val != NULL )
-                strcpy( p_name,(char *)(*z_name)->value.str.val );
-              break;
-
-      //
-      //  Server and estination name only, assume port 631
-      //
-      case 2: 
-              if (zend_get_parameters_ex( 2, &z_server, &z_name ) != SUCCESS)
-              {
-                WRONG_PARAM_COUNT;
-              }
-              convert_to_string_ex( z_server);
-              if ((char *)(*z_server)->value.str.val != NULL)
-                strcpy( p_server,(char *)(*z_server)->value.str.val );
-              convert_to_string_ex( z_name );
-              if ( (char *)(*z_name)->value.str.val != NULL )
-                strcpy( p_name,(char *)(*z_name)->value.str.val );
-              break;
-
-      //
-      //  Server, destination name and port.
-      //
-      case 3: 
-              if(zend_get_parameters_ex(3,&z_server,&z_port,&z_name) != SUCCESS)
-              {
-                WRONG_PARAM_COUNT;
-              }
-              convert_to_string_ex(z_server);
-              if ((char *)(*z_server)->value.str.val != NULL)
-                strcpy( p_server,(char *)(*z_server)->value.str.val );
-              convert_to_string_ex(z_name);
-              if ( (char *)(*z_name)->value.str.val != NULL )
-                strcpy( p_name,(char *)(*z_name)->value.str.val );
-              convert_to_string_ex(z_port);
-              if ( (char *)(*z_port)->value.str.val != NULL )
-                p_port = atoi( (char *)(*z_name)->value.str.val );
-              break;
-
-      default: WRONG_PARAM_COUNT;
-    }
-
-    printer_attrs = NULL;
-    count = _phpcups_get_printer_status( p_server, p_port, p_name );
-
-    /*
-     *  Create an array of objects containing name / value pairs.
-     */
-    for (i=0; i < count; i++)
-    {
-      if ((printer_attrs[i].name != NULL) && (printer_attrs[i].value != NULL))
-      {
-        MAKE_STD_ZVAL(new_object);
-        if (object_init(new_object) == SUCCESS)
-        {
-          add_property_string(new_object,"name",printer_attrs[i].name, 1 );
-          add_property_string(new_object,"value",printer_attrs[i].value, 1 );
-          add_next_index_zval( return_value, new_object );
-        }
-      }
-    }
-    _phpcups_free_attrs_list();
-}
-
-
-
-
-void _phpcups_free_attrs_list(void)
+PHP_FUNCTION(cups_print_file)
 {
-  int i;
-
-  if (num_attrs < 1)
-    return;
-
-  for ( i=0; i < num_attrs; i++ )
+  char         *dest;                  /* Destination */
+  int          dest_len;               /* Length of destination */
+  char         *filename;              /* Filename */
+  int          filename_len;           /* Length of filename */
+  char         *title;                 /* Title */
+  int          title_len;              /* Length of title */
+  zval         *optionsobj;            /* Array of options */
+  int          num_options;            /* Number of options */
+  cups_option_t        *options;               /* Options */
+  int          id;                     /* Job ID */
+
+
+  if (ZEND_NUM_ARGS() != 4 ||
+      zend_parse_parameters(4, "sssa", &dest, &dest_len,
+                            &filename, &filename_len,
+                           &title, &title_len, &optionsobj))
   {
-      if (printer_attrs[i].name != NULL)
-        efree(printer_attrs[i].name);
-      if (printer_attrs[i].value != NULL)
-        efree(printer_attrs[i].value );
+    WRONG_PARAM_COUNT;
   }
-  efree(printer_attrs);
-  num_attrs = 0;
-}
 
+  num_options = cups_convert_options(optionsobj, &options);
 
+  id = cupsPrintFile(dest, filename, title, num_options, options);
 
+  cupsFreeOptions(num_options, options);
 
-
-
-
-int _phpcups_update_attrs_list( char *name, char *value )
-{
-  if (num_attrs < 1)
-  {
-    printer_attrs = (printer_attrs_t *)emalloc(sizeof(printer_attrs_t));
-    printer_attrs->name = (char *)emalloc(strlen(name)+1);
-    printer_attrs->value = (char *)emalloc(strlen(value)+1);
-    strcpy( printer_attrs->name, name );
-    strcpy( printer_attrs->value, value );
-    num_attrs = 1;
-  }
-  else
-  {
-    printer_attrs = (printer_attrs_t *)erealloc(printer_attrs, 
-                                     (num_attrs + 1) * sizeof(printer_attrs_t));
-
-    printer_attrs[num_attrs].name = (char *)emalloc(strlen(name)+1);
-    printer_attrs[num_attrs].value = (char *)emalloc(strlen(value)+1);
-    strcpy( printer_attrs[num_attrs].name, name );
-    strcpy( printer_attrs[num_attrs].value, value );
-    num_attrs++;
-  }
-  return(num_attrs);
+  RETURN_LONG(id);
 }
 
 
+/*
+ * 'zif_cups_print_files()' - Print multiple files.
+ */
 
-int _phpcups_get_printer_status( char *server, int port, char *name )
+PHP_FUNCTION(cups_print_files)
 {
-  http_encryption_t encrypt = HTTP_ENCRYPT_IF_REQUESTED;
-
-  ipp_t                *request,       /* IPP Request */
-               *response;      /* IPP Response */
-  ipp_attribute_t *attr;       /* Current attribute */
-  cups_lang_t  *language;      /* Default language */
-
-  char          printer_uri[1024];
-  char          temp[1024];
-  static char  *req_attrs[] = {"printer-state", "printer-state-reason" };
-  int          i;
-  FILE         *fp;
-
-  if (name == NULL)
-  {
-    last_error = IPP_INTERNAL_ERROR;
-    return (0);
-  }
-
- /*
-  * Try to connect to the server...
-  */
-
-  if ((cups_server = httpConnectEncrypt(server, port, encrypt)) == NULL)
+  char         *dest;                  /* Destination */
+  int          dest_len;               /* Length of destination */
+  zval         *filesobj;              /* Files array */
+  int          num_files;              /* Number of files */
+  const char   *files[1000];           /* Files */
+  char         *title;                 /* Title */
+  int          title_len;              /* Length of title */
+  zval         *optionsobj;            /* Array of options */
+  int          num_options;            /* Number of options */
+  cups_option_t        *options;               /* Options */
+  HashTable    *ht2;                   /* Option array hash table */
+  Bucket       *current;               /* Current element in array */
+  int          id;                     /* Job ID */
+
+
+  if (ZEND_NUM_ARGS() != 4 ||
+      zend_parse_parameters(4, "sasa", &dest, &dest_len, &filesobj,
+                           &title, &title_len, &optionsobj))
   {
-    last_error = IPP_SERVICE_UNAVAILABLE;
-    return (0);
+    WRONG_PARAM_COUNT;
   }
 
- /*
-  * Build a CUPS_GET_PRINTERS request, which requires the following
-  * attributes:
-  *
-  *    attributes-charset
-  *    attributes-natural-language
-  *    requested-attributes
-  */
-
-  request = ippNew();
-
-  request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
-  request->request.op.request_id   = 1;
+  ht2       = Z_ARRVAL_P(filesobj);
+  num_files = 0;
 
-  language = cupsLangDefault();
-
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
-               "attributes-charset", NULL, cupsLangEncoding(language));
-
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
-               "attributes-natural-language", NULL, language->language);
-
-  sprintf(printer_uri, "ipp://localhost/printers/%-s", name );
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
-               "printer-uri", NULL, printer_uri );
-
- /*
-  * Do the request and get back a response...
-  */
-
-  num_attrs = 0;
-  printer_attrs = NULL;
-
-  if ((response = cupsDoRequest(cups_server, request, "/")) != NULL)
+  for (current = ht2->pListHead; current; current = current->pListNext)
   {
-    last_error = response->request.status.status_code;
-
-    for (attr = response->attrs; attr != NULL; attr = attr->next)
-    {
+    files[num_files ++] = Z_STRVAL_P(((zval *)current->pDataPtr));
 
-      if (attr->num_values < 1)
-        continue;
-
-      if (attr->name != NULL &&
-          strcasecmp(attr->name, "printer-state") == 0 &&
-          attr->value_tag == IPP_TAG_ENUM)
-      {
-       strcpy( temp, "unknown" );
-        switch( attr->values[0].integer )
-        {
-          case 3: strcpy( temp, "idle" );
-                  break;
-          case 4: strcpy( temp, "processing" );
-                  break;
-          case 5: strcpy( temp, "stopped" );
-                  break;
-          default: continue;
-        }
-        _phpcups_update_attrs_list( attr->name, temp );
-      }
-      else if (attr->name != NULL &&
-               (attr->value_tag == IPP_TAG_TEXT ||
-                attr->value_tag == IPP_TAG_URI ||
-                attr->value_tag == IPP_TAG_KEYWORD ||
-                attr->value_tag == IPP_TAG_STRING))
-      {
-        for (i=0; i < attr->num_values; i++)
-          _phpcups_update_attrs_list(attr->name, attr->values[i].string.text );
-      }
-      else if (attr->name != NULL &&
-               (attr->value_tag == IPP_TAG_ENUM ||
-                attr->value_tag == IPP_TAG_BOOLEAN ||
-                attr->value_tag == IPP_TAG_INTEGER))
-      {
-        for (i=0; i < attr->num_values; i++)
-        {
-          sprintf(temp,"%-d", attr->values[i].integer );
-          _phpcups_update_attrs_list(attr->name, temp );
-        }
-      }
-      else if (attr->name != NULL &&
-               attr->value_tag == IPP_TAG_RESOLUTION)
-      {
-        for (i=0; i < attr->num_values; i++)
-        {
-          sprintf(temp,"%-dx%-dx%-d",
-                         attr->values[i].resolution.xres,
-                         attr->values[i].resolution.yres,
-                         attr->values[i].resolution.units );
-          _phpcups_update_attrs_list(attr->name, temp );
-        }
-      }
-      else if (attr->name != NULL &&
-               attr->value_tag == IPP_TAG_RANGE)
-      {
-        for (i=0; i < attr->num_values; i++)
-        {
-          sprintf(temp,"%d-%d",
-                         attr->values[i].range.lower,
-                         attr->values[i].range.upper );
-          _phpcups_update_attrs_list(attr->name, temp );
-        }
-      }
-    }
-    ippDelete(response);
+    if (num_files >= (int)(sizeof(files) / sizeof(files[0])))
+      break;
   }
-  else
-  {
-    last_error = IPP_BAD_REQUEST;
-    return(0);
-  }
-  return (num_attrs);
-}
 
+  num_options = cups_convert_options(optionsobj, &options);
 
-void _zz_internal_log( char *func, char *line )
-{
-  FILE *fp;
+  id = cupsPrintFiles(dest, num_files, files, title, num_options, options);
 
-  if ((fp = fopen("/var/log/cups/project.log","a")) == NULL)
-       return;
+  cupsFreeOptions(num_options, options);
 
-  fprintf(fp,"phpcups: %s - %s\n", func, line );
-  fflush(fp);
-  fclose(fp);
+  RETURN_LONG(id);
 }
 
 
-
 /*
  * End of "$Id$".
  */
-
-
-/*
- */
diff --git a/scripting/php/phpcups.h b/scripting/php/phpcups.h
new file mode 100644 (file)
index 0000000..ef79ad1
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * "$Id$"
+ *
+ *   PHP module include file for the Common UNIX Printing System (CUPS).
+ *
+ *   Copyright 1997-2006 by Easy Software Products.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Easy Software Products 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 please contact Easy Software Products
+ *   at:
+ *
+ *       Attn: CUPS Licensing Information
+ *       Easy Software Products
+ *       44141 Airport View Drive, Suite 204
+ *       Hollywood, Maryland 20636 USA
+ *
+ *       Voice: (301) 373-9603
+ *       EMail: cups-info@cups.org
+ *         WWW: http://www.cups.org/
+ */
+
+#ifndef PHPCUPS_H
+#  define PHPCUPS_H
+
+/*
+ * Include necessary headers...
+ */
+
+#  include <cups/cups.h>
+#  include <cups/language.h>
+#  include <cups/debug.h>
+#  include <stdlib.h>
+#  include <ctype.h>
+#  include <errno.h>
+#  include <fcntl.h>
+#  include <sys/stat.h>
+#  if defined(WIN32) || defined(__EMX__)
+#    include <io.h>
+#  else
+#    include <unistd.h>
+#  endif /* WIN32 || __EMX__ */
+
+
+/*
+ * Zend definitions...
+ */
+
+extern zend_module_entry       phpcups_module_entry;
+#  define phpext_phpcups_ptr   &phpcups_module_entry
+
+#  ifdef PHP_WIN32
+#    define PHP_PHPCUPS_API    __declspec(dllexport)
+#  else
+#    define PHP_PHPCUPS_API
+#  endif
+
+#  ifdef ZTS
+#    include "TSRM.h"
+#  endif
+
+PHP_MINIT_FUNCTION(phpcups);
+
+PHP_FUNCTION(cups_cancel_job);
+PHP_FUNCTION(cups_get_dests);
+PHP_FUNCTION(cups_get_jobs);
+PHP_FUNCTION(cups_last_error);
+PHP_FUNCTION(cups_last_error_string);
+PHP_FUNCTION(cups_print_file);
+PHP_FUNCTION(cups_print_files);
+
+#endif /* !PHPCUPS_H */
+
+
+/*
+ * End of "$Id$".
+ */
old mode 100644 (file)
new mode 100755 (executable)
index 01ce6a8..0b56693
@@ -1,10 +1,11 @@
+#!/usr/bin/php -f
 <?
 //
 // "$Id: phpcups.php 3603 2003-04-11 18:42:52Z mike $"
 //
 //   PHP test script for the Common UNIX Printing System (CUPS).
 //
-//   Copyright 1997-2003 by Easy Software Products, all rights reserved.
+//   Copyright 1997-2006 by Easy Software Products, all rights reserved.
 //
 //   These coded instructions, statements, and computer programs are the
 //   property of Easy Software Products and are protected by Federal
 //       Attn: CUPS Licensing Information
 //       Easy Software Products
 //       44141 Airport View Drive, Suite 204
-//       Hollywood, Maryland 20636-3111 USA
+//       Hollywood, Maryland 20636 USA
 //
 //       Voice: (301) 373-9603
 //       EMail: cups-info@cups.org
-//         WWW: http://www.cups.org
+//         WWW: http://www.cups.org/
 //
 
 // Make sure the module is loaded...
-if(!extension_loaded('phpcups')) {
-       dl('phpcups.so');
+if(!extension_loaded("phpcups"))
+{
+  dl("phpcups.so");
 }
 
 // Get the list of functions in the module...
-$module    = 'phpcups';
+$module    = "phpcups";
 $functions = get_extension_funcs($module);
 
-echo "Functions available in the $module extension:<br>\n";
+print("Functions available in the $module extension:\n");
 
-foreach($functions as $func) {
-    echo $func."<br>\n";
+foreach ($functions as $func)
+{
+  print("$func\n");
 }
-echo "<br>\n";
 
-$function = 'confirm_' . $module . '_compiled';
-if (extension_loaded($module)) {
-       $str = $function($module);
-} else {
-       $str = "Module $module is not compiled into PHP";
-}
-echo "$str\n";
+print("\n");
+
+print("cups_get_dests:\n");
+print_r(cups_get_dests());
+
+print("cups_get_jobs(\"\", 0, -1):\n");
+print_r(cups_get_jobs("", 0, -1));
+
+print("cups_print_file(\"test\", \"../../test/testfile.jpg\", "
+     ."\"testfile.jpg\", ...):\n");
+print_r(cups_print_file("test", "../../test/testfile.jpg", "testfile.jpg",
+                        array("scaling" => "100",
+                             "page-label" => "testfile.jpg")));
+
+print("cups_print_files(\"test\", array(\"../../test/testfile.jpg\", "
+     ."\"../../test/testfile.ps\"), \"testfiles\", ...):\n");
+print_r(cups_print_files("test", array("../../test/testfile.jpg",
+                                       "../../test/testfile.ps"),
+                         "testfiles",
+                         array("scaling" => "100",
+                              "page-label" => "testfile.jpg")));
 
 //
 // End of "$Id: phpcups.php 3603 2003-04-11 18:42:52Z mike $".