Delete the standard.action file after moving
[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.11 2006/07/18 14:48:45 david__schmidt 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  * Revisions   :
33  *    $Log: amiga.h,v $
34  *    Revision 1.11  2006/07/18 14:48:45  david__schmidt
35  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
36  *    with what was really the latest development (the v_3_0_branch branch)
37  *
38  *    Revision 1.9  2002/03/26 22:29:54  swa
39  *    we have a new homepage!
40  *
41  *    Revision 1.8  2002/03/24 13:25:43  swa
42  *    name change related issues
43  *
44  *    Revision 1.7  2002/03/03 09:18:03  joergs
45  *    Made jumbjuster work on AmigaOS again.
46  *
47  *    Revision 1.6  2001/10/13 12:46:08  joergs
48  *    Added #undef EINTR to avoid warnings
49  *
50  *    Revision 1.5  2001/07/29 18:43:08  jongfoster
51  *    Changing #ifdef _FILENAME_H to FILENAME_H_INCLUDED, to conform to
52  *    ANSI C rules.
53  *
54  *    Revision 1.4  2001/05/29 20:05:06  joergs
55  *    Fixed exit() macro not exiting if called before InitAmiga()
56  *    (junkbuster --help and --version).
57  *
58  *    Revision 1.3  2001/05/25 21:53:27  jongfoster
59  *    Fixing indentation
60  *
61  *    Revision 1.2  2001/05/23 00:13:58  joergs
62  *    AmigaOS support fixed.
63  *
64  *    Revision 1.1.1.1  2001/05/15 13:58:46  oes
65  *    Initial import of version 2.9.3 source tree
66  *
67  *
68  *********************************************************************/
69 \f
70
71 #define _KERNEL
72 #include <sys/socket.h>
73 #undef _KERNEL
74
75 #define __NOLIBBASE__
76 #define __NOGLOBALIFACE__
77 #include <proto/socket.h>
78 #undef __NOLIBBASE__
79 #undef __NOGLOBALIFACE__
80
81 #define __CONSTLIBBASEDECL__ const
82 #include <proto/exec.h>
83 #include <exec/tasks.h>
84 #include <proto/dos.h>
85 #include <dos/dostags.h>
86
87 struct UserData
88 {
89 #ifdef __amigaos4__
90    struct SocketIFace *si;
91 #else
92    struct Library *sb;
93 #endif
94    int eno;
95 };
96
97 #ifdef __amigaos4__
98 #define ISocket (((struct UserData *)(FindTask(NULL)->tc_UserData))->si)
99 #undef errno
100 #else
101 #define SocketBase ((struct Library *)(((struct UserData *)(FindTask(NULL)->tc_UserData))->sb))
102 #endif
103 #define errno (((struct UserData *)(FindTask(NULL)->tc_UserData))->eno)
104 #define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,NULL)
105 #define inet_ntoa(x) Inet_NtoA(x.s_addr)
106
107 extern int childs;
108 extern struct Task *main_task;
109
110 void InitAmiga(void);
111 void amiga_exit(void);
112 void __memCleanUp(void);
113 SAVEDS ULONG server_thread(void);
114
115 #ifdef __amigaos4__
116 #define exit(x)                                             \
117 {                                                           \
118    if(main_task)                                            \
119    {                                                        \
120       if(main_task == FindTask(NULL))                       \
121       {                                                     \
122          while(childs) Delay(10*TICKS_PER_SECOND); exit(x); \
123       }                                                     \
124       else                                                  \
125       {                                                     \
126          if (ISocket)                                       \
127          {                                                  \
128              struct Library *sb = ISocket->Data.LibBase;    \
129              DropInterface((struct Interface *)ISocket);    \
130              CloseLibrary(sb);                              \
131          }                                                  \
132          childs--;                                          \
133          RemTask(NULL);                                     \
134       }                                                     \
135    }                                                        \
136    else                                                     \
137    {                                                        \
138       exit(x);                                              \
139    }                                                        \
140 }
141 #else
142 #define exit(x)                                             \
143 {                                                           \
144    if(main_task)                                            \
145    {                                                        \
146       if(main_task == FindTask(NULL))                       \
147       {                                                     \
148          while(childs) Delay(10*TICKS_PER_SECOND); exit(x); \
149       }                                                     \
150       else                                                  \
151       {                                                     \
152          CloseLibrary(SocketBase);                          \
153          childs--;                                          \
154          RemTask(NULL);                                     \
155       }                                                     \
156    }                                                        \
157    else                                                     \
158    {                                                        \
159       exit(x);                                              \
160    }                                                        \
161 }
162
163 #undef HAVE_RANDOM
164 #define h_errno 0
165 #define HAVE_TIMEGM
166 #define timegm(tm) mktime(tm)
167 #endif /* __amigaos4__ */
168
169 #undef EINTR
170 #define EINTR 0
171
172 #endif /* ndef AMIGA_H_INCLUDED */
173 #endif /* def AMIGA */