summaryrefslogtreecommitdiffstats
path: root/macro.h
diff options
context:
space:
mode:
authorAndreas Eversberg2009-10-27 07:53:27 +0100
committerAndreas Eversberg2009-10-27 07:53:27 +0100
commitb987a1bbbcabbf183ebe009903778671a1591337 (patch)
treec1cb7f202d4edb4bd5d8787047cfb12f6316be76 /macro.h
parentDon't detect tones for SS5, if the minimum noise level is not reached. (diff)
downloadlcr-b987a1bbbcabbf183ebe009903778671a1591337.tar.gz
lcr-b987a1bbbcabbf183ebe009903778671a1591337.tar.xz
lcr-b987a1bbbcabbf183ebe009903778671a1591337.zip
Fixes and improves parsing of config file.
Last character of unterminated line was ignored. Minor bug fix in 2600 Hz pulse dialing. modified: README modified: action_vbox.cpp modified: crypt.cpp modified: extension.c modified: gsm_conf.c modified: interface.c modified: macro.h modified: route.c modified: ss5.cpp modified: ss5.h
Diffstat (limited to 'macro.h')
-rw-r--r--macro.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/macro.h b/macro.h
index 29b2794..9e4bcd1 100644
--- a/macro.h
+++ b/macro.h
@@ -92,7 +92,7 @@ static inline void *_malloc(unsigned int size, const char *function, int line)
if (!addr)
fatal(function, line, "No memory for %d bytes.\n", size);
memset(addr, 0, size);
- return(addr);
+ return addr;
}
/* memory freeing with clearing memory to prevent using freed memory */
@@ -104,4 +104,20 @@ static inline void _free(void *addr, int size)
free(addr);
}
+/* fill buffer and be sure that it's result is 0-terminated, also remove newline */
+#define GETLINE(buffer, fp) _getline(buffer, sizeof(buffer), fp)
+static inline char *_getline(char *buffer, int size, FILE *fp)
+{
+ if (!fgets(buffer, size-1, fp))
+ return NULL;
+ buffer[size-1] = '\0';
+ if (!buffer[0])
+ return buffer;
+ if (buffer[strlen(buffer)-1] == '\n')
+ buffer[strlen(buffer)-1] = '\0';
+ if (buffer[strlen(buffer)-1] == '\r')
+ buffer[strlen(buffer)-1] = '\0';
+ return buffer;
+}
+