~ubuntu-branches/ubuntu/trusty/kstart/trusty-proposed

« back to all changes in this revision

Viewing changes to portable/system.h

  • Committer: Bazaar Package Importer
  • Author(s): Russ Allbery
  • Date: 2008-04-23 14:25:55 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080423142555-5vrmy64hjq4w54wh
Tags: 3.12-1
* New upstream release.
  - krenew now copies the ticket cache when running a command.
  - Fix command-line parsing problems in k4start and k5start.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: system.h 4067 2008-04-09 22:23:08Z rra $
 
2
 *
 
3
 * Declarations of routines and variables in the C library.  Including this
 
4
 * file is the equivalent of including all of the following headers, portably:
 
5
 *
 
6
 *     #include <sys/types.h>
 
7
 *     #include <stdarg.h>
 
8
 *     #include <stdbool.h>
 
9
 *     #include <stdio.h>
 
10
 *     #include <stdlib.h>
 
11
 *     #include <stddef.h>
 
12
 *     #include <stdint.h>
 
13
 *     #include <string.h>
 
14
 *     #include <unistd.h>
 
15
 *
 
16
 * Missing functions are provided via #define or prototyped if available.
 
17
 * Also provides some standard #defines.
 
18
 *
 
19
 * Written by Russ Allbery <rra@stanford.edu>
 
20
 * This work is hereby placed in the public domain by its author.
 
21
 */
 
22
 
 
23
#ifndef PORTABLE_SYSTEM_H
 
24
#define PORTABLE_SYSTEM_H 1
 
25
 
 
26
/* Make sure we have our configuration information. */
 
27
#include <config.h>
 
28
 
 
29
/* BEGIN_DECL and __attribute__. */
 
30
#include <portable/macros.h>
 
31
 
 
32
/* A set of standard ANSI C headers.  We don't care about pre-ANSI systems. */
 
33
#include <stdarg.h>
 
34
#include <stddef.h>
 
35
#include <stdio.h>
 
36
#include <stdlib.h>
 
37
#include <sys/types.h>
 
38
#include <string.h>
 
39
#if HAVE_INTTYPES_H
 
40
# include <inttypes.h>
 
41
#endif
 
42
#if HAVE_STDINT_H
 
43
# include <stdint.h>
 
44
#endif
 
45
#if HAVE_UNISTD_H
 
46
# include <unistd.h>
 
47
#endif
 
48
 
 
49
/* SCO OpenServer gets int32_t from here. */
 
50
#if HAVE_SYS_BITYPES_H
 
51
# include <sys/bitypes.h>
 
52
#endif
 
53
 
 
54
/* Get the bool type. */
 
55
#include <portable/stdbool.h>
 
56
 
 
57
BEGIN_DECLS
 
58
 
 
59
/*
 
60
 * Provide prototypes for functions not declared in system headers.  Use the
 
61
 * HAVE_DECL macros for those functions that may be prototyped but
 
62
 * implemented incorrectly or implemented without a prototype.
 
63
 */
 
64
#if !HAVE_ASPRINTF
 
65
extern int asprintf(char **, const char *, ...);
 
66
extern int vasprintf(char **, const char *, va_list);
 
67
#endif
 
68
#if !HAVE_DAEMON
 
69
extern int daemon(int, int);
 
70
#endif
 
71
#if !HAVE_MKSTEMP
 
72
extern int mkstemp(char *);
 
73
#endif
 
74
#if !HAVE_DECL_SNPRINTF
 
75
extern int snprintf(char *, size_t, const char *, ...)
 
76
    __attribute__((__format__(printf, 3, 4)));
 
77
#endif
 
78
#if !HAVE_DECL_VSNPRINTF
 
79
extern int vsnprintf(char *, size_t, const char *, va_list);
 
80
#endif
 
81
 
 
82
END_DECLS
 
83
 
 
84
/* Windows provides snprintf under a different name. */
 
85
#ifdef _WIN32
 
86
# define snprintf _snprintf
 
87
#endif
 
88
 
 
89
/*
 
90
 * POSIX requires that these be defined in <unistd.h>.  If one of them has
 
91
 * been defined, all the rest almost certainly have.
 
92
 */
 
93
#ifndef STDIN_FILENO
 
94
# define STDIN_FILENO   0
 
95
# define STDOUT_FILENO  1
 
96
# define STDERR_FILENO  2
 
97
#endif
 
98
 
 
99
/*
 
100
 * C99 requires va_copy.  Older versions of GCC provide __va_copy.  Per the
 
101
 * Autoconf manual, memcpy is a generally portable fallback.
 
102
 */
 
103
#ifndef va_copy
 
104
# ifdef __va_copy
 
105
#  define va_copy(d, s)         __va_copy((d), (s))
 
106
# else
 
107
#  define va_copy(d, s)         memcpy(&(d), &(s), sizeof(va_list))
 
108
# endif
 
109
#endif
 
110
 
 
111
#endif /* !PORTABLE_SYSTEM_H */