1 /*
2   PKTAPI Source, Version 1.00
3 
4   (c) & (p) 1999-2000 by Oliver 'Attila' Grimm
5 
6   Alle Rechte vorbehalten.
7 */
8 
9 #define INCL_DOSPROCESS
10 #include "pktapi.h"
11 #include "api_pkt2.h"
12 #include "pktapip.h"
13 
14 #include <os2.h>
15 #include <string.h>
16 
17 #ifdef OS_2
18   word _stdc far pktapierr=0;
19 #else
20   word _stdc pktapierr=0;
21 #endif
22 
_dll_end(dword p)23 static void _dll_end(dword p)
24 {
25   _Pkt2ClosePackets();
26 }
27 
PktOpenApi(struct _minf OS2FAR * minf)28 sword MAPIENTRY PktOpenApi(struct _minf OS2FAR *minf)
29 {
30   DosExitList(EXLST_ADD, (PFNEXITLIST) _dll_end);
31 
32   return MsgOpenApi(minf);
33 }
34 
PktCloseApi()35 sword MAPIENTRY PktCloseApi()
36 {
37 /* _dll_end() do this work */
38 /*  _Pkt2ClosePackets(); */
39   return MsgCloseApi();
40 }
41 
PktOpenPkt(byte far * name,word mode,word type)42 HPKT MAPIENTRY PktOpenPkt(byte far *name, word mode, word type)
43 {
44   if (type & PKTTYPE_2)
45     return (Pkt2OpenPkt(name,mode,type));
46   return 0;
47 }
48 
PktInvalidPh(HPKT hp)49 sword MAPIENTRY PktInvalidPh(HPKT hp)
50 {
51   if (hp==NULL || hp->id != PKTAPI_ID)
52   {
53     pktapierr = PERR_BADH;
54     return TRUE;
55   }
56 
57   return FALSE;
58 }
59 
PktCopyPktHdr(HPKT dest,HPKT src)60 sword MAPIENTRY PktCopyPktHdr(HPKT dest, HPKT src)
61 {
62   if (PktInvalidPh(dest) ||
63       PktInvalidPh(src) )
64   {
65     return -1;
66   }
67 
68   /* Nicht schoen, aber schnell */
69   memcpy(&dest->orig, &src->orig, (dword)&dest->api - (dword)&dest->orig );
70 
71   return 0;
72 }
73 
74