- Timestamp:
- Sep 13, 2024, 6:39:33 PM (2 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/cm_string.h
r3 r4 6 6 char* cm_strcat(const char* a, const char* b); 7 7 char* cm_strdup(const char* str); 8 char* cm_trimstart(const char* str); 9 char* cm_trimend(const char* str); 10 char* cm_trim(const char* str); 8 11 9 12 #endif -
trunk/Common/string.c
r3 r4 13 13 14 14 char* cm_strdup(const char* str) { return cm_strcat(str, ""); } 15 16 char* cm_trimstart(const char* str){ 17 int i; 18 for(i = 0; str[i] != 0; i++){ 19 if(str[i] != ' ' && str[i] != '\t'){ 20 return cm_strdup(str + i); 21 } 22 } 23 return cm_strdup(""); 24 } 25 26 char* cm_trimend(const char* str){ 27 char* s = cm_strdup(str); 28 int i; 29 for(i = strlen(s) - 1; i >= 0; i--){ 30 if(s[i] != '\t' && s[i] != ' '){ 31 s[i + 1] = 0; 32 break; 33 } 34 } 35 return s; 36 } 37 38 char* cm_trim(const char* str){ 39 char* tmp = cm_trimstart(str); 40 char* s = cm_trimend(tmp); 41 free(tmp); 42 return s; 43 } -
trunk/Makefile
r2 r4 3 3 PWD = `pwd` 4 4 PLATFORM = generic 5 PREFIX = /usr 5 PREFIX = /usr/local 6 6 7 7 FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM) PREFIX=$(PREFIX) -
trunk/Server/Makefile
r3 r4 6 6 .SUFFIXES: .c .o 7 7 8 OBJS = version.o main.o 8 OBJS = version.o main.o config.o 9 9 10 10 all: tewi$(EXEC) -
trunk/Server/main.c
r3 r4 7 7 #include <cm_log.h> 8 8 9 #include "tw_config.h" 9 10 #include "tw_version.h" 10 11 … … 13 14 int main(int argc, char** argv) { 14 15 int i; 16 const char* config = PREFIX "/etc/tewi.conf"; 15 17 for(i = 1; i < argc; i++) { 16 18 if(argv[i][0] == '-') { … … 22 24 cm_do_log = true; 23 25 } 26 } else if(strcmp(argv[i], "--config") == 0 || strcmp(argv[i], "-C") == 0){ 27 i++; 28 if(argv[i] == NULL){ 29 fprintf(stderr, "Missing argument\n"); 30 return 1; 31 } 32 config = argv[i]; 24 33 } else { 25 34 fprintf(stderr, "Unknown option: %s\n", argv[i]); … … 28 37 } 29 38 } 39 if(tw_config_read(config) != 0){ 40 fprintf(stderr, "Could not read the config\n"); 41 return 1; 42 } 30 43 cm_log("Daemon", "Ready"); 31 44 }
Note:
See TracChangeset
for help on using the changeset viewer.