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

Function cupsFileGets

cups/file.c:939–1011  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

937 */
938
939char * /* O - Line read or @code NULL@ on end of file or error */
940cupsFileGets(cups_file_t *fp, /* I - CUPS file */
941 char *buf, /* O - String buffer */
942 size_t buflen) /* I - Size of string buffer */
943{
944 int ch; /* Character from file */
945 char *ptr, /* Current position in line buffer */
946 *end; /* End of line buffer */
947
948
949 /*
950 * Range check input...
951 */
952
953 DEBUG_printf(("2cupsFileGets(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")", (void *)fp, (void *)buf, CUPS_LLCAST buflen));
954
955 if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 2)
956 return (NULL);
957
958 /*
959 * Now loop until we have a valid line...
960 */
961
962 for (ptr = buf, end = buf + buflen - 1; ptr < end ;)
963 {
964 if (fp->ptr >= fp->end)
965 if (cups_fill(fp) <= 0)
966 {
967 if (ptr == buf)
968 return (NULL);
969 else
970 break;
971 }
972
973 ch = *(fp->ptr)++;
974 fp->pos ++;
975
976 if (ch == '\r')
977 {
978 /*
979 * Check for CR LF...
980 */
981
982 if (fp->ptr >= fp->end)
983 if (cups_fill(fp) <= 0)
984 break;
985
986 if (*(fp->ptr) == '\n')
987 {
988 fp->ptr ++;
989 fp->pos ++;
990 }
991
992 break;
993 }
994 else if (ch == '\n')
995 {
996 /*

Callers 15

mime_load_convsFunction · 0.85
mime_load_typesFunction · 0.85
mainFunction · 0.85
cat_staticFunction · 0.85
load_driversFunction · 0.85
load_ppdFunction · 0.85
load_ppdsFunction · 0.85
add_printerFunction · 0.85
copy_modelFunction · 0.85
create_local_bg_threadFunction · 0.85
read_job_ticketFunction · 0.85
cupsdLoadJobFunction · 0.85

Calls 1

cups_fillFunction · 0.85

Tested by 4

read_hexFunction · 0.68
mainFunction · 0.68
count_linesFunction · 0.68
read_write_testsFunction · 0.68