MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsFileGetConf

Function cupsFileGetConf

cups/file.c:714–850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

712 */
713
714char * /* O - Line read or @code NULL@ on end of file or error */
715cupsFileGetConf(cups_file_t *fp, /* I - CUPS file */
716 char *buf, /* O - String buffer */
717 size_t buflen, /* I - Size of string buffer */
718 char **value, /* O - Pointer to value */
719 int *linenum) /* IO - Current line number */
720{
721 char *ptr; /* Pointer into line */
722
723
724 /*
725 * Range check input...
726 */
727
728 DEBUG_printf(("2cupsFileGetConf(fp=%p, buf=%p, buflen=" CUPS_LLFMT ", value=%p, linenum=%p)", (void *)fp, (void *)buf, CUPS_LLCAST buflen, (void *)value, (void *)linenum));
729
730 if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 2 || !value)
731 {
732 if (value)
733 *value = NULL;
734
735 return (NULL);
736 }
737
738 /*
739 * Read the next non-comment line...
740 */
741
742 *value = NULL;
743
744 while (cupsFileGets(fp, buf, buflen))
745 {
746 (*linenum) ++;
747
748 /*
749 * Handle escaped characters and strip any comments...
750 */
751
752 for (ptr = buf; *ptr; ptr ++)
753 {
754 if (*ptr == '#')
755 {
756 // Strip comment text...
757 *ptr = '\0';
758 break;
759 }
760 else if (*ptr == '\\' && (ptr[1] == '\\' || ptr[1] == '#' || ptr[1] == 'n' || ptr[1] == 'r'))
761 {
762 /*
763 * \\, \#, \n, or \r, remove backslash and update the escaped char as
764 * needed...
765 */
766
767 _cups_strcpy(ptr, ptr + 1);
768
769 if (*ptr == 'n')
770 *ptr = '\n';
771 else if (*ptr == 'r')

Callers 15

read_cups_files_confFunction · 0.85
cupsdLoadJobFunction · 0.85
load_job_cacheFunction · 0.85
load_next_job_idFunction · 0.85
read_cupsd_confFunction · 0.85
read_cups_files_confFunction · 0.85
read_locationFunction · 0.85
read_policyFunction · 0.85
cupsdLoadAllClassesFunction · 0.85
get_printerFunction · 0.85
cupsdLoadAllPrintersFunction · 0.85

Calls 3

cupsFileGetsFunction · 0.85
_cups_strcpyFunction · 0.85
_cups_isspaceFunction · 0.85

Tested by 1

read_write_testsFunction · 0.68