ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libukcprog/src/strf.c
Revision: 1.1
Committed: Sat Mar 29 16:30:33 2003 UTC (21 years, 7 months ago) by tdb
Content type: text/plain
Branch: MAIN
CVS Tags: LIBUKCPROG_1_0_2, LIBUKCPROG_1_0_1, LIBUKCPROG_1_0, HEAD
Log Message:
libukcprog is now a seperate package. I doubt this will be much use to
anyone other than us, but I see no reason why we can't package it up
and distribute it. Obviously we can't attach the GPL to this, as we
don't own it.

File Contents

# Content
1 /* strf.c -- formatted strings, storage allocated from malloc */
2
3 /* Copyright 1992 Godfrey Paul, University of Kent at Canterbury.
4 *
5 * You can do what you like with this source code as long as
6 * you don't try to make money out of it and you include an
7 * unaltered copy of this message (including the copyright).
8 */
9
10 char ukcprog_strf_sccsid[] = "$Id: strf.c,v 1.7 1993/05/30 18:15:16 gjap Exp $ UKC";
11
12 #ifdef __STDC__
13 #include <stdarg.h>
14 #else
15 #include <varargs.h>
16 #endif
17
18 #include <stdio.h>
19 #include <stdlib.h>
20
21 #include "ukcprog.h"
22
23
24 #ifdef __STDC__
25 char *
26 strf(const char *fmt, ...)
27 {
28
29 #else /* !__STDC__ */
30 char *
31 strf(va_alist)
32 va_dcl
33 {
34 char *fmt;
35 #endif /* !__STDC__ */
36 va_list args;
37 char buffer[100];
38 char *s;
39
40 #ifdef __STDC__
41 va_start(args, fmt);
42 #else
43 va_start(args);
44 fmt = va_arg(args, char *);
45 #endif
46
47 s = formf(buffer, sizeof(buffer), fmt, args);
48
49 va_end(args);
50
51 if (s == buffer) /* not obtained from malloc */
52 s = strsave(s);
53
54 return s;
55 }