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

Function cups_get_default

cups/dest.c:4117–4159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4115 */
4116
4117static char * /* O - Default destination or NULL */
4118cups_get_default(const char *filename, /* I - File to read */
4119 char *namebuf, /* I - Name buffer */
4120 size_t namesize, /* I - Size of name buffer */
4121 const char **instance) /* I - Instance */
4122{
4123 cups_file_t *fp; /* lpoptions file */
4124 char line[8192], /* Line from file */
4125 *value, /* Value for line */
4126 *nameptr; /* Pointer into name */
4127 int linenum; /* Current line */
4128
4129
4130 *namebuf = '\0';
4131
4132 if ((fp = cupsFileOpen(filename, "r")) != NULL)
4133 {
4134 linenum = 0;
4135
4136 while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
4137 {
4138 if (!_cups_strcasecmp(line, "default") && value)
4139 {
4140 strlcpy(namebuf, value, namesize);
4141
4142 if ((nameptr = strchr(namebuf, ' ')) != NULL)
4143 *nameptr = '\0';
4144 if ((nameptr = strchr(namebuf, '\t')) != NULL)
4145 *nameptr = '\0';
4146
4147 if ((nameptr = strchr(namebuf, '/')) != NULL)
4148 *nameptr++ = '\0';
4149
4150 *instance = nameptr;
4151 break;
4152 }
4153 }
4154
4155 cupsFileClose(fp);
4156 }
4157
4158 return (*namebuf ? namebuf : NULL);
4159}
4160
4161
4162/*

Callers 1

cupsGetNamedDestFunction · 0.85

Calls 4

cupsFileOpenFunction · 0.85
cupsFileGetConfFunction · 0.85
_cups_strcasecmpFunction · 0.85
cupsFileCloseFunction · 0.85

Tested by

no test coverage detected