s/ipc_process\b/ipc_client/

more_to_read
Philippe PITTOLI 2018-10-04 00:30:47 +02:00
parent 40109f439c
commit a0d9453902
30 changed files with 156 additions and 156 deletions

View File

@ -8,8 +8,8 @@ int main()
struct ipc_process_array tab_proc;
memset(&tab_proc, 0, sizeof(struct ipc_process_array));
struct ipc_process process_tab[5];
memset(&process_tab, 0, sizeof(struct ipc_process) * 5);
struct ipc_client process_tab[5];
memset(&process_tab, 0, sizeof(struct ipc_client) * 5);
int i;
for (i = 0; i < 5; i++) {

View File

@ -14,8 +14,8 @@ int main (int argc, char *argv[], char *env[])
struct ipc_message m;
memset (&m, 0, sizeof (struct ipc_message));
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
// index and version should be filled
srv.index = 0;

View File

@ -13,15 +13,15 @@ int main (int argc, char *argv[], char *env[])
struct ipc_message m;
memset (&m, 0, sizeof (struct ipc_message));
struct service srv;
memset(&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset(&srv, 0, sizeof (struct ipc_service));
// index and version should be filled
srv.index = 0;
srv.version = 0;
struct ipc_process p;
memset (&p, 0, sizeof (struct ipc_process));
struct ipc_client p;
memset (&p, 0, sizeof (struct ipc_client));
// init service
if (server_init (argc, argv, env, &srv, SERVICE_NAME) < 0) {

View File

@ -16,7 +16,7 @@ void service_path (char *path, const char *sname, int index, int version)
}
int ipc_server_init (int argc, char **argv, char **env
, struct service *srv, const char *sname)
, struct ipc_service *srv, const char *sname)
{
if (srv == NULL)
return ER_PARAMS;
@ -37,7 +37,7 @@ 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 ipc_process *p)
int ipc_server_accept (struct ipc_service *srv, struct ipc_client *p)
{
assert (srv != NULL);
assert (p != NULL);
@ -59,13 +59,13 @@ int ipc_server_accept (struct service *srv, struct ipc_process *p)
return 0;
}
int ipc_server_close (struct service *srv)
int ipc_server_close (struct ipc_service *srv)
{
usock_close (srv->service_fd);
return usock_remove (srv->spath);
}
int ipc_server_close_proc (struct ipc_process *p)
int ipc_server_close_proc (struct ipc_client *p)
{
// struct ipc_message m_ack_dis;
// memset (&m_ack_dis, 0, sizeof (struct ipc_message));
@ -78,18 +78,18 @@ int ipc_server_close_proc (struct ipc_process *p)
return usock_close (p->proc_fd);
}
int ipc_server_read (const struct ipc_process *p, struct ipc_message *m)
int ipc_server_read (const struct ipc_client *p, struct ipc_message *m)
{
return ipc_message_read (p->proc_fd, m);
}
int ipc_server_write (const struct ipc_process *p, const struct ipc_message *m)
int ipc_server_write (const struct ipc_client *p, const struct ipc_message *m)
{
return ipc_message_write (p->proc_fd, m);
}
int ipc_application_connection (int argc, char **argv, char **env
, struct service *srv, const char *sname
, struct ipc_service *srv, const char *sname
, const char *connectionstr, size_t msize)
{
argc = argc;
@ -135,7 +135,7 @@ 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)
int ipc_application_close (struct ipc_service *srv)
{
struct ipc_message m;
memset (&m, 0, sizeof (struct ipc_message));
@ -147,12 +147,12 @@ int ipc_application_close (struct service *srv)
return usock_close (srv->service_fd);
}
int ipc_application_read (struct service *srv, struct ipc_message *m)
int ipc_application_read (struct ipc_service *srv, struct ipc_message *m)
{
return ipc_message_read (srv->service_fd, m);
}
int ipc_application_write (struct service *srv, const struct ipc_message *m)
int ipc_application_write (struct ipc_service *srv, const struct ipc_message *m)
{
return ipc_message_write (srv->service_fd, m);
}
@ -187,7 +187,7 @@ int getMaxFd(struct ipc_process_array *ap)
* * les deux à la fois (CON_APP)
*/
int ipc_server_select (struct ipc_process_array *ap, struct service *srv
int ipc_server_select (struct ipc_process_array *ap, struct ipc_service *srv
, struct ipc_process_array *proc)
{
assert (ap != NULL);

View File

@ -22,7 +22,7 @@
#define APPLICATION 1
#define CON_APP 2
struct service {
struct ipc_service {
unsigned int version;
unsigned int index;
char spath[PATH_MAX];
@ -35,15 +35,15 @@ struct service {
// srv->version and srv->index must be already set
// init unix socket + fill srv->spath
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 ipc_process *p);
int ipc_server_accept (struct service *srv, struct ipc_process *p);
, struct ipc_service *srv, const char *sname);
int ipc_server_close (struct ipc_service *srv);
int ipc_server_close_proc (struct ipc_client *p);
int ipc_server_accept (struct ipc_service *srv, struct ipc_client *p);
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_read (const struct ipc_client *, struct ipc_message *m);
int ipc_server_write (const struct ipc_client *, const struct ipc_message *m);
int ipc_server_select (struct ipc_process_array *, struct service *, struct ipc_process_array *);
int ipc_server_select (struct ipc_process_array *, struct ipc_service *, struct ipc_process_array *);
// APPLICATION
@ -51,11 +51,11 @@ int ipc_server_select (struct ipc_process_array *, struct service *, struct ipc_
// send the connection string to $TMP/<service>
// fill srv->spath && srv->service_fd
int ipc_application_connection (int argc, char **argv, char **env
, struct service *, const char *, const char *, size_t);
int ipc_application_close (struct service *);
, struct ipc_service *, const char *, const char *, size_t);
int ipc_application_close (struct ipc_service *);
int ipc_application_read (struct service *srv, struct ipc_message *m);
int ipc_application_write (struct service *, const struct ipc_message *m);
int ipc_application_read (struct ipc_service *srv, struct ipc_message *m);
int ipc_application_write (struct ipc_service *, const struct ipc_message *m);

View File

@ -5,37 +5,37 @@
#include <string.h>
struct ipc_process * ipc_server_process_copy (const struct ipc_process *p)
struct ipc_client * ipc_server_process_copy (const struct ipc_client *p)
{
if (p == NULL)
return NULL;
struct ipc_process * copy = malloc (sizeof(struct ipc_process));
memcpy (copy, p, sizeof (struct ipc_process));
struct ipc_client * copy = malloc (sizeof(struct ipc_client));
memcpy (copy, p, sizeof (struct ipc_client));
return copy;
}
int ipc_server_process_eq (const struct ipc_process *p1, const struct ipc_process *p2)
int ipc_server_process_eq (const struct ipc_client *p1, const struct ipc_client *p2)
{
return (p1->version == p2->version && p1->index == p2->index
&& p1->proc_fd == p2->proc_fd);
}
void ipc_server_process_gen (struct ipc_process *p
void ipc_server_process_gen (struct ipc_client *p
, unsigned int index, unsigned int version)
{
p->version = version;
p->index = index;
}
int ipc_process_add (struct ipc_process_array *aproc, struct ipc_process *p)
int ipc_process_add (struct ipc_process_array *aproc, struct ipc_client *p)
{
assert(aproc != NULL);
assert(p != NULL);
aproc->size++;
aproc->tab_proc = realloc(aproc->tab_proc
, sizeof(struct ipc_process) * aproc->size);
, sizeof(struct ipc_client) * aproc->size);
if (aproc->tab_proc == NULL) {
return -1;
@ -45,7 +45,7 @@ int ipc_process_add (struct ipc_process_array *aproc, struct ipc_process *p)
return 0;
}
int ipc_process_del (struct ipc_process_array *aproc, struct ipc_process *p)
int ipc_process_del (struct ipc_process_array *aproc, struct ipc_client *p)
{
assert(aproc != NULL);
assert(p != NULL);
@ -65,7 +65,7 @@ int ipc_process_del (struct ipc_process_array *aproc, struct ipc_process *p)
}
else {
aproc->tab_proc = realloc(aproc->tab_proc
, sizeof(struct ipc_process) * aproc->size);
, sizeof(struct ipc_client) * aproc->size);
if (aproc->tab_proc == NULL) {
return -2;
@ -79,7 +79,7 @@ int ipc_process_del (struct ipc_process_array *aproc, struct ipc_process *p)
return -3;
}
void process_print (struct ipc_process *p)
void process_print (struct ipc_client *p)
{
if (p != NULL)
printf ("process %d : index %d, version %d\n"

View File

@ -1,28 +1,28 @@
#ifndef __IPC_PROCESS_H__
#define __IPC_PROCESS_H__
struct ipc_process {
struct ipc_client {
unsigned int version;
unsigned int index;
int proc_fd;
};
struct ipc_process_array {
struct ipc_process **tab_proc;
struct ipc_client **tab_proc;
int size;
};
int ipc_process_add (struct ipc_process_array *, struct ipc_process *);
int ipc_process_del (struct ipc_process_array *aproc, struct ipc_process *p);
int ipc_process_add (struct ipc_process_array *, struct ipc_client *);
int ipc_process_del (struct ipc_process_array *aproc, struct ipc_client *p);
void ipc_process_array_print (struct ipc_process_array *);
void ipc_process_array_free (struct ipc_process_array *);
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);
struct ipc_client * ipc_server_process_copy (const struct ipc_client *p);
int ipc_server_process_eq (const struct ipc_client *p1, const struct ipc_client *p2);
// create the service process structure
void ipc_server_process_gen (struct ipc_process *p
void ipc_server_process_gen (struct ipc_client *p
, unsigned int index, unsigned int version);
void process_print (struct ipc_process *);
void process_print (struct ipc_client *);
#endif

View File

@ -10,8 +10,8 @@ ohshit(int rvalue, const char* str) {
int main(int argc, char * argv[], char *env[])
{
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
ipc_server_init (argc, argv, env, &srv, SERVICE, NULL);
printf ("Listening on %s.\n", srv.spath);
@ -23,8 +23,8 @@ int main(int argc, char * argv[], char *env[])
* PROCESS
*/
struct ipc_process p;
memset (&p, 0, sizeof (struct ipc_process));
struct ipc_client p;
memset (&p, 0, sizeof (struct ipc_client));
int index = 0; // first time we communication with the service
int version = 1;

View File

@ -5,25 +5,25 @@ communication.h \- all functions explained
.nf
.B #include <communication.h>
.sp
.BI "int ipc_server_init (int "argc ", char **" argv ", char **" env ", struct service *" srv "
.BI "int ipc_server_init (int "argc ", char **" argv ", char **" env ", struct ipc_service *" srv "
.BI " , const char *" service_name );
.BI "int ipc_server_accept (struct service *" srv ", struct ipc_process *" p );
.BI "int ipc_server_accept (struct ipc_service *" srv ", struct ipc_client *" p );
.sp
.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 );
.BI "int ipc_server_read (const struct ipc_client *" p ", struct ipc_message *" message );
.BI "int ipc_server_write (const struct ipc_client *" p ", const struct ipc_message *" message );
.sp
.BI "int ipc_server_close (struct service *" srv );
.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_server_close (struct ipc_service *" srv );
.BI "int ipc_server_close_proc (struct ipc_client *" p );
.BI "int ipc_server_select (struct ipc_process_array *" fds ", struct ipc_service *" srv ", struct ipc_process_array *" readfds );
.BI "int ipc_application_connection (int " argc ", char **" argv ", char **" env ", struct service *" srv
.BI "int ipc_application_connection (int " argc ", char **" argv ", char **" env ", struct ipc_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 ipc_message *" message );
.BI "int ipc_application_write (const struct service *" srv ", const struct ipc_message *" message );
.BI "int ipc_application_read (const struct ipc_service *" srv ", struct ipc_message *" message );
.BI "int ipc_application_write (const struct ipc_service *" srv ", const struct ipc_message *" message );
.sp
.BI "int ipc_application_close (struct service *" srv );
.BI "int ipc_application_close (struct ipc_service *" srv );
.fi
@ -39,7 +39,7 @@ and
should be passed to the function in order to automatically change the behavior of the program without the application being modified.
.I *srv
is the pointer to the \fBstruct service\fR that should be filled (index and version parameters).
is the pointer to the \fBstruct ipc_service\fR that should be filled (index and version parameters).
The \fBserver_init()\fR function will fill the rest of the elements of this structure, such as the unix socket path and the unix socket file descriptor in order to be able to receive new connections.
.PP
The
@ -81,7 +81,7 @@ and
in argument for latter use.
It takes
.IR *srv
the pointer to the \fBstruct service\fR that should be filled (index and version parameters) and
the pointer to the \fBstruct ipc_service\fR that should be filled (index and version parameters) and
will fill the rest of the elements of this structure, such as the unix socket path and the unix socket file descriptor of the service in order to be able to talk to it.
The function also takes
.IR *service_name

