comparison dspad.c @ 2:f362b20de51e

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 22 Feb 2015 18:03:26 +0100
parents e70ea46d6073
children
comparison
equal deleted inserted replaced
1:05c8e0aef77d 2:f362b20de51e
5 5
6 #define __MAIN_FILE__ 6 #define __MAIN_FILE__
7 7
8 #include "ds.h" 8 #include "ds.h"
9 #include "uinput.h" 9 #include "uinput.h"
10 #include "service.h" 10 #include "service.h"
11 #include "restartOp.h" 11 #include "restartOp.h"
12 #include "XML.h" 12 #include "XML.h"
13 13
14 #include <stdio.h> 14 #include <stdio.h>
15 #include <stdint.h> 15 #include <stdint.h>
29 29
30 (void)elem; 30 (void)elem;
31 31
32 if(tag != NULL && content != NULL){ 32 if(tag != NULL && content != NULL){
33 if(strcmp(content, "")){ 33 if(strcmp(content, "")){
34 34
35 /* process atom: */ 35 /* process atom: */
36 if(!strcmp(tag, "base_port")){ 36 if(!strcmp(tag, "base_port")){
37 base_port = atoi(content); 37 base_port = atoi(content);
38 return 1; 38 return 1;
39 } 39 }
40 40
41 else if(!strcmp(tag, "uinput_dev")){ 41 else if(!strcmp(tag, "uinput_dev")){
42 if(uinput_dev != NULL) free(uinput_dev); 42 if(uinput_dev != NULL) free(uinput_dev);
43 uinput_dev = (char*)malloc(strlen(content)+1); 43 uinput_dev = (char*)malloc(strlen(content)+1);
44 strcpy(uinput_dev, content); 44 strcpy(uinput_dev, content);
45 return 1; 45 return 1;
47 47
48 else if(!strcmp(tag, "nb_pad")){ 48 else if(!strcmp(tag, "nb_pad")){
49 nbdev = atoi(content); 49 nbdev = atoi(content);
50 return 1; 50 return 1;
51 } 51 }
52 52
53 return ReadXML(elem, dspad_process_xml, content); 53 return ReadXML(elem, dspad_process_xml, content);
54 } 54 }
55 } 55 }
56 56
57 /* Should not happend... (compiler warning) */ 57 /* Should not happend... (compiler warning) */
58 return 0; 58 return 0;
59 } 59 }
60 60
61 61
66 0 error 66 0 error
67 */ 67 */
68 int config_read(char* path){ 68 int config_read(char* path){
69 int ok = 0; 69 int ok = 0;
70 char* text = NULL; 70 char* text = NULL;
71 71
72 text = LoadFile(path); 72 text = LoadFile(path);
73 if(text){ 73 if(text){
74 ok = ReadXML(NULL, dspad_process_xml, text); 74 ok = ReadXML(NULL, dspad_process_xml, text);
75 free(text); 75 free(text);
76 if(ok){ 76 if(ok){
89 int main(int argc, char** argv){ 89 int main(int argc, char** argv){
90 /* -- gcc -Werror satisfaction... -- */ 90 /* -- gcc -Werror satisfaction... -- */
91 (void)argc; 91 (void)argc;
92 (void)argv; 92 (void)argv;
93 /* --------------------------------- */ 93 /* --------------------------------- */
94 94
95 curdev = 0; 95 curdev = 0;
96 96
97 fprintf(stdout, "\n--- Starting DSPad Server v0.2 ---\n"); 97 fprintf(stdout, "\n--- Starting DSPad Server v0.2 ---\n");
98 98
99 pid_t pid = 0; 99 pid_t pid = 0;
100 100
101 if(argc == 3 && !strcmp("-f", argv[1])){ 101 if(argc == 3 && !strcmp("-f", argv[1])){
102 fprintf(stderr, "Loading \"%s\"\n", argv[2]); 102 fprintf(stderr, "Loading \"%s\"\n", argv[2]);
103 config_read(argv[2]); 103 config_read(argv[2]);
104 } 104 }
105 else{ 105 else{
106 fprintf(stderr, "Loading \"%s\"\n", DEFAULT_PATH); 106 fprintf(stderr, "Loading \"%s\"\n", DEFAULT_PATH);
107 config_read(DEFAULT_PATH); 107 config_read(DEFAULT_PATH);
108 } 108 }
109 109
110 110
111 111
112 /* fork servers */ 112 /* fork servers */
113 while(curdev < nbdev){ 113 while(curdev < nbdev){
114 pid = fork_rs(); 114 pid = fork_rs();
115 switch(pid){ 115 switch(pid){
116 case 0: 116 case 0:
129 fprintf(stdout, " [%d] Service finished\n", curdev); 129 fprintf(stdout, " [%d] Service finished\n", curdev);
130 waitpid(-1, NULL, 0); 130 waitpid(-1, NULL, 0);
131 exit(EXIT_SUCCESS); 131 exit(EXIT_SUCCESS);
132 break; 132 break;
133 } /* switch */ 133 } /* switch */
134 } 134 }
135 135
136 return 0; 136 return 0;
137 } 137 }
138 138