aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c46
-rw-r--r--src/rss.c3
-rw-r--r--src/stringutils.c47
-rw-r--r--src/stringutils.h9
4 files changed, 60 insertions, 45 deletions
diff --git a/src/main.c b/src/main.c
index 74ac1c0..bae9644 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,6 +2,7 @@
#include "fileutils.h"
#include "transmission.h"
#include "fileutils.h"
+#include "stringutils.h"
#include "rss.h"
#include "json.h"
@@ -184,51 +185,6 @@ static int compare_downloaded_item(const void *a, const void *b) {
return list_data_a->timestamp - list_data_b->timestamp;
}
-static void string_replace(char *str, char old, char new) {
- for(;;) {
- char c = *str;
- if(c == old)
- *str = new;
- else if(c == '\0')
- break;
- ++str;
- }
-}
-
-static char* lstrip(char *str) {
- for(;;) {
- char c = *str;
- if(c != ' ' && c != '\t' && c != '\n')
- break;
- else if(c == '\0')
- break;
- ++str;
- }
- return str;
-}
-
-static void rstrip(char *str) {
- int len = strlen(str);
- if(len == 0)
- return;
-
- char *p = str + len - 1;
- while(p != str) {
- char c = *p;
- if(c != ' ' && c != '\t' && c != '\n')
- break;
- --p;
- }
-
- p[1] = '\0';
-}
-
-static char* strip(char *str) {
- str = lstrip(str);
- rstrip(str);
- return str;
-}
-
static void command_add(int argc, char **argv, char *rss_config_dir, char *html_config_dir) {
if(argc < 2)
usage_add();
diff --git a/src/rss.c b/src/rss.c
index fdb932c..ba2f74d 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -170,6 +170,9 @@ int add_rss(const char *name, const char *url, const char *rss_config_dir, const
}
fprintf(stderr, "rss title: |%s|\n", rss_title);
+ /*if(!name)
+ name = rss_title*/
+
cleanup:
buffer_deinit(&buffer);
return result;
diff --git a/src/stringutils.c b/src/stringutils.c
new file mode 100644
index 0000000..172d40d
--- /dev/null
+++ b/src/stringutils.c
@@ -0,0 +1,47 @@
+#include "stringutils.h"
+#include <string.h>
+
+void string_replace(char *str, char old_char, char new_char) {
+ for(;;) {
+ char c = *str;
+ if(c == old_char)
+ *str = new_char;
+ else if(c == '\0')
+ break;
+ ++str;
+ }
+}
+
+char* lstrip(char *str) {
+ for(;;) {
+ char c = *str;
+ if(c != ' ' && c != '\t' && c != '\n')
+ break;
+ else if(c == '\0')
+ break;
+ ++str;
+ }
+ return str;
+}
+
+void rstrip(char *str) {
+ int len = strlen(str);
+ if(len == 0)
+ return;
+
+ char *p = str + len - 1;
+ while(p != str) {
+ char c = *p;
+ if(c != ' ' && c != '\t' && c != '\n')
+ break;
+ --p;
+ }
+
+ p[1] = '\0';
+}
+
+char* strip(char *str) {
+ str = lstrip(str);
+ rstrip(str);
+ return str;
+} \ No newline at end of file
diff --git a/src/stringutils.h b/src/stringutils.h
new file mode 100644
index 0000000..a14d76c
--- /dev/null
+++ b/src/stringutils.h
@@ -0,0 +1,9 @@
+#ifndef STRINGUTILS_H
+#define STRINGUTILS_H
+
+void string_replace(char *str, char old_char, char new_char);
+char* lstrip(char *str);
+void rstrip(char *str);
+char* strip(char *str);
+
+#endif