Archived
3
0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
libipc-old/lib/communication.h

64 lines
1.5 KiB
C
Raw Normal View History

2016-05-26 18:27:59 +02:00
#ifndef __COMMUNICATION_H__
#define __COMMUNICATION_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> // unlink
#include <sys/types.h> // mkfifo
#include <sys/stat.h> // mkfifo
#include <fcntl.h> // open
#include <errno.h> // error numbers
#define TMPDIR "/tmp/ipc/"
2016-05-26 18:27:59 +02:00
#define COMMUNICATION_VERSION 1
// TODO to check the right length for a path
#define PATH_MAX BUFSIZ
struct process {
pid_t pid;
unsigned int version;
unsigned int index;
FILE *in, *out;
2016-05-26 18:27:59 +02:00
};
struct service {
unsigned int version;
unsigned int index;
};
2016-05-26 18:27:59 +02:00
// TODO create the service process structure
int service_path (char *buf, const char *sname);
void gen_process_structure (struct process *p
, pid_t pid, unsigned int index, unsigned int version);
/*
* returns
* 0 : ok
* 1 : no service name
* 2 : service name too long
* 3 : unable to create fifo
*/
int service_create (const char *sname);
int service_close (const char *sname);
int service_get_new_process (struct process *proc, const char * spath);
void service_get_new_processes (struct process ***, int *nproc, char *spath);
2016-05-26 21:56:43 +02:00
void service_free_processes (struct process **, int nproc);
2016-05-26 18:27:59 +02:00
void process_print (struct process *);
2016-05-26 18:27:59 +02:00
int process_create (struct process *, int index); // called by the application
int process_destroy (struct process *); // called by the application
int process_read (struct process *, void * buf, size_t *);
int process_write (struct process *, void * buf, size_t);
#endif