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

60 lines
1.6 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>
2016-06-05 03:19:36 +02:00
#include "process.h"
2016-05-26 18:27:59 +02:00
#include <unistd.h> // unlink
#include <sys/types.h> // mkfifo
#include <sys/stat.h> // mkfifo
#include <fcntl.h> // open
#include <errno.h> // error numbers
2016-05-26 18:27:59 +02:00
#define COMMUNICATION_VERSION 1
struct service {
unsigned int version;
unsigned int index;
2016-06-05 20:48:13 +02:00
char spath[PATH_MAX];
FILE *spipe;
};
2016-06-05 20:48:13 +02:00
void srv_init (struct service *srv, const char *sname);
2016-06-04 20:33:44 +02:00
2016-06-07 11:45:21 +02:00
int srv_get_listen_raw (const struct service *srv, char **buf, size_t *msize);
int srv_get_new_process (const struct service *srv, struct process *proc);
2016-05-26 18:27:59 +02:00
/*
* returns
* 0 : ok
* 1 : no service name
* 2 : service name too long
* 3 : unable to create fifo
*/
2016-06-05 20:48:13 +02:00
int srv_create (struct service *srv);
int srv_close (struct service *srv);
2016-05-26 18:27:59 +02:00
2016-06-07 11:45:21 +02:00
int srv_read_cb (struct process *p, char ** buf, size_t * msize
, int (*cb)(FILE *f, char ** buf, size_t * msize));
int srv_read (struct process *, char ** buf, size_t *);
2016-06-05 03:19:36 +02:00
int srv_write (struct process *, void * buf, size_t);
2016-06-04 20:33:44 +02:00
2016-06-05 03:19:36 +02:00
// APPLICATION
2016-05-26 18:27:59 +02:00
// send the connection string to $TMP/<service>
int app_srv_connection (struct service *, const char *, size_t);
2016-06-05 03:19:36 +02:00
int app_create (struct process *, int index); // called by the application
int app_destroy (struct process *); // called by the application
2016-05-26 18:27:59 +02:00
2016-06-08 17:57:05 +02:00
int app_read_cb (struct process *p, char ** buf, size_t * msize
, int (*cb)(FILE *f, char ** buf, size_t * msize));
2016-06-05 03:19:36 +02:00
int app_read (struct process *, void * buf, size_t *);
int app_write (struct process *, void * buf, size_t);
2016-05-26 18:27:59 +02:00
#endif