annotate restartOp.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 Signal interruptible fonctions handlers
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 */
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 #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
6 #include <unistd.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 #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
8 #include <sys/ipc.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 #include <sys/sem.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 #include <sys/msg.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 #include <errno.h>
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 #include "restartOp.h"
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 /* fork */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 pid_t fork_rs(void){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 pid_t result;
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 do{
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 result = fork();
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 }while((result == -1) && (errno == EAGAIN));
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 return result;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 }
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 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 /* wait, waitpid */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 /********************************************************/
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 pid_t wait_rs(int *status)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 pid_t endPid;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 endPid=wait(status);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 } while ((endPid==-1) && (errno==EINTR));
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
39
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 return endPid;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 pid_t waitpid_rs(pid_t pid, int *status, int options)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 pid_t endPid;
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 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 endPid=waitpid(pid,status,options);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 } while ((endPid==-1) && (errno==EINTR));
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
51
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 return endPid;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 }
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
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57 /* sleep */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58 /********************************************************/
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
59
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 unsigned int sleep_rs(unsigned int seconds)
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 int nbSecondsElapsed = 0;
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
63
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 do {
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
65
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66 seconds = seconds - nbSecondsElapsed;
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
67
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 nbSecondsElapsed = sleep(seconds);
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
69
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70 } while (nbSecondsElapsed!=0);
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 return 0; // Zero if the requested time has elapsed
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
73 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77 /* read, write, close */
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 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 ssize_t read_rs(int fd, void *buf, size_t len)
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 ssize_t returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
83
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
84 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
85 returnValue = read(fd,buf,len);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86 } while ((returnValue==-1) && (errno==EINTR));
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 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
89 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
90 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
92 ssize_t write_rs(int fd, const void *buf, size_t count)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
93 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94 ssize_t returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
95
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
96 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97 returnValue = write(fd,buf,count);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
99
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
100 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 int close_rs(int fd)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
105 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
109 returnValue = close(fd);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
111
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
114 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117 /* dup, dup2 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 int dup_rs(int oldfd)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
123
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
124 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 returnValue = dup(oldfd);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
128 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
129 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
130 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
131 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
132 int dup2_rs(int oldfd, int newfd)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
133 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
134 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
135
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
136 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
137 returnValue = dup2(oldfd,newfd);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
138 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
139
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
140 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
141 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
142 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
143
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
144 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
145 /* semop */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
146 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
147 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
148 int semop_rs(int semid, struct sembuf *sops,unsigned nsops)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
149 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
150 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
151
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
152 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
153 returnValue = semop(semid,sops,nsops);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
154 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
155
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
156 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
157 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
158 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
159
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
160 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
161 /* msgsnd, msgrcv */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
162 /********************************************************/
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
163 /*
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
164 int msgsnd_rs(int msqid, void *msgp, int msgsz, int msgflg)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
165 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
166 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
167
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
168 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
169 returnValue = msgsnd(msqid,msgp,msgsz,msgflg);
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
170 } while ((returnValue==-1) && (errno==EINTR));
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
171
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
172 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
173 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
174 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
175 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
176 int msgrcv_rs(int msqid, void *msgp, int msgsz,long msgtyp,int msgflg)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
177 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
178 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
179
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
180 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
181 returnValue = msgrcv(msqid,msgp,msgsz,msgtyp,msgflg);
2
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
182 } while ((returnValue==-1) && (errno==EINTR));
f362b20de51e Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
183
0
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
184 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
185 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
186 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
187
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
188 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
189 /* connect, accept */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
190 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
191 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
192 int connect_rs(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
193 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
194 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
195
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
196 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
197 returnValue = connect(sockfd,serv_addr,addrlen);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
198 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
199
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
200 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
201 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
202 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
203 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
204 int accept_rs(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
205 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
206 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
207 int addrlenSaved = *addrlen;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
208
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
209 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
210 *addrlen = addrlenSaved;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
211 returnValue = accept(sockfd,addr,addrlen);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
212 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
213
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
214 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
215 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
216 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
217
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
218 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
219 /* recv, send (TCP ou UDP avec pseudo-connexions) */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
220 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
221 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
222 ssize_t recv_rs(int sockfd, void *buf, size_t len, int flags)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
223 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
224 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
225
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
226 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
227 returnValue = recv(sockfd,buf,len,flags);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
228 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
229
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
230 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
231 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
232 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
233 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
234 ssize_t send_rs(int sockfd, const void *buf, size_t count, int flags)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
235 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
236 int returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
237
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
238 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
239 returnValue = send(sockfd,buf,count,flags);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
240 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
241
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
242 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
243 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
244 */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
245
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
246 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
247 /* recvfrom, sendto (UDP) */
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
248 /********************************************************/
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
249
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
250 ssize_t recvfrom_rs(int sockfd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen){
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
251 ssize_t returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
252 do{
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
253 returnValue = recvfrom(sockfd, buf, len, flags, from, fromlen);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
254 }while( (returnValue == -1) && (errno == EINTR) );
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
255
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
256 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
257 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
258
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
259 /*
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
260 ssize_t sendto_rs(int sockfd, const void *msg, size_t count, int flags,
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
261 const struct sockaddr *to, socklen_t tolen)
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
262 {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
263 ssize_t returnValue = 0;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
264 do {
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
265 returnValue = sendto(sockfd,msg,count,flags,to,tolen);
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
266 } while ((returnValue==-1) && (errno==EINTR));
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
267
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
268 return returnValue;
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
269 }
e70ea46d6073 Initial import from http://wouhanegaine.free.fr/dev/DSPad02b_neo07.zip
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
270 */