From 66b821be62a1ecc9eab5c4a05c0c11adf81914bb Mon Sep 17 00:00:00 2001
From: Philippe PITTOLI
Date: Wed, 3 Oct 2018 22:02:37 +0200
Subject: [PATCH] cleaning names
---
core-test/app/array_proc.c | 18 +++++-----
core-test/app/communication-client.c | 4 +--
core-test/app/communication-server.c | 8 ++---
core/communication.c | 46 ++++++++++++------------
core/communication.h | 14 ++++----
core/msg.c | 20 +++++------
core/msg.h | 20 +++++------
core/process.c | 26 +++++++-------
core/process.h | 22 ++++++------
drop/init-connection.c | 4 +--
drop/pass-socket_client.c | 2 +-
drop/pass-socket_server.c | 2 +-
man/communication.h.3 | 14 ++++----
pong/app/pong.c | 8 ++---
pong/app/pongd.c | 36 +++++++++----------
pubsub/lib/channels.c | 22 ++++++------
pubsub/lib/channels.h | 12 +++----
pubsub/lib/pubsub.c | 8 ++---
pubsub/lib/pubsubd.c | 48 +++++++++++++-------------
pubsub/lib/pubsubd.h | 2 +-
pubsub/tests/channels.c | 10 +++---
pubsub/tests/pubsub-test-send-params.c | 8 ++---
pubsub/tests/pubsub-test-send.c | 4 +--
remote/lib/remotec.c | 8 ++---
remote/lib/remoted.c | 36 +++++++++----------
tcp/app/tcpd.c | 6 ++--
tcp/app/tcpd.h | 2 +-
27 files changed, 205 insertions(+), 205 deletions(-)
diff --git a/core-test/app/array_proc.c b/core-test/app/array_proc.c
index 0d64685..51fe6a6 100644
--- a/core-test/app/array_proc.c
+++ b/core-test/app/array_proc.c
@@ -5,30 +5,30 @@
int main()
{
int ret;
- struct array_proc tab_proc;
- memset(&tab_proc, 0, sizeof(struct array_proc));
+ struct ipc_process_array tab_proc;
+ memset(&tab_proc, 0, sizeof(struct ipc_process_array));
- struct process process_tab[5];
- memset(&process_tab, 0, sizeof(struct process) * 5);
+ struct ipc_process process_tab[5];
+ memset(&process_tab, 0, sizeof(struct ipc_process) * 5);
int i;
for (i = 0; i < 5; i++) {
process_tab[i].proc_fd = i;
- ret = add_proc(&tab_proc, &process_tab[i]);
+ ret = ipc_process_add(&tab_proc, &process_tab[i]);
if (ret == -1) {
printf("erreur realloc\n");
}
}
- array_proc_print(&tab_proc);
+ ipc_process_array_print(&tab_proc);
- ret = del_proc(&tab_proc, &process_tab[2]);
+ ret = ipc_process_del(&tab_proc, &process_tab[2]);
if(ret < 0) {
printf("erreur %d\n", ret );
}
- array_proc_print(&tab_proc);
+ ipc_process_array_print(&tab_proc);
- array_proc_free (&tab_proc);
+ ipc_process_array_free (&tab_proc);
return 0;
}
diff --git a/core-test/app/communication-client.c b/core-test/app/communication-client.c
index c996bb6..3c5551a 100644
--- a/core-test/app/communication-client.c
+++ b/core-test/app/communication-client.c
@@ -12,8 +12,8 @@
int main (int argc, char *argv[], char *env[])
{
- struct msg m;
- memset (&m, 0, sizeof (struct msg));
+ struct ipc_message m;
+ memset (&m, 0, sizeof (struct ipc_message));
struct service srv;
memset (&srv, 0, sizeof (struct service));
diff --git a/core-test/app/communication-server.c b/core-test/app/communication-server.c
index c5c3a44..2ad6550 100644
--- a/core-test/app/communication-server.c
+++ b/core-test/app/communication-server.c
@@ -11,8 +11,8 @@
int main (int argc, char *argv[], char *env[])
{
- struct msg m;
- memset (&m, 0, sizeof (struct msg));
+ struct ipc_message m;
+ memset (&m, 0, sizeof (struct ipc_message));
struct service srv;
memset(&srv, 0, sizeof (struct service));
@@ -20,8 +20,8 @@ int main (int argc, char *argv[], char *env[])
srv.index = 0;
srv.version = 0;
- struct process p;
- memset (&p, 0, sizeof (struct process));
+ struct ipc_process p;
+ memset (&p, 0, sizeof (struct ipc_process));
// init service
if (server_init (argc, argv, env, &srv, SERVICE_NAME) < 0) {
diff --git a/core/communication.c b/core/communication.c
index 113d3bd..c04185c 100644
--- a/core/communication.c
+++ b/core/communication.c
@@ -37,21 +37,21 @@ int ipc_server_init (int argc, char **argv, char **env
return usock_init (&srv->service_fd, srv->spath);
}
-int ipc_server_accept (struct service *srv, struct process *p)
+int ipc_server_accept (struct service *srv, struct ipc_process *p)
{
assert (srv != NULL);
assert (p != NULL);
usock_accept (srv->service_fd, &p->proc_fd);
- struct msg m_con;
- memset (&m_con, 0, sizeof (struct msg));
+ struct ipc_message m_con;
+ memset (&m_con, 0, sizeof (struct ipc_message));
ipc_server_read (p, &m_con);
// TODO: handle the parameters in the first message
ipc_message_free (&m_con);
- struct msg m_ack;
- memset (&m_ack, 0, sizeof (struct msg));
+ struct ipc_message m_ack;
+ memset (&m_ack, 0, sizeof (struct ipc_message));
ipc_message_format_ack (&m_ack, NULL, 0);
ipc_server_write (p, &m_ack);
ipc_message_free (&m_ack);
@@ -65,10 +65,10 @@ int ipc_server_close (struct service *srv)
return usock_remove (srv->spath);
}
-int ipc_server_close_proc (struct process *p)
+int ipc_server_close_proc (struct ipc_process *p)
{
- // struct msg m_ack_dis;
- // memset (&m_ack_dis, 0, sizeof (struct msg));
+ // struct ipc_message m_ack_dis;
+ // memset (&m_ack_dis, 0, sizeof (struct ipc_message));
// m_ack_dis.type = MSG_TYPE_CLOSE;
// if (ipc_message_write (p->proc_fd, &m_ack_dis) < 0) {
@@ -78,12 +78,12 @@ int ipc_server_close_proc (struct process *p)
return usock_close (p->proc_fd);
}
-int ipc_server_read (const struct process *p, struct msg *m)
+int ipc_server_read (const struct ipc_process *p, struct ipc_message *m)
{
return ipc_message_read (p->proc_fd, m);
}
-int ipc_server_write (const struct process *p, const struct msg *m)
+int ipc_server_write (const struct ipc_process *p, const struct ipc_message *m)
{
return ipc_message_write (p->proc_fd, m);
}
@@ -109,8 +109,8 @@ int ipc_application_connection (int argc, char **argv, char **env
usock_connect (&srv->service_fd, srv->spath);
// send connection string and receive acknowledgement
- struct msg m_con;
- memset (&m_con, 0, sizeof (struct msg));
+ struct ipc_message m_con;
+ memset (&m_con, 0, sizeof (struct ipc_message));
// format the connection msg
if (ipc_message_format_con (&m_con, connectionstr, msize) < 0) {
@@ -123,8 +123,8 @@ int ipc_application_connection (int argc, char **argv, char **env
ipc_message_free (&m_con);
// receive ack msg
- struct msg m_ack;
- memset (&m_ack, 0, sizeof (struct msg));
+ struct ipc_message m_ack;
+ memset (&m_ack, 0, sizeof (struct ipc_message));
ipc_application_read (srv, &m_ack);
assert (m_ack.type == MSG_TYPE_ACK);
@@ -137,8 +137,8 @@ int ipc_application_connection (int argc, char **argv, char **env
// send a CLOSE message then close the socket
int ipc_application_close (struct service *srv)
{
- struct msg m;
- memset (&m, 0, sizeof (struct msg));
+ struct ipc_message m;
+ memset (&m, 0, sizeof (struct ipc_message));
m.type = MSG_TYPE_CLOSE;
if (ipc_message_write (srv->service_fd, &m) < 0) {
handle_err ("application_close", "ipc_message_write < 0");
@@ -147,19 +147,19 @@ int ipc_application_close (struct service *srv)
return usock_close (srv->service_fd);
}
-int ipc_application_read (struct service *srv, struct msg *m)
+int ipc_application_read (struct service *srv, struct ipc_message *m)
{
return ipc_message_read (srv->service_fd, m);
}
-int ipc_application_write (struct service *srv, const struct msg *m)
+int ipc_application_write (struct service *srv, const struct ipc_message *m)
{
return ipc_message_write (srv->service_fd, m);
}
/*calculer le max filedescriptor*/
-int getMaxFd(struct array_proc *ap)
+int getMaxFd(struct ipc_process_array *ap)
{
int i;
@@ -187,14 +187,14 @@ int getMaxFd(struct array_proc *ap)
* * les deux à la fois (CON_APP)
*/
-int ipc_server_select (struct array_proc *ap, struct service *srv
- , struct array_proc *proc)
+int ipc_server_select (struct ipc_process_array *ap, struct service *srv
+ , struct ipc_process_array *proc)
{
assert (ap != NULL);
assert (proc != NULL);
// delete previous read process array
- array_proc_free (proc);
+ ipc_process_array_free (proc);
int i, j;
/* master file descriptor list */
@@ -239,7 +239,7 @@ int ipc_server_select (struct array_proc *ap, struct service *srv
for(j = 0; j < ap->size; j++) {
// printf ("loop ipc_server_select inner inner loop\n");
if(i == ap->tab_proc[j]->proc_fd ) {
- add_proc (proc, ap->tab_proc[j]);
+ ipc_process_add (proc, ap->tab_proc[j]);
}
}
}
diff --git a/core/communication.h b/core/communication.h
index a6813b8..0927270 100644
--- a/core/communication.h
+++ b/core/communication.h
@@ -37,13 +37,13 @@ struct service {
int ipc_server_init (int argc, char **argv, char **env
, struct service *srv, const char *sname);
int ipc_server_close (struct service *srv);
-int ipc_server_close_proc (struct process *p);
-int ipc_server_accept (struct service *srv, struct process *p);
+int ipc_server_close_proc (struct ipc_process *p);
+int ipc_server_accept (struct service *srv, struct ipc_process *p);
-int ipc_server_read (const struct process *, struct msg *m);
-int ipc_server_write (const struct process *, const struct msg *m);
+int ipc_server_read (const struct ipc_process *, struct ipc_message *m);
+int ipc_server_write (const struct ipc_process *, const struct ipc_message *m);
-int ipc_server_select (struct array_proc *, struct service *, struct array_proc *);
+int ipc_server_select (struct ipc_process_array *, struct service *, struct ipc_process_array *);
// APPLICATION
@@ -54,8 +54,8 @@ int ipc_application_connection (int argc, char **argv, char **env
, struct service *, const char *, const char *, size_t);
int ipc_application_close (struct service *);
-int ipc_application_read (struct service *srv, struct msg *m);
-int ipc_application_write (struct service *, const struct msg *m);
+int ipc_application_read (struct service *srv, struct ipc_message *m);
+int ipc_application_write (struct service *, const struct ipc_message *m);
diff --git a/core/msg.c b/core/msg.c
index 4375b6f..e68b6d1 100644
--- a/core/msg.c
+++ b/core/msg.c
@@ -4,13 +4,13 @@
#include
-void ipc_message_print (const struct msg *m)
+void ipc_message_print (const struct ipc_message *m)
{
assert (m != NULL);
printf ("msg: type %d len %d\n", m->type, m->valsize);
}
-int ipc_message_format_read (struct msg *m, const char *buf, size_t msize)
+int ipc_message_format_read (struct ipc_message *m, const char *buf, size_t msize)
{
assert (m != NULL);
assert (buf != NULL);
@@ -37,7 +37,7 @@ int ipc_message_format_read (struct msg *m, const char *buf, size_t msize)
return 0;
}
-int ipc_message_format_write (const struct msg *m, char **buf, size_t *msize)
+int ipc_message_format_write (const struct ipc_message *m, char **buf, size_t *msize)
{
assert (m != NULL);
assert (buf != NULL);
@@ -68,7 +68,7 @@ int ipc_message_format_write (const struct msg *m, char **buf, size_t *msize)
return 0;
}
-int ipc_message_read (int fd, struct msg *m)
+int ipc_message_read (int fd, struct ipc_message *m)
{
assert (m != NULL);
@@ -89,7 +89,7 @@ int ipc_message_read (int fd, struct msg *m)
return 0;
}
-int ipc_message_write (int fd, const struct msg *m)
+int ipc_message_write (int fd, const struct ipc_message *m)
{
assert (m != NULL);
@@ -111,7 +111,7 @@ int ipc_message_write (int fd, const struct msg *m)
// MSG FORMAT
-int ipc_message_format (struct msg *m, char type, const char *val, size_t valsize)
+int ipc_message_format (struct ipc_message *m, char type, const char *val, size_t valsize)
{
assert (m != NULL);
assert (valsize + 3 <= BUFSIZ);
@@ -132,22 +132,22 @@ int ipc_message_format (struct msg *m, char type, const char *val, size_t valsiz
return 0;
}
-int ipc_message_format_con (struct msg *m, const char *val, size_t valsize)
+int ipc_message_format_con (struct ipc_message *m, const char *val, size_t valsize)
{
return ipc_message_format (m, MSG_TYPE_CON, val, valsize);
}
-int ipc_message_format_data (struct msg *m, const char *val, size_t valsize)
+int ipc_message_format_data (struct ipc_message *m, const char *val, size_t valsize)
{
return ipc_message_format (m, MSG_TYPE_DATA, val, valsize);
}
-int ipc_message_format_ack (struct msg *m, const char *val, size_t valsize)
+int ipc_message_format_ack (struct ipc_message *m, const char *val, size_t valsize)
{
return ipc_message_format (m, MSG_TYPE_ACK, val, valsize);
}
-int ipc_message_free (struct msg *m)
+int ipc_message_free (struct ipc_message *m)
{
assert (m != NULL);
diff --git a/core/msg.h b/core/msg.h
index 488a877..2242a15 100644
--- a/core/msg.h
+++ b/core/msg.h
@@ -11,27 +11,27 @@
#define MSG_TYPE_ACK 3
#define MSG_TYPE_DATA 4
-struct msg {
+struct ipc_message {
char type;
unsigned short valsize;
char *val;
};
// used to create msg structure from buffer
-int ipc_message_format_read (struct msg *m, const char *buf, size_t msize);
+int ipc_message_format_read (struct ipc_message *m, const char *buf, size_t msize);
// used to create buffer from msg structure
-int ipc_message_format_write (const struct msg *m, char **buf, size_t *msize);
+int ipc_message_format_write (const struct ipc_message *m, char **buf, size_t *msize);
// read a structure msg from fd
-int ipc_message_read (int fd, struct msg *m);
+int ipc_message_read (int fd, struct ipc_message *m);
// write a structure msg to fd
-int ipc_message_write (int fd, const struct msg *m);
+int ipc_message_write (int fd, const struct ipc_message *m);
-int ipc_message_format_con (struct msg *m, const char *val, size_t valsize);
-int ipc_message_format_data (struct msg *m, const char *val, size_t valsize);
-int ipc_message_format_ack (struct msg *m, const char *val, size_t valsize);
+int ipc_message_format_con (struct ipc_message *m, const char *val, size_t valsize);
+int ipc_message_format_data (struct ipc_message *m, const char *val, size_t valsize);
+int ipc_message_format_ack (struct ipc_message *m, const char *val, size_t valsize);
-int ipc_message_free (struct msg *m);
-void ipc_message_print (const struct msg *m);
+int ipc_message_free (struct ipc_message *m);
+void ipc_message_print (const struct ipc_message *m);
#endif
diff --git a/core/process.c b/core/process.c
index ef7e47a..3e39f74 100644
--- a/core/process.c
+++ b/core/process.c
@@ -5,37 +5,37 @@
#include
-struct process * ipc_server_process_copy (const struct process *p)
+struct ipc_process * ipc_server_process_copy (const struct ipc_process *p)
{
if (p == NULL)
return NULL;
- struct process * copy = malloc (sizeof(struct process));
- memcpy (copy, p, sizeof (struct process));
+ struct ipc_process * copy = malloc (sizeof(struct ipc_process));
+ memcpy (copy, p, sizeof (struct ipc_process));
return copy;
}
-int ipc_server_process_eq (const struct process *p1, const struct process *p2)
+int ipc_server_process_eq (const struct ipc_process *p1, const struct ipc_process *p2)
{
return (p1->version == p2->version && p1->index == p2->index
&& p1->proc_fd == p2->proc_fd);
}
-void ipc_server_process_gen (struct process *p
+void ipc_server_process_gen (struct ipc_process *p
, unsigned int index, unsigned int version)
{
p->version = version;
p->index = index;
}
-int add_proc (struct array_proc *aproc, struct process *p)
+int ipc_process_add (struct ipc_process_array *aproc, struct ipc_process *p)
{
assert(aproc != NULL);
assert(p != NULL);
aproc->size++;
aproc->tab_proc = realloc(aproc->tab_proc
- , sizeof(struct process) * aproc->size);
+ , sizeof(struct ipc_process) * aproc->size);
if (aproc->tab_proc == NULL) {
return -1;
@@ -45,7 +45,7 @@ int add_proc (struct array_proc *aproc, struct process *p)
return 0;
}
-int del_proc (struct array_proc *aproc, struct process *p)
+int ipc_process_del (struct ipc_process_array *aproc, struct ipc_process *p)
{
assert(aproc != NULL);
assert(p != NULL);
@@ -61,11 +61,11 @@ int del_proc (struct array_proc *aproc, struct process *p)
aproc->tab_proc[i] = aproc->tab_proc[aproc->size-1];
aproc->size--;
if (aproc->size == 0) {
- array_proc_free (aproc);
+ ipc_process_array_free (aproc);
}
else {
aproc->tab_proc = realloc(aproc->tab_proc
- , sizeof(struct process) * aproc->size);
+ , sizeof(struct ipc_process) * aproc->size);
if (aproc->tab_proc == NULL) {
return -2;
@@ -79,14 +79,14 @@ int del_proc (struct array_proc *aproc, struct process *p)
return -3;
}
-void process_print (struct process *p)
+void process_print (struct ipc_process *p)
{
if (p != NULL)
printf ("process %d : index %d, version %d\n"
, p->proc_fd, p->index, p->version);
}
-void array_proc_print (struct array_proc *ap)
+void ipc_process_array_print (struct ipc_process_array *ap)
{
int i;
for (i = 0; i < ap->size; i++) {
@@ -95,7 +95,7 @@ void array_proc_print (struct array_proc *ap)
}
}
-void array_proc_free (struct array_proc *ap)
+void ipc_process_array_free (struct ipc_process_array *ap)
{
if (ap->tab_proc != NULL) {
free (ap->tab_proc);
diff --git a/core/process.h b/core/process.h
index 6a96114..a56f9e3 100644
--- a/core/process.h
+++ b/core/process.h
@@ -1,28 +1,28 @@
#ifndef __IPC_PROCESS_H__
#define __IPC_PROCESS_H__
-struct process {
+struct ipc_process {
unsigned int version;
unsigned int index;
int proc_fd;
};
-struct array_proc {
- struct process **tab_proc;
+struct ipc_process_array {
+ struct ipc_process **tab_proc;
int size;
};
-int add_proc (struct array_proc *, struct process *);
-int del_proc (struct array_proc *aproc, struct process *p);
+int ipc_process_add (struct ipc_process_array *, struct ipc_process *);
+int ipc_process_del (struct ipc_process_array *aproc, struct ipc_process *p);
-void array_proc_print (struct array_proc *);
-void array_proc_free (struct array_proc *);
+void ipc_process_array_print (struct ipc_process_array *);
+void ipc_process_array_free (struct ipc_process_array *);
-struct process * ipc_server_process_copy (const struct process *p);
-int ipc_server_process_eq (const struct process *p1, const struct process *p2);
+struct ipc_process * ipc_server_process_copy (const struct ipc_process *p);
+int ipc_server_process_eq (const struct ipc_process *p1, const struct ipc_process *p2);
// create the service process structure
-void ipc_server_process_gen (struct process *p
+void ipc_server_process_gen (struct ipc_process *p
, unsigned int index, unsigned int version);
-void process_print (struct process *);
+void process_print (struct ipc_process *);
#endif
diff --git a/drop/init-connection.c b/drop/init-connection.c
index 07a0302..220dc4f 100644
--- a/drop/init-connection.c
+++ b/drop/init-connection.c
@@ -23,8 +23,8 @@ int main(int argc, char * argv[], char *env[])
* PROCESS
*/
- struct process p;
- memset (&p, 0, sizeof (struct process));
+ struct ipc_process p;
+ memset (&p, 0, sizeof (struct ipc_process));
int index = 0; // first time we communication with the service
int version = 1;
diff --git a/drop/pass-socket_client.c b/drop/pass-socket_client.c
index 1b96401..ebe3d8d 100644
--- a/drop/pass-socket_client.c
+++ b/drop/pass-socket_client.c
@@ -66,7 +66,7 @@ void log_debug (const char* message, ...) {
static
int recvsockfd (int socket) // receive fd from socket
{
- struct msghdr msg = {0};
+ struct ipc_messagehdr msg = {0};
/* On Mac OS X, the struct iovec is needed, even if it points to minimal data */
char m_buffer[1];
diff --git a/drop/pass-socket_server.c b/drop/pass-socket_server.c
index fc35280..e1259f5 100644
--- a/drop/pass-socket_server.c
+++ b/drop/pass-socket_server.c
@@ -247,7 +247,7 @@ int build_unix_socket (char * path)
static
void sendfd (int socket, int fd) // send fd by socket
{
- struct msghdr msg = { 0 };
+ struct ipc_messagehdr msg = { 0 };
char buf[CMSG_SPACE(sizeof(fd))];
memset(buf, '\0', sizeof(buf));
diff --git a/man/communication.h.3 b/man/communication.h.3
index 19516d1..d044acd 100644
--- a/man/communication.h.3
+++ b/man/communication.h.3
@@ -7,21 +7,21 @@ communication.h \- all functions explained
.sp
.BI "int ipc_server_init (int "argc ", char **" argv ", char **" env ", struct service *" srv "
.BI " , const char *" service_name );
-.BI "int ipc_server_accept (struct service *" srv ", struct process *" p );
+.BI "int ipc_server_accept (struct service *" srv ", struct ipc_process *" p );
.sp
-.BI "int ipc_server_read (const struct process *" p ", struct msg *" message );
-.BI "int ipc_server_write (const struct process *" p ", const struct msg *" message );
+.BI "int ipc_server_read (const struct ipc_process *" p ", struct ipc_message *" message );
+.BI "int ipc_server_write (const struct ipc_process *" p ", const struct ipc_message *" message );
.sp
.BI "int ipc_server_close (struct service *" srv );
-.BI "int ipc_server_close_proc (struct process *" p );
-.BI "int ipc_server_select (struct array_proc *" fds ", struct service *" srv ", struct array_proc *" readfds );
+.BI "int ipc_server_close_proc (struct ipc_process *" p );
+.BI "int ipc_server_select (struct ipc_process_array *" fds ", struct service *" srv ", struct ipc_process_array *" readfds );
.BI "int ipc_application_connection (int " argc ", char **" argv ", char **" env ", struct service *" srv
.BI " , const char *" service_name "
.BI " , const char *" connection_buffer ", size_t " bufsize );
.sp
-.BI "int ipc_application_read (const struct service *" srv ", struct msg *" message );
-.BI "int ipc_application_write (const struct service *" srv ", const struct msg *" message );
+.BI "int ipc_application_read (const struct service *" srv ", struct ipc_message *" message );
+.BI "int ipc_application_write (const struct service *" srv ", const struct ipc_message *" message );
.sp
.BI "int ipc_application_close (struct service *" srv );
diff --git a/pong/app/pong.c b/pong/app/pong.c
index 7df42e5..a5d81b4 100644
--- a/pong/app/pong.c
+++ b/pong/app/pong.c
@@ -12,8 +12,8 @@
void non_interactive (int argc, char *argv[], char *env[])
{
- struct msg m;
- memset (&m, 0, sizeof (struct msg));
+ struct ipc_message m;
+ memset (&m, 0, sizeof (struct ipc_message));
struct service srv;
memset (&srv, 0, sizeof (struct service));
@@ -53,8 +53,8 @@ void non_interactive (int argc, char *argv[], char *env[])
void interactive (int argc, char *argv[], char *env[])
{
- struct msg m;
- memset (&m, 0, sizeof (struct msg));
+ struct ipc_message m;
+ memset (&m, 0, sizeof (struct ipc_message));
struct service srv;
memset (&srv, 0, sizeof (struct service));
diff --git a/pong/app/pongd.c b/pong/app/pongd.c
index 1d4987f..b5385c7 100644
--- a/pong/app/pongd.c
+++ b/pong/app/pongd.c
@@ -10,10 +10,10 @@
int cpt = 0;
-void handle_new_connection (struct service *srv, struct array_proc *ap)
+void handle_new_connection (struct service *srv, struct ipc_process_array *ap)
{
- struct process *p = malloc(sizeof(struct process));
- memset(p, 0, sizeof(struct process));
+ struct ipc_process *p = malloc(sizeof(struct ipc_process));
+ memset(p, 0, sizeof(struct ipc_process));
if (ipc_server_accept (srv, p) < 0) {
handle_error("server_accept < 0");
@@ -21,18 +21,18 @@ void handle_new_connection (struct service *srv, struct array_proc *ap)
printf("new connection\n");
}
- if (add_proc (ap, p) < 0) {
- handle_error("add_proc < 0");
+ if (ipc_process_add (ap, p) < 0) {
+ handle_error("ipc_process_add < 0");
}
cpt++;
printf ("%d client(s)\n", cpt);
}
-void handle_new_msg (struct array_proc *ap, struct array_proc *proc_to_read)
+void handle_new_msg (struct ipc_process_array *ap, struct ipc_process_array *proc_to_read)
{
- struct msg m;
- memset (&m, 0, sizeof (struct msg));
+ struct ipc_message m;
+ memset (&m, 0, sizeof (struct ipc_message));
int i;
for (i = 0; i < proc_to_read->size; i++) {
// printf ("loop handle_new_msg\n");
@@ -47,10 +47,10 @@ void handle_new_msg (struct array_proc *ap, struct array_proc *proc_to_read)
if (ipc_server_close_proc (proc_to_read->tab_proc[i]) < 0)
handle_err( "handle_new_msg", "server_close_proc < 0");
- if (del_proc (ap, proc_to_read->tab_proc[i]) < 0)
- handle_err( "handle_new_msg", "del_proc < 0");
- if (del_proc (proc_to_read, proc_to_read->tab_proc[i]) < 0)
- handle_err( "handle_new_msg", "del_proc < 0");
+ if (ipc_process_del (ap, proc_to_read->tab_proc[i]) < 0)
+ handle_err( "handle_new_msg", "ipc_process_del < 0");
+ if (ipc_process_del (proc_to_read, proc_to_read->tab_proc[i]) < 0)
+ handle_err( "handle_new_msg", "ipc_process_del < 0");
i--;
continue;
}
@@ -74,16 +74,16 @@ void main_loop (struct service *srv)
{
int i, ret = 0;
- struct array_proc ap;
- memset(&ap, 0, sizeof(struct array_proc));
+ struct ipc_process_array ap;
+ memset(&ap, 0, sizeof(struct ipc_process_array));
- struct array_proc proc_to_read;
- memset(&proc_to_read, 0, sizeof(struct array_proc));
+ struct ipc_process_array proc_to_read;
+ memset(&proc_to_read, 0, sizeof(struct ipc_process_array));
while(1) {
ret = ipc_server_select (&ap, srv, &proc_to_read);
// printf ("on peut lire ces process:\n");
- // array_proc_print (&proc_to_read);
+ // ipc_process_array_print (&proc_to_read);
// printf ("-- \n\n");
if (ret == CONNECTION) {
@@ -94,7 +94,7 @@ void main_loop (struct service *srv)
handle_new_connection (srv, &ap);
handle_new_msg (&ap, &proc_to_read);
}
- array_proc_free (&proc_to_read);
+ ipc_process_array_free (&proc_to_read);
}
for (i = 0; i < ap.size; i++) {
diff --git a/pubsub/lib/channels.c b/pubsub/lib/channels.c
index 64e0aa3..6984d3d 100644
--- a/pubsub/lib/channels.c
+++ b/pubsub/lib/channels.c
@@ -19,7 +19,7 @@ void pubsubd_channel_print (const struct channel *chan)
handle_err ("pubsubd_channel_print", "chan->subs == NULL");
}
else {
- array_proc_print (chan->subs);
+ ipc_process_array_print (chan->subs);
}
}
@@ -98,8 +98,8 @@ int pubsubd_channel_new (struct channel *c, const char * name)
memcpy (c->chan, name, nlen);
c->chanlen = nlen;
- c->subs = malloc (sizeof (struct array_proc));
- memset (c->subs, 0, sizeof (struct array_proc));
+ c->subs = malloc (sizeof (struct ipc_process_array));
+ memset (c->subs, 0, sizeof (struct ipc_process_array));
return 0;
}
@@ -115,7 +115,7 @@ void pubsubd_channel_free (struct channel * c)
}
if (c->subs != NULL) {
- array_proc_free (c->subs);
+ ipc_process_array_free (c->subs);
free (c->subs);
}
}
@@ -152,18 +152,18 @@ int pubsubd_channel_eq (const struct channel *c1, const struct channel *c2)
strncmp (c1->chan, c2->chan, c1->chanlen) == 0;
}
-void pubsubd_channel_subscribe (const struct channel *c, struct process *p)
+void pubsubd_channel_subscribe (const struct channel *c, struct ipc_process *p)
{
- add_proc (c->subs, p);
+ ipc_process_add (c->subs, p);
}
-void pubsubd_channel_unsubscribe (const struct channel *c, struct process *p)
+void pubsubd_channel_unsubscribe (const struct channel *c, struct ipc_process *p)
{
- del_proc (c->subs, p);
+ ipc_process_del (c->subs, p);
}
void pubsubd_channels_subscribe (struct channels *chans
- , char *chname, struct process *p)
+ , char *chname, struct ipc_process *p)
{
struct channel *chan = pubsubd_channel_search (chans, chname);
if (chan == NULL) {
@@ -175,7 +175,7 @@ void pubsubd_channels_subscribe (struct channels *chans
}
void pubsubd_channels_unsubscribe (struct channels *chans
- , char *chname, struct process *p)
+ , char *chname, struct ipc_process *p)
{
struct channel *chan = pubsubd_channel_search (chans, chname);
if (chan == NULL) {
@@ -186,7 +186,7 @@ void pubsubd_channels_unsubscribe (struct channels *chans
}
void pubsubd_channels_unsubscribe_everywhere (struct channels *chans
- , struct process *p)
+ , struct ipc_process *p)
{
struct channel * chan = NULL;
LIST_FOREACH(chan, chans, entries) {
diff --git a/pubsub/lib/channels.h b/pubsub/lib/channels.h
index 606a6e2..41ed156 100644
--- a/pubsub/lib/channels.h
+++ b/pubsub/lib/channels.h
@@ -12,7 +12,7 @@ LIST_HEAD(channels, channel);
struct channel {
char *chan;
size_t chanlen;
- struct array_proc *subs;
+ struct ipc_process_array *subs;
LIST_ENTRY(channel) entries;
};
@@ -32,15 +32,15 @@ void pubsubd_channels_del_all (struct channels *chans);
struct channel * pubsubd_channel_search (struct channels *chans, char *chan);
// add and remove subscribers
-void pubsubd_channel_subscribe (const struct channel *c, struct process *p);
-void pubsubd_channel_unsubscribe (const struct channel *c, struct process *p);
+void pubsubd_channel_subscribe (const struct channel *c, struct ipc_process *p);
+void pubsubd_channel_unsubscribe (const struct channel *c, struct ipc_process *p);
void pubsubd_channels_subscribe (struct channels *chans
- , char *chname, struct process *p);
+ , char *chname, struct ipc_process *p);
void pubsubd_channels_unsubscribe (struct channels *chans
- , char *chname, struct process *p);
+ , char *chname, struct ipc_process *p);
void pubsubd_channels_unsubscribe_everywhere (struct channels *chans
- , struct process *p);
+ , struct ipc_process *p);
#endif
diff --git a/pubsub/lib/pubsub.c b/pubsub/lib/pubsub.c
index 7ef12c0..bb2661b 100644
--- a/pubsub/lib/pubsub.c
+++ b/pubsub/lib/pubsub.c
@@ -57,8 +57,8 @@ int pubsub_message_send (struct service *srv, const struct pubsub_msg * m)
char * buf = NULL;
pubsub_message_serialize (m, &buf, &msize);
- struct msg m_data;
- memset (&m_data, 0, sizeof (struct msg));
+ struct ipc_message m_data;
+ memset (&m_data, 0, sizeof (struct ipc_message));
// format the connection msg
if (msg_format_data (&m_data, buf, msize) < 0) {
@@ -89,8 +89,8 @@ int pubsub_message_recv (struct service *srv, struct pubsub_msg *m)
return -1;
}
- struct msg m_recv;
- memset (&m_recv, 0, sizeof (struct msg));
+ struct ipc_message m_recv;
+ memset (&m_recv, 0, sizeof (struct ipc_message));
ipc_application_read (srv, &m_recv);
pubsub_message_unserialize (m, m_recv.val, m_recv.valsize);
diff --git a/pubsub/lib/pubsubd.c b/pubsub/lib/pubsubd.c
index edb5d19..4f7c8d8 100644
--- a/pubsub/lib/pubsubd.c
+++ b/pubsub/lib/pubsubd.c
@@ -11,7 +11,7 @@
#include
#include
-void pubsubd_send (const struct array_proc *ap, const struct pubsub_msg * m)
+void pubsubd_send (const struct ipc_process_array *ap, const struct pubsub_msg * m)
{
if (ap == NULL) {
fprintf (stderr, "pubsubd_send: ap == NULL");
@@ -27,8 +27,8 @@ void pubsubd_send (const struct array_proc *ap, const struct pubsub_msg * m)
size_t msize = 0;
pubsub_message_serialize (m, &buf, &msize);
- struct msg m_data;
- memset (&m_data, 0, sizeof (struct msg));
+ struct ipc_message m_data;
+ memset (&m_data, 0, sizeof (struct ipc_message));
ipc_message_format_data (&m_data, buf, msize);
int i;
@@ -42,10 +42,10 @@ void pubsubd_send (const struct array_proc *ap, const struct pubsub_msg * m)
}
}
-// void pubsubd_recv (struct process *p, struct pubsub_msg *m)
+// void pubsubd_recv (struct ipc_process *p, struct pubsub_msg *m)
// {
-// struct msg m_data;
-// memset (&m_data, 0, sizeof (struct msg));
+// struct ipc_message m_data;
+// memset (&m_data, 0, sizeof (struct ipc_message));
//
// // read the message from the process
// ipc_server_read (p, &m_data);
@@ -59,10 +59,10 @@ void pubsubd_send (const struct array_proc *ap, const struct pubsub_msg * m)
* new connection, once accepted the process is added to the array_proc
* structure to be checked periodically for new messages
*/
-void handle_new_connection (struct service *srv, struct array_proc *ap)
+void handle_new_connection (struct service *srv, struct ipc_process_array *ap)
{
- struct process *p = malloc(sizeof(struct process));
- memset(p, 0, sizeof(struct process));
+ struct ipc_process *p = malloc(sizeof(struct ipc_process));
+ memset(p, 0, sizeof(struct ipc_process));
if (server_accept (srv, p) < 0) {
handle_error("server_accept < 0");
@@ -70,16 +70,16 @@ void handle_new_connection (struct service *srv, struct array_proc *ap)
printf("new connection\n");
}
- if (add_proc (ap, p) < 0) {
- handle_error("add_proc < 0");
+ if (ipc_process_add (ap, p) < 0) {
+ handle_error("ipc_process_add < 0");
}
}
void handle_new_msg (struct channels *chans
- , struct array_proc *ap, struct array_proc *proc_to_read)
+ , struct ipc_process_array *ap, struct ipc_process_array *proc_to_read)
{
- struct msg m;
- memset (&m, 0, sizeof (struct msg));
+ struct ipc_message m;
+ memset (&m, 0, sizeof (struct ipc_message));
int i;
for (i = 0; i < proc_to_read->size; i++) {
// printf ("loop handle_new_msg\n");
@@ -91,7 +91,7 @@ void handle_new_msg (struct channels *chans
// close the process then delete it from the process array
if (m.type == MSG_TYPE_CLOSE) {
- struct process *p = proc_to_read->tab_proc[i];
+ struct ipc_process *p = proc_to_read->tab_proc[i];
printf ("proc %d disconnecting\n", p->proc_fd);
@@ -104,10 +104,10 @@ void handle_new_msg (struct channels *chans
// remove the process from the processes list
- if (del_proc (ap, p) < 0)
- handle_error( "del_proc < 0");
- if (del_proc (proc_to_read, p) < 0)
- handle_err( "handle_new_msg", "del_proc < 0");
+ if (ipc_process_del (ap, p) < 0)
+ handle_error( "ipc_process_del < 0");
+ if (ipc_process_del (proc_to_read, p) < 0)
+ handle_err( "handle_new_msg", "ipc_process_del < 0");
ipc_message_free (&m);
@@ -169,11 +169,11 @@ void pubsubd_main_loop (struct service *srv, struct channels *chans)
{
int i, ret = 0;
- struct array_proc ap;
- memset(&ap, 0, sizeof(struct array_proc));
+ struct ipc_process_array ap;
+ memset(&ap, 0, sizeof(struct ipc_process_array));
- struct array_proc proc_to_read;
- memset(&proc_to_read, 0, sizeof(struct array_proc));
+ struct ipc_process_array proc_to_read;
+ memset(&proc_to_read, 0, sizeof(struct ipc_process_array));
while(1) {
ret = ipc_server_select (&ap, srv, &proc_to_read);
@@ -186,7 +186,7 @@ void pubsubd_main_loop (struct service *srv, struct channels *chans)
handle_new_connection (srv, &ap);
handle_new_msg (chans, &ap, &proc_to_read);
}
- array_proc_free (&proc_to_read);
+ ipc_process_array_free (&proc_to_read);
}
for (i = 0; i < ap.size; i++) {
diff --git a/pubsub/lib/pubsubd.h b/pubsub/lib/pubsubd.h
index b74ae8b..418bfe4 100644
--- a/pubsub/lib/pubsubd.h
+++ b/pubsub/lib/pubsubd.h
@@ -10,6 +10,6 @@
#define PUBSUBD_SERVICE_NAME "pubsubd"
void pubsubd_main_loop (struct service *srv, struct channels * chans);
-void pubsubd_message_send (const struct array_proc *ap, const struct pubsub_msg * m);
+void pubsubd_message_send (const struct ipc_process_array *ap, const struct pubsub_msg * m);
#endif
diff --git a/pubsub/tests/channels.c b/pubsub/tests/channels.c
index 81de4be..95393f9 100644
--- a/pubsub/tests/channels.c
+++ b/pubsub/tests/channels.c
@@ -5,7 +5,7 @@
#include "../lib/channels.h"
#include "../../core/error.h"
-void fake_process (struct process *p
+void fake_process (struct ipc_process *p
, unsigned int index, unsigned int version, int fake_fd)
{
p->version = version;
@@ -84,10 +84,10 @@ void phase4 ()
struct channel * chan1 = pubsubd_channels_add (&chans, "chan1");
struct channel * chan2 = pubsubd_channels_add (&chans, "chan2");
- struct process proc1;
+ struct ipc_process proc1;
fake_process (&proc1, 0, 0, 1);
- struct process proc2;
+ struct ipc_process proc2;
fake_process (&proc2, 0, 0, 2);
printf ("chan1: proc1, chan2: proc2\n");
@@ -110,10 +110,10 @@ void phase5 ()
pubsubd_channels_add (&chans, "chan1");
pubsubd_channels_add (&chans, "chan2");
- struct process proc1;
+ struct ipc_process proc1;
fake_process (&proc1, 0, 0, 1);
- struct process proc2;
+ struct ipc_process proc2;
fake_process (&proc2, 0, 0, 2);
printf ("chan1 & 2 => proc1 and 2 added\n");
diff --git a/pubsub/tests/pubsub-test-send-params.c b/pubsub/tests/pubsub-test-send-params.c
index 3054aa6..7d50053 100644
--- a/pubsub/tests/pubsub-test-send-params.c
+++ b/pubsub/tests/pubsub-test-send-params.c
@@ -29,8 +29,8 @@ void sim_connection (int argc, char **argv, char **env, pid_t pid, int index, in
ipc_server_init (argc, argv, env, &srv, PUBSUB_SERVICE_NAME, NULL);
printf ("Writing on %s.\n", srv.spath);
- struct process p;
- memset (&p, 0, sizeof (struct process));
+ struct ipc_process p;
+ memset (&p, 0, sizeof (struct ipc_process));
printf ("app creation\n");
if (application_create (&p, pid, index, version)) // called by the application
@@ -85,8 +85,8 @@ void sim_disconnection (int argc, char **argv, char **env, pid_t pid, int index,
ipc_server_init (argc, argv, env, &srv, PUBSUB_SERVICE_NAME, NULL);
printf ("Disconnecting from %s.\n", srv.spath);
- struct process p;
- memset (&p, 0, sizeof (struct process));
+ struct ipc_process p;
+ memset (&p, 0, sizeof (struct ipc_process));
// create the fake process
ipc_server_process_gen (&p, pid, index, version);
diff --git a/pubsub/tests/pubsub-test-send.c b/pubsub/tests/pubsub-test-send.c
index 9e7c7c2..048fcdf 100644
--- a/pubsub/tests/pubsub-test-send.c
+++ b/pubsub/tests/pubsub-test-send.c
@@ -22,8 +22,8 @@ main(int argc, char **argv, char **env)
ipc_server_init (argc, argv, env, &srv, PUBSUB_SERVICE_NAME, NULL);
printf ("Writing on %s.\n", srv.spath);
- struct process p;
- memset (&p, 0, sizeof (struct process));
+ struct ipc_process p;
+ memset (&p, 0, sizeof (struct ipc_process));
int index = 1;
pid_t pid = getpid();
diff --git a/remote/lib/remotec.c b/remote/lib/remotec.c
index a6691e7..113351d 100644
--- a/remote/lib/remotec.c
+++ b/remote/lib/remotec.c
@@ -30,8 +30,8 @@ int remotec_message_send (struct service *srv, const struct remoted_msg * m)
char * buf = NULL;
remote_message_serialize (m, &buf, &msize);
- struct msg m_data;
- memset (&m_data, 0, sizeof (struct msg));
+ struct ipc_message m_data;
+ memset (&m_data, 0, sizeof (struct ipc_message));
// format the connection msg
if (msg_format_data (&m_data, buf, msize) < 0) {
@@ -62,8 +62,8 @@ int remotec_message_recv (struct service *srv, struct remoted_msg *m)
return -1;
}
- struct msg m_recv;
- memset (&m_recv, 0, sizeof (struct msg));
+ struct ipc_message m_recv;
+ memset (&m_recv, 0, sizeof (struct ipc_message));
ipc_application_read (srv, &m_recv);
remote_message_unserialize (m, m_recv.val, m_recv.valsize);
diff --git a/remote/lib/remoted.c b/remote/lib/remoted.c
index 5ea8082..4accf9f 100644
--- a/remote/lib/remoted.c
+++ b/remote/lib/remoted.c
@@ -15,10 +15,10 @@
* new connection, once accepted the process is added to the array_proc
* structure to be checked periodically for new messages
*/
-void handle_new_connection (struct service *srv, struct array_proc *ap)
+void handle_new_connection (struct service *srv, struct ipc_process_array *ap)
{
- struct process *p = malloc(sizeof(struct process));
- memset(p, 0, sizeof(struct process));
+ struct ipc_process *p = malloc(sizeof(struct ipc_process));
+ memset(p, 0, sizeof(struct ipc_process));
if (server_accept (srv, p) < 0) {
handle_error("server_accept < 0");
@@ -26,15 +26,15 @@ void handle_new_connection (struct service *srv, struct array_proc *ap)
log_debug ("remoted, new connection", p->proc_fd);
}
- if (add_proc (ap, p) < 0) {
- handle_error("add_proc < 0");
+ if (ipc_process_add (ap, p) < 0) {
+ handle_error("ipc_process_add < 0");
}
}
-void handle_new_msg (struct array_proc *ap, struct array_proc *proc_to_read)
+void handle_new_msg (struct ipc_process_array *ap, struct ipc_process_array *proc_to_read)
{
- struct msg m;
- memset (&m, 0, sizeof (struct msg));
+ struct ipc_message m;
+ memset (&m, 0, sizeof (struct ipc_message));
int i;
for (i = 0; i < proc_to_read->size; i++) {
if (server_read (proc_to_read->tab_proc[i], &m) < 0) {
@@ -45,7 +45,7 @@ void handle_new_msg (struct array_proc *ap, struct array_proc *proc_to_read)
// close the process then delete it from the process array
if (m.type == MSG_TYPE_CLOSE) {
- struct process *p = proc_to_read->tab_proc[i];
+ struct ipc_process *p = proc_to_read->tab_proc[i];
log_debug ("remoted, proc %d disconnecting", p->proc_fd);
@@ -54,10 +54,10 @@ void handle_new_msg (struct array_proc *ap, struct array_proc *proc_to_read)
handle_error( "server_close_proc < 0");
// remove the process from the processes list
- if (del_proc (ap, p) < 0)
- handle_error( "del_proc < 0");
- if (del_proc (proc_to_read, p) < 0)
- handle_err( "handle_new_msg", "del_proc < 0");
+ if (ipc_process_del (ap, p) < 0)
+ handle_error( "ipc_process_del < 0");
+ if (ipc_process_del (proc_to_read, p) < 0)
+ handle_err( "handle_new_msg", "ipc_process_del < 0");
ipc_message_free (&m);
@@ -114,11 +114,11 @@ void remoted_main_loop (struct service *srv, struct remoted_ctx *ctx)
log_debug ("remoted entering main loop");
int i, ret = 0;
- struct array_proc ap;
- memset(&ap, 0, sizeof(struct array_proc));
+ struct ipc_process_array ap;
+ memset(&ap, 0, sizeof(struct ipc_process_array));
- struct array_proc proc_to_read;
- memset(&proc_to_read, 0, sizeof(struct array_proc));
+ struct ipc_process_array proc_to_read;
+ memset(&proc_to_read, 0, sizeof(struct ipc_process_array));
while(1) {
/* TODO: authorizations */
@@ -132,7 +132,7 @@ void remoted_main_loop (struct service *srv, struct remoted_ctx *ctx)
handle_new_connection (srv, &ap);
handle_new_msg (&ap, &proc_to_read);
}
- array_proc_free (&proc_to_read);
+ ipc_process_array_free (&proc_to_read);
}
for (i = 0; i < ap.size; i++) {
diff --git a/tcp/app/tcpd.c b/tcp/app/tcpd.c
index 6b3152f..305f09e 100644
--- a/tcp/app/tcpd.c
+++ b/tcp/app/tcpd.c
@@ -132,7 +132,7 @@ void * service_thread(void * c_data) {
}
free(piv);
- /*struct process p;
+ /*struct ipc_process p;
ipc_application_create(&p, getpid(), cda->index, version);
ipc_server_process_print(&p);*/
//sleep(1);
@@ -663,7 +663,7 @@ void main_loop (struct service *srv) {
break;
}
- tab_req[nbclient].p = malloc(sizeof(struct process));
+ tab_req[nbclient].p = malloc(sizeof(struct ipc_process));
// -1 : error, 0 = no new process, 1 = new process
ret = ipc_server_get_new_request (buf, &tab_req[nbclient]);
tab_req[nbclient].p->proc_fd = newfd;
@@ -714,7 +714,7 @@ void main_loop (struct service *srv) {
break;
}
- tab_req[nbclient].p = malloc(sizeof(struct process));
+ tab_req[nbclient].p = malloc(sizeof(struct ipc_process));
// -1 : error, 0 = no new process, 1 = new process
ret = ipc_server_get_new_request (buf, &tab_req[nbclient]);
tab_req[nbclient].p->proc_fd = i;
diff --git a/tcp/app/tcpd.h b/tcp/app/tcpd.h
index ca71373..d574f12 100644
--- a/tcp/app/tcpd.h
+++ b/tcp/app/tcpd.h
@@ -18,7 +18,7 @@ typedef struct {
typedef struct {
struct sockaddr_in addr;
char * request;
- struct process *p;
+ struct ipc_process *p;
} info_request;
int initConnection (const info_request *req);