blob: 4f55b30e761515e1a3d5381b7dbb7b469efb1f3f [file] [log] [blame]
Kristian Monsen5ab50182010-05-14 18:53:44 +01001/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
Alex Deymo8f1a2142016-06-28 14:49:26 -07008 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
Kristian Monsen5ab50182010-05-14 18:53:44 +01009 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
Alex Deymo8f1a2142016-06-28 14:49:26 -070012 * are also available at https://curl.haxx.se/docs/copyright.html.
Kristian Monsen5ab50182010-05-14 18:53:44 +010013 *
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
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070023#include "curl_setup.h"
24
25#if defined(__AMIGA__) && !defined(__ixemul__)
26
27#include <amitcp/socketbasetags.h>
Kristian Monsen5ab50182010-05-14 18:53:44 +010028
29#include "amigaos.h"
Kristian Monsen5ab50182010-05-14 18:53:44 +010030
31struct Library *SocketBase = NULL;
32extern int errno, h_errno;
33
34#ifdef __libnix__
35#include <stabs.h>
36void __request(const char *msg);
37#else
Alex Deymo8f1a2142016-06-28 14:49:26 -070038# define __request(msg) Printf(msg "\n\a")
Kristian Monsen5ab50182010-05-14 18:53:44 +010039#endif
40
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070041void Curl_amiga_cleanup()
Kristian Monsen5ab50182010-05-14 18:53:44 +010042{
43 if(SocketBase) {
44 CloseLibrary(SocketBase);
45 SocketBase = NULL;
46 }
47}
48
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070049bool Curl_amiga_init()
Kristian Monsen5ab50182010-05-14 18:53:44 +010050{
51 if(!SocketBase)
52 SocketBase = OpenLibrary("bsdsocket.library", 4);
53
54 if(!SocketBase) {
55 __request("No TCP/IP Stack running!");
56 return FALSE;
57 }
58
59 if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG) &errno,
Elliott Hughescee03382017-06-23 12:17:18 -070060 SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG) "curl",
Kristian Monsen5ab50182010-05-14 18:53:44 +010061 TAG_DONE)) {
62 __request("SocketBaseTags ERROR");
63 return FALSE;
64 }
65
66#ifndef __libnix__
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070067 atexit(Curl_amiga_cleanup);
Kristian Monsen5ab50182010-05-14 18:53:44 +010068#endif
69
70 return TRUE;
71}
72
73#ifdef __libnix__
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070074ADD2EXIT(Curl_amiga_cleanup, -50);
Kristian Monsen5ab50182010-05-14 18:53:44 +010075#endif
76
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070077#endif /* __AMIGA__ && ! __ixemul__ */