View File

@ -14,8 +14,8 @@ void non_interactive (int argc, char *argv[], char *env[])
{
struct ipc_message m;
memset (&m, 0, sizeof (struct ipc_message));
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
// index and version should be filled
srv.index = 0;
@ -55,8 +55,8 @@ void interactive (int argc, char *argv[], char *env[])
{
struct ipc_message m;
memset (&m, 0, sizeof (struct ipc_message));
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
char buf[BUFSIZ];
memset (buf, 0, BUFSIZ);

View File

@ -10,10 +10,10 @@
int cpt = 0;
void handle_new_connection (struct service *srv, struct ipc_process_array *ap)
void handle_new_connection (struct ipc_service *srv, struct ipc_process_array *ap)
{
struct ipc_process *p = malloc(sizeof(struct ipc_process));
memset(p, 0, sizeof(struct ipc_process));
struct ipc_client *p = malloc(sizeof(struct ipc_client));
memset(p, 0, sizeof(struct ipc_client));
if (ipc_server_accept (srv, p) < 0) {
handle_error("server_accept < 0");
@ -70,7 +70,7 @@ void handle_new_msg (struct ipc_process_array *ap, struct ipc_process_array *pro
* close a connection if MSG_TYPE_CLOSE received
*/
void main_loop (struct service *srv)
void main_loop (struct ipc_service *srv)
{
int i, ret = 0;
@ -117,8 +117,8 @@ void main_loop (struct service *srv)
int main(int argc, char * argv[], char **env)
{
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
srv.index = 0;
srv.version = 0;

View File

@ -26,8 +26,8 @@ void * listener (void *params)
handle_err ("listener", "pthread_setcancelstate != 0");
}
struct service *srv = NULL;
srv = (struct service *) params;
struct ipc_service *srv = NULL;
srv = (struct ipc_service *) params;
if (srv == NULL) {
handle_err ("listener", "no service passed");
return NULL;
@ -48,7 +48,7 @@ void * listener (void *params)
pthread_exit (NULL);
}
void chan_sub (struct service *srv, char *chan)
void chan_sub (struct ipc_service *srv, char *chan)
{
struct pubsub_msg msg;
memset (&msg, 0, sizeof (struct pubsub_msg));
@ -75,8 +75,8 @@ void main_loop (int argc, char **argv, char **env
"cmd %s chan %s\n"
, index, version, cmd, chan );
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
pubsub_connection (argc, argv, env, &srv);
printf ("connected\n");

View File

@ -10,7 +10,7 @@
#include <signal.h>
// to quit them properly if a signal occurs
struct service srv;
struct ipc_service srv;
struct channels chans;
void handle_signal (int signalnumber)
@ -29,7 +29,7 @@ void handle_signal (int signalnumber)
int
main(int argc, char **argv, char **env)
{
memset (&srv, 0, sizeof (struct service));
memset (&srv, 0, sizeof (struct ipc_service));
srv.index = 0;
srv.version = 0;

View File

@ -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 ipc_process *p)
void pubsubd_channel_subscribe (const struct channel *c, struct ipc_client *p)
{
ipc_process_add (c->subs, p);
}
void pubsubd_channel_unsubscribe (const struct channel *c, struct ipc_process *p)
void pubsubd_channel_unsubscribe (const struct channel *c, struct ipc_client *p)
{
ipc_process_del (c->subs, p);
}
void pubsubd_channels_subscribe (struct channels *chans
, char *chname, struct ipc_process *p)
, char *chname, struct ipc_client *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 ipc_process *p)
, char *chname, struct ipc_client *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 ipc_process *p)
, struct ipc_client *p)
{
struct channel * chan = NULL;
LIST_FOREACH(chan, chans, entries) {

View File

@ -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 ipc_process *p);
void pubsubd_channel_unsubscribe (const struct channel *c, struct ipc_process *p);
void pubsubd_channel_subscribe (const struct channel *c, struct ipc_client *p);
void pubsubd_channel_unsubscribe (const struct channel *c, struct ipc_client *p);
void pubsubd_channels_subscribe (struct channels *chans
, char *chname, struct ipc_process *p);
, char *chname, struct ipc_client *p);
void pubsubd_channels_unsubscribe (struct channels *chans
, char *chname, struct ipc_process *p);
, char *chname, struct ipc_client *p);
void pubsubd_channels_unsubscribe_everywhere (struct channels *chans
, struct ipc_process *p);
, struct ipc_client *p);
#endif

View File

@ -24,7 +24,7 @@ char * pubsub_action_to_str (enum subscriber_action action)
#if 0
// tell the service to stop
void pubsub_quit (struct service *srv)
void pubsub_quit (struct ipc_service *srv)
{
// line fmt : 0 0 0 quit
char line[BUFSIZ];
@ -34,7 +34,7 @@ void pubsub_quit (struct service *srv)
#endif
int pubsub_connection (int argc, char **argv, char **env
, struct service *srv)
, struct ipc_service *srv)
{
int ret = ipc_application_connection (argc, argv, env
, srv, PUBSUBD_SERVICE_NAME, NULL, 0);
@ -46,12 +46,12 @@ int pubsub_connection (int argc, char **argv, char **env
return ret;
}
int pubsub_disconnect (struct service *srv)
int pubsub_disconnect (struct ipc_service *srv)
{
return ipc_application_close (srv);
}
int pubsub_message_send (struct service *srv, const struct pubsub_msg * m)
int pubsub_message_send (struct ipc_service *srv, const struct pubsub_msg * m)
{
size_t msize = 0;
char * buf = NULL;
@ -77,7 +77,7 @@ int pubsub_message_send (struct service *srv, const struct pubsub_msg * m)
return 0;
}
int pubsub_message_recv (struct service *srv, struct pubsub_msg *m)
int pubsub_message_recv (struct ipc_service *srv, struct pubsub_msg *m)
{
if (srv == NULL) {
handle_err ("pubsub_message_recv", "srv == NULL");

View File

@ -15,12 +15,12 @@ enum subscriber_action {PUBSUB_QUIT = 1, PUBSUB_PUB, PUBSUB_SUB, PUBSUB_BOTH};
#define PUBSUB_TYPE_DEBUG 4
#define PUBSUB_TYPE_INFO 5
int pubsub_connection (int argc, char **argv, char **env, struct service *srv);
int pubsub_disconnect (struct service *srv);
int pubsub_message_send (struct service *srv, const struct pubsub_msg * m);
int pubsub_message_recv (struct service *srv, struct pubsub_msg *m);
int pubsub_connection (int argc, char **argv, char **env, struct ipc_service *srv);
int pubsub_disconnect (struct ipc_service *srv);
int pubsub_message_send (struct ipc_service *srv, const struct pubsub_msg * m);
int pubsub_message_recv (struct ipc_service *srv, struct pubsub_msg *m);
// TODO
void pubsub_quit (struct service *srv);
void pubsub_quit (struct ipc_service *srv);
#endif

View File

@ -42,7 +42,7 @@ void pubsubd_send (const struct ipc_process_array *ap, const struct pubsub_msg *
}
}
// void pubsubd_recv (struct ipc_process *p, struct pubsub_msg *m)
// void pubsubd_recv (struct ipc_client *p, struct pubsub_msg *m)
// {
// struct ipc_message m_data;
// memset (&m_data, 0, sizeof (struct ipc_message));
@ -59,10 +59,10 @@ void pubsubd_send (const struct ipc_process_array *ap, const struct pubsub_msg *
* 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 ipc_process_array *ap)
void handle_new_connection (struct ipc_service *srv, struct ipc_process_array *ap)
{
struct ipc_process *p = malloc(sizeof(struct ipc_process));
memset(p, 0, sizeof(struct ipc_process));
struct ipc_client *p = malloc(sizeof(struct ipc_client));
memset(p, 0, sizeof(struct ipc_client));
if (ipc_server_accept (srv, p) < 0) {
handle_error("server_accept < 0");
@ -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 ipc_process *p = proc_to_read->tab_proc[i];
struct ipc_client *p = proc_to_read->tab_proc[i];
printf ("proc %d disconnecting\n", p->proc_fd);
@ -165,7 +165,7 @@ void handle_new_msg (struct channels *chans
* close a connection if MSG_TYPE_CLOSE received
*/
void pubsubd_main_loop (struct service *srv, struct channels *chans)
void pubsubd_main_loop (struct ipc_service *srv, struct channels *chans)
{
int i, ret = 0;

View File

@ -9,7 +9,7 @@
#define PUBSUBD_SERVICE_NAME "pubsubd"
void pubsubd_main_loop (struct service *srv, struct channels * chans);
void pubsubd_main_loop (struct ipc_service *srv, struct channels * chans);
void pubsubd_message_send (const struct ipc_process_array *ap, const struct pubsub_msg * m);
#endif

View File

@ -5,7 +5,7 @@
#include "../lib/channels.h"
#include "../../core/error.h"
void fake_process (struct ipc_process *p
void fake_process (struct ipc_client *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 ipc_process proc1;
struct ipc_client proc1;
fake_process (&proc1, 0, 0, 1);
struct ipc_process proc2;
struct ipc_client 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 ipc_process proc1;
struct ipc_client proc1;
fake_process (&proc1, 0, 0, 1);
struct ipc_process proc2;
struct ipc_client proc2;
fake_process (&proc2, 0, 0, 2);
printf ("chan1 & 2 => proc1 and 2 added\n");

View File

@ -24,13 +24,13 @@ void sim_connection (int argc, char **argv, char **env, pid_t pid, int index, in
"cmd %s chan %s\n"
, pid, index, version, cmd, chan );
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
ipc_server_init (argc, argv, env, &srv, PUBSUB_SERVICE_NAME, NULL);
printf ("Writing on %s.\n", srv.spath);
struct ipc_process p;
memset (&p, 0, sizeof (struct ipc_process));
struct ipc_client p;
memset (&p, 0, sizeof (struct ipc_client));
printf ("app creation\n");
if (application_create (&p, pid, index, version)) // called by the application
@ -80,13 +80,13 @@ void sim_connection (int argc, char **argv, char **env, pid_t pid, int index, in
void sim_disconnection (int argc, char **argv, char **env, pid_t pid, int index, int version)
{
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
ipc_server_init (argc, argv, env, &srv, PUBSUB_SERVICE_NAME, NULL);
printf ("Disconnecting from %s.\n", srv.spath);
struct ipc_process p;
memset (&p, 0, sizeof (struct ipc_process));
struct ipc_client p;
memset (&p, 0, sizeof (struct ipc_client));
// create the fake process
ipc_server_process_gen (&p, pid, index, version);

View File

@ -17,13 +17,13 @@ ohshit(int rvalue, const char* str) {
int
main(int argc, char **argv, char **env)
{
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
ipc_server_init (argc, argv, env, &srv, PUBSUB_SERVICE_NAME, NULL);
printf ("Writing on %s.\n", srv.spath);
struct ipc_process p;
memset (&p, 0, sizeof (struct ipc_process));
struct ipc_client p;
memset (&p, 0, sizeof (struct ipc_client));
int index = 1;
pid_t pid = getpid();

View File

@ -35,8 +35,8 @@ void * listener (void *params)
handle_err ("listener", "pthread_setcancelstate != 0");
}
struct service *srv = NULL;
srv = (struct service *) params;
struct ipc_service *srv = NULL;
srv = (struct ipc_service *) params;
if (srv == NULL) {
handle_err ("listener", "no service passed");
return NULL;
@ -68,8 +68,8 @@ void main_loop (int argc, char **argv, char **env
(void) argv;
(void) env;
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
remotec_connection (argc, argv, env, &srv);
log_debug ("remotec connected, entering main loop");

View File

@ -14,7 +14,7 @@
#include <stdio.h>
// to quit them properly if a signal occurs
struct service srv;
struct ipc_service srv;
void handle_signal (int signalnumber)
{
@ -77,7 +77,7 @@ int main(int argc, char **argv, char **env)
struct remoted_ctx ctx;
memset (&ctx, 0, sizeof (struct remoted_ctx));
memset (&srv, 0, sizeof (struct service));
memset (&srv, 0, sizeof (struct ipc_service));
srv.index = 0;
srv.version = 0;

View File

@ -7,7 +7,7 @@
#include <stdlib.h>
#include <string.h>
int remotec_connection (int argc, char **argv, char **env, struct service *srv)
int remotec_connection (int argc, char **argv, char **env, struct ipc_service *srv)
{
int ret = ipc_application_connection (argc, argv, env
, srv, REMOTED_SERVICE_NAME, NULL, 0);
@ -19,12 +19,12 @@ int remotec_connection (int argc, char **argv, char **env, struct service *srv)
return ret;
}
int remotec_disconnection (struct service *srv)
int remotec_disconnection (struct ipc_service *srv)
{
return ipc_application_close (srv);
}
int remotec_message_send (struct service *srv, const struct remoted_msg * m)
int remotec_message_send (struct ipc_service *srv, const struct remoted_msg * m)
{
size_t msize = 0;
char * buf = NULL;
@ -50,7 +50,7 @@ int remotec_message_send (struct service *srv, const struct remoted_msg * m)
return 0;
}
int remotec_message_recv (struct service *srv, struct remoted_msg *m)
int remotec_message_recv (struct ipc_service *srv, struct remoted_msg *m)
{
if (srv == NULL) {
handle_err ("remotec_message_recv", "srv == NULL");

View File

@ -7,10 +7,10 @@
/* TODO */
int remotec_connection (int argc, char **argv, char **env, struct service *srv);
int remotec_disconnection (struct service *srv);
int remotec_connection (int argc, char **argv, char **env, struct ipc_service *srv);
int remotec_disconnection (struct ipc_service *srv);
int remotec_message_send (struct service *srv, const struct remoted_msg *msg);
int remotec_message_recv (struct service *srv, struct remoted_msg *msg);
int remotec_message_send (struct ipc_service *srv, const struct remoted_msg *msg);
int remotec_message_recv (struct ipc_service *srv, struct remoted_msg *msg);
#endif

View File

@ -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 ipc_process_array *ap)
void handle_new_connection (struct ipc_service *srv, struct ipc_process_array *ap)
{
struct ipc_process *p = malloc(sizeof(struct ipc_process));
memset(p, 0, sizeof(struct ipc_process));
struct ipc_client *p = malloc(sizeof(struct ipc_client));
memset(p, 0, sizeof(struct ipc_client));
if (server_accept (srv, p) < 0) {
handle_error("server_accept < 0");
@ -45,7 +45,7 @@ void handle_new_msg (struct ipc_process_array *ap, struct ipc_process_array *pro
// close the process then delete it from the process array
if (m.type == MSG_TYPE_CLOSE) {
struct ipc_process *p = proc_to_read->tab_proc[i];
struct ipc_client *p = proc_to_read->tab_proc[i];
log_debug ("remoted, proc %d disconnecting", p->proc_fd);
@ -109,7 +109,7 @@ void handle_new_msg (struct ipc_process_array *ap, struct ipc_process_array *pro
}
}
void remoted_main_loop (struct service *srv, struct remoted_ctx *ctx)
void remoted_main_loop (struct ipc_service *srv, struct remoted_ctx *ctx)
{
log_debug ("remoted entering main loop");
int i, ret = 0;

View File

@ -12,7 +12,7 @@ struct remoted_ctx {
/* TODO: authorizations */
};
void remoted_main_loop (struct service *srv, struct remoted_ctx *ctx);
void remoted_main_loop (struct ipc_service *srv, struct remoted_ctx *ctx);
void remoted_free_ctx (struct remoted_ctx *ctx);
#endif

View File

@ -122,8 +122,8 @@ void * service_thread(void * c_data) {
}
makePivMessage(&piv, getpid(), cda->index, version);
struct service srv;
memset (&srv, 0, sizeof (struct service));
struct ipc_service srv;
memset (&srv, 0, sizeof (struct ipc_service));
srv->index = 0;
srv->version = 0;
ipc_server_init (0, NULL, NULL, &srv, service, NULL);
@ -132,7 +132,7 @@ void * service_thread(void * c_data) {
}
free(piv);
/*struct ipc_process p;
/*struct ipc_client p;
ipc_application_create(&p, getpid(), cda->index, version);
ipc_server_process_print(&p);*/
//sleep(1);
@ -568,7 +568,7 @@ void request_print (const info_request *req) {
* listen : lancer un serveur, ecouter sur un port ie "listen 127.0.0.1 6000"
* connect : connecter à une adresse, port ie "connect 127.0.0.1 6000 ${pid} 1 1"
*/
void main_loop (struct service *srv) {
void main_loop (struct ipc_service *srv) {
//request
info_request tab_req[NBCLIENT];
int ret;
@ -663,7 +663,7 @@ void main_loop (struct service *srv) {
break;
}
tab_req[nbclient].p = malloc(sizeof(struct ipc_process));
tab_req[nbclient].p = malloc(sizeof(struct ipc_client));
// -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 ipc_process));
tab_req[nbclient].p = malloc(sizeof(struct ipc_client));
// -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;
@ -774,7 +774,7 @@ void main_loop (struct service *srv) {
}
int main(int argc, char * argv[], char **env) {
struct service srv;
struct ipc_service srv;
ipc_server_init (argc, argv, env, &srv, SERVICE_TCP, NULL);
printf ("Listening on %s.\n", srv.spath);

View File

@ -18,7 +18,7 @@ typedef struct {
typedef struct {
struct sockaddr_in addr;
char * request;
struct ipc_process *p;
struct ipc_client *p;
} info_request;
int initConnection (const info_request *req);
@ -52,7 +52,7 @@ int ipc_server_get_new_request(char *buf, info_request *req);
void request_print (const info_request *req);
void main_loop(struct service *srv);
void main_loop(struct ipc_service *srv);
#endif