CHANGES IN CUPS V1.1.19
+ - Merged several weight-reducing changes into the CUPS
+ baseline donated by Apple.
- Added preliminary support for CDSA; patch provided by
Apple.
- Implicit classes are now created from identical
/*
- * "$Id: dest.c,v 1.18.2.11 2003/01/07 18:26:24 mike Exp $"
+ * "$Id: dest.c,v 1.18.2.12 2003/01/24 20:45:10 mike Exp $"
*
* User-defined destination (and option) support for the Common UNIX
* Printing System (CUPS).
cups_lang_t *language; /* Default language */
const char *name; /* printer-name attribute */
char job_sheets[1024]; /* job-sheets option */
- static const char *pattrs[] = /* Attributes we're interested in */
+ static const char * const pattrs[] = /* Attributes we're interested in */
{
"printer-name",
"job-sheets-default"
/*
- * End of "$Id: dest.c,v 1.18.2.11 2003/01/07 18:26:24 mike Exp $".
+ * End of "$Id: dest.c,v 1.18.2.12 2003/01/24 20:45:10 mike Exp $".
*/
/*
- * "$Id: encode.c,v 1.1.2.10 2003/01/07 18:26:24 mike Exp $"
+ * "$Id: encode.c,v 1.1.2.11 2003/01/24 20:45:11 mike Exp $"
*
* Option encoding routines for the Common UNIX Printing System (CUPS).
*
ipp_tag_t value_tag;
} ipp_option_t;
-static ipp_option_t ipp_options[] =
+static const ipp_option_t ipp_options[] =
{
{ "blackplot", IPP_TAG_BOOLEAN },
{ "brightness", IPP_TAG_INTEGER },
/*
- * End of "$Id: encode.c,v 1.1.2.10 2003/01/07 18:26:24 mike Exp $".
+ * End of "$Id: encode.c,v 1.1.2.11 2003/01/24 20:45:11 mike Exp $".
*/
/*
- * "$Id: http-addr.c,v 1.1.2.9 2003/01/14 14:34:14 mike Exp $"
+ * "$Id: http-addr.c,v 1.1.2.10 2003/01/24 20:45:11 mike Exp $"
*
* HTTP address routines for the Common UNIX Printing System (CUPS).
*
static char *packed_ptr[2]; /* Pointer to packed address */
static struct hostent host_ip; /* Host entry for IP address */
+
#if defined(__APPLE__)
/* OS X hack to avoid it's ocassional long delay in lookupd */
- static char sLoopback[] = "127.0.0.1";
+ static const char sLoopback[] = "127.0.0.1";
if (strcmp(name, "localhost") == 0)
name = sLoopback;
#endif /* __APPLE__ */
/*
- * End of "$Id: http-addr.c,v 1.1.2.9 2003/01/14 14:34:14 mike Exp $".
+ * End of "$Id: http-addr.c,v 1.1.2.10 2003/01/24 20:45:11 mike Exp $".
*/
/*
- * "$Id: http.c,v 1.82.2.24 2003/01/24 19:19:42 mike Exp $"
+ * "$Id: http.c,v 1.82.2.25 2003/01/24 20:45:11 mike Exp $"
*
* HTTP routines for the Common UNIX Printing System (CUPS).
*
* Local globals...
*/
-static const char *http_fields[] =
+static const char * const http_fields[] =
{
"Accept-Language",
"Accept-Ranges",
"User-Agent",
"WWW-Authenticate"
};
-static const char *days[7] =
+static const char * const days[7] =
{
"Sun",
"Mon",
"Fri",
"Sat"
};
-static const char *months[12] =
+static const char * const months[12] =
{
"Jan",
"Feb",
const char *in) /* I - String to read from */
{
char *outptr; /* Output pointer */
- static char base64[] = /* Base64 characters... */
+ static const char base64[] = /* Base64 characters... */
{
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
int i; /* Looping var */
char *ptr, /* Pointer in buffer */
buf[1024]; /* Encoded URI buffer */
- static const char *codes[] = /* Request code strings */
- {
+ static const char * const codes[] =
+ { /* Request code strings */
NULL,
"OPTIONS",
"GET",
"TRACE",
"CLOSE"
};
- static const char *hex = "0123456789ABCDEF";
+ static const char hex[] = "0123456789ABCDEF";
/* Hex digits */
/*
- * End of "$Id: http.c,v 1.82.2.24 2003/01/24 19:19:42 mike Exp $".
+ * End of "$Id: http.c,v 1.82.2.25 2003/01/24 20:45:11 mike Exp $".
*/
/*
- * "$Id: ipp-support.c,v 1.2.2.2 2003/01/07 21:58:03 mike Exp $"
+ * "$Id: ipp-support.c,v 1.2.2.3 2003/01/24 20:45:12 mike Exp $"
*
* Internet Printing Protocol support functions for the Common UNIX
* Printing System (CUPS).
ippErrorString(ipp_status_t error) /* I - Error status */
{
static char unknown[255]; /* Unknown error statuses */
- static const char *status_oks[] = /* "OK" status codes */
+ static const char * const status_oks[] = /* "OK" status codes */
{
"successful-ok",
"successful-ok-ignored-or-substituted-attributes",
"successful-ok-too-many-events",
"successful-ok-but-cancel-subscription"
},
- *status_400s[] = /* Client errors */
+ * const status_400s[] = /* Client errors */
{
"client-error-bad-request",
"client-error-forbidden",
"client-error-ignored-all-notifications",
"client-error-print-support-file-not-found"
},
- *status_500s[] = /* Server errors */
+ * const status_500s[] = /* Server errors */
{
"server-error-internal-error",
"server-error-operation-not-supported",
/*
- * End of "$Id: ipp-support.c,v 1.2.2.2 2003/01/07 21:58:03 mike Exp $".
+ * End of "$Id: ipp-support.c,v 1.2.2.3 2003/01/24 20:45:12 mike Exp $".
*/
/*
- * "$Id: ipp.c,v 1.55.2.26 2003/01/16 13:48:10 mike Exp $"
+ * "$Id: ipp.c,v 1.55.2.27 2003/01/24 20:45:12 mike Exp $"
*
* Internet Printing Protocol support functions for the Common UNIX
* Printing System (CUPS).
*/
ipp_attribute_t * /* O - New attribute */
-ippAddStrings(ipp_t *ipp, /* I - IPP request */
- ipp_tag_t group, /* I - IPP group */
- ipp_tag_t type, /* I - Type of attribute */
- const char *name, /* I - Name of attribute */
- int num_values, /* I - Number of values */
- const char *charset, /* I - Character set */
- const char **values) /* I - Values */
+ippAddStrings(ipp_t *ipp, /* I - IPP request */
+ ipp_tag_t group, /* I - IPP group */
+ ipp_tag_t type, /* I - Type of attribute */
+ const char *name, /* I - Name of attribute */
+ int num_values, /* I - Number of values */
+ const char *charset, /* I - Character set */
+ const char * const *values) /* I - Values */
{
int i; /* Looping var */
ipp_attribute_t *attr; /* New attribute */
/*
- * End of "$Id: ipp.c,v 1.55.2.26 2003/01/16 13:48:10 mike Exp $".
+ * End of "$Id: ipp.c,v 1.55.2.27 2003/01/24 20:45:12 mike Exp $".
*/
/*
- * "$Id: ipp.h,v 1.36.2.13 2003/01/07 21:58:04 mike Exp $"
+ * "$Id: ipp.h,v 1.36.2.14 2003/01/24 20:45:13 mike Exp $"
*
* Internet Printing Protocol definitions for the Common UNIX Printing
* System (CUPS).
extern ipp_attribute_t *ippAddResolutions(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, ipp_res_t units, const int *xres, const int *yres);
extern ipp_attribute_t *ippAddSeparator(ipp_t *ipp);
extern ipp_attribute_t *ippAddString(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, const char *charset, const char *value);
-extern ipp_attribute_t *ippAddStrings(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int num_values, const char *charset, const char **values);
+extern ipp_attribute_t *ippAddStrings(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int num_values, const char *charset, const char * const *values);
extern time_t ippDateToTime(const ipp_uchar_t *date);
extern void ippDelete(ipp_t *ipp);
extern void ippDeleteAttribute(ipp_t *ipp, ipp_attribute_t *attr);
#endif /* !_IPP_IPP_H_ */
/*
- * End of "$Id: ipp.h,v 1.36.2.13 2003/01/07 21:58:04 mike Exp $".
+ * End of "$Id: ipp.h,v 1.36.2.14 2003/01/24 20:45:13 mike Exp $".
*/
/*
- * "$Id: language.c,v 1.20.2.11 2003/01/07 18:26:27 mike Exp $"
+ * "$Id: language.c,v 1.20.2.12 2003/01/24 20:45:13 mike Exp $"
*
* I18N/language support for the Common UNIX Printing System (CUPS).
*
static cups_lang_t *lang_cache = NULL; /* Language string cache */
static const char *lang_blank = ""; /* Blank constant string */
-static const char *lang_encodings[] = /* Encoding strings */
+static const char * const lang_encodings[] = /* Encoding strings */
{
"us-ascii", "iso-8859-1",
"iso-8859-2", "iso-8859-3",
"euc-cn", "euc-jp",
"euc-kr", "euc-tw"
};
-static const char *lang_default[] = /* Default POSIX locale */
+static const char *const lang_default[] = /* Default POSIX locale */
{
#include "cups_C.h"
NULL
cupsLangEncoding(cups_lang_t *lang) /* I - Language data */
{
if (lang == NULL)
- return (lang_encodings[0]);
+ return ((char*)lang_encodings[0]);
else
- return (lang_encodings[lang->encoding]);
+ return ((char*)lang_encodings[lang->encoding]);
}
/*
- * End of "$Id: language.c,v 1.20.2.11 2003/01/07 18:26:27 mike Exp $".
+ * End of "$Id: language.c,v 1.20.2.12 2003/01/24 20:45:13 mike Exp $".
*/
/*
- * "$Id: md5passwd.c,v 1.5.2.6 2003/01/07 18:26:27 mike Exp $"
+ * "$Id: md5passwd.c,v 1.5.2.7 2003/01/24 20:45:14 mike Exp $"
*
* MD5 password support for the Common UNIX Printing System (CUPS).
*
{
int i; /* Looping var */
char *md5ptr; /* Pointer into MD5 string */
- static char *hex = "0123456789abcdef";
+ static const char hex[] = "0123456789abcdef";
/* Hex digits */
/*
- * End of "$Id: md5passwd.c,v 1.5.2.6 2003/01/07 18:26:27 mike Exp $".
+ * End of "$Id: md5passwd.c,v 1.5.2.7 2003/01/24 20:45:14 mike Exp $".
*/
/*
- * "$Id: ppd.c,v 1.51.2.25 2003/01/15 14:52:50 mike Exp $"
+ * "$Id: ppd.c,v 1.51.2.26 2003/01/24 20:45:14 mike Exp $"
*
* PPD file routines for the Common UNIX Printing System (CUPS).
*
ppd_fix(char *string) /* IO - String to fix */
{
unsigned char *p; /* Pointer into string */
- static unsigned char lut[32] = /* Lookup table for characters */
+ static const unsigned char lut[32] = /* Lookup table for characters */
{
0x20,
0x20,
/*
- * End of "$Id: ppd.c,v 1.51.2.25 2003/01/15 14:52:50 mike Exp $".
+ * End of "$Id: ppd.c,v 1.51.2.26 2003/01/24 20:45:14 mike Exp $".
*/
/*
- * "$Id: tempfile.c,v 1.1.2.8 2003/01/15 16:08:44 mike Exp $"
+ * "$Id: tempfile.c,v 1.1.2.9 2003/01/24 20:45:14 mike Exp $"
*
* Temp file utilities for the Common UNIX Printing System (CUPS).
*
#else
struct timeval curtime; /* Current time */
#endif /* WIN32 */
- static char buf[1024] = ""; /* Buffer if you pass in NULL and 0 */
+ static char *buf = NULL; /* Buffer if you pass in NULL and 0 */
/*
if (filename == NULL)
{
+ if (buf == NULL)
+ buf = calloc(1024, sizeof(char));
+
+ if (buf == NULL)
+ return (-1);
+
filename = buf;
- len = sizeof(buf);
+ len = 1024;
}
/*
/*
- * End of "$Id: tempfile.c,v 1.1.2.8 2003/01/15 16:08:44 mike Exp $".
+ * End of "$Id: tempfile.c,v 1.1.2.9 2003/01/24 20:45:14 mike Exp $".
*/
/*
- * "$Id: testlang.c,v 1.1.2.2 2003/01/07 18:26:30 mike Exp $"
+ * "$Id: testlang.c,v 1.1.2.3 2003/01/24 20:45:15 mike Exp $"
*
* HTTP test program for the Common UNIX Printing System (CUPS).
*
char *argv[]) /* I - Command-line arguments */
{
cups_lang_t *language; /* Message catalog */
- static const char *charsets[] = /* Character sets */
+ static const char * const charsets[] =/* Character sets */
{
"us-ascii",
"iso-8859-1",
/*
- * End of "$Id: testlang.c,v 1.1.2.2 2003/01/07 18:26:30 mike Exp $".
+ * End of "$Id: testlang.c,v 1.1.2.3 2003/01/24 20:45:15 mike Exp $".
*/
/*
- * "$Id: usersys.c,v 1.14.2.6 2003/01/07 18:26:31 mike Exp $"
+ * "$Id: usersys.c,v 1.14.2.7 2003/01/24 20:45:15 mike Exp $"
*
* User, system, and password routines for the Common UNIX Printing
* System (CUPS).
FILE *fp; /* client.conf file */
char *encryption; /* CUPS_ENCRYPTION variable */
const char *home; /* Home directory of user */
- static char line[1024]; /* Line from file */
+ char line[1024]; /* Line from file */
/*
FILE *fp; /* client.conf file */
char *server; /* Pointer to server name */
const char *home; /* Home directory of user */
- static char line[1024]; /* Line from file */
+ char line[1024]; /* Line from file */
/*
/*
- * End of "$Id: usersys.c,v 1.14.2.6 2003/01/07 18:26:31 mike Exp $".
+ * End of "$Id: usersys.c,v 1.14.2.7 2003/01/24 20:45:15 mike Exp $".
*/
/*
- * "$Id: util.c,v 1.81.2.21 2003/01/15 04:25:50 mike Exp $"
+ * "$Id: util.c,v 1.81.2.22 2003/01/24 20:45:15 mike Exp $"
*
* Printing utilities for the Common UNIX Printing System (CUPS).
*
*title, /* job-name */
*user; /* job-originating-user-name */
char uri[HTTP_MAX_URI]; /* URI for jobs */
- static const char *attrs[] = /* Requested attributes */
+ static const char * const attrs[] = /* Requested attributes */
{
"job-id",
"job-priority",
http_status_t status; /* HTTP status from server */
char prompt[1024]; /* Prompt string */
static char filename[HTTP_MAX_URI]; /* Local filename */
- static const char *requested_attrs[] =/* Requested attributes */
- {
+ static const char * const requested_attrs[] =
+ { /* Requested attributes */
"printer-uri-supported",
"printer-type",
"member-uris"
/*
- * End of "$Id: util.c,v 1.81.2.21 2003/01/15 04:25:50 mike Exp $".
+ * End of "$Id: util.c,v 1.81.2.22 2003/01/24 20:45:15 mike Exp $".
*/
/*
- * "$Id: image-colorspace.c,v 1.22.2.8 2003/01/07 18:26:53 mike Exp $"
+ * "$Id: image-colorspace.c,v 1.22.2.9 2003/01/24 20:45:16 mike Exp $"
*
* Colorspace conversions for the Common UNIX Printing System (CUPS).
*
#endif /* !M_SQRT1_2 */
+/*
+ * Lookup table structure...
+ */
+
+typedef int cups_clut_t[3][256];
+
+
/*
* Local globals...
*/
static int ImageHaveProfile = 0;
/* Do we have a color profile? */
-static int ImageDensity[256];
- /* Ink/marker density LUT */
-static int ImageMatrix[3][3][256];
- /* Color transform matrix LUT */
+static int *ImageDensity; /* Ink/marker density LUT */
+static cups_clut_t *ImageMatrix; /* Color transform matrix LUT */
static cups_cspace_t ImageColorSpace = CUPS_CSPACE_RGB;
/* Destination colorspace */
float m; /* Current matrix value */
int *im; /* Pointer into ImageMatrix */
+
+ /*
+ * Allocate memory for the profile data...
+ */
+
+ if (ImageMatrix == NULL)
+ ImageMatrix = calloc(3, sizeof(cups_clut_t));
+
+ if (ImageMatrix == NULL)
+ return;
+
+ if (ImageDensity == NULL)
+ ImageDensity = calloc(256, sizeof(int));
+
+ if (ImageDensity == NULL)
+ return;
+
+ /*
+ * Populate the profile lookup tables...
+ */
+
ImageHaveProfile = 1;
for (i = 0, im = ImageMatrix[0][0]; i < 3; i ++)
*/
void
-ImageRGBAdjust(ib_t *pixels, /* IO - Input/output pixels */
- int count, /* I - Number of pixels to adjust */
- int saturation, /* I - Color saturation (%) */
- int hue) /* I - Color hue (degrees) */
+ImageRGBAdjust(ib_t *pixels, /* IO - Input/output pixels */
+ int count, /* I - Number of pixels to adjust */
+ int saturation, /* I - Color saturation (%) */
+ int hue) /* I - Color hue (degrees) */
{
- int i, j, k; /* Looping vars */
- float mat[3][3]; /* Color adjustment matrix */
- static int last_sat = 100, /* Last saturation used */
- last_hue = 0; /* Last hue used */
- static int lut[3][3][256]; /* Lookup table for matrix */
+ int i, j, k; /* Looping vars */
+ float mat[3][3]; /* Color adjustment matrix */
+ static int last_sat = 100, /* Last saturation used */
+ last_hue = 0; /* Last hue used */
+ static cups_clut_t *lut = NULL; /* Lookup table for matrix */
if (saturation != last_sat ||
saturate(mat, saturation * 0.01);
huerotate(mat, (float)hue);
+ /*
+ * Allocate memory for the lookup table...
+ */
+
+ if (lut == NULL)
+ lut = calloc(3, sizeof(cups_clut_t));
+
+ if (lut == NULL)
+ return;
+
/*
* Convert the matrix into a 3x3 array of lookup tables...
*/
/*
- * End of "$Id: image-colorspace.c,v 1.22.2.8 2003/01/07 18:26:53 mike Exp $".
+ * End of "$Id: image-colorspace.c,v 1.22.2.9 2003/01/24 20:45:16 mike Exp $".
*/
/*
- * "$Id: image-gif.c,v 1.8.2.8 2003/01/07 18:26:54 mike Exp $"
+ * "$Id: image-gif.c,v 1.8.2.9 2003/01/24 20:45:16 mike Exp $"
*
* GIF image routines for the Common UNIX Printing System (CUPS).
*
#define GIF_COLORMAP 0x80
typedef ib_t gif_cmap_t[256][4];
+typedef short gif_table_t[4096];
/*
lastbit, /* Last bit in buffer */
done, /* Done with this buffer? */
last_byte; /* Last byte in buffer */
- static unsigned char bits[8] = /* Bit masks for codes */
+ static const unsigned char bits[8] = /* Bit masks for codes */
{
0x01, 0x02, 0x04, 0x08,
0x10, 0x20, 0x40, 0x80
int first_time, /* I - 1 = first time, 0 = not first time */
int input_code_size) /* I - Code size in bits */
{
- int i, /* Looping var */
- code, /* Current code */
- incode; /* Input code */
- static short fresh = 0, /* 1 = empty buffers */
- code_size, /* Current code size */
- set_code_size, /* Initial code size set */
- max_code, /* Maximum code used */
- max_code_size, /* Maximum code size */
- firstcode, /* First code read */
- oldcode, /* Last code read */
- clear_code, /* Clear code for LZW input */
- end_code, /* End code for LZW input */
- table[2][4096], /* String table */
- stack[8192], /* Output stack */
- *sp; /* Current stack pointer */
+ int i, /* Looping var */
+ code, /* Current code */
+ incode; /* Input code */
+ static short fresh = 0, /* 1 = empty buffers */
+ code_size, /* Current code size */
+ set_code_size, /* Initial code size set */
+ max_code, /* Maximum code used */
+ max_code_size, /* Maximum code size */
+ firstcode, /* First code read */
+ oldcode, /* Last code read */
+ clear_code, /* Clear code for LZW input */
+ end_code, /* End code for LZW input */
+ *stack = NULL, /* Output stack */
+ *sp; /* Current stack pointer */
+ static gif_table_t *table = NULL; /* String table */
if (first_time)
max_code_size = 2 * clear_code;
max_code = clear_code + 2;
+ /*
+ * Allocate memory for buffers...
+ */
+
+ if (table == NULL)
+ table = calloc(2, sizeof(gif_table_t));
+
+ if (table == NULL)
+ return (-1);
+
+ if (stack == NULL)
+ stack = calloc(8192, sizeof(short));
+
+ if (stack == NULL)
+ return (-1);
+
/*
* Initialize input buffers...
*/
gif_cmap_t cmap, /* I - Colormap */
int interlace) /* I - Non-zero = interlaced image */
{
- unsigned char code_size; /* Code size */
- ib_t *pixels, /* Pixel buffer */
- *temp; /* Current pixel */
- int xpos, /* Current X position */
- ypos, /* Current Y position */
- pass; /* Current pass */
- int pixel; /* Current pixel */
- int bpp; /* Bytes per pixel */
- static int xpasses[4] = { 8, 8, 4, 2 },
- ypasses[5] = { 0, 4, 2, 1, 999999 };
+ unsigned char code_size; /* Code size */
+ ib_t *pixels, /* Pixel buffer */
+ *temp; /* Current pixel */
+ int xpos, /* Current X position */
+ ypos, /* Current Y position */
+ pass; /* Current pass */
+ int pixel; /* Current pixel */
+ int bpp; /* Bytes per pixel */
+ static const int xpasses[4] = /* X interleaving */
+ { 8, 8, 4, 2 },
+ ypasses[5] = /* Y interleaving */
+ { 0, 4, 2, 1, 999999 };
bpp = ImageGetDepth(img);
/*
- * End of "$Id: image-gif.c,v 1.8.2.8 2003/01/07 18:26:54 mike Exp $".
+ * End of "$Id: image-gif.c,v 1.8.2.9 2003/01/24 20:45:16 mike Exp $".
*/
/*
- * "$Id: auth.c,v 1.41.2.18 2003/01/15 04:25:53 mike Exp $"
+ * "$Id: auth.c,v 1.41.2.19 2003/01/24 20:45:17 mike Exp $"
*
* Authorization routines for the Common UNIX Printing System (CUPS).
*
*best; /* Best match for location so far */
int bestlen; /* Length of best match */
int limit; /* Limit field */
- static int limits[] = /* Map http_status_t to AUTH_LIMIT_xyz */
+ static const int limits[] = /* Map http_status_t to AUTH_LIMIT_xyz */
{
AUTH_LIMIT_ALL,
AUTH_LIMIT_OPTIONS,
struct spwd *spw; /* Shadow password data */
# endif /* HAVE_SHADOW_H */
#endif /* HAVE_LIBPAM */
- static const char *states[] = /* HTTP client states... */
+ static const char * const states[] = /* HTTP client states... */
{
"WAITING",
"OPTIONS",
/*
- * End of "$Id: auth.c,v 1.41.2.18 2003/01/15 04:25:53 mike Exp $".
+ * End of "$Id: auth.c,v 1.41.2.19 2003/01/24 20:45:17 mike Exp $".
*/
/*
- * "$Id: cert.c,v 1.7.2.8 2003/01/07 18:27:15 mike Exp $"
+ * "$Id: cert.c,v 1.7.2.9 2003/01/24 20:45:18 mike Exp $"
*
* Authentication certificate routines for the Common UNIX
* Printing System (CUPS).
int fd; /* Certificate file */
char filename[1024]; /* Certificate filename */
struct group *grp; /* System group */
- static const char *hex = "0123456789ABCDEF";
+ static const char hex[] = "0123456789ABCDEF";
/* Hex constants... */
/*
- * End of "$Id: cert.c,v 1.7.2.8 2003/01/07 18:27:15 mike Exp $".
+ * End of "$Id: cert.c,v 1.7.2.9 2003/01/24 20:45:18 mike Exp $".
*/
/*
- * "$Id: client.c,v 1.91.2.39 2003/01/24 19:19:43 mike Exp $"
+ * "$Id: client.c,v 1.91.2.40 2003/01/24 20:45:18 mike Exp $"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
static int check_if_modified(client_t *con,
struct stat *filestats);
static void decode_auth(client_t *con);
-static char *get_file(client_t *con, struct stat *filestats);
+static char *get_file(client_t *con, struct stat *filestats,
+ char *filename, int len);
static http_status_t install_conf_file(client_t *con);
static int pipe_command(client_t *con, int infile, int *outfile,
char *command, char *options);
ipp_state_t ipp_state; /* State of IPP transfer */
int bytes; /* Number of bytes to POST */
char *filename; /* Name of file for GET/HEAD */
+ char buf[1024]; /* Buffer for real filename */
struct stat filestats; /* File information */
mime_type_t *type; /* MIME type of file */
printer_t *p; /* Printer */
* Serve a file...
*/
- if ((filename = get_file(con, &filestats)) == NULL)
+ if ((filename = get_file(con, &filestats, buf,
+ sizeof(buf))) == NULL)
{
if (!SendError(con, HTTP_NOT_FOUND))
{
break;
}
- else if ((filename = get_file(con, &filestats)) == NULL)
+ else if ((filename = get_file(con, &filestats, buf,
+ sizeof(buf))) == NULL)
{
if (!SendHeader(con, HTTP_NOT_FOUND, "text/html"))
{
* 'get_file()' - Get a filename and state info.
*/
-static char * /* O - Real filename */
-get_file(client_t *con, /* I - Client connection */
- struct stat *filestats)/* O - File information */
+static char * /* O - Real filename */
+get_file(client_t *con, /* I - Client connection */
+ struct stat *filestats,/* O - File information */
+ char *filename, /* IO - Filename buffer */
+ int len) /* I - Buffer length */
{
int status; /* Status of filesystem calls */
char *params; /* Pointer to parameters in URI */
- static char filename[1024]; /* Filename buffer */
/*
*/
if (strncmp(con->uri, "/ppd/", 5) == 0)
- snprintf(filename, sizeof(filename), "%s%s", ServerRoot, con->uri);
+ snprintf(filename, len, "%s%s", ServerRoot, con->uri);
else if (strncmp(con->uri, "/admin/conf/", 12) == 0)
- snprintf(filename, sizeof(filename), "%s%s", ServerRoot, con->uri + 11);
+ snprintf(filename, len, "%s%s", ServerRoot, con->uri + 11);
else if (con->language != NULL)
- snprintf(filename, sizeof(filename), "%s/%s%s", DocumentRoot, con->language->language,
+ snprintf(filename, len, "%s/%s%s", DocumentRoot, con->language->language,
con->uri);
else
- snprintf(filename, sizeof(filename), "%s%s", DocumentRoot, con->uri);
+ snprintf(filename, len, "%s%s", DocumentRoot, con->uri);
if ((params = strchr(filename, '?')) != NULL)
*params = '\0';
if (strncmp(con->uri, "/ppd/", 5) != 0 &&
strncmp(con->uri, "/admin/conf/", 12) != 0)
{
- snprintf(filename, sizeof(filename), "%s%s", DocumentRoot, con->uri);
+ snprintf(filename, len, "%s%s", DocumentRoot, con->uri);
status = stat(filename, filestats);
}
if (!status && S_ISDIR(filestats->st_mode))
{
if (filename[strlen(filename) - 1] == '/')
- strlcat(filename, "index.html", sizeof(filename));
+ strlcat(filename, "index.html", len);
else
- strlcat(filename, "/index.html", sizeof(filename));
+ strlcat(filename, "/index.html", len);
status = stat(filename, filestats);
}
/*
- * End of "$Id: client.c,v 1.91.2.39 2003/01/24 19:19:43 mike Exp $".
+ * End of "$Id: client.c,v 1.91.2.40 2003/01/24 20:45:18 mike Exp $".
*/
/*
- * "$Id: cups-lpd.c,v 1.24.2.11 2003/01/07 18:27:18 mike Exp $"
+ * "$Id: cups-lpd.c,v 1.24.2.12 2003/01/24 20:45:19 mike Exp $"
*
* Line Printer Daemon interface for the Common UNIX Printing System (CUPS).
*
char uri[HTTP_MAX_URI]; /* Printer URI */
char queue[256], /* Printer/class queue */
*instance; /* Printer/class instance */
- static const char *ranks[10] = /* Ranking strings */
+ static const char * const ranks[10] = /* Ranking strings */
{
"th",
"st",
"th",
"th"
};
- static const char *requested[] = /* Requested attributes */
- {
+ static const char * const requested[] =
+ { /* Requested attributes */
"job-id",
"job-k-octets",
"job-state",
/*
- * End of "$Id: cups-lpd.c,v 1.24.2.11 2003/01/07 18:27:18 mike Exp $".
+ * End of "$Id: cups-lpd.c,v 1.24.2.12 2003/01/24 20:45:19 mike Exp $".
*/
/*
- * "$Id: cups-polld.c,v 1.5.2.10 2003/01/23 16:27:18 mike Exp $"
+ * "$Id: cups-polld.c,v 1.5.2.11 2003/01/24 20:45:20 mike Exp $"
*
* Polling daemon for the Common UNIX Printing System (CUPS).
*
ipp_pstate_t state; /* printer-state */
struct sockaddr_in addr; /* Broadcast address */
char packet[1540]; /* Data packet */
- static const char *attrs[] = /* Requested attributes */
+ static const char * const attrs[] = /* Requested attributes */
{
"printer-info",
"printer-location",
/*
- * End of "$Id: cups-polld.c,v 1.5.2.10 2003/01/23 16:27:18 mike Exp $".
+ * End of "$Id: cups-polld.c,v 1.5.2.11 2003/01/24 20:45:20 mike Exp $".
*/
/*
- * "$Id: log.c,v 1.19.2.7 2003/01/07 18:27:25 mike Exp $"
+ * "$Id: log.c,v 1.19.2.8 2003/01/24 20:45:20 mike Exp $"
*
* Log file routines for the Common UNIX Printing System (CUPS).
*
{
struct tm *date; /* Date/time value */
static char s[1024]; /* Date/time string */
- static const char *months[12] =/* Months */
- {
+ static const char * const months[12] =
+ { /* Months */
"Jan",
"Feb",
"Mar",
int len; /* Length of message */
char line[1024]; /* Line for output file */
va_list ap; /* Argument pointer */
- static char levels[] = /* Log levels... */
+ static const char levels[] = /* Log levels... */
{
' ',
'X',
'd'
};
#ifdef HAVE_VSYSLOG
- static int syslevels[] = /* SYSLOG levels... */
+ static const int syslevels[] =/* SYSLOG levels... */
{
0,
LOG_EMERG,
LogRequest(client_t *con, /* I - Request to log */
http_status_t code) /* I - Response code */
{
- static const char *states[] = /* HTTP client states... */
- {
+ static const char * const states[] =
+ { /* HTTP client states... */
"WAITING",
"OPTIONS",
"GET",
/*
- * End of "$Id: log.c,v 1.19.2.7 2003/01/07 18:27:25 mike Exp $".
+ * End of "$Id: log.c,v 1.19.2.8 2003/01/24 20:45:20 mike Exp $".
*/