Update "Support and Service" section to contain links to the participate and donate...
[privoxy.git] / amiga.h
1 #ifdef AMIGA
2 #ifndef AMIGA_H_INCLUDED
3 #define AMIGA_H_INCLUDED
4 #define AMIGA_H_VERSION "$Id: amiga.h,v 1.12 2007/01/07 07:40:52 joergs Exp $"
5 /*********************************************************************
6  *
7  * File        :  $Source: /cvsroot/ijbswa/current/amiga.h,v $
8  *
9  * Purpose     :  Amiga-specific declarations.
10  *
11  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
12  *                Privoxy team. http://www.privoxy.org/
13  *
14  *                This program is free software; you can redistribute it 
15  *                and/or modify it under the terms of the GNU General
16  *                Public License as published by the Free Software
17  *                Foundation; either version 2 of the License, or (at
18  *                your option) any later version.
19  *
20  *                This program is distributed in the hope that it will
21  *                be useful, but WITHOUT ANY WARRANTY; without even the
22  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
23  *                PARTICULAR PURPOSE.  See the GNU General Public
24  *                License for more details.
25  *
26  *                The GNU General Public License should be included with
27  *                this file.  If not, you can view it at
28  *                http://www.gnu.org/copyleft/gpl.html
29  *                or write to the Free Software Foundation, Inc., 59
30  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
31  *
32  *********************************************************************/
33
34
35 #define _KERNEL
36 #include <sys/socket.h>
37 #undef _KERNEL
38
39 #define __NOLIBBASE__
40 #define __NOGLOBALIFACE__
41 #include <proto/socket.h>
42 #undef __NOLIBBASE__
43 #undef __NOGLOBALIFACE__
44
45 #define __CONSTLIBBASEDECL__ const
46 #include <proto/exec.h>
47 #include <exec/tasks.h>
48 #include <proto/dos.h>
49 #include <dos/dostags.h>
50
51 struct UserData
52 {
53 #ifdef __amigaos4__
54    struct SocketIFace *si;
55 #else
56    struct Library *sb;
57 #endif
58    int eno;
59 };
60
61 #ifdef __amigaos4__
62 #define ISocket (((struct UserData *)(FindTask(NULL)->tc_UserData))->si)
63 #undef errno
64 #else
65 #define SocketBase ((struct Library *)(((struct UserData *)(FindTask(NULL)->tc_UserData))->sb))
66 #endif
67 #define errno (((struct UserData *)(FindTask(NULL)->tc_UserData))->eno)
68 #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,NULL)
69 #define inet_ntoa(x) Inet_NtoA(x.s_addr)
70
71 extern int childs;
72 extern struct Task *main_task;
73
74 void InitAmiga(void);
75 void amiga_exit(void);
76 void __memCleanUp(void);
77 SAVEDS ULONG server_thread(void);
78
79 #ifdef __amigaos4__
80 #define exit(x)                                             \
81 {                                                           \
82    if(main_task)                                            \
83    {                                                        \
84       if(main_task == FindTask(NULL))                       \
85       {                                                     \
86          while(childs) Delay(10*TICKS_PER_SECOND); exit(x); \
87       }                                                     \
88       else                                                  \
89       {                                                     \
90          if (ISocket)                                       \
91          {                                                  \
92              struct Library *sb = ISocket->Data.LibBase;    \
93              DropInterface((struct Interface *)ISocket);    \
94              CloseLibrary(sb);                              \
95          }                                                  \
96          childs--;                                          \
97          RemTask(NULL);                                     \
98       }                                                     \
99    }                                                        \
100    else                                                     \
101    {                                                        \
102       exit(x);                                              \
103    }                                                        \
104 }
105 #else
106 #define exit(x)                                             \
107 {                                                           \
108    if(main_task)                                            \
109    {                                                        \
110       if(main_task == FindTask(NULL))                       \
111       {                                                     \
112          while(childs) Delay(10*TICKS_PER_SECOND); exit(x); \
113       }                                                     \
114       else                                                  \
115       {                                                     \
116          CloseLibrary(SocketBase);                          \
117          childs--;                                          \
118          RemTask(NULL);                                     \
119       }                                                     \
120    }                                                        \
121    else                                                     \
122    {                                                        \
123       exit(x);                                              \
124    }                                                        \
125 }
126
127 #undef HAVE_RANDOM
128 #define h_errno 0
129 #define HAVE_TIMEGM
130 #define timegm(tm) mktime(tm)
131 #endif /* __amigaos4__ */
132
133 #undef EINTR
134 #define EINTR 0
135
136 #endif /* ndef AMIGA_H_INCLUDED */
137 #endif /* def AMIGA */