view service.h @ 5:c0223d75444d

Fill the .hgignore with compiled files.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 23 Feb 2015 00:27:48 +0100
parents e70ea46d6073
children
line wrap: on
line source

#ifndef SERVICE_H
#define SERVICE_H

#include "uinput.h"
#include "ds.h"
#include "restartOp.h"

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>

#define DEFAULT_DEV_QTY 2       /* How many jsX devices */
#define DEFAULT_BASE_UDP_PORT   16150   /* Listen DS datagrams */


/* Globals... */
#ifndef __MAIN_FILE__
    extern uint8_t nbdev;
    extern uint8_t curdev;
    extern uint16_t base_port;
    extern char* uinput_dev;
#else
    uint8_t nbdev = DEFAULT_DEV_QTY;
    uint8_t curdev;
    uint16_t base_port = DEFAULT_BASE_UDP_PORT;
    char* uinput_dev = NULL;
#endif


/*
    Create a socket
    Returns socket descriptor (-1 if error)
*/
extern int create_socket(unsigned short *port, int type);

/*
    Receive a DS datagram
*/
extern ssize_t receive_ds_info(int socket, ds_t* ds);

/*
    Start the listening service yeah!
*/
extern void start_service(void);



#endif /* SERVICE_H */