author | viric@llimona |
Tue, 27 Mar 2007 23:29:56 +0200 | |
changeset 58 | 3c492266923e |
parent 49 | 09bb8a5583e9 |
child 92 | 05004c52ecff |
permissions | -rw-r--r-- |
49 | 1 |
/* |
2 |
Task Spooler - a task queue system for the unix user |
|
3 |
Copyright (C) 2007 LluĂs Batlle i Rossell |
|
4 |
||
5 |
Please find the license in the provided COPYING file. |
|
6 |
*/ |
|
44 | 7 |
#include <sys/types.h> |
8 |
#include <sys/socket.h> |
|
9 |
#include <stdio.h> |
|
10 |
#include <stdlib.h> |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
11 |
#include "msg.h" |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
12 |
|
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
13 |
void send_bytes(const int fd, const char *data, const int bytes) |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
14 |
{ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
15 |
int res; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
16 |
/* Send the message */ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
17 |
res = send(fd, data, bytes, 0); |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
18 |
if(res == -1) |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
19 |
{ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
20 |
perror("c: send"); |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
21 |
exit(-1); |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
22 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
23 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
24 |
|
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
25 |
int recv_bytes(const int fd, char *data, const int bytes) |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
26 |
{ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
27 |
int res; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
28 |
/* Send the message */ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
29 |
res = recv(fd, data, bytes, 0); |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
30 |
|
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
31 |
return res; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
32 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
33 |
|
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
34 |
void send_msg(const int fd, const struct msg *m) |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
35 |
{ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
36 |
int res; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
37 |
/* Send the message */ |
32 | 38 |
msgdump(m); |
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
39 |
res = send(fd, m, sizeof(*m), 0); |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
40 |
if(res == -1) |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
41 |
{ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
42 |
perror("c: send"); |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
43 |
exit(-1); |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
44 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
45 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
46 |
|
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
47 |
int recv_msg(const int fd, struct msg *m) |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
48 |
{ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
49 |
int res; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
50 |
/* Send the message */ |
21 | 51 |
res = recv(fd, m, sizeof(*m), 0); |
32 | 52 |
if (res == sizeof(*m)) |
53 |
msgdump(m); |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
54 |
|
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
55 |
return res; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
diff
changeset
|
56 |
} |