vdprintf.c (10b3b54548f2290bbe8d8f88c59c28d12b7a635d) | vdprintf.c (1b0181df2f46ef73a41ea8c9b7026718f8eec3a1) |
---|---|
1/*- 2 * Copyright (c) 2009 David Schultz <das@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 25 unchanged lines hidden (view full) --- 34#include <stdio.h> 35#include "un-namespace.h" 36 37#include "local.h" 38 39int 40vdprintf(int fd, const char * __restrict fmt, va_list ap) 41{ | 1/*- 2 * Copyright (c) 2009 David Schultz <das@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 25 unchanged lines hidden (view full) --- 34#include <stdio.h> 35#include "un-namespace.h" 36 37#include "local.h" 38 39int 40vdprintf(int fd, const char * __restrict fmt, va_list ap) 41{ |
42 FILE f; | 42 FILE f = FAKE_FILE; |
43 unsigned char buf[BUFSIZ]; 44 int ret; 45 46 if (fd > SHRT_MAX) { 47 errno = EMFILE; 48 return (EOF); 49 } 50 51 f._p = buf; 52 f._w = sizeof(buf); 53 f._flags = __SWR; 54 f._file = fd; 55 f._cookie = &f; 56 f._write = __swrite; 57 f._bf._base = buf; 58 f._bf._size = sizeof(buf); | 43 unsigned char buf[BUFSIZ]; 44 int ret; 45 46 if (fd > SHRT_MAX) { 47 errno = EMFILE; 48 return (EOF); 49 } 50 51 f._p = buf; 52 f._w = sizeof(buf); 53 f._flags = __SWR; 54 f._file = fd; 55 f._cookie = &f; 56 f._write = __swrite; 57 f._bf._base = buf; 58 f._bf._size = sizeof(buf); |
59 f._orientation = 0; 60 bzero(&f._mbstate, sizeof(f._mbstate)); | |
61 62 if ((ret = __vfprintf(&f, fmt, ap)) < 0) 63 return (ret); 64 65 return (__fflush(&f) ? EOF : ret); 66} | 59 60 if ((ret = __vfprintf(&f, fmt, ap)) < 0) 61 return (ret); 62 63 return (__fflush(&f) ? EOF : ret); 64} |