summaryrefslogtreecommitdiffstats
path: root/ax25/axgetput
diff options
context:
space:
mode:
Diffstat (limited to 'ax25/axgetput')
-rw-r--r--ax25/axgetput/axgetput.c12
-rw-r--r--ax25/axgetput/proto_bin.c72
-rw-r--r--ax25/axgetput/util.c66
3 files changed, 75 insertions, 75 deletions
diff --git a/ax25/axgetput/axgetput.c b/ax25/axgetput/axgetput.c
index c2f4d25..595215c 100644
--- a/ax25/axgetput/axgetput.c
+++ b/ax25/axgetput/axgetput.c
@@ -264,17 +264,17 @@ int main(int argc, char *argv[])
#define get_filename(f) { \
if (!strcmp(f, "-")) { \
if (mode % 2) \
- fdin_is_pipe = 1; \
- else \
- fdout_is_pipe = 1; \
+ fdin_is_pipe = 1; \
+ else \
+ fdout_is_pipe = 1; \
} else { \
- strncpy(filename, f, sizeof(filename)-1); \
- filename[sizeof(filename)-1] = 0; \
+ strncpy(filename, f, sizeof(filename)-1); \
+ filename[sizeof(filename)-1] = 0; \
if (mode % 2) { \
if (fdin_is_pipe) \
fdin_is_pipe = 0; \
} else { \
- if (fdout_is_pipe) \
+ if (fdout_is_pipe) \
fdout_is_pipe = 0; \
} \
} \
diff --git a/ax25/axgetput/proto_bin.c b/ax25/axgetput/proto_bin.c
index d02249b..9be7a58 100644
--- a/ax25/axgetput/proto_bin.c
+++ b/ax25/axgetput/proto_bin.c
@@ -26,7 +26,7 @@ static int init_crc(void)
crctab[i] = 0;
for (j = 0; j < 8; j++) {
if ((bittab[j] & i) != 0) {
- crctab[i] = crctab[i] ^ crcbit[j];
+ crctab[i] = crctab[i] ^ crcbit[j];
}
}
}
@@ -113,7 +113,7 @@ int bput(void)
return 1;
}
if (buf[len-1] == '\r' && len > 5 && !memcmp(buf, "#BIN#", 5)) {
- break;
+ break;
}
if (len == sizeof(buf)) {
sprintf(err_msg, "line to long\n");
@@ -139,12 +139,12 @@ int bput(void)
break;
default:
if (*p == '|') {
- msg_crc = (unsigned int ) atoi(p+1);
+ msg_crc = (unsigned int ) atoi(p+1);
} else if (*p == '$') {
- file_time = parse_sfbin_date_to_unix(p+1);
+ file_time = parse_sfbin_date_to_unix(p+1);
} else {
- strncpy(filename_given, p, sizeof(filename_given)-1);
- filename_given[sizeof(filename_given)-1] = 0;
+ strncpy(filename_given, p, sizeof(filename_given)-1);
+ filename_given[sizeof(filename_given)-1] = 0;
}
}
}
@@ -159,8 +159,8 @@ int bput(void)
if (!stat(filename, &statbuf)) {
/* file exist */
if (unlink(filename)) {
- sprintf(err_msg, "error: cannot unlink %s (%s)\n", filename, strerror(errno));
- goto abort;
+ sprintf(err_msg, "error: cannot unlink %s (%s)\n", filename, strerror(errno));
+ goto abort;
}
}
if ((fddata = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0640)) < 0) {
@@ -194,7 +194,7 @@ int bput(void)
if (!len) {
save_close(fddata);
if (!term_line) {
- sprintf(err_msg, "error: unexpected end of file during read: %s\n", strerror(errno));
+ sprintf(err_msg, "error: unexpected end of file during read: %s\n", strerror(errno));
return 1;
}
return 0;
@@ -203,14 +203,14 @@ int bput(void)
if (msg_crc) {
int i;
for (i = 0; i < len; i++)
- crc = do_crc((int ) buf[i], 1, crc);
+ crc = do_crc((int ) buf[i], 1, crc);
}
if (buf[len-1] == '\r') {
if (last_line_had_CR) {
if (IS_BIN_ABORT(buf, len)) {
/* "\r#ABORT#\r" was sent */
- if (!fdout_is_pipe) {
+ if (!fdout_is_pipe) {
close(fddata);
/* clean up */
unlink(filename);
@@ -218,8 +218,8 @@ int bput(void)
return 1;
}
if (term_line && len == len_termline && !memcmp(buf, term_line, len_termline)) {
- /* sucessfully read until termination string */
- break;
+ /* sucessfully read until termination string */
+ break;
}
}
last_line_had_CR = 1;
@@ -241,7 +241,7 @@ int bput(void)
if (is_eof) {
if (!term_line && len_read_left) {
save_close(fddata);
- goto abort;
+ goto abort;
}
break;
}
@@ -304,13 +304,13 @@ int bget(void) {
}
#define store_line(s, len) { \
- if (!(sl = (struct strlist *) malloc(sizeof(struct strlist *) + sizeof(size_t) + len))) \
+ if (!(sl = (struct strlist *) malloc(sizeof(struct strlist *) + sizeof(size_t) + len))) \
return 1; \
sl->next = 0; \
sl->len = len; \
memcpy(sl->data, s, len); \
if (!stored_file) { \
- stored_file = sl; \
+ stored_file = sl; \
} else { \
sl_tail->next = sl; \
} \
@@ -336,7 +336,7 @@ int bget(void) {
while ((len = read(fddata, buf, BLOCKSIZ)) > 0) {
int i;
for (i = 0; i < len; i++)
- crc = do_crc((int ) buf[i], 1, crc);
+ crc = do_crc((int ) buf[i], 1, crc);
file_size += len;
}
if (len < 0) {
@@ -356,17 +356,17 @@ int bget(void) {
if (!is_stream || do_crc_only) {
sprintf(err_msg, "error: not enough memory\n");
while ((len = read(fddata, buf, sizeof(buf))) > 0) {
- int i;
- for (i = 0; i < len; i++)
- crc = do_crc((int ) buf[i], 1, crc);
- file_size += len;
+ int i;
+ for (i = 0; i < len; i++)
+ crc = do_crc((int ) buf[i], 1, crc);
+ file_size += len;
if (!do_crc_only)
store_line(buf, len);
}
if (len < 0) {
- sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
- close(fddata);
- return 1;
+ sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
+ close(fddata);
+ return 1;
}
*err_msg = 0;
sprintf(buf, "\r#BIN#%ld#|%d#$%s#%s\r", file_size, crc, unix_to_sfbin_date_string(file_time), get_fixed_filename(filename, file_size, crc, 1));
@@ -396,7 +396,7 @@ int bget(void) {
/* wait for answer */
for (;;) {
- /*
+ /*
* make sure we do not read from a pipe. fdout is also
* assigned to the tty
*/
@@ -442,26 +442,26 @@ int bget(void) {
FD_SET(fdin, &readfds);
if (select(fdin+1, &readfds, 0, 0, &timeout) && FD_ISSET(fdin, &readfds)) {
if ((len = read(fdin, buf, sizeof(buf))) < 0) {
- sprintf(err_msg, "read from tty failed (%s)\n", strerror(errno));
- save_close(fddata);
- goto abort;
+ sprintf(err_msg, "read from tty failed (%s)\n", strerror(errno));
+ save_close(fddata);
+ goto abort;
}
if (IS_BIN_ABORT(buf, len)) {
- sprintf(err_msg, "Aborted by user request\n");
- save_close(fddata);
- return 1;
+ sprintf(err_msg, "Aborted by user request\n");
+ save_close(fddata);
+ return 1;
}
}
/* read data */
if (!fdin_is_pipe || is_stream) {
p_buf = buf;
if ((len = my_read(fddata, buf, ((len_remains > BLOCKSIZ || is_stream) ? BLOCKSIZ : len_remains), &is_eof, 0)) < 1) {
- save_close(fddata);
- if (len < 0) {
- sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
+ save_close(fddata);
+ if (len < 0) {
+ sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
goto abort;
- }
- break;
+ }
+ break;
}
len_remains -= len;
} else {
diff --git a/ax25/axgetput/util.c b/ax25/axgetput/util.c
index 98caeeb..f20937f 100644
--- a/ax25/axgetput/util.c
+++ b/ax25/axgetput/util.c
@@ -54,8 +54,8 @@ 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;
/*
@@ -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,22 +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);
}