#ifndef _UTILS_H_ #define _UTILS_H_ #define TIMEGAP 10 #define SERVER_URL "test.com" #include #include "cJSON.h" typedef unsigned long uint64_t; typedef struct _current_time_gap { // 当前时间,用20060102150405表示 time_t now; // now gap time time_t now_gap; // 距离下一个gap还差多少秒 int gap_remaining; // next_gap time; time_t next_gap; } current_time_gap_t; // Content-Type: multipart/form-data; boundary=%s // Content-Type: application/json #define HTTP_HEAD "POST %s HTTP/1.1\r\n" \ "Host: %s\r\n" \ "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:59.0) Gecko/20100101 Firefox/59.0\r\n" \ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" \ "Accept-Language: en-US,en;q=0.5\r\n" \ "Accept-Encoding: gzip, deflate\r\n" \ "Content-Type: %s\r\n" \ "Content-Length: %ld\r\n" \ "Connection: close\r\n" \ "Upgrade-Insecure-Requests: 1\r\n" \ "DNT: 1\r\n\r\n" #define UPLOAD_REQUEST "--%s\r\n" \ "Content-Disposition: form-data; name=\"file\"; filename=\"%s\"\r\n" \ "Content-Type: application/octet-stream\r\n\r\n" // #define SERVER_PATH "/h264/upload" // HOST: domain name, like git.asxalex.pw // URI: uri path, like /h264/upload int post_data(const char *ip, const unsigned int port, char *host, char *URI, const char *filepath); int get_current_time_gap(current_time_gap_t *); uint64_t convert_time_to_name(time_t now); double current_time_stamp(); int read_data_from_file(const char *path, char **out_data); int post_json(const char *ip, const unsigned int port, const char *host, const char *uri, cJSON *data); #endif