amigaos.c 1.9 KB

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