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

Function ppdEmitFd

cups/ppd-emit.c:291–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289 */
290
291int /* O - 0 on success, -1 on failure */
292ppdEmitFd(ppd_file_t *ppd, /* I - PPD file record */
293 int fd, /* I - File to write to */
294 ppd_section_t section) /* I - Section to write */
295{
296 char *buffer, /* Option code */
297 *bufptr; /* Pointer into code */
298 size_t buflength; /* Length of option code */
299 ssize_t bytes; /* Bytes written */
300 int status; /* Return status */
301
302
303 /*
304 * Range check input...
305 */
306
307 if (!ppd || fd < 0)
308 return (-1);
309
310 /*
311 * Get the string...
312 */
313
314 buffer = ppdEmitString(ppd, section, 0.0);
315
316 /*
317 * Write it as needed and return...
318 */
319
320 if (buffer)
321 {
322 buflength = strlen(buffer);
323 bufptr = buffer;
324 bytes = 0;
325
326 while (buflength > 0)
327 {
328#ifdef _WIN32
329 if ((bytes = (ssize_t)write(fd, bufptr, (unsigned)buflength)) < 0)
330#else
331 if ((bytes = write(fd, bufptr, buflength)) < 0)
332#endif /* _WIN32 */
333 {
334 if (errno == EAGAIN || errno == EINTR)
335 continue;
336
337 break;
338 }
339
340 buflength -= (size_t)bytes;
341 bufptr += bytes;
342 }
343
344 status = bytes < 0 ? -1 : 0;
345
346 free(buffer);
347 }
348 else

Callers

nothing calls this directly

Calls 1

ppdEmitStringFunction · 0.85

Tested by

no test coverage detected