annotate dspad.c @ 9:5e15d64a2d24 default tip

If somebody closed stdin, fd could be both valid and 0, don’t check for that.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 18 Aug 2015 02:09:55 +0100
parents f362b20de51e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 DSPad
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 Convert Nintendo DS keypress into joystick events
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 #define __MAIN_FILE__
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 #include "ds.h"
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 #include "uinput.h"
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
10 #include "service.h"
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 #include "restartOp.h"
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 #include "XML.h"
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 #include <stdio.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 #include <stdint.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 #include <sys/types.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 #include <unistd.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 #include <stdlib.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 #include <sys/wait.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 #define DEFAULT_PATH "~/DSPad_server.xml"
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 Process xml atoms
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 int dspad_process_xml(void* elem, char* tag, char* content){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 (void)elem;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 if(tag != NULL && content != NULL){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 if(strcmp(content, "")){
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
34
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 /* process atom: */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 if(!strcmp(tag, "base_port")){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 base_port = atoi(content);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 return 1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 }
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
40
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 else if(!strcmp(tag, "uinput_dev")){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 if(uinput_dev != NULL) free(uinput_dev);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 uinput_dev = (char*)malloc(strlen(content)+1);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 strcpy(uinput_dev, content);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 return 1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 else if(!strcmp(tag, "nb_pad")){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 nbdev = atoi(content);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 return 1;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 }
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
52
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 return ReadXML(elem, dspad_process_xml, content);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 }
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
56
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57 /* Should not happend... (compiler warning) */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58 return 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 Read config file
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65 returns 1 OK
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66 0 error
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
67 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 int config_read(char* path){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
69 int ok = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70 char* text = NULL;
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
71
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
72 text = LoadFile(path);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
73 if(text){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74 ok = ReadXML(NULL, dspad_process_xml, text);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 free(text);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76 if(ok){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77 fprintf(stderr, "Reading \"%s\" OK\n", path);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
79 else{
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 fprintf(stderr, "Reading \"%s\" FAILED\n", path);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
81 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
82 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
83 return ok;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
84 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
85
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
87
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
88
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
89 int main(int argc, char** argv){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
90 /* -- gcc -Werror satisfaction... -- */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91 (void)argc;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
92 (void)argv;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
93 /* --------------------------------- */
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
94
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
95 curdev = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
96
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97 fprintf(stdout, "\n--- Starting DSPad Server v0.2 ---\n");
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
98
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
99 pid_t pid = 0;
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
100
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 if(argc == 3 && !strcmp("-f", argv[1])){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102 fprintf(stderr, "Loading \"%s\"\n", argv[2]);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 config_read(argv[2]);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
105 else{
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 fprintf(stderr, "Loading \"%s\"\n", DEFAULT_PATH);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107 config_read(DEFAULT_PATH);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108 }
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
109
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
110
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
111
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 /* fork servers */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113 while(curdev < nbdev){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
114 pid = fork_rs();
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115 switch(pid){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 case 0:
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117 curdev++;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 // Wait 2 seconds before next because
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 // of kernel dev creation latency
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 sleep_rs(2);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 break;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 case -1:
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
123 fprintf(stderr, " [%d] Creation of service: failed\n", curdev);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
124 exit(EXIT_FAILURE);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 break;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126 default:
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127 start_service();
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
128 sleep(5);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
129 fprintf(stdout, " [%d] Service finished\n", curdev);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
130 waitpid(-1, NULL, 0);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
131 exit(EXIT_SUCCESS);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
132 break;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
133 } /* switch */
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
134 }
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
135
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
136 return 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
137 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
138