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 2 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
23 Syren string manipulation package
29 #include "syren_common.h"
32 char *SySPrintfEx (int addonBytes
, const char *fmt
, ...);
33 #define SySPrintf(fmt, ...) SySPrintfEx(0, fmt, __VA_ARGS__)
36 /* src can be NULL; maxlen < 0: maxlen = strlen(src?src:"") */
37 char *SyStrNew (const char *src
, int maxlen
);
38 #define SyStrDup(str) SyStrNew(str, -1)
39 #define SyStrNewEmpty() SyStrNew(NULL, -1)
40 void SyStrFree (char *str
);
44 typedef struct _TSyKVListItem TSyKVListItem
;
45 struct _TSyKVListItem
{
49 char *ustr
; /* for configs (descr); autofree */
50 void *udata
; /* for configs/cookies */
51 int uidata
; /* for configs/cookies */
62 TSyKVList
*SyKVListNew (void);
63 void SyKVListFree (TSyKVList
*lst
);
64 void SyKVListClear (TSyKVList
*lst
);
65 TSyKVListItem
*SyKVListFind (TSyKVList
*lst
, const char *key
);
66 TSyResult
SyKVListDelete (TSyKVList
*lst
, const char *key
);
67 TSyKVListItem
*SyKVListSet (TSyKVList
*lst
, const char *key
, const char *value
, int *newKey
);
70 /* trim [dynamic] string "in-place" */
71 void SyStrTrim (char *s
);
73 /* return NULL or new string */
74 char *SyURLDecode (const char *s
);
75 /* return NULL or new string */
76 char *SyURLEncode (const char *s
);
78 /* return NULL or new string */
79 char *SyBuildAuthStr (const char *user
, const char *pass
);
88 SY_PROTO_DEFAULT
=SY_PROTO_HTTP
90 #define SY_PROTO_DEFAULT_STR "http"
98 int port
; TSyBool defaultPort
;
99 char *dir
, *file
, *query
, *anchor
;
103 TSyURL
*SyURLNew (void);
104 void SyURLFree (TSyURL
*url
);
105 void SyURLClear (TSyURL
*url
);
106 TSyResult
SyURLParse (TSyURL
*dest
, const char *urlstr
);
107 TSyURL
*SyURLClone (const TSyURL
*src
);
109 #ifdef SY_STR_URL2STR
110 /* return NULL or new string */
111 char *SyURL2StrEx (TSyURL
*url
, TSyBool userpass
, TSyBool hidepass
);
112 /* return NULL or new string */
113 char *SyURL2Str (TSyURL
*url
);
118 int64_t SyStr2Long (const char *s
);
120 int SyStr2Int (const char *s
);
122 TSyResult
SyLong2Str (char *dest
, int64_t num
);
126 /* dest: at least 26 chars */
128 int SyLong2StrComma (char *dest
, int64_t num
);
130 /* dest: at least 10 bytes */
131 void SySize2Str (char *dest
, int64_t size
);
133 /* dest: at least 10 bytes */
134 void SyTime2Str (char *dest
, int value
);