2015-11-06 06:57:03 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2016-01-13 06:01:36 +08:00
|
|
|
#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>
|
2015-11-06 06:57:03 +08:00
|
|
|
|
2016-01-13 06:01:36 +08:00
|
|
|
#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;
|
|
|
|
|
|
|
|
|
2016-01-13 06:01:36 +08:00
|
|
|
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)
|
2016-01-13 06:01:36 +08:00
|
|
|
pthread_t thread;
|
2016-06-05 04:54:17 +08:00
|
|
|
client_status_t status;
|
|
|
|
|
2016-01-13 06:01:36 +08:00
|
|
|
} client_t;
|
2015-12-02 21:51:20 +08:00
|
|
|
|
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);
|