1da2e3ebdSchin /***********************************************************************
2da2e3ebdSchin * *
3da2e3ebdSchin * This software is part of the ast package *
4*3e14f97fSRoger A. Faulkner * Copyright (c) 1985-2010 AT&T Intellectual Property *
5da2e3ebdSchin * and is licensed under the *
6da2e3ebdSchin * Common Public License, Version 1.0 *
77c2fbfb3SApril Chin * by AT&T Intellectual Property *
8da2e3ebdSchin * *
9da2e3ebdSchin * A copy of the License is available at *
10da2e3ebdSchin * http://www.opensource.org/licenses/cpl1.0.txt *
11da2e3ebdSchin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12da2e3ebdSchin * *
13da2e3ebdSchin * Information and Software Systems Research *
14da2e3ebdSchin * AT&T Research *
15da2e3ebdSchin * Florham Park NJ *
16da2e3ebdSchin * *
17da2e3ebdSchin * Glenn Fowler <gsf@research.att.com> *
18da2e3ebdSchin * David Korn <dgk@research.att.com> *
19da2e3ebdSchin * Phong Vo <kpv@research.att.com> *
20da2e3ebdSchin * *
21da2e3ebdSchin ***********************************************************************/
22da2e3ebdSchin #include "FEATURE/uwin"
23da2e3ebdSchin
24da2e3ebdSchin #if !_UWIN
25da2e3ebdSchin
_STUB_err()26da2e3ebdSchin void _STUB_err(){}
27da2e3ebdSchin
28da2e3ebdSchin #else
29da2e3ebdSchin
30da2e3ebdSchin #pragma prototyped
31da2e3ebdSchin
32da2e3ebdSchin /*
33da2e3ebdSchin * bsd 4.4 compatibility
34da2e3ebdSchin *
35da2e3ebdSchin * NOTE: errorv(ERROR_NOID) => the first arg is the printf format
36da2e3ebdSchin */
37da2e3ebdSchin
38da2e3ebdSchin #include <ast.h>
39da2e3ebdSchin #include <error.h>
40da2e3ebdSchin
41da2e3ebdSchin #include <windows.h>
42da2e3ebdSchin
43da2e3ebdSchin #ifdef __EXPORT__
44da2e3ebdSchin #define extern __EXPORT__
45da2e3ebdSchin #endif
46da2e3ebdSchin
47da2e3ebdSchin static void
errmsg(int level,int code,const char * fmt,va_list ap)48da2e3ebdSchin errmsg(int level, int code, const char* fmt, va_list ap)
49da2e3ebdSchin {
50da2e3ebdSchin if (!error_info.id)
51da2e3ebdSchin {
52da2e3ebdSchin struct _astdll* dp = _ast_getdll();
53da2e3ebdSchin char* s;
54da2e3ebdSchin char* t;
55da2e3ebdSchin
56da2e3ebdSchin if (s = dp->_ast__argv[0])
57da2e3ebdSchin {
58da2e3ebdSchin if (t = strrchr(s, '/'))
59da2e3ebdSchin s = t + 1;
60da2e3ebdSchin error_info.id = s;
61da2e3ebdSchin }
62da2e3ebdSchin }
63da2e3ebdSchin errorv(fmt, level|ERROR_NOID, ap);
64da2e3ebdSchin if ((level & ERROR_LEVEL) >= ERROR_ERROR)
65da2e3ebdSchin exit(code);
66da2e3ebdSchin }
67da2e3ebdSchin
verr(int code,const char * fmt,va_list ap)68da2e3ebdSchin extern void verr(int code, const char* fmt, va_list ap)
69da2e3ebdSchin {
70da2e3ebdSchin errmsg(ERROR_ERROR|ERROR_SYSTEM, code, fmt, ap);
71da2e3ebdSchin }
72da2e3ebdSchin
err(int code,const char * fmt,...)73da2e3ebdSchin extern void err(int code, const char* fmt, ...)
74da2e3ebdSchin {
75da2e3ebdSchin va_list ap;
76da2e3ebdSchin
77da2e3ebdSchin va_start(ap, fmt);
78da2e3ebdSchin errmsg(ERROR_ERROR|ERROR_SYSTEM, code, fmt, ap);
79da2e3ebdSchin va_end(ap);
80da2e3ebdSchin }
81da2e3ebdSchin
verrx(int code,const char * fmt,va_list ap)82da2e3ebdSchin extern void verrx(int code, const char* fmt, va_list ap)
83da2e3ebdSchin {
84da2e3ebdSchin errmsg(ERROR_ERROR, code, fmt, ap);
85da2e3ebdSchin }
86da2e3ebdSchin
errx(int code,const char * fmt,...)87da2e3ebdSchin extern void errx(int code, const char* fmt, ...)
88da2e3ebdSchin {
89da2e3ebdSchin va_list ap;
90da2e3ebdSchin
91da2e3ebdSchin va_start(ap, fmt);
92da2e3ebdSchin errmsg(ERROR_ERROR, code, fmt, ap);
93da2e3ebdSchin va_end(ap);
94da2e3ebdSchin }
95da2e3ebdSchin
vwarn(const char * fmt,va_list ap)96da2e3ebdSchin extern void vwarn(const char* fmt, va_list ap)
97da2e3ebdSchin {
98da2e3ebdSchin errmsg(ERROR_WARNING|ERROR_SYSTEM, 0, fmt, ap);
99da2e3ebdSchin }
100da2e3ebdSchin
warn(const char * fmt,...)101da2e3ebdSchin extern void warn(const char* fmt, ...)
102da2e3ebdSchin {
103da2e3ebdSchin va_list ap;
104da2e3ebdSchin
105da2e3ebdSchin va_start(ap, fmt);
106da2e3ebdSchin errmsg(ERROR_WARNING|ERROR_SYSTEM, 0, fmt, ap);
107da2e3ebdSchin va_end(ap);
108da2e3ebdSchin }
109da2e3ebdSchin
vwarnx(const char * fmt,va_list ap)110da2e3ebdSchin extern void vwarnx(const char* fmt, va_list ap)
111da2e3ebdSchin {
112da2e3ebdSchin errmsg(ERROR_WARNING, 0, fmt, ap);
113da2e3ebdSchin }
114da2e3ebdSchin
warnx(const char * fmt,...)115da2e3ebdSchin extern void warnx(const char* fmt, ...)
116da2e3ebdSchin {
117da2e3ebdSchin va_list ap;
118da2e3ebdSchin
119da2e3ebdSchin va_start(ap, fmt);
120da2e3ebdSchin errmsg(ERROR_WARNING, 0, fmt, ap);
121da2e3ebdSchin va_end(ap);
122da2e3ebdSchin }
123da2e3ebdSchin
124da2e3ebdSchin #endif
125