local.h revision 1
1N/A * Copyright (c) 2000-2002, 2004-2006 Sendmail, Inc. and its suppliers. 1N/A * All rights reserved. 1N/A * Copyright (c) 1990, 1993 1N/A * The Regents of the University of California. All rights reserved. 1N/A * This code is derived from software contributed to Berkeley by 1N/A * By using this file, you agree to the terms and conditions set 1N/A * forth in the LICENSE file which can be found at the top level of 1N/A * the sendmail distribution. 1N/A * $Id: local.h,v 1.58 2006/12/19 19:44:23 ca Exp $ 1N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1N/A** Information local to this implementation of stdio, 1N/A** in particular, macros and private variables. 1N/A#
endif /* !SM_CONF_MEMCHR */ 1N/A/* std io functions */ 1N/A/* stdio io functions */ 1N/A/* string io functions */ 1N/A/* syslog io functions */ 1N/A/* Return true iff the given SM_FILE_T cannot be written now. */ 1N/A** Test whether the given stdio file has an active ungetc buffer; 1N/A** release such a buffer, without restoring ordinary unread data. 1N/A** SM_CONVERT_TIME -- convert the API timeout flag for select() usage. 1N/A** This takes a 'fp' (a file type pointer) and obtains the "raw" 1N/A** file descriptor (fd) if possible. The 'fd' is needed to possibly 1N/A** the type of timeout. If timeout is SM_TIME_FOREVER then the 1N/A** timeout using select won't be needed and the file is best placed 1N/A** in blocking mode. If there is to be a finite timeout then the file 1N/A** is best placed in non-blocking mode. Then, if not enough can be 1N/A** written, select() can be used to test when something can be written 1N/A** yet still timeout if the wait is too long. 1N/A** If the mode is already in the correct state we don't change it. 1N/A** Iff (yes "iff") the 'fd' is "-1" in value then the mode change 1N/A** will not happen. This situation arises when a late-binding-to-disk 1N/A** file type is in use. An example of this is the sendmail buffered 1N/A** fp -- the file pointer the timeout is for 1N/A** fd -- to become the file descriptor value from 'fp' 1N/A** val -- the timeout value to be converted 1N/A** time -- a struct timeval holding the converted value 1N/A** nothing, this is flow-through code 1N/A** May or may not change the mode of a currently open file. 1N/A** The file mode may be changed to O_NONBLOCK or ~O_NONBLOCK 1N/A** (meaning block). This is done to best match the type of 1N/A** timeout and for (possible) use with select(). 1N/A /* can't get an fd, likely internal 'fake' fp */ \
1N/A /* errno should be set */ \
1N/A /* errno should be set */ \
1N/A** SM_IO_WR_TIMEOUT -- setup the timeout for the write 1N/A** This #define uses a select() to wait for the 'fd' to become writable. 1N/A** The select() can be active for up to 'to' time. The select may not 1N/A** use all of the the 'to' time. Hence, the amount of "wall-clock" time is 1N/A** measured to decide how much to subtract from 'to' to update it. On some 1N/A** amount of time used. On many/most systems this does not happen. Therefore 1N/A** the updating of 'to' must be done ourselves; a copy of 'to' is passed 1N/A** since a BSD-like system will have updated it and we don't want to 1N/A** double the time used! 1N/A** Note: if a valid 'fd' doesn't exist yet, don't use this (e.g. the 1N/A** fd -- a file descriptor for doing select() with 1N/A** timeout -- the original user set value. 1N/A** nothing, this is flow through code 1N/A** adjusts 'timeout' for time used 1N/A /* something went wrong, errno set */ \
1N/A /* else loop again */ \
1N/A** If there is no 'fd' just error (we can't timeout). If the timeout 1N/A** is SM_TIME_FOREVER then there is no need to do a timeout with 1N/A** select since this will be a real error. If the error is not 1N/A** Specify the condition here as macro so it can be used in several places.