aboutsummaryrefslogtreecommitdiff
path: root/bikewedge/software/RetoolingForOpenSprints/serproxy-0.1.3.src/string.c
diff options
context:
space:
mode:
authorDonald Delmar Davis <don@suspectdevices.com>2015-06-01 12:44:28 -0700
committerDonald Delmar Davis <don@suspectdevices.com>2015-06-01 12:44:28 -0700
commitdbb49b7c3aba71c7f2d6d9d5e38e0239da3876b8 (patch)
treed55f15be80393d286ab532290967a0396d96e852 /bikewedge/software/RetoolingForOpenSprints/serproxy-0.1.3.src/string.c
parent919a9ea9007a3b8a472e0a92dac43143b1001662 (diff)
Add last bit of last minute stuff requested by Chrome which failed on the road
Diffstat (limited to 'bikewedge/software/RetoolingForOpenSprints/serproxy-0.1.3.src/string.c')
-rw-r--r--bikewedge/software/RetoolingForOpenSprints/serproxy-0.1.3.src/string.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/bikewedge/software/RetoolingForOpenSprints/serproxy-0.1.3.src/string.c b/bikewedge/software/RetoolingForOpenSprints/serproxy-0.1.3.src/string.c
new file mode 100644
index 0000000..a15fef5
--- /dev/null
+++ b/bikewedge/software/RetoolingForOpenSprints/serproxy-0.1.3.src/string.c
@@ -0,0 +1,70 @@
+/*
+ * string.c
+ *
+ * string handling routines
+ *
+ * (C)1999 Stefano Busti
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "string.h"
+
+int str_assign(char **pstr, char *text)
+{
+ char *p;
+
+ if (!text)
+ {
+ free(*pstr);
+ *pstr = NULL;
+ return 0;
+ }
+
+ p = realloc(*pstr, strlen(text) + 1);
+ if (!p)
+ return -1;
+ *pstr = p;
+ strcpy(p, text);
+
+ return 0;
+}
+
+int str_cat(char **pstr, char *text)
+{
+ char *p = realloc(*pstr, strlen(*pstr) + strlen(text) + 1);
+ if (!p)
+ return -1;
+
+ *pstr = p;
+ strcat(p, text);
+
+ return 0;
+}
+
+/* strips trailing spaces */
+int str_striptrail(char *str)
+{
+ char *p;
+
+ for (p = str + strlen(str) - 1; p >= str; p--)
+ {
+ if (*p != ' ')
+ {
+ *(p + 1) = '\0';
+ return 0;
+ }
+ }
+ return 0;
+}
+
+void str_cleanup(char **pstr)
+{
+ if (*pstr)
+ {
+ free(*pstr);
+ *pstr = NULL;
+ }
+}