diff options
author | Didier Raboud <odyx@debian.org> | 2012-10-25 21:07:57 +0200 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2012-10-25 21:07:57 +0200 |
commit | 81ab83f382660bc7980ae954725c4ebf28764b03 (patch) | |
tree | 523268f698a63a8fd44f3491d94d140266b2403b /scripting/php | |
parent | a75966e33dbc3e3e096338fd332f515cb313b58a (diff) | |
download | cups-upstream/1.6.0.tar.gz |
Imported Upstream version 1.6.0upstream/1.6.0
Diffstat (limited to 'scripting/php')
-rw-r--r-- | scripting/php/Dependencies | 7 | ||||
-rw-r--r-- | scripting/php/Makefile | 153 | ||||
-rw-r--r-- | scripting/php/README | 157 | ||||
-rw-r--r-- | scripting/php/phpcups.c | 487 | ||||
-rw-r--r-- | scripting/php/phpcups.h | 67 | ||||
-rwxr-xr-x | scripting/php/phpcups.php | 60 |
6 files changed, 0 insertions, 931 deletions
diff --git a/scripting/php/Dependencies b/scripting/php/Dependencies deleted file mode 100644 index d48a560c..00000000 --- a/scripting/php/Dependencies +++ /dev/null @@ -1,7 +0,0 @@ -# DO NOT DELETE THIS LINE -- make depend depends on it. - -phpcups.o: ../../cups/string-private.h ../../config.h phpcups.h -phpcups.o: ../../cups/cups.h ../../cups/file.h ../../cups/versioning.h -phpcups.o: ../../cups/ipp.h ../../cups/http.h ../../cups/array.h -phpcups.o: ../../cups/language.h ../../cups/language.h -phpcups.o: ../../cups/debug-private.h ../../cups/versioning.h diff --git a/scripting/php/Makefile b/scripting/php/Makefile deleted file mode 100644 index a10f4f49..00000000 --- a/scripting/php/Makefile +++ /dev/null @@ -1,153 +0,0 @@ -# -# "$Id: Makefile 3572 2003-04-08 19:56:25Z mike $" -# -# PHP Makefile for CUPS. -# -# Copyright 2007-2011 by Apple Inc. -# Copyright 1997-2007 by Easy Software Products, all rights reserved. -# -# 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/". -# - -include ../../Makedefs - - -# -# Where to install and how to compile the PHP module... -# - -PHPDIR = $(BUILDROOT)`$(PHPCONFIG) --extension-dir` -OPTIONS = $(PHPOPTIONS) - - -# -# Object files... -# - -OBJS = phpcups.o - - -# -# Targets in this directory... -# - -PHPCUPS = phpcups.so - - -# -# Make all targets... -# - -all: $(PHPCUPS) - - -# -# Make library targets... -# - -libs: - - -# -# Make unit tests... -# - -unittests: - - -# -# Remove object and target files... -# - -clean: - $(RM) $(OBJS) $(PHPCUPS) - - -# -# Update dependencies (without system header dependencies...) -# - -depend: - makedepend -Y -I../.. -fDependencies $(OBJS:.o=.c) >/dev/null 2>&1 - - -# -# Install all targets... -# - -install: all install-data install-headers install-libs install-exec - - -# -# Install data files... -# - -install-data: - - -# -# Install programs... -# - -install-exec: - echo Installing $(PHPCUPS) in $(PHPDIR) - $(INSTALL_DIR) $(PHPDIR) - $(INSTALL_LIB) $(PHPCUPS) $(PHPDIR) - if test "x$(SYMROOT)" != x; then \ - $(INSTALL_DIR) $(SYMROOT); \ - cp $(PHPCUPS) $(SYMROOT); \ - fi - - -# -# Install headers... -# - -install-headers: - - -# -# Install libraries... -# - -install-libs: - - -# -# Uninstall object and target files... -# - -uninstall: - $(RM) $(PHPDIR)/$(PHPCUPS) - -$(RMDIR) $(PHPDIR) - - -# -# phpcups.so -# - -phpcups.so: $(OBJS) ../../Makedefs - echo Linking $@... - if test `uname` = Darwin; then \ - DSOFLAGS="-bundle -flat_namespace -undefined suppress $(RC_CFLAGS)"; \ - else \ - DSOFLAGS="$(DSOFLAGS)"; \ - fi; \ - echo $(DSO) $$DSOFLAGS $(ARCHFLAGS) -o $@ $(OBJS) -L../../cups $(LIBS); \ - $(DSO) $$DSOFLAGS $(ARCHFLAGS) -o $@ $(OBJS) -L../../cups $(LIBS) - - -# -# Dependencies... -# - -include Dependencies - - -# -# End of "$Id: Makefile 3572 2003-04-08 19:56:25Z mike $". -# diff --git a/scripting/php/README b/scripting/php/README deleted file mode 100644 index e4ab27d8..00000000 --- a/scripting/php/README +++ /dev/null @@ -1,157 +0,0 @@ -README - 02/25/2006 -------------------- - -INTRODUCTION - - 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. - - -COMPILING AND INSTALLING - - Run "make" to compile the PHP CUPS extension: - - make - - 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: - - bool cups_cancel_job(string dest, int id) - - The return value is TRUE on success and FALSE on failure. - - Example: - - if (!cups_cancel_job("myprinter", 123)) - print("Unable to cancel job: " . cups_last_error_string() . "\n"); - - - CUPS_GET_DESTS - - Gets a list of available destinations: - - array 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 - - Example: - - $dest = cups_get_dests(); - - - CUPS_GET_JOBS - - Gets a list of jobs: - - array cups_get_jobs(string dest, bool myjobs, int 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 - - Example: - - $jobs = cups_get_jobs("", FALSE, -1); - - - CUPS_LAST_ERROR - - Returns the IPP status code for the most recent request: - - int cups_last_error() - - Example: - - $error = cups_last_error(); - - - CUPS_LAST_ERROR_STRING - - Returns the IPP status-message string for the most recent request: - - string cups_last_error_string() - - Example: - - $message = cups_last_error_string(); - - - CUPS_PRINT_FILE - - Prints a single file to a printer or class: - - int cups_print_file(string dest, string filename, string title, - array options) - - The return value is the job ID or 0 if there was an error. - - Example: - - $options = array("name" => "value", "name2" => "value2"); - $id = cups_print_file("dest", "filename", "title", $options); - - - CUPS_PRINT_FILES - - Prints one or more files to a printer or class: - - int cups_print_files(string dest, array files, string title, - array options); - - The return value is the job ID or 0 if there was an error. - - Example: - - $files = array("file1", "file2", "file3"); - $options = array("name" => "value", "name2" => "value2"); - $id = cups_print_file("dest", $files, "title", $options); - diff --git a/scripting/php/phpcups.c b/scripting/php/phpcups.c deleted file mode 100644 index dbd1f262..00000000 --- a/scripting/php/phpcups.c +++ /dev/null @@ -1,487 +0,0 @@ -/* - * "$Id: phpcups.c 10197 2012-01-27 16:34:04Z mike $" - * - * Printing utilities for CUPS. - * - * Copyright 2007-2012 by Apple Inc. - * Copyright 1997-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/". - * - * Contents: - * - * cups_convert_options() - Convert a PHP options array to a CUPS options array. - * zm_startup_phpcups() - Initialize the CUPS module. - * zif_cups_cancel_job() - Cancel a job. - * zif_cups_get_dests() - Get a list of printers and classes. - * zif_cups_get_jobs() - Get a list of jobs. - * zif_cups_last_error() - Return the last IPP status code. - * zif_cups_last_error_string() - Return the last IPP status - * zif_cups_print_file() - Print a single file. - * zif_cups_print_files() - Print multiple files. - */ - -/* - * Include necessary headers... - */ - -#include <cups/string-private.h> -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "phpcups.h" - - -/* - * PHP function list... - */ - -zend_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... - */ - -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_GET_MODULE(phpcups) - - -/* - * 'cups_convert_options()' - Convert a PHP options array to a CUPS options array. - */ - -static int /* O - Number of options */ -cups_convert_options( - zval *optionsobj, /* I - Options array object */ - cups_option_t **options) /* O - Options */ -{ - int num_options; /* Number of options */ - HashTable *ht; /* Option array hash table */ - Bucket *current; /* Current element in array */ - zval *value; /* Current value in array */ - char temp[255]; /* String value for numbers */ - - - ht = Z_ARRVAL_P(optionsobj); - num_options = 0; - - for (current = ht->pListHead; current; current = current->pListNext) - { - value = (zval *)current->pDataPtr; - - switch (Z_TYPE_P(value)) - { - case IS_LONG : - sprintf(temp, "%ld", Z_LVAL_P(value)); - num_options = cupsAddOption(current->arKey, temp, num_options, - options); - break; - - case IS_DOUBLE : - sprintf(temp, "%g", Z_DVAL_P(value)); - num_options = cupsAddOption(current->arKey, temp, num_options, - options); - break; - - case IS_BOOL : - num_options = cupsAddOption(current->arKey, - Z_BVAL_P(value) ? "true" : "false", - num_options, options); - break; - - case IS_STRING : - num_options = cupsAddOption(current->arKey, Z_STRVAL_P(value), - num_options, options); - break; - } - } - - return (num_options); -} - - -/* - * 'zm_startup_phpcups()' - Initialize the CUPS module. - */ - -PHP_MINIT_FUNCTION(phpcups) -{ - 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_DISCOVERED", CUPS_PRINTER_DISCOVERED, 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_FUNCTION(cups_cancel_job) -{ - char *dest; /* Destination */ - int dest_len, /* Length of destination */ - id; /* Job ID */ - - - if (ZEND_NUM_ARGS() != 2 || - zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &dest, &dest_len, &id)) - { - WRONG_PARAM_COUNT; - } - - RETURN_LONG(cupsCancelJob(dest, id)); -} - - -/* - * 'zif_cups_get_dests()' - Get a list of printers and classes. - */ - -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 */ - - - if (ZEND_NUM_ARGS() != 0) - { - WRONG_PARAM_COUNT; - } - - if ((num_dests = cupsGetDests(&dests)) <= 0) - { - RETURN_NULL(); - } - - if (array_init(return_value) == SUCCESS) - { - for (i = 0, dest = dests; i < num_dests; i ++, dest ++) - { - MAKE_STD_ZVAL(destobj); - - if (object_init(destobj) == SUCCESS) - { - /* - * Add properties to the destination for each of the cups_dest_t - * members... - */ - - 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); - - /* - * Create an associative array for the options... - */ - - MAKE_STD_ZVAL(optionsobj); - - 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); - - add_property_zval(destobj, "options", optionsobj); - } - - add_index_zval(return_value, i, destobj); - } - } - } - - cupsFreeDests(num_dests, dests); -} - - -/* - * 'zif_cups_get_jobs()' - Get a list of jobs. - */ - -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 */ - - - - - if (ZEND_NUM_ARGS() != 3 || - zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sll", &dest, &dest_len, &myjobs, &completed)) - { - WRONG_PARAM_COUNT; - } - - if (!*dest) - dest = NULL; - - if ((num_jobs = cupsGetJobs(&jobs, dest, myjobs, completed)) <= 0) - { - RETURN_NULL(); - } - - if (array_init(return_value) == SUCCESS) - { - for (i = 0, job = jobs; i < num_jobs; i ++, job ++) - { - MAKE_STD_ZVAL(jobobj); - - if (object_init(jobobj) == SUCCESS) - { - /* - * 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); -} - - -/* - * 'zif_cups_last_error()' - Return the last IPP status code. - */ - -PHP_FUNCTION(cups_last_error) -{ - if (ZEND_NUM_ARGS() != 0) - { - WRONG_PARAM_COUNT; - } - - RETURN_LONG(cupsLastError()); -} - - -/* - * 'zif_cups_last_error_string()' - Return the last IPP status-message. - */ - -PHP_FUNCTION(cups_last_error_string) -{ - if (ZEND_NUM_ARGS() != 0) - { - WRONG_PARAM_COUNT; - } - - RETURN_STRING((char *)cupsLastErrorString(), 1); -} - - -/* - * 'zif_cups_print_file()' - Print a single file. - */ - -PHP_FUNCTION(cups_print_file) -{ - 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(ZEND_NUM_ARGS() TSRMLS_CC, "sssa", &dest, &dest_len, - &filename, &filename_len, - &title, &title_len, &optionsobj)) - { - WRONG_PARAM_COUNT; - } - - num_options = cups_convert_options(optionsobj, &options); - - id = cupsPrintFile(dest, filename, title, num_options, options); - - cupsFreeOptions(num_options, options); - - RETURN_LONG(id); -} - - -/* - * 'zif_cups_print_files()' - Print multiple files. - */ - -PHP_FUNCTION(cups_print_files) -{ - 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(ZEND_NUM_ARGS() TSRMLS_CC, "sasa", &dest, &dest_len, &filesobj, - &title, &title_len, &optionsobj)) - { - WRONG_PARAM_COUNT; - } - - ht2 = Z_ARRVAL_P(filesobj); - num_files = 0; - - for (current = ht2->pListHead; current; current = current->pListNext) - { - files[num_files ++] = Z_STRVAL_P(((zval *)current->pDataPtr)); - - if (num_files >= (int)(sizeof(files) / sizeof(files[0]))) - break; - } - - num_options = cups_convert_options(optionsobj, &options); - - id = cupsPrintFiles(dest, num_files, files, title, num_options, options); - - cupsFreeOptions(num_options, options); - - RETURN_LONG(id); -} - - -/* - * End of "$Id: phpcups.c 10197 2012-01-27 16:34:04Z mike $". - */ diff --git a/scripting/php/phpcups.h b/scripting/php/phpcups.h deleted file mode 100644 index 9cd9f88e..00000000 --- a/scripting/php/phpcups.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * "$Id: phpcups.h 9771 2011-05-12 05:21:56Z mike $" - * - * PHP module include file for CUPS. - * - * Copyright 2007-2011 by Apple Inc. - * Copyright 1997-2006 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/". - */ - -#ifndef PHPCUPS_H -# define PHPCUPS_H - -/* - * Include necessary headers... - */ - -# include <cups/cups.h> -# include <cups/language.h> -# include <cups/debug-private.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: phpcups.h 9771 2011-05-12 05:21:56Z mike $". - */ diff --git a/scripting/php/phpcups.php b/scripting/php/phpcups.php deleted file mode 100755 index 0fe57190..00000000 --- a/scripting/php/phpcups.php +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/php -f -<? -// -// "$Id: phpcups.php 3603 2003-04-11 18:42:52Z mike $" -// -// PHP test script for CUPS. -// -// Copyright 2007-2011 by Apple Inc. -// Copyright 1997-2006 by Easy Software Products, all rights reserved. -// -// 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/". -// - -// Make sure the module is loaded... -if(!extension_loaded("phpcups")) -{ - dl("phpcups.so"); -} - -// Get the list of functions in the module... -$module = "phpcups"; -$functions = get_extension_funcs($module); - -print("Functions available in the $module extension:\n"); - -foreach ($functions as $func) -{ - print("$func\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 $". -// -?> |