amigaos.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2012, 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. #include "curl_setup.h"
  23. #if defined(__AMIGA__) && !defined(__ixemul__)
  24. #include <amitcp/socketbasetags.h>
  25. #include "amigaos.h"
  26. struct Library *SocketBase = NULL;
  27. extern int errno, h_errno;
  28. #ifdef __libnix__
  29. #include <stabs.h>
  30. void __request(const char *msg);
  31. #else
  32. # define __request( msg ) Printf( msg "\n\a")
  33. #endif
  34. void Curl_amiga_cleanup()
  35. {
  36. if(SocketBase) {
  37. CloseLibrary(SocketBase);
  38. SocketBase = NULL;
  39. }
  40. }
  41. bool Curl_amiga_init()
  42. {
  43. if(!SocketBase)
  44. SocketBase = OpenLibrary("bsdsocket.library", 4);
  45. if(!SocketBase) {
  46. __request("No TCP/IP Stack running!");
  47. return FALSE;
  48. }
  49. if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG) &errno,
  50. SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG) "cURL",
  51. TAG_DONE)) {
  52. __request("SocketBaseTags ERROR");
  53. return FALSE;
  54. }
  55. #ifndef __libnix__
  56. atexit(Curl_amiga_cleanup);
  57. #endif
  58. return TRUE;
  59. }
  60. #ifdef __libnix__
  61. ADD2EXIT(Curl_amiga_cleanup,-50);
  62. #endif
  63. #endif /* __AMIGA__ && ! __ixemul__ */