head	1.7;
access;
symbols
	release_4_2:1.7
	aix_ok:1.6
	Version_2_1:1.5
	C_Demo_1:1.3;
locks; strict;
comment	@ * @;


1.7
date	93.10.03.01.40.49;	author aoki;	state Exp;
branches;
next	1.6;

1.6
date	93.06.24.04.02.41;	author aoki;	state Exp;
branches;
next	1.5;

1.5
date	91.02.10.18.23.49;	author cimarron;	state Exp;
branches;
next	1.4;

1.4
date	90.09.25.16.52.01;	author kemnitz;	state Exp;
branches;
next	1.3;

1.3
date	89.09.05.17.27.51;	author mao;	state C_Demo_1;
branches;
next	1.2;

1.2
date	89.02.02.18.21.21;	author aoki;	state Stab;
branches;
next	1.1;

1.1
date	89.01.17.05.58.58;	author cimarron;	state Exp;
branches;
next	;


desc
@@


1.7
log
@removed a bogus comment
changed NO_VSPRINTF to NEED_VSPRINTF
@
text
@/* ----------------------------------------------------------------
 *   FILE
 *	format.c
 *	
 *   DESCRIPTION
 *	a wrapper around code that does what vsprintf does.
 *
 *   INTERFACE ROUTINES
 *	form
 *
 *   NOTES
 *
 *   IDENTIFICATION
 *	$Header: /usr/local/devel/postgres/src/backend/utils/error/RCS/format.c,v 1.6 1993/06/24 04:02:41 aoki Exp aoki $
 * ----------------------------------------------------------------
 */

/*LINTLIBRARY*/

#include <stdio.h>
#include <varargs.h>
#include "tmp/c.h"

RcsId("$Header: /usr/local/devel/postgres/src/backend/utils/error/RCS/format.c,v 1.6 1993/06/24 04:02:41 aoki Exp aoki $");

#ifdef	_SBFSIZ
typedef unsigned char iochar;
#else
typedef char iochar;
#endif

#ifndef _IOSTRG
#define _IOSTRG	0
#endif

#ifndef	_NFILE
#define _NFILE (-1)
#endif

#define FormMaxSize	1024
#define FormMinSize	(FormMaxSize / 8)

static	char	FormBuf[FormMaxSize];
static	char	*FormBufP = FormBuf;

/* ----------------
 *	form
 * ----------------
 */
/*VARARGS1*/
char *
#ifdef lint
form(fmt, va_alist)
	char	*fmt;
#else
form(va_alist)
#endif
    va_dcl
{
    va_list	args;
    char	*format;
    char	*str;
#ifdef NEED_VSPRINTF
    FILE	fake;

#ifdef lint
    fmt = fmt;
#endif /* lint */

    if (FormBufP + FormMinSize > FormBuf + FormMaxSize)
	FormBufP = FormBuf;

    fake._cnt  = ((FormBuf + FormMaxSize) - FormBufP) - 1;
    fake._base = fake._ptr = (iochar *) FormBufP;
    fake._flag = _IOWRT | _IOSTRG;
    fake._file = _NFILE;
#endif /* NEED_VSPRINTF */
    
    va_start(args);
    format = va_arg(args, char *);

    str = FormBufP;
#ifdef NEED_VSPRINTF
    _doprnt(format, args, &fake);
#ifndef	lint
    (void) putc('\0', &fake);
#endif  /* lint */
    FormBufP += strlen(FormBufP) + 1;
#else /* !NEED_VSPRINTF */
    (void) vsprintf(FormBuf, format, args);
#endif /* !NEED_VSPRINTF */
    va_end(args);
    
    return (str);
}
@


1.6
log
@changed to use vsprintf() unless you explicitly ask for
the old hacky unportable cruft using _doprnt
@
text
@a11 3
 *	If this file is changed, make sure to change
 *	lib/libpq/fe-pqstubs.c file too.  That is the copy
 *	that gets compiled into libpq.a
d14 1
a14 1
 *	$Header: /usr/local/dev/postgres/newtree/src/backend/utils/error/RCS/format.c,v 1.5 1991/02/10 18:23:49 cimarron Exp $
d24 1
a24 1
RcsId("$Header: /usr/local/dev/postgres/newtree/src/backend/utils/error/RCS/format.c,v 1.5 1991/02/10 18:23:49 cimarron Exp $");
d63 1
a63 1
#ifdef NO_VSPRINTF
d66 1
a66 1
#ifdef	lint
d68 1
a68 1
#endif  /* lint */
d77 1
a77 1
#endif /* NO_VSPRINTF */
d83 1
a83 1
#ifdef NO_VSPRINTF
d89 1
a89 1
#else /* NO_VSPRINTF */
d91 1
a91 1
#endif /* NO_VSPRINTF */
@


