csdr/ddcd.h

57 lines
898 B
C
Raw Normal View History

#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
2016-06-04 23:42:29 +08:00
#include <signal.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <vector>
2016-06-05 04:54:17 +08:00
#include <limits.h>
#define SOFTWARE_NAME "ddcd"
#define MSG_START SOFTWARE_NAME ": "
2015-12-02 21:51:20 +08:00
2016-06-05 04:54:17 +08:00
typedef enum ddc_method_e
2015-12-02 21:51:20 +08:00
{
M_TD,
M_FASTDDC
} ddc_method_t;
2016-06-05 04:54:17 +08:00
typedef enum client_status_e
{
CS_CREATED,
CS_THREAD_RUNNING,
CS_THREAD_FINISHED
} client_status_t;
typedef struct client_s
{
struct sockaddr_in addr;
int socket;
2016-06-05 04:54:17 +08:00
int error; //set to non-zero on error (data transfer failed)
pthread_t thread;
2016-06-05 04:54:17 +08:00
client_status_t status;
} client_t;
2015-12-02 21:51:20 +08:00
typedef enum command_type_e
{
CT_SHIFT,
CT_BYPASS
} command_type_t;
typedef struct command_s
{
command_type_t type;
float float_param;
} command_t;
2016-06-04 23:42:29 +08:00
void print_exit(const char* why);
void error_exit(const char* why);
void maxfd(int* maxfd, int fd);