190792Sgshapiro/* 2261194Sgshapiro * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers. 390792Sgshapiro * All rights reserved. 490792Sgshapiro * Copyright (c) 1990, 1993 590792Sgshapiro * The Regents of the University of California. All rights reserved. 690792Sgshapiro * 790792Sgshapiro * This code is derived from software contributed to Berkeley by 890792Sgshapiro * Chris Torek. 990792Sgshapiro * 1090792Sgshapiro * By using this file, you agree to the terms and conditions set 1190792Sgshapiro * forth in the LICENSE file which can be found at the top level of 1290792Sgshapiro * the sendmail distribution. 1390792Sgshapiro */ 1490792Sgshapiro 1590792Sgshapiro#include <sm/gen.h> 16266527SgshapiroSM_RCSID("@(#)$Id: put.c,v 1.28 2013-11-22 20:51:43 ca Exp $") 1790792Sgshapiro#include <string.h> 1890792Sgshapiro#include <errno.h> 1990792Sgshapiro#include <sm/io.h> 2090792Sgshapiro#include <sm/assert.h> 2190792Sgshapiro#include <sm/errstring.h> 2290792Sgshapiro#include <sm/string.h> 2390792Sgshapiro#include "local.h" 2490792Sgshapiro#include "fvwrite.h" 2590792Sgshapiro 2690792Sgshapiro/* 2790792Sgshapiro** SM_IO_PUTC -- output a character to the file 2890792Sgshapiro** 2990792Sgshapiro** Function version of the macro sm_io_putc (in <sm/io.h>). 3090792Sgshapiro** 3190792Sgshapiro** Parameters: 3290792Sgshapiro** fp -- file to output to 3390792Sgshapiro** timeout -- time to complete putc 3490792Sgshapiro** c -- int value of character to output 3590792Sgshapiro** 3690792Sgshapiro** Returns: 3790792Sgshapiro** Failure: returns SM_IO_EOF _and_ sets errno 3890792Sgshapiro** Success: returns sm_putc() value. 3990792Sgshapiro** 4090792Sgshapiro*/ 4190792Sgshapiro 4290792Sgshapiro#undef sm_io_putc 4390792Sgshapiro 4490792Sgshapiroint 4590792Sgshapirosm_io_putc(fp, timeout, c) 4690792Sgshapiro SM_FILE_T *fp; 4790792Sgshapiro int timeout; 4890792Sgshapiro int c; 4990792Sgshapiro{ 5090792Sgshapiro SM_REQUIRE_ISA(fp, SmFileMagic); 5190792Sgshapiro if (cantwrite(fp)) 5290792Sgshapiro { 5390792Sgshapiro errno = EBADF; 5490792Sgshapiro return SM_IO_EOF; 5590792Sgshapiro } 5690792Sgshapiro return sm_putc(fp, timeout, c); 5790792Sgshapiro} 5890792Sgshapiro 5990792Sgshapiro 6090792Sgshapiro/* 6190792Sgshapiro** SM_PERROR -- print system error messages to smioerr 6290792Sgshapiro** 6390792Sgshapiro** Parameters: 6490792Sgshapiro** s -- message to print 6590792Sgshapiro** 6690792Sgshapiro** Returns: 6790792Sgshapiro** none 6890792Sgshapiro*/ 6990792Sgshapiro 7090792Sgshapirovoid 7190792Sgshapirosm_perror(s) 7290792Sgshapiro const char *s; 7390792Sgshapiro{ 7490792Sgshapiro int save_errno = errno; 7590792Sgshapiro 7690792Sgshapiro if (s != NULL && *s != '\0') 7790792Sgshapiro (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "%s: ", s); 7890792Sgshapiro (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "%s\n", 7990792Sgshapiro sm_errstring(save_errno)); 8090792Sgshapiro} 81