1.5
log
@reorganization of libpq routines to provide
 PQexec and PQfn functionality from both the front
 end applications and the postgres backend.
@
text
@d6 1
d17 1
a17 1
 *	$Header$
d27 1
a27 1
RcsId("$Header$");
d66 1
a68 5
#if !sprite
    /* ----------------
     *	non-sprite hacks
     * ----------------
     */
d77 1
a77 1
    fake._base = fake._ptr = (iochar *)FormBufP;
d80 1
a80 1
#endif /* sprite */
d85 2
a86 5
#if !sprite
    /* ----------------
     *	when not in sprite use _doprnt.
     * ----------------
     */
a87 2
    va_end(args);

a90 2

    str = FormBufP;
d92 3
a94 7
    
#else /* sprite */
    /* ----------------
     *	when in sprite, use vsprintf.
     * ----------------
     */
    str = vsprintf(FormBuf, format, args);
a95 1
#endif /* sprite */
@


1.4
log
@Updating from revision 1.3 to revision 1.4
@
text
@d1 19
d22 1
a22 9
#ifndef lint
#ifdef	SCCS
static char sccsid[] = "%W% (serge) %G%";
#endif	/* defined(SCCS) */
#ifdef	RCS
static char rcsid[] = "$Header: RCS/format.c,v 1.4 90/08/22 15:28:45 choi Exp $";
#endif	/* defined(RCS) */
#endif	/* !defined(lint) */

d24 1
a24 1
#include <stdio.h>
d26 2
d48 4
d54 1
a54 1
#ifdef	lint
d60 1
a60 1
	va_dcl
d62 4
a65 4
	va_list	args;
	char	*format;
	char	*str;
	FILE	fake;
d68 4
d73 2
a74 2
	fmt = fmt;
#endif /* lint */
d76 2
a77 2
	if (FormBufP + FormMinSize > FormBuf + FormMaxSize)
		FormBufP = FormBuf;
d79 4
a82 4
	fake._cnt  = ((FormBuf + FormMaxSize) - FormBufP) - 1;
	fake._base = fake._ptr = (iochar *)FormBufP;
	fake._flag = _IOWRT | _IOSTRG;
	fake._file = _NFILE;
d84 3
a86 1
	va_start(args);
a87 1
	format = va_arg(args, char *);
d89 6
a94 1
	_doprnt(format, args, &fake);
a95 2
	va_end(args);

d97 1
a97 1
	(void) putc('\0', &fake);
d100 13
a112 8
	str = FormBufP;

	FormBufP += strlen(FormBufP) + 1;
#else   /* sprite */
        str = vsprintf(FormBuf, format, args);
        va_end(args);
#endif  /* sprite */
	return (str);
@


1.3
log
@Working version of C-only demo
@
text
@d8 1
a8 1
static char rcsid[] = "$Header: /usr6/postgres/mao/postgres/src/utils/error/RCS/format.c,v 1.2 89/02/02 18:21:21 aoki Stab $";
d50 1
d53 1
a53 1
#endif
d62 1
a62 1

d66 1
a66 1

d73 1
a73 1
#endif
d78 4
a81 1

@


1.2
log
@MERGE WITH OLD TREE
@
text
@d8 1
a8 1
static char rcsid[] = "$Header: format.c,v 1.1 87/06/16 14:01:06 aoki Locked $";
@


1.1
log
@Initial revision
@
text
@a0 27

/*
 * 
 * POSTGRES Data Base Management System
 * 
 * Copyright (c) 1988 Regents of the University of California
 * 
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for educational, research, and non-profit purposes and
 * without fee is hereby granted, provided that the above copyright
 * notice appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation, and that
 * the name of the University of California not be used in advertising
 * or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Permission to incorporate this
 * software into commercial products can be obtained from the Campus
 * Software Office, 295 Evans Hall, University of California, Berkeley,
 * Ca., 94720 provided only that the the requestor give the University
 * of California a free licence to any derived software for educational
 * and research purposes.  The University of California makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 * 
 */



d8 1
a8 1
static char rcsid[] = "$Header: format.c,v 1.1 88/11/11 16:42:15 postgres Exp $";
@
