amigaos.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2021, 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 https://curl.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. #ifdef __AMIGA__
  24. # include "amigaos.h"
  25. # if defined(HAVE_PROTO_BSDSOCKET_H) && !defined(USE_AMISSL)
  26. # include <amitcp/socketbasetags.h>
  27. # endif
  28. # ifdef __libnix__
  29. # include <stabs.h>
  30. # endif
  31. #endif
  32. /* The last #include files should be: */
  33. #include "curl_memory.h"
  34. #include "memdebug.h"
  35. #ifdef __AMIGA__
  36. #if defined(HAVE_PROTO_BSDSOCKET_H) && !defined(USE_AMISSL)
  37. struct Library *SocketBase = NULL;
  38. extern int errno, h_errno;
  39. #ifdef __libnix__
  40. void __request(const char *msg);
  41. #else
  42. # define __request(msg) Printf(msg "\n\a")
  43. #endif
  44. void Curl_amiga_cleanup()
  45. {
  46. if(SocketBase) {
  47. CloseLibrary(SocketBase);
  48. SocketBase = NULL;
  49. }
  50. }
  51. bool Curl_amiga_init()
  52. {
  53. if(!SocketBase)
  54. SocketBase = OpenLibrary("bsdsocket.library", 4);
  55. if(!SocketBase) {
  56. __request("No TCP/IP Stack running!");
  57. return FALSE;
  58. }
  59. if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG) &errno,
  60. SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG) "curl",
  61. TAG_DONE)) {
  62. __request("SocketBaseTags ERROR");
  63. return FALSE;
  64. }
  65. #ifndef __libnix__
  66. atexit(Curl_amiga_cleanup);
  67. #endif
  68. return TRUE;
  69. }
  70. #ifdef __libnix__
  71. ADD2EXIT(Curl_amiga_cleanup, -50);
  72. #endif
  73. #endif /* HAVE_PROTO_BSDSOCKET_H */
  74. #ifdef USE_AMISSL
  75. void Curl_amiga_X509_free(X509 *a)
  76. {
  77. X509_free(a);
  78. }
  79. /* AmiSSL replaces many functions with macros. Curl requires pointer
  80. * to some of these functions. Thus, we have to encapsulate these macros.
  81. */
  82. #include "warnless.h"
  83. int (SHA256_Init)(SHA256_CTX *c)
  84. {
  85. return SHA256_Init(c);
  86. };
  87. int (SHA256_Update)(SHA256_CTX *c, const void *data, size_t len)
  88. {
  89. return SHA256_Update(c, data, curlx_uztoui(len));
  90. };
  91. int (SHA256_Final)(unsigned char *md, SHA256_CTX *c)
  92. {
  93. return SHA256_Final(md, c);
  94. };
  95. void (X509_INFO_free)(X509_INFO *a)
  96. {
  97. X509_INFO_free(a);
  98. };
  99. #endif /* USE_AMISSL */
  100. #endif /* __AMIGA__ */