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