#
-# "$Id: Makefile,v 1.2 1999/01/28 22:00:43 mike Exp $"
+# "$Id: Makefile,v 1.3 1999/02/05 17:40:50 mike Exp $"
#
# Support library Makefile for the Common UNIX Printing System (CUPS).
#
# libcups.a object files...
#
-OBJS = emit.o filter.o http.o ipp.o mark.o mime.o page.o ppd.o type.o
+OBJS = emit.o filter.o http.o ipp.o mark.o mime.o options.o page.o \
+ ppd.o type.o util.o
#
# Header files to install...
emit.o: ppd.h ../config.h ../Makedefs
filter.o: mime.h ../config.h ../Makedefs
-http.o: http.h ../config.h ../Makedefs
+http.o: http.h string.h ../config.h ../Makedefs
ipp.o: http.h ipp.h ../config.h ../Makedefs
mark.o: ppd.h ../config.h ../Makedefs
mime.o: mime.h ../config.h ../Makedefs
+options.o: cups.h ../config.h ../Makedefs
page.o: ppd.h ../config.h ../Makedefs
ppd.o: ppd.h ../config.h ../Makedefs
type.o: mime.h ../config.h ../Makedefs
+util.o: cups.h http.h ipp.h ../config.h ../Makedefs
#
# testhttp
testppd.o: ppd.h ../Makedefs
#
-# End of "$Id: Makefile,v 1.2 1999/01/28 22:00:43 mike Exp $".
+# End of "$Id: Makefile,v 1.3 1999/02/05 17:40:50 mike Exp $".
#
/*
- * "$Id: cups.h,v 1.3 1999/01/28 22:00:44 mike Exp $"
+ * "$Id: cups.h,v 1.4 1999/02/05 17:40:50 mike Exp $"
*
* API definitions for the Common UNIX Printing System (CUPS).
*
* Include necessary headers...
*/
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-# include <time.h>
-
# include <cups/ipp.h>
# include <cups/mime.h>
# include <cups/ppd.h>
* Types and structures...
*/
-typedef enum /**** Printer Status Bits ****/
-{
- CUPS_PRINTER_IDLE = 0x00, /* Printer is idle */
- CUPS_PRINTER_BUSY = 0x01, /* Printer is busy */
- CUPS_PRINTER_FAULTED = 0x02, /* Printer is faulted */
- CUPS_PRINTER_UNAVAILABLE = 0x03, /* Printer is unavailable */
- CUPS_PRINTER_DISABLED = 0x04, /* Printer is disabled */
- CUPS_PRINTER_REJECTING = 0x08 /* Printer is rejecting jobs */
-} cups_pstatus_t;
-
typedef enum /**** Printer Type/Capability Bits ****/
{
CUPS_PRINTER_CLASS = 0x0001, /* Printer class */
CUPS_PRINTER_VARIABLE = 0x8000 /* Can do variable sizes */
} cups_ptype_t;
-typedef enum /**** Job Priorities ****/
-{
- CUPS_PRIORITY_ANY = -1, /* Use the default priority */
- CUPS_PRIORITY_LOW, /* Lowest priority */
- CUPS_PRIORITY_NORMAL = 50, /* Default priority */
- CUPS_PRIORITY_HIGH = 100 /* Highest priority */
-} cups_jpriority_t;
-
-typedef enum /**** Job Status ****/
-{
- CUPS_JOB_PRINTING,
- CUPS_JOB_PENDING,
- CUPS_JOB_STOPPED
-} cups_jstatus_t;
-
-/*
- * Error codes...
- */
-
-# define CUPS_ERROR_NONE 0x00
-# define CUPS_ERROR_ACCESS 0x01
-# define CUPS_ERROR_NOT_AVAILABLE 0x02
-# define CUPS_ERROR_NOT_PRIVILEDGED 0x03
-
-# define CUPS_ERROR_BAD_PRINTER 0x10
-# define CUPS_ERROR_BAD_CLASS 0x11
-# define CUPS_ERROR_BAD_URI 0x12
-# define CUPS_ERROR_BAD_INTERFACE 0x13
-# define CUPS_ERROR_BAD_PPD 0x14
-# define CUPS_ERROR_BAD_LOCATION_CODE 0x15
-# define CUPS_ERROR_BAD_STATUS_CODE 0x16
-# define CUPS_ERROR_BAD_ACL 0x17
-# define CUPS_ERROR_BAD_JOB 0x18
-# define CUPS_ERROR_BAD_USER 0x19
-# define CUPS_ERROR_BAD_FILENAME 0x1a
-# define CUPS_ERROR_BAD_ID 0x1b
-# define CUPS_ERROR_BAD_COPIES 0x1c
-# define CUPS_ERROR_BAD_PRIORITY 0x1d
-# define CUPS_ERROR_BAD_OPTIONS 0x1e
-# define CUPS_ERROR_BAD_DATE 0x1f
-
/*
* Types & structures...
typedef struct /**** Printer Information ****/
{
- char printer_or_class[128], /* Printer or class name */
- device_uri[128], /* Universal resource identifier */
- description[64], /* Printer or class description */
- location_code[32], /* Location code */
- location_text[96], /* Location text */
- short type_code, /* Printer type code */
- status_code; /* Status code */
- unsigned char status_text[60]; /* Status text */
-} cups_printer_t;
-
-typedef struct /**** Job Information ****/
-{
- char printer_or_class[128], /* Printer or class name */
- user[64], /* Username (user@host) */
- super[MIME_MAX_SUPER], /* Super-type of job file */
- type[MIME_MAX_TYPE], /* Type of job file */
- description[128], /* Job title or filename */
- int id; /* Job identifier */
- unsigned size; /* Size of file in bytes */
- int status_code, /* Status code */
- priority, /* Job priority */
- num_copies, /* Number of copies */
- num_options; /* Number of job options */
- char **options; /* Job options (name=value) */
-} cups_job_t;
-
-typedef struct /**** Page Information ****/
-{
- char printer_or_class[128], /* Printer or class name */
- user[64]; /* Username (user@host) */
- unsigned char description[128]; /* Job title or filename */
- int id; /* Job identifier */
- time_t secs; /* Time stamp */
- int num_copies, /* Number of copies */
- num_options; /* Number of job options */
- char **options; /* Job options (name=value) */
-} cups_page_t;
-
-typedef struct /**** Message Header ****/
+ char name[IPP_MAX_NAME], /* Printer or class name */
+ uri[HTTP_MAX_URI]; /* Universal resource identifier */
+ unsigned char info[IPP_MAX_NAME], /* Printer or class info/description */
+ location[IPP_MAX_NAME]; /* Location text */
+ ipp_pstate_t state; /* Printer state */
+ unsigned char message[IPP_MAX_NAME]; /* State text */
+ cups_ptype_t type; /* Printer type/capability codes */
+} cups_browse_t;
+
+typedef struct /**** Printer Options ****/
{
- short type, /* Message type (see above) */
- count; /* Number of records in message */
- unsigned length; /* Length of message in bytes */
-} cups_header_t;
-
-
-typedef struct /**** Option Structure ****/
-{
- char *name; /* Option name */
- char *value; /* Option value */
+ char *name; /* Name of option */
+ char *value; /* Value of option */
} cups_option_t;
* Functions...
*/
-extern int cupsOpen(void);
-extern int cupsClose(int fd);
-
-extern unsigned char *cupsErrorString(int code);
-extern unsigned char *cupsJobStatusString(int code);
-extern unsigned char *cupsPrinterStatusString(int code);
-
-extern int cupsPrinterUpdate(int fd, char *name, short status_code,
- unsigned char *status_text);
-extern cups_msg_t *cupsPrinterQuery(char *name);
-extern cups_msg_t *cupsPrinterFind(char *name, char *classes,
- unsigned char *location_code,
- unsigned char *location_text);
-
-extern cups_msg_t *cupsJobAdd(unsigned char *name, char *queue_name,
- char *filename, int copies, int priority,
- int copy_file, cups_array_t *options);
-extern cups_msg_t *cupsJobRemove(int id, char *queue_name);
-extern cups_msg_t *cupsJobUpdate(int id, char *queue_name,
- int copies, int priority,
- cups_array_t *options);
-extern cups_msg_t *cupsJobQuery(int id);
-extern cups_msg_t *cupsJobFind(int id, char *queue_name, int priority);
-
-extern cups_msg_t *cupsPageAdd(unsigned char *job_name,
- char *printer_name, char *user,
- char *filename, int copies, int priority,
- time_t start_date, time_t end_date,
- cups_array_t *options);
-extern cups_msg_t *cupsPageQuery(char *printer_name, char *user,
- int copies);
-extern cups_msg_t *cupsPageFind(unsigned char *job_name,
- char *printer_name, char *user,
- char *filename, int priority,
- time_t start_date, time_t end_date);
-extern cups_msg_t *cupsPageClear(unsigned char *job_name,
- char *printer_name, char *user,
- char *filename, int priority,
- time_t start_date, time_t end_date);
-
-extern int *cupsParseOptions(char *arg, cups_option_t **options);
+extern int cupsCancelJob(char *printer, int job);
+extern int cupsGetClasses(char ***classes);
+extern char *cupsGetPPD(char *printer);
+extern int cupsGetPrinters(char ***printers);
+extern int cupsPrintFile(char *printer, char *filename,
+ int num_options, cups_option_t *options);
+
+extern int cupsAddOption(char *name, char *value, int num_options,
+ cups_option_t **options);
+extern void cupsFreeOptions(int num_options, cups_option_t *options);
+extern char *cupsGetOption(char *name, int num_options,
+ cups_option_t *options);
+extern int cupsParseOptions(char *arg, cups_option_t **options);
# ifdef _cplusplus
}
#endif /* !_CUPS_CUPS_H_ */
/*
- * End of "$Id: cups.h,v 1.3 1999/01/28 22:00:44 mike Exp $".
+ * End of "$Id: cups.h,v 1.4 1999/02/05 17:40:50 mike Exp $".
*/
/*
- * "$Id: emit.c,v 1.6 1999/01/30 13:25:54 mike Exp $"
+ * "$Id: emit.c,v 1.7 1999/02/05 17:40:50 mike Exp $"
*
* PPD code emission routines for the Common UNIX Printing System (CUPS).
*
*/
#include "ppd.h"
-#ifdef WIN32
+#include <stdlib.h>
+
+#if defined(WIN32) || defined(__EMX__)
# include <io.h>
#else
# include <unistd.h>
-#endif /* WIN32 */
+#endif /* WIN32 || __EMX__ */
/*
*/
for (i = ppd->num_jcls, o = ppd->jcls; i > 0; i --, o ++)
- for (j = o->num_choices, c = o->choices; j > 0; j --, c ++)
- if (c->marked && count < 1000)
- {
- collect[count] = c;
- count ++;
- }
+ if (o->section == section)
+ for (j = o->num_choices, c = o->choices; j > 0; j --, c ++)
+ if (c->marked && count < 1000)
+ {
+ collect[count] = c;
+ count ++;
+ }
for (i = ppd->num_options, o = ppd->options; i > 0; i --, o ++)
- for (j = o->num_choices, c = o->choices; j > 0; j --, c ++)
- if (c->marked && count < 1000)
- {
- collect[count] = c;
- count ++;
- }
+ if (o->section == section)
+ for (j = o->num_choices, c = o->choices; j > 0; j --, c ++)
+ if (c->marked && count < 1000)
+ {
+ collect[count] = c;
+ count ++;
+ }
for (i = ppd->num_nonuis, o = ppd->nonuis; i > 0; i --, o ++)
- for (j = o->num_choices, c = o->choices; j > 0; j --, c ++)
- if (c->marked && count < 1000)
- {
- collect[count] = c;
- count ++;
- }
-
- for (i = ppd->num_groups, g = ppd->groups; i > 0; i --, g ++)
- {
- for (j = g->num_options, o = g->options; j > 0; j --, o ++)
- for (k = o->num_choices, c = o->choices; k > 0; k --, c ++)
+ if (o->section == section)
+ for (j = o->num_choices, c = o->choices; j > 0; j --, c ++)
if (c->marked && count < 1000)
{
collect[count] = c;
count ++;
}
- for (j = g->num_subgroups, sg = g->subgroups; j > 0; j --, sg ++)
- for (k = sg->num_options, o = sg->options; k > 0; k --, o ++)
- for (m = o->num_choices, c = o->choices; m > 0; m --, c ++)
+ for (i = ppd->num_groups, g = ppd->groups; i > 0; i --, g ++)
+ {
+ for (j = g->num_options, o = g->options; j > 0; j --, o ++)
+ if (o->section == section)
+ for (k = o->num_choices, c = o->choices; k > 0; k --, c ++)
if (c->marked && count < 1000)
{
collect[count] = c;
count ++;
}
+
+ for (j = g->num_subgroups, sg = g->subgroups; j > 0; j --, sg ++)
+ for (k = sg->num_options, o = sg->options; k > 0; k --, o ++)
+ if (o->section == section)
+ for (m = o->num_choices, c = o->choices; m > 0; m --, c ++)
+ if (c->marked && count < 1000)
+ {
+ collect[count] = c;
+ count ++;
+ }
}
/*
/*
- * End of "$Id: emit.c,v 1.6 1999/01/30 13:25:54 mike Exp $".
+ * End of "$Id: emit.c,v 1.7 1999/02/05 17:40:50 mike Exp $".
*/
/*
- * "$Id: filter.c,v 1.3 1999/01/24 14:18:43 mike Exp $"
+ * "$Id: filter.c,v 1.4 1999/02/05 17:40:51 mike Exp $"
*
* File type conversion routines for the Common UNIX Printing System (CUPS).
*
* Revision History:
*
* $Log: filter.c,v $
+ * Revision 1.4 1999/02/05 17:40:51 mike
+ * Added IPP client read/write code.
+ *
+ * Added string functions missing from some UNIXs.
+ *
+ * Added option parsing functions.
+ *
+ * Added IPP convenience functions (not implemented yet).
+ *
+ * Updated source files to use local string.h as needed (for
+ * missing string functions)
+ *
* Revision 1.3 1999/01/24 14:18:43 mike
* Check-in prior to CVS use.
*
* Include necessary headers...
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "string.h"
#include "mime.h"
/*
- * End of "$Id: filter.c,v 1.3 1999/01/24 14:18:43 mike Exp $".
+ * End of "$Id: filter.c,v 1.4 1999/02/05 17:40:51 mike Exp $".
*/
/*
- * "$Id: http.c,v 1.13 1999/02/01 22:06:36 mike Exp $"
+ * "$Id: http.c,v 1.14 1999/02/05 17:40:51 mike Exp $"
*
* HTTP routines for the Common UNIX Printing System (CUPS) scheduler.
*
* content-length or transfer-encoding fields.
* http_send() - Send a request with all fields and the trailing
* blank line.
- * http_sighandler() - Handle broken pipe signals from lost network
- * clients.
*/
/*
* Include necessary headers...
*/
-#include "http.h"
+#include <stdio.h>
+#include <stdlib.h>
#include <stdarg.h>
+#include <ctype.h>
+#include "string.h"
+#include <time.h>
+#include <fcntl.h>
-#ifdef WIN32
-# define strcasecmp(s,t) stricmp(s,t)
-#endif /* WIN32 */
+#include "http.h"
/*
static http_field_t http_field(char *name);
static void http_get_length(http_t *http);
static int http_send(http_t *http, http_state_t request, char *uri);
-static void http_sighandler(int sig);
/*
/*
- * 'http_sighandler()' - Handle 'broken pipe' signals from lost network
- * clients.
- */
-
-static void
-http_sighandler(int sig) /* I - Signal number */
-{
-/* IGNORE */
-}
-
-
-/*
- * End of "$Id: http.c,v 1.13 1999/02/01 22:06:36 mike Exp $".
+ * End of "$Id: http.c,v 1.14 1999/02/05 17:40:51 mike Exp $".
*/
/*
- * "$Id: http.h,v 1.10 1999/02/01 22:06:37 mike Exp $"
+ * "$Id: http.h,v 1.11 1999/02/05 17:40:52 mike Exp $"
*
* Hyper-Text Transport Protocol definitions for the Common UNIX Printing
* System (CUPS).
* Include necessary headers...
*/
-# include <stdio.h>
-# include <stdlib.h>
# include <string.h>
-# include <time.h>
-# include <fcntl.h>
-
-# ifdef WIN32
-# include <winsock.h>
-# else
-# include <sys/time.h>
-# include <sys/socket.h>
-# include <netdb.h>
-# include <netinet/in.h>
-# include <netinet/in_systm.h>
-# include <netinet/ip.h>
-# include <netinet/tcp.h>
-# endif /* WIN32 */
+
+#if defined(WIN32) || defined(__EMX__)
+# include <winsock.h>
+#else
+# include <unistd.h>
+# include <sys/time.h>
+# include <sys/socket.h>
+# include <netdb.h>
+# include <netinet/in.h>
+# include <netinet/in_systm.h>
+# include <netinet/ip.h>
+# include <netinet/tcp.h>
+#endif /* WIN32 || __EMX__ */
+
/*
* C++ magic...
#endif /* !_CUPS_HTTP_H_ */
/*
- * End of "$Id: http.h,v 1.10 1999/02/01 22:06:37 mike Exp $".
+ * End of "$Id: http.h,v 1.11 1999/02/05 17:40:52 mike Exp $".
*/
/*
- * "$Id: ipp.c,v 1.3 1999/01/28 22:00:45 mike Exp $"
+ * "$Id: ipp.c,v 1.4 1999/02/05 17:40:52 mike Exp $"
*
* Internet Printing Protocol support functions for the Common UNIX
* Printing System (CUPS).
* ippFindAttribute() - Find a named attribute in a request...
* ippLength() - Compute the length of an IPP request.
* ippRead() - Read data for an IPP request.
- * ipp_TimeToDate() - Convert from UNIX time to RFC 1903 format.
+ * ippTimeToDate() - Convert from UNIX time to RFC 1903 format.
* ippWrite() - Write data for an IPP request.
* add_attr() - Add a new attribute to the request.
*/
* Include necessary headers...
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
#include "ipp.h"
* 'ippRead()' - Read data for an IPP request.
*/
-int
-ippRead(http_t *http,
- ipp_t *ipp)
+ipp_state_t /* O - Current state */
+ippRead(http_t *http, /* I - HTTP data */
+ ipp_t *ipp) /* I - IPP data */
{
- return (1);
+ int n; /* Length of data */
+ char buffer[8192]; /* Data buffer */
+ ipp_attribute_t *attr; /* Current attribute */
+ ipp_tag_t tag; /* Current tag */
+
+
+ if (http == NULL || ipp == NULL)
+ return (IPP_ERROR);
+
+ switch (ipp->state)
+ {
+ case IPP_IDLE :
+ break;
+
+ case IPP_HEADER :
+ /*
+ * Get the request header...
+ */
+
+ if (httpRead(http, buffer, 8) < 8)
+ return (IPP_ERROR);
+
+ /*
+ * Verify the major version number...
+ */
+
+ if (buffer[0] != 1)
+ return (IPP_ERROR);
+
+ /*
+ * Then copy the request header over...
+ */
+
+ ipp->request.any.version[0] = buffer[0];
+ ipp->request.any.version[1] = buffer[1];
+ ipp->request.any.op_status = (buffer[2] << 8) | buffer[3];
+ ipp->request.any.request_id = (((((buffer[4] << 8) | buffer[5]) << 8) |
+ buffer[6]) << 8) | buffer[7];
+
+ ipp->state = IPP_ATTRIBUTE;
+ ipp->current = NULL;
+ ipp->curtag = IPP_TAG_ZERO;
+
+ /*
+ * If blocking is disabled, stop here...
+ */
+
+ if (!http->blocking)
+ break;
+
+ case IPP_ATTRIBUTE :
+ while (httpRead(http, buffer, 1) > 0)
+ {
+ /*
+ * Read this attribute...
+ */
+
+ tag = (ipp_tag_t)buffer[0];
+
+ if (tag == IPP_TAG_END)
+ {
+ /*
+ * No more attributes left...
+ */
+
+ ipp->state = IPP_DATA;
+ break;
+ }
+ else if (tag < IPP_TAG_UNSUPPORTED)
+ {
+ /*
+ * Group tag... Set the current group and continue...
+ */
+
+ ipp->curtag = tag;
+ ipp->current = NULL;
+ continue;
+ }
+
+ /*
+ * Get the name...
+ */
+
+ if (httpRead(http, buffer, 2) < 2)
+ return (IPP_ERROR);
+
+ n = (buffer[0] << 8) | buffer[1];
+
+ if (n == 0)
+ {
+ /*
+ * More values for current attribute...
+ */
+
+ if (ipp->current == NULL)
+ return (IPP_ERROR);
+
+ attr = ipp->current;
+
+ if (attr->num_values >= IPP_MAX_VALUES)
+ return (IPP_ERROR);
+ }
+ else
+ {
+ /*
+ * New attribute; read the name and add it...
+ */
+
+ if (httpRead(http, buffer, n) < n)
+ return (IPP_ERROR);
+
+ buffer[n] = '\0';
+ attr = ipp->current = add_attr(ipp, IPP_MAX_VALUES);
+
+ attr->group_tag = ipp->curtag;
+ attr->value_tag = tag;
+ attr->name = strdup(buffer);
+ }
+
+ switch (tag)
+ {
+ case IPP_TAG_INTEGER :
+ case IPP_TAG_ENUM :
+ if (httpRead(http, buffer, 4) < 4)
+ return (IPP_ERROR);
+
+ n = (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
+ buffer[3];
+
+ attr->values[attr->num_values].integer = n;
+ break;
+ case IPP_TAG_BOOLEAN :
+ if (httpRead(http, buffer, 1) < 4)
+ return (IPP_ERROR);
+
+ attr->values[attr->num_values].boolean = buffer[0];
+ break;
+ case IPP_TAG_TEXT :
+ case IPP_TAG_NAME :
+ case IPP_TAG_KEYWORD :
+ case IPP_TAG_STRING :
+ case IPP_TAG_URI :
+ case IPP_TAG_URISCHEME :
+ case IPP_TAG_CHARSET :
+ case IPP_TAG_LANGUAGE :
+ case IPP_TAG_MIMETYPE :
+ if (httpRead(http, buffer, 2) < 2)
+ return (IPP_ERROR);
+
+ n = (buffer[0] << 8) | buffer[1];
+
+ if (httpRead(http, buffer, n) < n)
+ return (IPP_ERROR);
+
+ buffer[n] = '\0';
+
+ attr->values[attr->num_values].string = strdup(buffer);
+ break;
+ case IPP_TAG_DATE :
+ if (httpRead(http, buffer, 11) < 11)
+ return (IPP_ERROR);
+
+ memcpy(attr->values[attr->num_values].date, buffer, 11);
+ break;
+ case IPP_TAG_RESOLUTION :
+ if (httpRead(http, buffer, 9) < 9)
+ return (IPP_ERROR);
+
+ attr->values[attr->num_values].resolution.xres =
+ (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
+ buffer[3];
+ attr->values[attr->num_values].resolution.yres =
+ (((((buffer[4] << 8) | buffer[5]) << 8) | buffer[6]) << 8) |
+ buffer[7];
+ attr->values[attr->num_values].resolution.units =
+ (ipp_res_t)buffer[8];
+ break;
+ case IPP_TAG_RANGE :
+ if (httpRead(http, buffer, 8) < 8)
+ return (IPP_ERROR);
+
+ attr->values[attr->num_values].range.lower =
+ (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
+ buffer[3];
+ attr->values[attr->num_values].range.upper =
+ (((((buffer[4] << 8) | buffer[5]) << 8) | buffer[6]) << 8) |
+ buffer[7];
+ break;
+ case IPP_TAG_TEXTLANG :
+ case IPP_TAG_NAMELANG :
+ if (httpRead(http, buffer, 2) < 2)
+ return (IPP_ERROR);
+
+ n = (buffer[0] << 8) | buffer[1];
+
+ if (httpRead(http, buffer, n) < n)
+ return (IPP_ERROR);
+
+ buffer[n] = '\0';
+
+ attr->values[attr->num_values].lstring.charset = strdup(buffer);
+
+ if (httpRead(http, buffer, 2) < 2)
+ return (IPP_ERROR);
+
+ n = (buffer[0] << 8) | buffer[1];
+
+ if (httpRead(http, buffer, n) < n)
+ return (IPP_ERROR);
+
+ buffer[n] = '\0';
+
+ attr->values[attr->num_values].lstring.string =
+ (unsigned char *)strdup(buffer);
+ break;
+ }
+
+ attr->num_values ++;
+
+ /*
+ * If blocking is disabled, stop here...
+ */
+
+ if (!http->blocking)
+ break;
+ }
+ break;
+
+ case IPP_DATA :
+ break;
+ }
+
+ return (ipp->state);
}
/*
- * 'ipp_TimeToDate()' - Convert from UNIX time to RFC 1903 format.
+ * 'ippTimeToDate()' - Convert from UNIX time to RFC 1903 format.
*/
uchar * /* O - RFC-1903 date/time data */
-ipp_TimeToDate(time_t t) /* I - UNIX time value */
+ippTimeToDate(time_t t) /* I - UNIX time value */
{
struct tm *unixdate; /* UNIX unixdate/time info */
static uchar date[11]; /* RFC-1903 date/time data */
* 'ippWrite()' - Write data for an IPP request.
*/
-int
-ippWrite(http_t *http,
- ipp_t *ipp)
+ipp_state_t /* O - Current state */
+ippWrite(http_t *http, /* I - HTTP data */
+ ipp_t *ipp) /* I - IPP data */
{
- return (1);
+ int i; /* Looping var */
+ int n; /* Length of data */
+ char buffer[8192], /* Data buffer */
+ *bufptr;/* Pointer into buffer */
+ ipp_attribute_t *attr; /* Current attribute */
+
+
+ if (http == NULL || ipp == NULL)
+ return (IPP_ERROR);
+
+ switch (ipp->state)
+ {
+ case IPP_IDLE :
+ break;
+
+ case IPP_HEADER :
+ /*
+ * Send the request header...
+ */
+
+ bufptr = buffer;
+
+ *bufptr++ = 1;
+ *bufptr++ = 0;
+ *bufptr++ = ipp->request.any.op_status >> 8;
+ *bufptr++ = ipp->request.any.op_status;
+ *bufptr++ = ipp->request.any.request_id >> 24;
+ *bufptr++ = ipp->request.any.request_id >> 16;
+ *bufptr++ = ipp->request.any.request_id >> 8;
+ *bufptr++ = ipp->request.any.request_id;
+
+ if (httpWrite(http, buffer, bufptr - buffer) < 0)
+ return (IPP_ERROR);
+
+ ipp->state = IPP_ATTRIBUTE;
+ ipp->current = ipp->attrs;
+ ipp->curtag = IPP_TAG_ZERO;
+
+ /*
+ * If blocking is disabled, stop here...
+ */
+
+ if (!http->blocking)
+ break;
+
+ case IPP_ATTRIBUTE :
+ while (ipp->current != NULL)
+ {
+ /*
+ * Write this attribute...
+ */
+
+ bufptr = buffer;
+ attr = ipp->current;
+
+ ipp->current = ipp->current->next;
+
+ if (ipp->curtag != attr->group_tag)
+ {
+ /*
+ * Send a group operation tag...
+ */
+
+ *bufptr++ = attr->group_tag;
+ ipp->curtag = attr->group_tag;
+ }
+
+ n = strlen(attr->name);
+ *bufptr++ = attr->value_tag;
+ *bufptr++ = n >> 8;
+ *bufptr++ = n;
+ memcpy(bufptr, attr->name, n);
+ bufptr += n;
+
+ switch (attr->value_tag)
+ {
+ case IPP_TAG_INTEGER :
+ case IPP_TAG_ENUM :
+ for (i = 0; i < attr->num_values; i ++)
+ {
+ if (i)
+ {
+ /*
+ * Arrays and sets are done by sending additional
+ * values with a zero-length name...
+ */
+
+ *bufptr++ = attr->value_tag;
+ *bufptr++ = 0;
+ *bufptr++ = 0;
+ }
+
+ *bufptr++ = 0;
+ *bufptr++ = 4;
+ *bufptr++ = attr->values[i].integer >> 24;
+ *bufptr++ = attr->values[i].integer >> 16;
+ *bufptr++ = attr->values[i].integer >> 8;
+ *bufptr++ = attr->values[i].integer;
+ }
+ break;
+
+ case IPP_TAG_BOOLEAN :
+ for (i = 0; i < attr->num_values; i ++)
+ {
+ if (i)
+ {
+ /*
+ * Arrays and sets are done by sending additional
+ * values with a zero-length name...
+ */
+
+ *bufptr++ = attr->value_tag;
+ *bufptr++ = 0;
+ *bufptr++ = 0;
+ }
+
+ *bufptr++ = 0;
+ *bufptr++ = 1;
+ *bufptr++ = attr->values[i].boolean;
+ }
+ break;
+
+ case IPP_TAG_TEXT :
+ case IPP_TAG_NAME :
+ case IPP_TAG_KEYWORD :
+ case IPP_TAG_STRING :
+ case IPP_TAG_URI :
+ case IPP_TAG_URISCHEME :
+ case IPP_TAG_CHARSET :
+ case IPP_TAG_LANGUAGE :
+ case IPP_TAG_MIMETYPE :
+ for (i = 0; i < attr->num_values; i ++)
+ {
+ if (i)
+ {
+ /*
+ * Arrays and sets are done by sending additional
+ * values with a zero-length name...
+ */
+
+ *bufptr++ = attr->value_tag;
+ *bufptr++ = 0;
+ *bufptr++ = 0;
+ }
+
+ n = strlen(attr->values[i].string);
+ *bufptr++ = n >> 8;
+ *bufptr++ = n;
+ memcpy(bufptr, attr->values[i].string, n);
+ bufptr += n;
+ }
+ break;
+
+ case IPP_TAG_DATE :
+ for (i = 0; i < attr->num_values; i ++)
+ {
+ if (i)
+ {
+ /*
+ * Arrays and sets are done by sending additional
+ * values with a zero-length name...
+ */
+
+ *bufptr++ = attr->value_tag;
+ *bufptr++ = 0;
+ *bufptr++ = 0;
+ }
+
+ *bufptr++ = 0;
+ *bufptr++ = 11;
+ memcpy(bufptr, attr->values[i].date, 11);
+ bufptr += 11;
+ }
+ break;
+
+ case IPP_TAG_RESOLUTION :
+ for (i = 0; i < attr->num_values; i ++)
+ {
+ if (i)
+ {
+ /*
+ * Arrays and sets are done by sending additional
+ * values with a zero-length name...
+ */
+
+ *bufptr++ = attr->value_tag;
+ *bufptr++ = 0;
+ *bufptr++ = 0;
+ }
+
+ *bufptr++ = 0;
+ *bufptr++ = 9;
+ *bufptr++ = attr->values[i].resolution.xres >> 24;
+ *bufptr++ = attr->values[i].resolution.xres >> 16;
+ *bufptr++ = attr->values[i].resolution.xres >> 8;
+ *bufptr++ = attr->values[i].resolution.xres;
+ *bufptr++ = attr->values[i].resolution.yres >> 24;
+ *bufptr++ = attr->values[i].resolution.yres >> 16;
+ *bufptr++ = attr->values[i].resolution.yres >> 8;
+ *bufptr++ = attr->values[i].resolution.yres;
+ *bufptr++ = attr->values[i].resolution.units;
+ }
+ break;
+
+ case IPP_TAG_RANGE :
+ for (i = 0; i < attr->num_values; i ++)
+ {
+ if (i)
+ {
+ /*
+ * Arrays and sets are done by sending additional
+ * values with a zero-length name...
+ */
+
+ *bufptr++ = attr->value_tag;
+ *bufptr++ = 0;
+ *bufptr++ = 0;
+ }
+
+ *bufptr++ = 0;
+ *bufptr++ = 8;
+ *bufptr++ = attr->values[i].range.lower >> 24;
+ *bufptr++ = attr->values[i].range.lower >> 16;
+ *bufptr++ = attr->values[i].range.lower >> 8;
+ *bufptr++ = attr->values[i].range.lower;
+ *bufptr++ = attr->values[i].range.upper >> 24;
+ *bufptr++ = attr->values[i].range.upper >> 16;
+ *bufptr++ = attr->values[i].range.upper >> 8;
+ *bufptr++ = attr->values[i].range.upper;
+ }
+ break;
+
+ case IPP_TAG_TEXTLANG :
+ case IPP_TAG_NAMELANG :
+ for (i = 0; i < attr->num_values; i ++)
+ {
+ if (i)
+ {
+ /*
+ * Arrays and sets are done by sending additional
+ * values with a zero-length name...
+ */
+
+ *bufptr++ = attr->value_tag;
+ *bufptr++ = 0;
+ *bufptr++ = 0;
+ }
+
+ n = strlen(attr->values[i].lstring.charset);
+ *bufptr++ = n >> 8;
+ *bufptr++ = n;
+ memcpy(bufptr, attr->values[i].lstring.charset, n);
+ bufptr += n;
+
+ n = strlen((char *)attr->values[i].lstring.string);
+ *bufptr++ = n >> 8;
+ *bufptr++ = n;
+ memcpy(bufptr, attr->values[i].lstring.string, n);
+ bufptr += n;
+ }
+ break;
+ }
+
+ /*
+ * Write the data out...
+ */
+
+ if (httpWrite(http, buffer, bufptr - buffer) < 0)
+ return (IPP_ERROR);
+
+ /*
+ * If blocking is disabled, stop here...
+ */
+
+ if (!http->blocking)
+ break;
+ }
+
+ if (ipp->current == NULL)
+ {
+ /*
+ * Done with all of the attributes; add the end-of-attributes tag...
+ */
+
+ buffer[0] = IPP_TAG_END;
+ if (httpWrite(http, buffer, 1) < 0)
+ return (IPP_ERROR);
+
+ ipp->state = IPP_DATA;
+ }
+ break;
+
+ case IPP_DATA :
+ break;
+ }
+
+ return (ipp->state);
}
/*
- * End of "$Id: ipp.c,v 1.3 1999/01/28 22:00:45 mike Exp $".
+ * End of "$Id: ipp.c,v 1.4 1999/02/05 17:40:52 mike Exp $".
*/
/*
- * "$Id: ipp.h,v 1.3 1999/01/28 22:00:45 mike Exp $"
+ * "$Id: ipp.h,v 1.4 1999/02/05 17:40:52 mike Exp $"
*
* Internet Printing Protocol definitions for the Common UNIX Printing
* System (CUPS).
# define IPP_VERSION "\001\000"
+/*
+ * Common limits...
+ */
+
+# define IPP_MAX_NAME 128
+# define IPP_MAX_VALUES 100
+
+
/*
* Types and structures...
*/
IPP_JOB_CANCELED,
IPP_JOB_ABORTED,
IPP_JOB_COMPLETED
-} ipp_jobstate_t;
+} ipp_jstate_t;
+
+typedef enum /**** Printer States.... */
+{
+ IPP_PRINTER_IDLE = 3,
+ IPP_PRINTER_PROCESSING,
+ IPP_PRINTER_STOPPED
+} ipp_pstate_t;
typedef enum /**** IPP states... ****/
{
- IPP_IDLE,
- IPP_REQUEST_HEADER,
- IPP_REQUEST_ATTR,
- IPP_REQUEST_DATA,
- IPP_RESPONSE_HEADER,
- IPP_RESPONSE_ATTR,
- IPP_RESPONSE_DATA
+ IPP_ERROR = -1, /* An error occurred */
+ IPP_IDLE, /* Nothing is happening/request completed */
+ IPP_HEADER, /* The request header needs to be sent/received */
+ IPP_ATTRIBUTE, /* One or more attributes need to be sent/received */
+ IPP_DATA /* IPP request data needs to be sent/received */
} ipp_state_t;
typedef enum /**** IPP operations... ****/
IPP_GET_JOB_ATTRIBUTES,
IPP_GET_JOBS,
IPP_GET_PRINTER_ATTRIBUTES,
- IPP_PRIVATE = 0x4000
+ IPP_PRIVATE = 0x4000,
+ CUPS_GET_PRINTERS,
+ CUPS_ADD_PRINTER,
+ CUPS_DELETE_PRINTER,
+ CUPS_GET_CLASSES,
+ CUPS_ADD_CLASS,
+ CUPS_DELETE_CLASS
} ipp_op_t;
typedef enum /**** IPP status codes... ****/
typedef union /**** Request Header ****/
{
+ struct /* Any Header */
+ {
+ uchar version[2]; /* Protocol version number */
+ int op_status; /* Operation ID or status code*/
+ int request_id; /* Request ID */
+ } any;
+
struct /* Operation Header */
{
uchar version[2]; /* Protocol version number */
ipp_attribute_t *attrs, /* Attributes */
*last, /* Last attribute in list */
*current; /* Current attribute (for read/write) */
+ ipp_tag_t curtag; /* Current attribute group tag */
} ipp_t;
extern ipp_attribute_t *ippFindAttribute(ipp_t *ipp, char *name);
extern size_t ippLength(ipp_t *ipp);
extern ipp_t *ippNew(void);
-extern int ippRead(http_t *http, ipp_t *ipp);
+extern ipp_state_t ippRead(http_t *http, ipp_t *ipp);
extern uchar *ippTimeToDate(time_t t);
-extern int ippWrite(http_t *http, ipp_t *ipp);
+extern ipp_state_t ippWrite(http_t *http, ipp_t *ipp);
/*
* C++ magic...
#endif /* !_CUPS_IPP_H_ */
/*
- * End of "$Id: ipp.h,v 1.3 1999/01/28 22:00:45 mike Exp $".
+ * End of "$Id: ipp.h,v 1.4 1999/02/05 17:40:52 mike Exp $".
*/
/*
- * "$Id: mark.c,v 1.4 1999/01/27 18:31:56 mike Exp $"
+ * "$Id: mark.c,v 1.5 1999/02/05 17:40:53 mike Exp $"
*
* Option marking routines for the Common UNIX Printing System (CUPS).
*
*/
#include "ppd.h"
+#include "string.h"
/*
/*
- * End of "$Id: mark.c,v 1.4 1999/01/27 18:31:56 mike Exp $".
+ * End of "$Id: mark.c,v 1.5 1999/02/05 17:40:53 mike Exp $".
*/
/*
- * "$Id: mime.c,v 1.6 1999/02/01 22:08:39 mike Exp $"
+ * "$Id: mime.c,v 1.7 1999/02/05 17:40:53 mike Exp $"
*
* MIME database file routines for the Common UNIX Printing System (CUPS).
*
* Revision History:
*
* $Log: mime.c,v $
+ * Revision 1.7 1999/02/05 17:40:53 mike
+ * Added IPP client read/write code.
+ *
+ * Added string functions missing from some UNIXs.
+ *
+ * Added option parsing functions.
+ *
+ * Added IPP convenience functions (not implemented yet).
+ *
+ * Updated source files to use local string.h as needed (for
+ * missing string functions)
+ *
* Revision 1.6 1999/02/01 22:08:39 mike
* Restored original directory-scanning functionality of mimeLoad().
*
* Include necessary headers...
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "string.h"
#include "mime.h"
-#include <config.h>
#ifdef HAVE_SYS_DIR_H
# include <sys/types.h>
*temp = '\0';
/*
- * Add the filter to the MIME database; if "type" is "*" (as in "super/*")
+ * Add the filter to the MIME database; if "type" is "*" (as in "super / *")
* then add a filter for each super type listed in the database.
*/
/*
- * End of "$Id: mime.c,v 1.6 1999/02/01 22:08:39 mike Exp $".
+ * End of "$Id: mime.c,v 1.7 1999/02/05 17:40:53 mike Exp $".
*/
/*
- * "$Id: mime.h,v 1.3 1999/01/24 14:18:43 mike Exp $"
+ * "$Id: mime.h,v 1.4 1999/02/05 17:40:53 mike Exp $"
*
* MIME type/conversion database definitions for the Common UNIX Printing System (CUPS).
*
#ifndef _MIME_H_
# define _MIME_H_
-/*
- * Include necessary headers...
- */
-
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-# include <ctype.h>
-
-
/*
* C++ magic...
*/
*/
extern void mimeDelete(mime_t *mime);
-#define mimeLoad(pathname) mimeMerge(NULL, (pathname));
+#define mimeLoad(pathname) mimeMerge((mime_t *)0, (pathname));
extern mime_t *mimeMerge(mime_t *mime, char *pathname);
extern mime_t *mimeNew(void);
#endif /* !_MIME_H_ */
/*
- * End of "$Id: mime.h,v 1.3 1999/01/24 14:18:43 mike Exp $".
+ * End of "$Id: mime.h,v 1.4 1999/02/05 17:40:53 mike Exp $".
*/
--- /dev/null
+/*
+ * "$Id: options.c,v 1.1 1999/02/05 17:40:54 mike Exp $"
+ *
+ * Option routines for the Common UNIX Printing System (CUPS).
+ *
+ * Copyright 1997-1999 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
+ * 44145 Airport View Drive, Suite 204
+ * Hollywood, Maryland 20636-3111 USA
+ *
+ * Voice: (301) 373-9603
+ * EMail: cups-info@cups.org
+ * WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ * cupsAddOption() - Add an option to an option array.
+ * cupsFreeOptions() - Free all memory used by options.
+ * cupsGetOption() - Get an option value.
+ * cupsParseOptions() - Parse options from a command-line argument.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "cups.h"
+#include <stdlib.h>
+#include <ctype.h>
+#include "string.h"
+
+
+/*
+ * 'cupsAddOption()' - Add an option to an option array.
+ */
+
+int /* O - Number of options */
+cupsAddOption(char *name, /* I - Name of option */
+ char *value, /* I - Value of option */
+ int num_options, /* I - Number of options */
+ cups_option_t **options) /* IO - Pointer to options */
+{
+ cups_option_t *temp; /* Pointer to new option */
+
+
+ if (name == NULL || value == NULL || options == NULL)
+ return (0);
+
+ if (num_options == 0)
+ temp = (cups_option_t *)malloc(sizeof(cups_option_t));
+ else
+ temp = (cups_option_t *)realloc(*options, sizeof(cups_option_t) *
+ (num_options + 1));
+
+ if (temp == NULL)
+ return (0);
+
+ *options = temp;
+ temp += num_options;
+
+ temp->name = strdup(name);
+ temp->value = strdup(value);
+
+ return (num_options + 1);
+}
+
+
+/*
+ * 'cupsFreeOptions()' - Free all memory used by options.
+ */
+
+void
+cupsFreeOptions(int num_options, /* I - Number of options */
+ cups_option_t *options) /* I - Pointer to options */
+{
+ int i; /* Looping var */
+
+
+ if (num_options == 0 || options == NULL)
+ return;
+
+ for (i = 0; i < num_options; i ++)
+ {
+ free(options[i].name);
+ free(options[i].value);
+ }
+
+ free(options);
+}
+
+
+/*
+ * 'cupsGetOption()' - Get an option value.
+ */
+
+char * /* O - Option value or NULL */
+cupsGetOption(char *name, /* I - Name of option */
+ int num_options,/* I - Number of options */
+ cups_option_t *options) /* I - Options */
+{
+ int i; /* Looping var */
+
+
+ if (name == NULL || num_options == 0 || options == NULL)
+ return (NULL);
+
+ for (i = 0; i < num_options; i ++)
+ if (strcmp(options[i].name, name) == 0)
+ return (options[i].value);
+
+ return (NULL);
+}
+
+
+/*
+ * 'cupsParseOptions()' - Parse options from a command-line argument.
+ */
+
+int /* O - Number of options found */
+cupsParseOptions(char *arg, /* I - Argument to parse */
+ cups_option_t **options) /* O - Options found */
+{
+ int num_options; /* Number of options */
+ char *copyarg, /* Copy of input string */
+ *ptr, /* Pointer into string */
+ *name, /* Pointer to name */
+ *value; /* Pointer to value */
+
+
+ if (arg == NULL || options == NULL)
+ return (0);
+
+ /*
+ * Make a copy of the argument string and then divide it up...
+ */
+
+ copyarg = strdup(arg);
+ num_options = 0;
+ ptr = copyarg;
+
+ while (*ptr != '\0')
+ {
+ /*
+ * Get the name up to a SPACE, =, or end-of-string...
+ */
+
+ name = ptr;
+ while (!isspace(*ptr) && *ptr != '=' && *ptr != '\0')
+ ptr ++;
+
+ /*
+ * Skip trailing spaces...
+ */
+
+ while (isspace(*ptr))
+ *ptr++ = '\0';
+
+ if (*ptr != '=')
+ {
+ /*
+ * Start of another option...
+ */
+
+ num_options = cupsAddOption(name, "", num_options, options);
+ continue;
+ }
+
+ /*
+ * Remove = and parse the value...
+ */
+
+ *ptr++ = '\0';
+
+ if (*ptr == '\'')
+ {
+ /*
+ * Quoted string constant...
+ */
+
+ ptr ++;
+ value = ptr;
+
+ while (*ptr != '\'' && *ptr != '\0')
+ ptr ++;
+
+ if (*ptr != '\0')
+ *ptr++ = '\0';
+ }
+ else if (*ptr == '\"')
+ {
+ /*
+ * Double-quoted string constant...
+ */
+
+ ptr ++;
+ value = ptr;
+
+ while (*ptr != '\"' && *ptr != '\0')
+ ptr ++;
+
+ if (*ptr != '\0')
+ *ptr++ = '\0';
+ }
+ else
+ {
+ /*
+ * Normal space-delimited string...
+ */
+
+ value = ptr;
+
+ while (!isspace(*ptr) && *ptr != '\0')
+ ptr ++;
+
+ while (isspace(*ptr))
+ *ptr++ = '\0';
+ }
+
+ /*
+ * Add the string value...
+ */
+
+ num_options = cupsAddOption(name, value, num_options, options);
+ }
+
+ /*
+ * Free the copy of the argument we made and return the number of options
+ * found.
+ */
+
+ free(copyarg);
+
+ return (num_options);
+}
+
+
+/*
+ * End of "$Id: options.c,v 1.1 1999/02/05 17:40:54 mike Exp $".
+ */
/*
- * "$Id: page.c,v 1.3 1999/01/24 14:18:43 mike Exp $"
+ * "$Id: page.c,v 1.4 1999/02/05 17:40:54 mike Exp $"
*
* Page size functions for the Common UNIX Printing System (CUPS).
*
*/
#include "ppd.h"
+#include "string.h"
/*
/*
- * End of "$Id: page.c,v 1.3 1999/01/24 14:18:43 mike Exp $".
+ * End of "$Id: page.c,v 1.4 1999/02/05 17:40:54 mike Exp $".
*/
/*
- * "$Id: ppd.c,v 1.5 1999/01/30 13:25:57 mike Exp $"
+ * "$Id: ppd.c,v 1.6 1999/02/05 17:40:54 mike Exp $"
*
* PPD file routines for the Common UNIX Printing System (CUPS).
*
*/
#include "ppd.h"
+#include <stdlib.h>
#include <ctype.h>
-/*#define DEBUG*/
+#include "string.h"
/*
* Definitions...
*/
-#if defined(WIN32) || defined(OS2)
+#if defined(WIN32) || defined(__EMX__)
# define READ_BINARY "rb" /* Open a binary file for reading */
# define WRITE_BINARY "wb" /* Open a binary file for writing */
#else
# define READ_BINARY "r" /* Open a binary file for reading */
# define WRITE_BINARY "w" /* Open a binary file for writing */
-#endif /* WIN32 || OS2 */
+#endif /* WIN32 || __EMX__ */
#define PPD_KEYWORD 1 /* Line contained a keyword */
#define PPD_OPTION 2 /* Line contained an option name */
/*
- * End of "$Id: ppd.c,v 1.5 1999/01/30 13:25:57 mike Exp $".
+ * End of "$Id: ppd.c,v 1.6 1999/02/05 17:40:54 mike Exp $".
*/
/*
- * "$Id: ppd.h,v 1.4 1999/01/27 18:31:57 mike Exp $"
+ * "$Id: ppd.h,v 1.5 1999/02/05 17:40:55 mike Exp $"
*
* PostScript Printer Description definitions for the Common UNIX Printing
* System (CUPS).
*/
# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
/*
#endif /* !_CUPS_PPD_H_ */
/*
- * End of "$Id: ppd.h,v 1.4 1999/01/27 18:31:57 mike Exp $".
+ * End of "$Id: ppd.h,v 1.5 1999/02/05 17:40:55 mike Exp $".
*/
--- /dev/null
+/*
+ * "$Id: string.c,v 1.1 1999/02/05 17:40:55 mike Exp $"
+ *
+ * String functions for the Common UNIX Printing System (CUPS).
+ *
+ * Copyright 1997-1999 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
+ * 44145 Airport View Drive, Suite 204
+ * Hollywood, Maryland 20636-3111 USA
+ *
+ * Voice: (301) 373-9603
+ * EMail: cups-info@cups.org
+ * WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ * strdup() - Duplicate a string.
+ * strcasecmp() - Do a case-insensitive comparison.
+ * strncasecmp() - Do a case-insensitive comparison on up to N chars.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "string.h"
+
+
+/*
+ * 'strdup()' - Duplicate a string.
+ */
+
+# ifndef HAVE_STRDUP
+char * /* O - New string pointer */
+strdup(const char *s) /* I - String to duplicate */
+{
+ char *t; /* New string pointer */
+
+
+ if (s == NULL)
+ return (NULL);
+
+ if ((t = malloc(strlen(s) + 1)) == NULL)
+ return (NULL);
+
+ return (strcpy(t, s));
+}
+# endif /* !HAVE_STRDUP */
+
+
+/*
+ * 'strcasecmp()' - Do a case-insensitive comparison.
+ */
+
+# ifndef HAVE_STRCASECMP
+int /* O - Result of comparison (-1, 0, or 1) */
+strcasecmp(const char *s, /* I - First string */
+ const char *t) /* I - Second string */
+{
+ while (*s != '\0' && *t != '\0')
+ {
+ if (tolower(*s) < tolower(*t))
+ return (-1);
+ else if (tolower(*s) > tolower(*t))
+ return (1);
+
+ s ++;
+ t ++;
+ };
+
+ if (*s == '\0' && *t == '\0')
+ return (0);
+ else if (*s != '\0')
+ return (1);
+ else
+ return (-1);
+}
+# endif /* !HAVE_STRCASECMP */
+
+/*
+ * 'strncasecmp()' - Do a case-insensitive comparison on up to N chars.
+ */
+
+# ifndef HAVE_STRNCASECMP
+int /* O - Result of comparison (-1, 0, or 1) */
+strncasecmp(const char *s, /* I - First string */
+ const char *t, /* I - Second string */
+ size_t n) /* I - Maximum number of characters to compare */
+{
+ while (*s != '\0' && *t != '\0' && n > 0)
+ {
+ if (tolower(*s) < tolower(*t))
+ return (-1);
+ else if (tolower(*s) > tolower(*t))
+ return (1);
+
+ s ++;
+ t ++;
+ n --;
+ };
+
+ if (n == 0)
+ return (0);
+ else if (*s == '\0' && *t == '\0')
+ return (0);
+ else if (*s != '\0')
+ return (1);
+ else
+ return (-1);
+}
+# endif /* !HAVE_STRNCASECMP */
+
+
+/*
+ * End of "$Id: string.c,v 1.1 1999/02/05 17:40:55 mike Exp $".
+ */
--- /dev/null
+/*
+ * "$Id: string.h,v 1.1 1999/02/05 17:40:56 mike Exp $"
+ *
+ * String definitions for the Common UNIX Printing System (CUPS).
+ *
+ * Copyright 1997-1999 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
+ * 44145 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 _CUPS_STRING_H_
+# define _CUPS_STRING_H_
+
+/*
+ * Include necessary headers...
+ */
+
+# include <config.h>
+# include <string.h>
+
+
+/*
+ * Stuff for WIN32 and OS/2...
+ */
+
+# if defined(WIN32) || defined(__EMX__)
+# define strcasecmp stricmp
+# define strncasecmp strnicmp
+# endif /* WIN32 || __EMX__ */
+
+
+/*
+ * Prototypes...
+ */
+
+# ifndef HAVE_STRDUP
+extern char *strdup(const char *);
+# endif /* !HAVE_STRDUP */
+
+# ifndef HAVE_STRCASECMP
+extern int strcasecmp(const char *, const char *);
+# endif /* !HAVE_STRCASECMP */
+
+# ifndef HAVE_STRNCASECMP
+extern int strncasecmp(const char *, const char *, size_t n);
+# endif /* !HAVE_STRNCASECMP */
+
+#endif /* !_CUPS_STRING_H_ */
+
+/*
+ * End of "$Id: string.h,v 1.1 1999/02/05 17:40:56 mike Exp $".
+ */
/*
- * "$Id: testhttp.c,v 1.3 1999/02/01 22:06:37 mike Exp $"
+ * "$Id: testhttp.c,v 1.4 1999/02/05 17:40:56 mike Exp $"
*
* HTTP test program for the Common UNIX Printing System (CUPS).
*
* Include necessary headers...
*/
-#include <config.h>
+#include <stdio.h>
#include "http.h"
/*
- * End of "$Id: testhttp.c,v 1.3 1999/02/01 22:06:37 mike Exp $".
+ * End of "$Id: testhttp.c,v 1.4 1999/02/05 17:40:56 mike Exp $".
*/
/*
- * "$Id: testmime.c,v 1.3 1999/01/24 14:18:43 mike Exp $"
+ * "$Id: testmime.c,v 1.4 1999/02/05 17:40:56 mike Exp $"
*
* MIME test program for the Common UNIX Printing System (CUPS).
*
* Include necessary headers...
*/
-#include <config.h>
+#include <stdio.h>
#include "mime.h"
/*
- * End of "$Id: testmime.c,v 1.3 1999/01/24 14:18:43 mike Exp $".
+ * End of "$Id: testmime.c,v 1.4 1999/02/05 17:40:56 mike Exp $".
*/
/*
- * "$Id: testppd.c,v 1.4 1999/01/27 18:31:57 mike Exp $"
+ * "$Id: testppd.c,v 1.5 1999/02/05 17:40:57 mike Exp $"
*
* PPD test program for the Common UNIX Printing System (CUPS).
*
* Include necessary headers...
*/
-#include <config.h>
#include "ppd.h"
+#include "string.h"
/*
/*
- * End of "$Id: testppd.c,v 1.4 1999/01/27 18:31:57 mike Exp $".
+ * End of "$Id: testppd.c,v 1.5 1999/02/05 17:40:57 mike Exp $".
*/
/*
- * "$Id: type.c,v 1.3 1999/01/24 14:18:43 mike Exp $"
+ * "$Id: type.c,v 1.4 1999/02/05 17:40:57 mike Exp $"
*
* MIME typing routines for the Common UNIX Printing System (CUPS).
*
* Revision History:
*
* $Log: type.c,v $
+ * Revision 1.4 1999/02/05 17:40:57 mike
+ * Added IPP client read/write code.
+ *
+ * Added string functions missing from some UNIXs.
+ *
+ * Added option parsing functions.
+ *
+ * Added IPP convenience functions (not implemented yet).
+ *
+ * Updated source files to use local string.h as needed (for
+ * missing string functions)
+ *
* Revision 1.3 1999/01/24 14:18:43 mike
* Check-in prior to CVS use.
*
* Include necessary headers...
*/
-#include "mime.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
#include <locale.h>
+#include "string.h"
+#include "mime.h"
+
/*
* Local functions...
int i; /* Result of comparison */
- if ((i = strcmp((*t0)->super, (*t1)->super)) == 0)
- i = strcmp((*t0)->type, (*t1)->type);
+ if ((i = strcasecmp((*t0)->super, (*t1)->super)) == 0)
+ i = strcasecmp((*t0)->type, (*t1)->type);
return (i);
}
/*
- * End of "$Id: type.c,v 1.3 1999/01/24 14:18:43 mike Exp $".
+ * End of "$Id: type.c,v 1.4 1999/02/05 17:40:57 mike Exp $".
*/
--- /dev/null
+/*
+ * "$Id: util.c,v 1.1 1999/02/05 17:40:58 mike Exp $"
+ *
+ * Printing utilities for the Common UNIX Printing System (CUPS).
+ *
+ * Copyright 1997-1999 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
+ * 44145 Airport View Drive, Suite 204
+ * Hollywood, Maryland 20636-3111 USA
+ *
+ * Voice: (301) 373-9603
+ * EMail: cups-info@cups.org
+ * WWW: http://www.cups.org
+ *
+ * Contents:
+ *
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "cups.h"
+
+
+int
+cupsCancelJob(char *printer,
+ int job)
+{
+}
+
+
+int
+cupsGetClasses(char ***classes)
+{
+}
+
+
+char *
+cupsGetPPD(char *printer)
+{
+}
+
+
+int
+cupsGetPrinters(char ***printers)
+{
+}
+
+
+int
+cupsPrintFile(char *printer,
+ char *filename,
+ int num_options,
+ cups_option_t *options)
+{
+}
+
+
+/*
+ * End of "$Id: util.c,v 1.1 1999/02/05 17:40:58 mike Exp $".
+ */