Git init
[external/curl.git] / lib / amigaos.c
1 /***************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at http://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  ***************************************************************************/
22
23 #ifdef __AMIGA__ /* Any AmigaOS flavour */
24
25 #include "amigaos.h"
26 #include <amitcp/socketbasetags.h>
27
28 struct Library *SocketBase = NULL;
29 extern int errno, h_errno;
30
31 #ifdef __libnix__
32 #include <stabs.h>
33 void __request(const char *msg);
34 #else
35 # define __request( msg )       Printf( msg "\n\a")
36 #endif
37
38 void amiga_cleanup()
39 {
40   if(SocketBase) {
41     CloseLibrary(SocketBase);
42     SocketBase = NULL;
43   }
44 }
45
46 BOOL amiga_init()
47 {
48   if(!SocketBase)
49     SocketBase = OpenLibrary("bsdsocket.library", 4);
50
51   if(!SocketBase) {
52     __request("No TCP/IP Stack running!");
53     return FALSE;
54   }
55
56   if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG) &errno,
57                     SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG) "cURL",
58                     TAG_DONE)) {
59     __request("SocketBaseTags ERROR");
60     return FALSE;
61   }
62
63 #ifndef __libnix__
64   atexit(amiga_cleanup);
65 #endif
66
67   return TRUE;
68 }
69
70 #ifdef __libnix__
71 ADD2EXIT(amiga_cleanup,-50);
72 #endif
73
74 #else /* __AMIGA__ */
75
76 #ifdef __POCC__
77 #  pragma warn(disable:2024)  /* Disable warning #2024: Empty input file */
78 #endif
79
80 #endif /* __AMIGA__ */