amigaos.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. * $Id$
  22. ***************************************************************************/
  23. #ifdef __AMIGA__ /* Any AmigaOS flavour */
  24. #include "amigaos.h"
  25. #include <amitcp/socketbasetags.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 amiga_cleanup()
  35. {
  36. if(SocketBase) {
  37. CloseLibrary(SocketBase);
  38. SocketBase = NULL;
  39. }
  40. }
  41. BOOL 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(amiga_cleanup);
  57. #endif
  58. return TRUE;
  59. }
  60. #ifdef __libnix__
  61. ADD2EXIT(amiga_cleanup,-50);
  62. #endif
  63. #else /* __AMIGA__ */
  64. #ifdef __POCC__
  65. # pragma warn(disable:2024) /* Disable warning #2024: Empty input file */
  66. #endif
  67. #endif /* __AMIGA__ */