1N/A/*
1N/A * Copyright (c) 2000-2001 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 *
1N/A * This code is derived from software contributed to Berkeley by
1N/A * Chris Torek.
1N/A *
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 */
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A#include <sm/gen.h>
1N/ASM_RCSID("@(#)$Id: put.c,v 1.27 2001/12/19 05:19:35 ca Exp $")
1N/A#include <string.h>
1N/A#include <errno.h>
1N/A#include <sm/io.h>
1N/A#include <sm/assert.h>
1N/A#include <sm/errstring.h>
1N/A#include <sm/string.h>
1N/A#include "local.h"
1N/A#include "fvwrite.h"
1N/A
1N/A/*
1N/A** SM_IO_PUTC -- output a character to the file
1N/A**
1N/A** Function version of the macro sm_io_putc (in <sm/io.h>).
1N/A**
1N/A** Parameters:
1N/A** fp -- file to output to
1N/A** timeout -- time to complete putc
1N/A** c -- int value of character to output
1N/A**
1N/A** Returns:
1N/A** Failure: returns SM_IO_EOF _and_ sets errno
1N/A** Success: returns sm_putc() value.
1N/A**
1N/A*/
1N/A
1N/A#undef sm_io_putc
1N/A
1N/Aint
1N/Asm_io_putc(fp, timeout, c)
1N/A SM_FILE_T *fp;
1N/A int timeout;
1N/A int c;
1N/A{
1N/A SM_REQUIRE_ISA(fp, SmFileMagic);
1N/A if (cantwrite(fp))
1N/A {
1N/A errno = EBADF;
1N/A return SM_IO_EOF;
1N/A }
1N/A return sm_putc(fp, timeout, c);
1N/A}
1N/A
1N/A
1N/A/*
1N/A** SM_PERROR -- print system error messages to smioerr
1N/A**
1N/A** Parameters:
1N/A** s -- message to print
1N/A**
1N/A** Returns:
1N/A** none
1N/A*/
1N/A
1N/Avoid
1N/Asm_perror(s)
1N/A const char *s;
1N/A{
1N/A int save_errno = errno;
1N/A
1N/A if (s != NULL && *s != '\0')
1N/A (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "%s: ", s);
1N/A (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "%s\n",
1N/A sm_errstring(save_errno));
1N/A}