2 Syren -- a lightweight downloader for Linux/BSD/Win/MacOSX
3 inspired by Axel Copyright 2001-2002 Wilmer van der Gaast
4 version 0.0.6 (atomic alien)
5 coded by Ketmar // Avalon Group
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License with
18 the Debian GNU/Linux distribution in file /usr/doc/copyright/GPL;
19 if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 Suite 330, Boston, MA 02111-1307 USA
29 #include "syren_common.h"
30 #include "syren_msg.h"
34 #ifdef SYOPT_ALLOW_HTTPS
39 int errCode
; /* 0: no error */
43 #define SY_TCP_DONT_ALLOWPARTIAL 0
44 #define SY_TCP_ALLOWPARTIAL 1
47 /* returns allocated string or NULL */
48 char *SyTCPGetLastErrorMsg (TSySocket
*fd
);
50 /* put interface IP address to `ip' */
51 TSyResult
SyGetIFIP (char *ip
, const char *iface
);
53 /* initialize socket */
54 TSyResult
SyTCPInitSocket (TSySocket
*fd
);
55 #ifdef SYOPT_ALLOW_HTTPS
56 TSyResult
SyTCPInitSSL (TSySocket
*fd
, int timeout
);
58 TSyResult
SyTCPCloseSocket (TSySocket
*fd
);
60 /* create a TCP connection; fd must not be initialized */
61 TSyResult
SyTCPConnect (TSySocket
*fd
, char *hostname
, int port
, const char *iface
, int timeout
, const TSyPrintStr
*pfn
);
62 TSyResult
SyTCPSend (TSySocket
*fd
, const void *buf
, int bufSize
);
63 TSyResult
SyTCPSendStr (TSySocket
*fd
, const char *str
);
64 /* <0: received (-res) bytes; read error */
65 int SyTCPReceiveEx (TSySocket
*fd
, void *buf
, int bufSize
, int allowPartial
);
66 /* <0: received (-res) bytes; read error */
67 int SyTCPReceive (TSySocket
*fd
, void *buf
, int bufSize
);
69 char *SyTCPReceiveStrEx (TSySocket
*fd
, int maxSize
, char *dest
);
70 /* return NULL if string was too big */
71 char *SyTCPReceiveStr (TSySocket
*fd
, int maxSize
);
73 TSyResult
SyTCPSendLine (const TSyPrintStr
*pfn
, int printLine
, TSySocket
*fd
, const char *fmt
, ...);
75 /* return NULL if string was too big or on error;
76 tries to receive all headers
78 char *SyTCPReceiveHdrs (TSySocket
*fd
, int maxSize
);