Skip to content

Commit

Permalink
introduction of os-specific.c and os-specific.h
Browse files Browse the repository at this point in the history
  • Loading branch information
yangtse committed Jun 5, 2009
1 parent 2e7b36d commit f1261bc
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 27 deletions.
11 changes: 8 additions & 3 deletions src/Makefile.Watcom
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -78,15 +79,16 @@ $(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 &
..\include\curl\curlbuild.h ..\include\curl\curlrules.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

Expand All @@ -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 &
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/Makefile.riscos
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/Makefile.vc6
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ RELEASE_OBJS= \
getpassr.obj \
homedirr.obj \
curlutilr.obj \
os-specificr.obj \
rawstrr.obj \
strtoofftr.obj \
mainr.obj \
Expand All @@ -110,6 +111,7 @@ DEBUG_OBJS= \
getpassd.obj \
homedird.obj \
curlutild.obj \
os-specificd.obj \
rawstrd.obj \
strtoofftd.obj \
maind.obj \
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
46 changes: 26 additions & 20 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
#include <netinet/tcp.h> /* 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
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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" \
Expand All @@ -5021,12 +5028,12 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
"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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/makefile.amiga
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
112 changes: 112 additions & 0 deletions src/os-specific.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, 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 <curl/curl.h>

#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 */

41 changes: 41 additions & 0 deletions src/os-specific.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef HEADER_CURL_OS_SPECIFIC_H
#define HEADER_CURL_OS_SPECIFIC_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, 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 */
3 changes: 2 additions & 1 deletion src/urlglob.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -34,6 +34,7 @@
#include <curl/mprintf.h>

#include "urlglob.h"
#include "os-specific.h"

#if defined(CURLDEBUG) && defined(CURLTOOLDEBUG)
#include "memdebug.h"
Expand Down
Loading

0 comments on commit f1261bc

Please sign in to comment.