2 Syren -- a lightweight downloader for Linux/BSD/MacOSX
3 inspired by Axel Copyright 2001-2002 Wilmer van der Gaast
4 version 0.0.6 (atomic alien)
5 coded by Ketmar // Vampire Avalon
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
23 Syren os-specific functions
32 double SyGetTimeD (void) {
34 gettimeofday(&time
, 0);
35 return ((double)time
.tv_sec
+(double)time
.tv_usec
/1000000);
39 #ifdef SY_INCLUDE_FILE_IO
40 TSyResult
SyDeleteFile (const char *fname
) {
41 if (!unlink(fname
)) return SY_OK
;
46 int SyOpenFile (const char *fname
, TSyFileMode mode
, TSyBool mustCreate
) {
47 int mm
= (mode
==SY_FMODE_WRITE
)?O_WRONLY
:O_RDONLY
;
49 if (mustCreate
!= SY_FALSE
) mm
= mm
| O_CREAT
;
50 return open(fname
, mm
, SY_FILE_DEFMODE
);
54 TSyResult
SyWriteFile (int fd
, const void *buf
, int count
) {
55 int wr
= write(fd
, buf
, count
);
56 if (wr
!= count
) return SY_ERROR
;
61 TSyResult
SyReadFile (int fd
, void *buf
, int count
) {
62 int rd
= read(fd
, buf
, count
);
63 if (rd
!= count
) return SY_ERROR
;
68 TSyResult
SySeekFile (int fd
, int64_t offset
) {
70 offset
= offset
<0?SY_LSEEK(fd
, offset
, SEEK_END
):SY_LSEEK(fd
, offset
, SEEK_SET
);
71 if (offset
< 0) return SY_ERROR
;
76 int64_t SyFileSize (int fd
) {
78 int64_t ppos
= SY_LSEEK(fd
, 0, SEEK_CUR
);
79 if (ppos
< 0) return -1;
80 size
= SY_LSEEK(fd
, 0, SEEK_END
);
81 if (SY_LSEEK(fd
, ppos
, SEEK_SET
) < 0) return -1;
87 TSyResult
SySocketInit (void) {
91 void SySocketShutdown (void) {