diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2015-05-02 00:19:09 +0200 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-05-02 00:19:09 +0200 |
commit | 56e847dae8f585254c6b336ea557bd75a0574711 (patch) | |
tree | 7e775ea62e06caa505e7ad017e17bbc0800d8ab3 /ax25/axgetput/util.c | |
parent | 62ceba5818d888041adbd466e8c67a8104bcf4fa (diff) | |
parent | 67d85b3d5cf145a5bf0a1431d6052473b017daa9 (diff) |
Merge branch 'master' of git://git.linux-ax25.org/pub/scm/ralf/ax25-tools
Conflicts:
ax25/axspawn.c
Diffstat (limited to 'ax25/axgetput/util.c')
-rw-r--r-- | ax25/axgetput/util.c | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/ax25/axgetput/util.c b/ax25/axgetput/util.c index 4aff6a0..5501035 100644 --- a/ax25/axgetput/util.c +++ b/ax25/axgetput/util.c @@ -54,15 +54,15 @@ int my_read(int fd, char *s, int len_max, int *eof, char *p_break) if ((len = read(fd, s_curr, (p_break ? 1 : len_max))) < 1) { if (len == -1 && errno == EAGAIN) { - sleep(10); - continue; + sleep(10); + continue; } *eof = 1; /* * len = 0: normal eof. if we're looking for a string, return -1 since * we have'nt found */ - return (len == 0 && p_break ? -1 : (len_got ? len_got : len)); + return len == 0 && p_break ? -1 : (len_got ? len_got : len); } len_got += len; @@ -79,7 +79,7 @@ int my_read(int fd, char *s, int len_max, int *eof, char *p_break) return len_got; } - + /*---------------------------------------------------------------------------*/ int secure_write(int fd, char *s, int len_write) { @@ -89,8 +89,8 @@ int secure_write(int fd, char *s, int len_write) { int len; if ((len = write(fd, s, len_write_left_curr)) < 0) { if (len == -1 && errno == EAGAIN) { - sleep(10); - continue; + sleep(10); + continue; } return -1; } @@ -162,22 +162,22 @@ char *get_fixed_filename(char *line, long size, unsigned int msg_crc, int genera /* Linear day numbers of the respective 1sts in non-leap years. */ static int day_n[] = { 0,31,59,90,120,151,181,212,243,273,304,334,0,0,0,0 }; - /* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */ + /* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */ /*---------------------------------------------------------------------------*/ long date_dos2unix(unsigned short time,unsigned short date) { - int month,year; - long secs; - - month = ((date >> 5) & 15)-1; - year = date >> 9; - secs = (time & 31)*2+60*((time >> 5) & 63)+(time >> 11)*3600+86400* - ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 && - month < 2 ? 1 : 0)+3653); - /* days since 1.1.70 plus 80's leap day */ - return secs; + int month,year; + long secs; + + month = ((date >> 5) & 15)-1; + year = date >> 9; + secs = (time & 31)*2+60*((time >> 5) & 63)+(time >> 11)*3600+86400* + ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 && + month < 2 ? 1 : 0)+3653); + /* days since 1.1.70 plus 80's leap day */ + return secs; } /*---------------------------------------------------------------------------*/ @@ -186,23 +186,22 @@ long date_dos2unix(unsigned short time,unsigned short date) void date_unix2dos(int unix_date,unsigned short *time, unsigned short *date) { - int day,year,nl_day,month; - - *time = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+ - (((unix_date/3600) % 24) << 11); - day = unix_date/86400-3652; - year = day/365; - if ((year+3)/4+365*year > day) year--; - day -= (year+3)/4+365*year; - if (day == 59 && !(year & 3)) { - nl_day = day; - month = 2; - } - else { - nl_day = (year & 3) || day <= 59 ? day : day-1; - for (month = 0; month < 12; month++) - if (day_n[month] > nl_day) break; - } - *date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9); + int day,year,nl_day,month; + + *time = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+ + (((unix_date/3600) % 24) << 11); + day = unix_date/86400-3652; + year = day/365; + if ((year+3)/4+365*year > day) year--; + day -= (year+3)/4+365*year; + if (day == 59 && !(year & 3)) { + nl_day = day; + month = 2; + } + else { + nl_day = (year & 3) || day <= 59 ? day : day-1; + for (month = 0; month < 12; month++) + if (day_n[month] > nl_day) break; + } + *date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9); } - |