kill macos prior to panther
[openafs.git] / src / afs / afs_warn.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * afs_warn.c - afs_warn
12  *
13  * Implements: afs_warn, afs_warnuser
14  */
15 #include <afsconfig.h>
16 #include "afs/param.h"
17
18
19 #include "afs/stds.h"
20 #include "afs/sysincludes.h"    /* Standard vendor system headers */
21
22 #if !defined(UKERNEL)
23 #if !defined(AFS_LINUX20_ENV)
24 #include <net/if.h>
25 #include "stdarg.h"
26 #endif
27 #include <netinet/in.h>
28
29 #ifdef AFS_SGI62_ENV
30 #include "h/hashing.h"
31 #endif
32 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
33 #include <netinet/in_var.h>
34 #endif /* ! AFS_HPUX110_ENV */
35 #endif /* !defined(UKERNEL) */
36
37 #include "afsincludes.h"        /* Afs-based standard headers */
38 #include "afs/afs_stats.h"      /* afs statistics */
39
40 #if     defined(AFS_SUN56_ENV)
41 #include <inet/led.h>
42 #include <inet/common.h>
43 #if     defined(AFS_SUN58_ENV)
44 #include <netinet/ip6.h>
45 #endif
46 #include <inet/ip.h>
47 #endif
48
49 #if     defined(AFS_AIX_ENV)
50 #include <sys/fp_io.h>
51 #endif
52
53 #if defined(AFS_LINUX26_ENV)
54 # define afs_vprintf(fmt, ap) vprintk(fmt, ap)
55 #elif defined(AFS_SGI_ENV)
56 # define afs_vprintf(fmt, ap) icmn_err(CE_WARN, fmt, ap)
57 #elif (defined(AFS_DARWIN80_ENV) && !defined(AFS_DARWIN90_ENV)) || (defined(AFS_LINUX22_ENV))
58 static_inline void
59 afs_vprintf(const char *fmt, va_list ap) {
60     char buf[256];
61
62     vsnprintf(buf, sizeof(buf), fmt, ap);
63     printf(buf);
64 }
65 #else
66 # define afs_vprintf(fmt, ap) vprintf(fmt, ap)
67 #endif
68
69 #ifdef AFS_AIX_ENV
70 void
71 afs_warn(fmt, a, b, c, d, e, f, g, h, i)
72     char *fmt;
73     void *a, *b, *c, *d, *e, *f, *g, *h, *i;
74 #else
75 void
76 afs_warn(char *fmt, ...)
77 #endif
78 {
79     AFS_STATCNT(afs_warn);
80
81     if (afs_showflags & GAGCONSOLE) {
82 #if defined(AFS_AIX_ENV)
83         struct file *fd;
84
85         /* cf. console_printf() in oncplus/kernext/nfs/serv/shared.c */
86         if (fp_open
87             ("/dev/console", O_WRONLY | O_NOCTTY | O_NDELAY, 0666, 0, FP_SYS,
88              &fd) == 0) {
89             char buf[1024];
90             ssize_t len;
91             ssize_t count;
92
93             sprintf(buf, fmt, a, b, c, d, e, f, g, h, i);
94             len = strlen(buf);
95             fp_write(fd, buf, len, 0, UIO_SYSSPACE, &count);
96             fp_close(fd);
97         }
98 #else
99         va_list ap;
100
101         va_start(ap, fmt);
102         afs_vprintf(fmt, ap);
103         va_end(ap);
104 #endif
105     }
106 }
107
108 #ifdef AFS_AIX_ENV
109 void
110 afs_warnuser(fmt, a, b, c, d, e, f, g, h, i)
111     char *fmt;
112     void *a, *b, *c, *d, *e, *f, *g, *h, *i;
113 #else
114 void
115 afs_warnuser(char *fmt, ...)
116 #endif
117 {
118     AFS_STATCNT(afs_warnuser);
119     if (afs_showflags & GAGUSER) {
120 #if !defined(AFS_AIX_ENV)
121         va_list ap;
122 #endif
123 #ifdef AFS_GLOBAL_SUNLOCK
124         int haveGlock = ISAFS_GLOCK();
125         if (haveGlock)
126             AFS_GUNLOCK();
127 #endif /* AFS_GLOBAL_SUNLOCK */
128
129 #if defined(AFS_AIX_ENV)
130         uprintf(fmt, a, b, c, d, e, f, g, h, i);
131 #else
132
133         va_start(ap, fmt);
134         afs_vprintf(fmt, ap);
135         va_end(ap);
136 #endif
137
138 #ifdef AFS_GLOBAL_SUNLOCK
139         if (haveGlock)
140             AFS_GLOCK();
141 #endif /* AFS_GLOBAL_SUNLOCK */
142     }
143 }