1 /* @(#)error.c 1.18 15/08/01 Copyright 1985, 1989, 1995-2015 J. Schilling */ 2 /* 3 * fprintf() on standard error stdio stream 4 * 5 * Copyright (c) 1985, 1989, 1995-2015 J. Schilling 6 */ 7 /* 8 * The contents of this file are subject to the terms of the 9 * Common Development and Distribution License, Version 1.0 only 10 * (the "License"). You may not use this file except in compliance 11 * with the License. 12 * 13 * See the file CDDL.Schily.txt in this distribution for details. 14 * A copy of the CDDL is also available via the Internet at 15 * http://www.opensource.org/licenses/cddl1.txt 16 * 17 * When distributing Covered Code, include this CDDL HEADER in each 18 * file and include the License file CDDL.Schily.txt from this distribution. 19 */ 20 21 #include <schily/mconfig.h> 22 #include <schily/stdio.h> 23 #include <schily/standard.h> 24 #include <schily/varargs.h> 25 #include <schily/schily.h> 26 27 #undef error 28 29 #ifndef NO_WEAK_SYMBOLS 30 /* 31 * The Cygwin compile environment incorrectly implements #pragma weak. 32 * The weak symbols are only defined as local symbols making it impossible 33 * to use them from outside the scope of this source file. 34 * A platform that allows linking with global symbols has HAVE_LINK_WEAK 35 * defined. 36 */ 37 #if defined(HAVE_PRAGMA_WEAK) && defined(HAVE_LINK_WEAK) 38 #pragma weak error = js_error 39 #else 40 /* VARARGS1 */ 41 #ifdef PROTOTYPES 42 EXPORT int 43 error(const char *fmt, ...) 44 #else 45 EXPORT int 46 error(fmt, va_alist) 47 char *fmt; 48 va_dcl 49 #endif 50 { 51 va_list args; 52 int ret; 53 54 #ifdef PROTOTYPES 55 va_start(args, fmt); 56 #else 57 va_start(args); 58 #endif 59 ret = js_fprintf(stderr, "%r", fmt, args); 60 va_end(args); 61 return (ret); 62 } 63 #endif 64 #endif /* NO_WEAK_SYMBOLS */ 65 66 /* VARARGS1 */ 67 #ifdef PROTOTYPES 68 EXPORT int 69 js_error(const char *fmt, ...) 70 #else 71 EXPORT int 72 js_error(fmt, va_alist) 73 char *fmt; 74 va_dcl 75 #endif 76 { 77 va_list args; 78 int ret; 79 80 #ifdef PROTOTYPES 81 va_start(args, fmt); 82 #else 83 va_start(args); 84 #endif 85 ret = js_fprintf(stderr, "%r", fmt, args); 86 va_end(args); 87 return (ret); 88 } 89