| 4164 | */ |
| 4165 | |
| 4166 | static int /* O - Number of destinations */ |
| 4167 | cups_get_dests( |
| 4168 | const char *filename, /* I - File to read from */ |
| 4169 | const char *match_name, /* I - Destination name we want */ |
| 4170 | const char *match_inst, /* I - Instance name we want */ |
| 4171 | int load_all, /* I - Load all saved destinations? */ |
| 4172 | int user_default_set, /* I - User default printer set? */ |
| 4173 | int num_dests, /* I - Number of destinations */ |
| 4174 | cups_dest_t **dests) /* IO - Destinations */ |
| 4175 | { |
| 4176 | int i; /* Looping var */ |
| 4177 | cups_dest_t *dest; /* Current destination */ |
| 4178 | cups_file_t *fp; /* File pointer */ |
| 4179 | char line[8192], /* Line from file */ |
| 4180 | *lineptr, /* Pointer into line */ |
| 4181 | *name, /* Name of destination/option */ |
| 4182 | *instance; /* Instance of destination */ |
| 4183 | int linenum; /* Current line number */ |
| 4184 | |
| 4185 | |
| 4186 | DEBUG_printf(("7cups_get_dests(filename=\"%s\", match_name=\"%s\", match_inst=\"%s\", load_all=%d, user_default_set=%d, num_dests=%d, dests=%p)", filename, match_name, match_inst, load_all, user_default_set, num_dests, (void *)dests)); |
| 4187 | |
| 4188 | /* |
| 4189 | * Try to open the file... |
| 4190 | */ |
| 4191 | |
| 4192 | if ((fp = cupsFileOpen(filename, "r")) == NULL) |
| 4193 | return (num_dests); |
| 4194 | |
| 4195 | /* |
| 4196 | * Read each printer; each line looks like: |
| 4197 | * |
| 4198 | * Dest name[/instance] options |
| 4199 | * Default name[/instance] options |
| 4200 | */ |
| 4201 | |
| 4202 | linenum = 0; |
| 4203 | |
| 4204 | while (cupsFileGetConf(fp, line, sizeof(line), &lineptr, &linenum)) |
| 4205 | { |
| 4206 | /* |
| 4207 | * See what type of line it is... |
| 4208 | */ |
| 4209 | |
| 4210 | DEBUG_printf(("9cups_get_dests: linenum=%d line=\"%s\" lineptr=\"%s\"", |
| 4211 | linenum, line, lineptr)); |
| 4212 | |
| 4213 | if ((_cups_strcasecmp(line, "dest") && _cups_strcasecmp(line, "default")) || !lineptr) |
| 4214 | { |
| 4215 | DEBUG_puts("9cups_get_dests: Not a dest or default line..."); |
| 4216 | continue; |
| 4217 | } |
| 4218 | |
| 4219 | name = lineptr; |
| 4220 | |
| 4221 | /* |
| 4222 | * Search for an instance... |
| 4223 | */ |
no test coverage detected