diff --git a/src/Makefile.Watcom b/src/Makefile.Watcom index c5b80bfe8..a8c66aff2 100644 --- a/src/Makefile.Watcom +++ b/src/Makefile.Watcom @@ -14,7 +14,8 @@ OBJ_DIR = WC_Win32.obj OBJS = $(OBJ_DIR)\getpass.obj $(OBJ_DIR)\homedir.obj $(OBJ_DIR)\hugehelp.obj & $(OBJ_DIR)\main.obj $(OBJ_DIR)\urlglob.obj $(OBJ_DIR)\writeenv.obj & - $(OBJ_DIR)\writeout.obj $(OBJ_DIR)\curlutil.obj $(OBJ_DIR)\rawstr.obj + $(OBJ_DIR)\writeout.obj $(OBJ_DIR)\curlutil.obj $(OBJ_DIR)\rawstr.obj & + $(OBJ_DIR)\os-specific.obj RESOURCE = $(OBJ_DIR)\curl.res @@ -78,7 +79,8 @@ $(OBJ_DIR)\main.obj: main.c setup.h config-win32.h ..\lib\setup_once.h & version.h ..\include\curl\curlver.h ..\lib\curlx.h & ..\include\curl\mprintf.h ..\lib\strequal.h ..\lib\strtoofft.h & ..\lib\setup.h ..\lib\config-win32.h ..\include\curl\curlbuild.h & - ..\include\curl\curlrules.h ..\lib\timeval.h ..\lib\memdebug.h + ..\include\curl\curlrules.h ..\lib\timeval.h ..\lib\memdebug.h & + os-specific.h $(OBJ_DIR)\urlglob.obj: urlglob.c setup.h config-win32.h ..\lib\setup_once.h & ..\include\curl\curl.h ..\include\curl\curlver.h & @@ -86,7 +88,7 @@ $(OBJ_DIR)\urlglob.obj: urlglob.c setup.h config-win32.h ..\lib\setup_once.h & ..\include\curl\easy.h ..\include\curl\multi.h ..\include\curl\curl.h & ..\include\curl\mprintf.h urlglob.h ..\lib\memdebug.h ..\lib\setup.h & ..\lib\config-win32.h ..\include\curl\curlbuild.h & - ..\include\curl\curlrules.h + ..\include\curl\curlrules.h os-specific.h $(OBJ_DIR)\writeenv.obj: writeenv.c setup.h config-win32.h ..\lib\setup_once.h @@ -99,6 +101,9 @@ $(OBJ_DIR)\writeout.obj: writeout.c setup.h config-win32.h ..\lib\setup_once.h & $(OBJ_DIR)\curlutil.obj: curlutil.c setup.h config-win32.h ..\lib\setup_once.h & curlutil.h +$(OBJ_DIR)\os-specific.obj: os-specific.c os-specific.h setup.h config-win32.h & + ..\lib\setup_once.h + $(OBJ_DIR)\rawstr.obj: ..\lib\rawstr.c ..\lib\setup.h ..\lib\config-win32.h & ..\include\curl\curlbuild.h ..\include\curl\curlrules.h ..\lib\setup_once.h & ..\include\curl\curl.h ..\include\curl\curlver.h ..\include\curl\curlrules.h & diff --git a/src/Makefile.inc b/src/Makefile.inc index 8c0a1f1f7..e0c132137 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -7,10 +7,10 @@ CURLX_ONES = $(top_srcdir)/lib/strtoofft.c \ $(top_srcdir)/lib/rawstr.c CURL_SOURCES = main.c hugehelp.c urlglob.c writeout.c writeenv.c \ - getpass.c homedir.c curlutil.c + getpass.c homedir.c curlutil.c os-specific.c CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \ - config-riscos.h urlglob.h version.h \ + config-riscos.h urlglob.h version.h os-specific.h \ writeout.h writeenv.h getpass.h homedir.h curlutil.h curl_SOURCES = $(CURL_SOURCES) $(CURLX_ONES) $(CURL_HFILES) diff --git a/src/Makefile.riscos b/src/Makefile.riscos index 5dc775cbc..ad7dc6de5 100644 --- a/src/Makefile.riscos +++ b/src/Makefile.riscos @@ -22,6 +22,9 @@ o.hugehelp: c.hugehelp o.main: c.main gcc $(compileropts) -c -o main.o c.main +o.os-specific: c.os-specific + gcc $(compileropts) -c -o os-specific.o c.os-specific + o.urlglob: c.urlglob gcc $(compileropts) -c -o urlglob.o c.urlglob @@ -39,12 +42,18 @@ o.hugehelp: c.hugehelp o.main: c.main o.main: h.setup +o.main: h.os-specific o.main: h.urlglob o.main: h.writeout o.main: h.version +o.os-specific: c.os-specific +o.os-specific: h.setup +o.os-specific: h.os-specific + o.urlglob: c.urlglob o.urlglob: h.setup +o.urlglob: h.os-specific o.urlglob: h.urlglob o.writeout: c.writeout diff --git a/src/Makefile.vc6 b/src/Makefile.vc6 index e85ca2f7f..e6236aa45 100644 --- a/src/Makefile.vc6 +++ b/src/Makefile.vc6 @@ -98,6 +98,7 @@ RELEASE_OBJS= \ getpassr.obj \ homedirr.obj \ curlutilr.obj \ + os-specificr.obj \ rawstrr.obj \ strtoofftr.obj \ mainr.obj \ @@ -110,6 +111,7 @@ DEBUG_OBJS= \ getpassd.obj \ homedird.obj \ curlutild.obj \ + os-specificd.obj \ rawstrd.obj \ strtoofftd.obj \ maind.obj \ @@ -247,6 +249,8 @@ homedirr.obj: homedir.c $(CCR) $(CFLAGS) /Fo"$@" homedir.c curlutilr.obj: curlutil.c $(CCR) $(CFLAGS) /Fo"$@" curlutil.c +os-specificr.obj: os-specific.c + $(CCR) $(CFLAGS) /Fo"$@" os-specific.c rawstrr.obj: ../lib/rawstr.c $(CCR) $(CFLAGS) /Fo"$@" ../lib/rawstr.c strtoofftr.obj: ../lib/strtoofft.c @@ -269,6 +273,8 @@ homedird.obj: homedir.c $(CCD) $(CFLAGS) /Fo"$@" homedir.c curlutild.obj: curlutil.c $(CCD) $(CFLAGS) /Fo"$@" curlutil.c +os-specificd.obj: os-specific.c + $(CCD) $(CFLAGS) /Fo"$@" os-specific.c rawstrd.obj: ../lib/rawstr.c $(CCD) $(CFLAGS) /Fo"$@" ../lib/rawstr.c strtoofftd.obj: ../lib/strtoofft.c diff --git a/src/main.c b/src/main.c index 77de03b17..586d00e2a 100644 --- a/src/main.c +++ b/src/main.c @@ -114,6 +114,12 @@ #include /* for TCP_KEEPIDLE, TCP_KEEPINTVL */ #endif +#ifdef __VMS +# include "curlmsg_vms.h" +#endif + +#include "os-specific.h" + /* The last #include file should be: */ #ifdef CURLDEBUG #ifndef CURLTOOLDEBUG @@ -200,10 +206,6 @@ typedef enum { #define mkdir(x,y) (mkdir)(x) #endif -#ifdef VMS -#include "curlmsg_vms.h" -#endif - /* * Large file support (>2Gb) using WIN32 functions. */ @@ -4996,16 +4998,21 @@ operate(struct Configurable *config, int argc, argv_item_t argv[]) show_error: -#ifdef VMS - if (!config->showerror) { - vms_show = VMSSTS_HIDE; +#ifdef __VMS + if(is_vms_shell()) { + /* VMS DCL shell behavior */ + if(!config->showerror) { + vms_show = VMSSTS_HIDE; + } } -#else - if((res!=CURLE_OK) && config->showerror) { - fprintf(config->errors, "curl: (%d) %s\n", res, - errorbuffer[0]? errorbuffer: - curl_easy_strerror((CURLcode)res)); - if(CURLE_SSL_CACERT == res) { + else +#endif + { + if((res!=CURLE_OK) && config->showerror) { + fprintf(config->errors, "curl: (%d) %s\n", res, + errorbuffer[0]? errorbuffer: + curl_easy_strerror((CURLcode)res)); + if(CURLE_SSL_CACERT == res) { #define CURL_CA_CERT_ERRORMSG1 \ "More details here: http://curl.haxx.se/docs/sslcerts.html\n\n" \ "curl performs SSL certificate verification by default, using a \"bundle\"\n" \ @@ -5021,12 +5028,12 @@ show_error: "If you'd like to turn off curl's verification of the certificate, use\n" \ " the -k (or --insecure) option.\n" - fprintf(config->errors, "%s%s", - CURL_CA_CERT_ERRORMSG1, - CURL_CA_CERT_ERRORMSG2 ); + fprintf(config->errors, "%s%s", + CURL_CA_CERT_ERRORMSG1, + CURL_CA_CERT_ERRORMSG2 ); + } } } -#endif if (outfile && !curlx_strequal(outfile, "-") && outs.stream) fclose(outs.stream); @@ -5182,9 +5189,8 @@ int main(int argc, char *argv[]) #ifdef __NOVELL_LIBC__ pressanykey(); #endif -#ifdef VMS - if (res > CURL_LAST) res = CURL_LAST; /* If CURL_LAST exceeded then */ - return (vms_cond[res]|vms_show); /* curlmsg.h is out of sync. */ +#ifdef __VMS + vms_special_exit(res, vms_show); #else return res; #endif diff --git a/src/makefile.amiga b/src/makefile.amiga index 2608744e0..c2371a6cc 100644 --- a/src/makefile.amiga +++ b/src/makefile.amiga @@ -14,7 +14,7 @@ MANPAGE = ../docs/curl.1 README = ../docs/MANUAL MKHELP = ../src/mkhelp.pl -OBJS = getpass.c hugehelp.c main.c urlglob.c writeenv.c writeout.c curlutil.c ../lib/rawstr.c +OBJS = getpass.c hugehelp.c main.c urlglob.c writeenv.c writeout.c curlutil.c os-specific.c ../lib/rawstr.c all: hugehelp.c $(OBJS:.c=.o) diff --git a/src/os-specific.c b/src/os-specific.c new file mode 100644 index 000000000..457368d8d --- /dev/null +++ b/src/os-specific.c @@ -0,0 +1,112 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + ***************************************************************************/ +#include "setup.h" + +#include + +#ifdef __VMS +# include "curlmsg_vms.h" +#endif + +#define ENABLE_CURLX_PRINTF +#include "curlx.h" + +#include "os-specific.h" + +#if defined(CURLDEBUG) && defined(CURLTOOLDEBUG) +# include "memdebug.h" +#endif + +#ifdef __VMS + +int vms_shell = -1; + +/* VMS has a DCL shell and and also has Unix shells ported to it. + * When curl is running under a Unix shell, we want it to be as much + * like Unix as possible. + */ +int is_vms_shell(void) +{ + char *shell; + + /* Have we checked the shell yet? */ + if(vms_shell >= 0) + return vms_shell; + + shell = getenv("SHELL"); + + /* No shell, means DCL */ + if(shell == NULL) { + vms_shell = 1; + return 1; + } + + /* Have to make sure some one did not set shell to DCL */ + if(strcmp(shell, "DCL") == 0) { + vms_shell = 1; + return 1; + } + + vms_shell = 0; + return 0; +} + +/* + * VMS has two exit() routines. When running under a Unix style shell, then + * Unix style and the __posix_exit() routine is used. + * + * When running under the DCL shell, then the VMS encoded codes and decc$exit() + * is used. + * + * We can not use exit() or return a code from main() because the actual + * routine called depends on both the compiler version, compile options, and + * feature macro settings, and one of the exit routines is hidden at compile + * time. + * + * Since we want Curl to work properly under the VMS DCL shell and Unix + * shells under VMS, this routine should compile correctly regardless of + * the settings. + */ + +void vms_special_exit(int code, int vms_show) +{ + int vms_code; + + /* The Posix exit mode is only available after VMS 7.0 */ +#if __CRTL_VER >= 70000000 + if(is_vms_shell() == 0) { + decc$__posix_exit(code); + } +#endif + + if(code > CURL_LAST) { /* If CURL_LAST exceeded then */ + vms_code = CURL_LAST; /* curlmsg.h is out of sync. */ + } + else { + vms_code = vms_cond[code] | vms_show; + } + decc$exit(vms_code); +} + +#endif /* __VMS */ + diff --git a/src/os-specific.h b/src/os-specific.h new file mode 100644 index 000000000..96f91cb76 --- /dev/null +++ b/src/os-specific.h @@ -0,0 +1,41 @@ +#ifndef HEADER_CURL_OS_SPECIFIC_H +#define HEADER_CURL_OS_SPECIFIC_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + ***************************************************************************/ + +#ifdef __VMS + +extern int vms_shell; + +void decc$__posix_exit(int __status); +void decc$exit(int __status); + +int is_vms_shell(void); +void vms_special_exit(int code, int vms_show); + +#undef exit +#define exit(__code) vms_special_exit((__code), (0)) + +#endif /* __VMS */ + +#endif /* HEADER_CURL_OS_SPECIFIC_H */ diff --git a/src/urlglob.c b/src/urlglob.c index 5f9a3e5e6..afbb66ca5 100644 --- a/src/urlglob.c +++ b/src/urlglob.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -34,6 +34,7 @@ #include #include "urlglob.h" +#include "os-specific.h" #if defined(CURLDEBUG) && defined(CURLTOOLDEBUG) #include "memdebug.h" diff --git a/src/vc6curlsrc.dsp b/src/vc6curlsrc.dsp index cba6924e2..e888451dd 100644 --- a/src/vc6curlsrc.dsp +++ b/src/vc6curlsrc.dsp @@ -159,6 +159,10 @@ SOURCE=.\main.c # End Source File # Begin Source File +SOURCE=.\os-specific.c +# End Source File +# Begin Source File + SOURCE=..\lib\rawstr.c # End Source File # Begin Source File @@ -203,6 +207,10 @@ SOURCE=.\hugehelp.h # End Source File # Begin Source File +SOURCE=.\os-specific.h +# End Source File +# Begin Source File + SOURCE=.\setup.h # End Source File # Begin Source File