const char * /* O - Option value or @code NULL@ */ cupsGetOption(const char *name, /* I - Name of option */ int num_options,/* I - Number of options */ cups_option_t *options) /* I - Options */ { int diff, /* Result of comparison */ match; /* Matching index */ DEBUG_printf(("2cupsGetOption(name=\"%s\", num_options=%d, options=%p)", name, num_options, (void *)options)); if (!name || num_options <= 0 || !options) { DEBUG_puts("3cupsGetOption: Returning NULL"); return (NULL); } match = cups_find_option(name, num_options, options, -1, &diff); if (!diff) { DEBUG_printf(("3cupsGetOption: Returning \"%s\"", options[match].value)); return (options[match].value); } DEBUG_puts("3cupsGetOption: Returning NULL"); return (NULL); }
ipp_status_t /* O - Status of document submission */ cupsFinishDestDocument( http_t *http, /* I - Connection to destination */ cups_dest_t *dest, /* I - Destination */ cups_dinfo_t *info) /* I - Destination information */ { DEBUG_printf(("cupsFinishDestDocument(http=%p, dest=%p(%s/%s), info=%p)", http, dest, dest ? dest->name : NULL, dest ? dest->instance : NULL, info)); /* * Range check input... */ if (!http || !dest || !info) { _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0); DEBUG_puts("1cupsFinishDestDocument: Bad arguments."); return (IPP_STATUS_ERROR_INTERNAL); } /* * Get the response at the end of the document and return it... */ ippDelete(cupsGetResponse(http, info->resource)); DEBUG_printf(("1cupsFinishDestDocument: %s (%s)", ippErrorString(cupsLastError()), cupsLastErrorString())); return (cupsLastError()); }
int /* O - Number of jobs */ cupsGetJobs(cups_job_t **jobs, /* O - Job data */ const char *mydest, /* I - NULL = all destinations, * * otherwise show jobs for mydest */ int myjobs, /* I - 0 = all users, 1 = mine */ int completed) /* I - -1 = show all, 0 = active, * * 1 = completed jobs */ { _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ /* * Try to connect to the server... */ if (!cups_connect("default", NULL, NULL)) { DEBUG_puts("Unable to connect to server!"); return (-1); } /* * Return the jobs... */ return (cupsGetJobs2(cg->http, jobs, mydest, myjobs, completed)); }
mime_type_t * /* O - Matching file type definition */ mimeType(mime_t *mime, /* I - MIME database */ const char *super, /* I - Super-type name */ const char *type) /* I - Type name */ { mime_type_t key, /* MIME type search key */ *mt; /* Matching type */ DEBUG_printf(("mimeType(mime=%p, super=\"%s\", type=\"%s\")", mime, super, type)); /* * Range check input... */ if (!mime || !super || !type) { DEBUG_puts("1mimeType: Returning NULL."); return (NULL); } /* * Lookup the type in the array... */ strlcpy(key.super, super, sizeof(key.super)); strlcpy(key.type, type, sizeof(key.type)); mt = (mime_type_t *)cupsArrayFind(mime->types, &key); DEBUG_printf(("1mimeType: Returning %p.", mt)); return (mt); }
int /* O - New number of options */ cupsRemoveOption( const char *name, /* I - Option name */ int num_options, /* I - Current number of options */ cups_option_t **options) /* IO - Options */ { int i; /* Looping var */ cups_option_t *option; /* Current option */ DEBUG_printf(("2cupsRemoveOption(name=\"%s\", num_options=%d, options=%p)", name, num_options, options)); /* * Range check input... */ if (!name || num_options < 1 || !options) { DEBUG_printf(("3cupsRemoveOption: Returning %d", num_options)); return (num_options); } /* * Loop for the option... */ for (i = num_options, option = *options; i > 0; i --, option ++) if (!_cups_strcasecmp(name, option->name)) break; if (i) { /* * Remove this option from the array... */ DEBUG_puts("4cupsRemoveOption: Found option, removing it..."); num_options --; i --; _cupsStrFree(option->name); _cupsStrFree(option->value); if (i > 0) memmove(option, option + 1, (size_t)i * sizeof(cups_option_t)); } /* * Return the new number of options... */ DEBUG_printf(("3cupsRemoveOption: Returning %d", num_options)); return (num_options); }
int /* O - 1 if prefixed, 0 if not prefixed */ _cupsSNMPIsOIDPrefixed( cups_snmp_t *packet, /* I - Response packet */ const int *prefix) /* I - OID prefix */ { int i; /* Looping var */ /* * Range check input... */ DEBUG_printf(("4_cupsSNMPIsOIDPrefixed(packet=%p, prefix=%p)", packet, prefix)); if (!packet || !prefix) { DEBUG_puts("5_cupsSNMPIsOIDPrefixed: Returning 0"); return (0); } /* * Compare OIDs... */ for (i = 0; i < CUPS_SNMP_MAX_OID && prefix[i] >= 0 && packet->object_name[i] >= 0; i ++) if (prefix[i] != packet->object_name[i]) { DEBUG_puts("5_cupsSNMPIsOIDPrefixed: Returning 0"); return (0); } DEBUG_printf(("5_cupsSNMPIsOIDPrefixed: Returning %d", i < CUPS_SNMP_MAX_OID)); return (i < CUPS_SNMP_MAX_OID); }
void init_uart() { DMA_start(hDmaRx); /* Start the MCBSP and Sample Rate Generator */ MCBSP_start(C55XX_UART_hMcbsp, MCBSP_SRGR_START, 0xFFFF); /* Take MCBSP receive and transmit out of reset */ MCBSP_start(C55XX_UART_hMcbsp, MCBSP_XMIT_START | MCBSP_RCV_START, 0xFFFF); MCBSP_write32(C55XX_UART_hMcbsp, 0xffffffff); /* kickstart the serial port */ DEBUG_putc('d'); DEBUG_puts("ebug_printf_ok\r\n"); }
_cups_raster_error_t * /* O - Pointer to error buffer */ get_error_buffer(void) { _cups_raster_error_t *buf; /* Pointer to error buffer */ /* * Initialize the global data exactly once... */ DEBUG_puts("3get_error_buffer()"); pthread_once(&raster_key_once, raster_init); /* * See if we have allocated the data yet... */ if ((buf = (_cups_raster_error_t *)pthread_getspecific(raster_key)) == NULL) { DEBUG_puts("4get_error_buffer: allocating memory for thread."); /* * No, allocate memory as set the pointer for the key... */ buf = calloc(1, sizeof(_cups_raster_error_t)); pthread_setspecific(raster_key, buf); DEBUG_printf(("4get_error_buffer: buf=%p", (void *)buf)); } /* * Return the pointer to the data... */ return (buf); }
int /* O - 1 if equal, 0 if not equal */ _cupsSNMPIsOID(cups_snmp_t *packet, /* I - Response packet */ const int *oid) /* I - OID */ { int i; /* Looping var */ /* * Range check input... */ DEBUG_printf(("4_cupsSNMPIsOID(packet=%p, oid=%p)", packet, oid)); if (!packet || !oid) { DEBUG_puts("5_cupsSNMPIsOID: Returning 0"); return (0); } /* * Compare OIDs... */ for (i = 0; i < CUPS_SNMP_MAX_OID && oid[i] >= 0 && packet->object_name[i] >= 0; i ++) if (oid[i] != packet->object_name[i]) { DEBUG_puts("5_cupsSNMPIsOID: Returning 0"); return (0); } DEBUG_printf(("5_cupsSNMPIsOID: Returning %d", i < CUPS_SNMP_MAX_OID && oid[i] == packet->object_name[i])); return (i < CUPS_SNMP_MAX_OID && oid[i] == packet->object_name[i]); }
void cupsImageClose(cups_image_t *img) /* I - Image to close */ { cups_ic_t *current, /* Current cached tile */ *next; /* Next cached tile */ /* * Wipe the tile cache file (if any)... */ if (img->cachefile >= 0) { DEBUG_printf(("Closing/removing swap file \"%s\"...\n", img->cachename)); close(img->cachefile); unlink(img->cachename); } /* * Free the image cache... */ DEBUG_puts("Freeing memory..."); for (current = img->first, next = NULL; current != NULL; current = next) { DEBUG_printf(("Freeing cache (%p, next = %p)...\n", current, next)); next = current->next; free(current); } /* * Free the rest of memory... */ if (img->tiles != NULL) { DEBUG_printf(("Freeing tiles (%p)...\n", img->tiles[0])); free(img->tiles[0]); DEBUG_printf(("Freeing tile pointers (%p)...\n", img->tiles)); free(img->tiles); } free(img); }
static cups_lang_t * /* O - Language data or NULL */ cups_cache_lookup( const char *name, /* I - Name of locale */ cups_encoding_t encoding) /* I - Encoding of locale */ { cups_lang_t *lang; /* Current language */ DEBUG_printf(("7cups_cache_lookup(name=\"%s\", encoding=%d(%s))", name, encoding, encoding == CUPS_AUTO_ENCODING ? "auto" : lang_encodings[encoding])); /* * Loop through the cache and return a match if found... */ for (lang = lang_cache; lang != NULL; lang = lang->next) { DEBUG_printf(("9cups_cache_lookup: lang=%p, language=\"%s\", " "encoding=%d(%s)", lang, lang->language, lang->encoding, lang_encodings[lang->encoding])); if (!strcmp(lang->language, name) && (encoding == CUPS_AUTO_ENCODING || encoding == lang->encoding)) { lang->used ++; DEBUG_puts("8cups_cache_lookup: returning match!"); return (lang); } } DEBUG_puts("8cups_cache_lookup: returning NULL!"); return (NULL); }
void mimeDeleteFilter(mime_t *mime, /* I - MIME database */ mime_filter_t *filter) /* I - Filter */ { DEBUG_printf(("mimeDeleteFilter(mime=%p, filter=%p(%s/%s->%s/%s, cost=%d, " "maxsize=" CUPS_LLFMT "))", mime, filter, filter ? filter->src->super : "???", filter ? filter->src->type : "???", filter ? filter->dst->super : "???", filter ? filter->dst->super : "???", filter ? filter->cost : -1, filter ? CUPS_LLCAST filter->maxsize : CUPS_LLCAST -1)); if (!mime || !filter) return; #ifdef DEBUG if (!cupsArrayFind(mime->filters, filter)) DEBUG_puts("1mimeDeleteFilter: Filter not in MIME database."); #endif /* DEBUG */ cupsArrayRemove(mime->filters, filter); free(filter); /* * Deleting a filter invalidates the source lookup cache used by * mimeFilter()... */ if (mime->srcs) { DEBUG_puts("1mimeDeleteFilter: Deleting source lookup cache."); cupsArrayDelete(mime->srcs); mime->srcs = NULL; } }
int /* O - Port number */ ippPort(void) { _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ DEBUG_puts("ippPort()"); if (!cg->ipp_port) _cupsSetDefaults(); DEBUG_printf(("1ippPort: Returning %d...", cg->ipp_port)); return (cg->ipp_port); }
int /* O - Character or -1 on end of file */ cupsFileGetChar(cups_file_t *fp) /* I - CUPS file */ { /* * Range check input... */ if (!fp || (fp->mode != 'r' && fp->mode != 's')) { DEBUG_puts("3cupsFileGetChar: Bad arguments!"); return (-1); } /* * If the input buffer is empty, try to read more data... */ if (fp->ptr >= fp->end) if (cups_fill(fp) < 0) { DEBUG_puts("3cupsFileGetChar: Unable to fill buffer!"); return (-1); } /* * Return the next character in the buffer... */ DEBUG_printf(("3cupsFileGetChar: Returning %d...", *(fp->ptr) & 255)); fp->pos ++; DEBUG_printf(("4cupsFileGetChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); return (*(fp->ptr)++ & 255); }
static void cgi_sort_variables(void) { #ifdef DEBUG int i; DEBUG_puts("cgi_sort_variables: Sorting variables..."); #endif /* DEBUG */ if (form_count < 2) return; qsort(form_vars, (size_t)form_count, sizeof(_cgi_var_t), (int (*)(const void *, const void *))cgi_compare_variables); #ifdef DEBUG DEBUG_puts("cgi_sort_variables: Sorted variable list is:"); for (i = 0; i < form_count; i ++) DEBUG_printf(("cgi_sort_variables: %d: %s (%d) = \"%s\" ...\n", i, form_vars[i].name, form_vars[i].nvalues, form_vars[i].values[0])); #endif /* DEBUG */ }
int mimeNumTypes(mime_t *mime) /* I - MIME database */ { DEBUG_printf(("mimeNumTypes(mime=%p)", mime)); if (!mime) { DEBUG_puts("1mimeNumTypes: Returning 0."); return (0); } else { DEBUG_printf(("1mimeNumTypes: Returning %d.", cupsArrayCount(mime->types))); return (cupsArrayCount(mime->types)); } }
mime_type_t * /* O - Type or NULL */ mimeFirstType(mime_t *mime) /* I - MIME database */ { DEBUG_printf(("6mimeFirstType(mime=%p)", mime)); if (!mime) { DEBUG_puts("7mimeFirstType: Returning NULL."); return (NULL); } else { mime_type_t *first = (mime_type_t *)cupsArrayFirst(mime->types); /* First type */ DEBUG_printf(("7mimeFirstType: Returning %p.", first)); return (first); } }
mime_type_t * /* O - Type or NULL */ mimeNextType(mime_t *mime) /* I - MIME database */ { DEBUG_printf(("6mimeNextType(mime=%p)", mime)); if (!mime) { DEBUG_puts("7mimeNextType: Returning NULL."); return (NULL); } else { mime_type_t *next = (mime_type_t *)cupsArrayNext(mime->types); /* Next type */ DEBUG_printf(("7mimeNextType: Returning %p.", next)); return (next); } }
mime_filter_t * /* O - Filter or NULL */ mimeNextFilter(mime_t *mime) /* I - MIME database */ { DEBUG_printf(("6mimeNextFilter(mime=%p)", mime)); if (!mime) { DEBUG_puts("7mimeNextFilter: Returning NULL."); return (NULL); } else { mime_filter_t *next = (mime_filter_t *)cupsArrayNext(mime->filters); /* Next filter */ DEBUG_printf(("7mimeNextFilter: Returning %p.", next)); return (next); } }
void mimeDeleteType(mime_t *mime, /* I - MIME database */ mime_type_t *mt) /* I - Type */ { DEBUG_printf(("mimeDeleteType(mime=%p, mt=%p(%s/%s))", mime, mt, mt ? mt->super : "???", mt ? mt->type : "???")); if (!mime || !mt) return; #ifdef DEBUG if (!cupsArrayFind(mime->types, mt)) DEBUG_puts("1mimeDeleteFilter: Type not in MIME database."); #endif /* DEBUG */ cupsArrayRemove(mime->types, mt); mime_delete_rules(mt->rules); free(mt); }
int /* O - 0 on success, -1 on error */ cupsFileFlush(cups_file_t *fp) /* I - CUPS file */ { ssize_t bytes; /* Bytes to write */ DEBUG_printf(("cupsFileFlush(fp=%p)", fp)); /* * Range check input... */ if (!fp || fp->mode != 'w') { DEBUG_puts("1cupsFileFlush: Attempt to flush a read-only file..."); return (-1); } bytes = (ssize_t)(fp->ptr - fp->buf); DEBUG_printf(("2cupsFileFlush: Flushing " CUPS_LLFMT " bytes...", CUPS_LLCAST bytes)); if (bytes > 0) { #ifdef HAVE_LIBZ if (fp->compressed) bytes = cups_compress(fp, fp->buf, bytes); else #endif /* HAVE_LIBZ */ bytes = cups_write(fp, fp->buf, bytes); if (bytes < 0) return (-1); fp->ptr = fp->buf; } return (0); }
const char * /* O - Filename for PPD file */ cupsGetPPD(const char *name) /* I - Printer name */ { _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ /* * See if we can connect to the server... */ if (!cups_connect(name, NULL, NULL)) { DEBUG_puts("Unable to connect to server!"); return (NULL); } /* * Return the PPD file... */ return (cupsGetPPD2(cg->http, name)); }
static int /* O - 1 if form data read */ cgi_initialize_get(void) { char *data; /* Pointer to form data string */ DEBUG_puts("cgi_initialize_get: Initializing variables using GET method..."); /* * Check to see if there is anything for us to read... */ data = getenv("QUERY_STRING"); if (data == NULL || strlen(data) == 0) return (0); /* * Parse it out and return... */ return (cgi_initialize_string(data)); }
int /* O - 1 on success, 0 on failure */ cupsArrayAdd(cups_array_t *a, /* I - Array */ void *e) /* I - Element */ { DEBUG_printf(("2cupsArrayAdd(a=%p, e=%p)", a, e)); /* * Range check input... */ if (!a || !e) { DEBUG_puts("3cupsArrayAdd: returning 0"); return (0); } /* * Append the element... */ return (cups_array_add(a, e, 0)); }
int /* O - 0 on failure, 1 on success */ cupsArrayInsert(cups_array_t *a, /* I - Array */ void *e) /* I - Element */ { DEBUG_printf(("2cupsArrayInsert(a=%p, e=%p)", a, e)); /* * Range check input... */ if (!a || !e) { DEBUG_puts("3cupsArrayInsert: returning 0"); return (0); } /* * Insert the element... */ return (cups_array_add(a, e, 1)); }
ppd_choice_t * /* O - Pointer to choice or @code NULL@ */ ppdFindMarkedChoice(ppd_file_t *ppd, /* I - PPD file */ const char *option) /* I - Keyword/option name */ { ppd_choice_t key, /* Search key for choice */ *marked; /* Marked choice */ DEBUG_printf(("2ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option)); if ((key.option = ppdFindOption(ppd, option)) == NULL) { DEBUG_puts("3ppdFindMarkedChoice: Option not found, returning NULL"); return (NULL); } marked = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key); DEBUG_printf(("3ppdFindMarkedChoice: Returning %p(%s)...", marked, marked ? marked->choice : "NULL")); return (marked); }
static const char * /* O - Full path to filter or NULL */ mime_add_fcache( cups_array_t *filtercache, /* I - Filter cache */ const char *name, /* I - Filter name */ const char *filterpath) /* I - Filter path */ { _mime_fcache_t key, /* Search key */ *temp; /* New filter cache */ char path[1024]; /* Full path to filter */ DEBUG_printf(("2mime_add_fcache(filtercache=%p, name=\"%s\", " "filterpath=\"%s\")", filtercache, name, filterpath)); key.name = (char *)name; if ((temp = (_mime_fcache_t *)cupsArrayFind(filtercache, &key)) != NULL) { DEBUG_printf(("3mime_add_fcache: Returning \"%s\".", temp->path)); return (temp->path); } if ((temp = calloc(1, sizeof(_mime_fcache_t))) == NULL) { DEBUG_puts("3mime_add_fcache: Returning NULL."); return (NULL); } temp->name = strdup(name); if (cupsFileFind(name, filterpath, 1, path, sizeof(path))) temp->path = strdup(path); cupsArrayAdd(filtercache, temp); DEBUG_printf(("3mime_add_fcache: Returning \"%s\".", temp->path)); return (temp->path); }
int /* O - Job ID */ cupsPrintFiles(const char *name, /* I - Printer or class name */ int num_files, /* I - Number of files */ const char **files, /* I - File(s) to print */ const char *title, /* I - Title of job */ int num_options, /* I - Number of options */ cups_option_t *options) /* I - Options */ { _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ DEBUG_printf(("cupsPrintFiles(name=\"%s\", num_files=%d, " "files=%p, title=\"%s\", num_options=%d, options=%p)\n", name, num_files, files, title, num_options, options)); /* * Setup a connection and request data... */ if (!cups_connect(name, NULL, NULL)) { DEBUG_printf(("cupsPrintFiles: Unable to open connection - %s.\n", strerror(errno))); DEBUG_puts("Unable to connect to server!"); return (0); } /* * Print the file(s)... */ return (cupsPrintFiles2(cg->http, name, num_files, files, title, num_options, options)); }
const char * /* O - Default printer or NULL */ cupsGetDefault(void) { const char *var; /* Environment variable */ _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ /* * First see if the LPDEST or PRINTER environment variables are * set... However, if PRINTER is set to "lp", ignore it to work * around a "feature" in most Linux distributions - the default * user login scripts set PRINTER to "lp"... */ if ((var = getenv("LPDEST")) != NULL) return (var); else if ((var = getenv("PRINTER")) != NULL && strcmp(var, "lp") != 0) return (var); /* * Try to connect to the server... */ if (!cups_connect("default", NULL, NULL)) { DEBUG_puts("Unable to connect to server!"); return (NULL); } /* * Return the default printer... */ return (cupsGetDefault2(cg->http)); }
const char * /* O - Default community name */ _cupsSNMPDefaultCommunity(void) { cups_file_t *fp; /* snmp.conf file */ char line[1024], /* Line from file */ *value; /* Value from file */ int linenum; /* Line number in file */ _cups_globals_t *cg = _cupsGlobals(); /* Global data */ DEBUG_puts("4_cupsSNMPDefaultCommunity()"); if (!cg->snmp_community[0]) { strlcpy(cg->snmp_community, "public", sizeof(cg->snmp_community)); snprintf(line, sizeof(line), "%s/snmp.conf", cg->cups_serverroot); if ((fp = cupsFileOpen(line, "r")) != NULL) { linenum = 0; while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum)) if (!_cups_strcasecmp(line, "Community") && value) { strlcpy(cg->snmp_community, value, sizeof(cg->snmp_community)); break; } cupsFileClose(fp); } } DEBUG_printf(("5_cupsSNMPDefaultCommunity: Returning \"%s\"", cg->snmp_community)); return (cg->snmp_community); }