50 lines
934 B
C
50 lines
934 B
C
#ifndef LIBCURL_H
|
|
#define LIBCURL_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <fcntl.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include <signal.h>
|
|
#include <sys/wait.h>
|
|
#include <curl/curl.h>
|
|
#include <sys/types.h>
|
|
#include <arpa/inet.h>
|
|
#include <assert.h>
|
|
#include <limits.h>
|
|
#include <stdarg.h>
|
|
|
|
#include <cjson/cJSON.h>
|
|
|
|
// 定义嵌套的数据结构
|
|
typedef struct {
|
|
char continent[64];
|
|
char country[64];
|
|
char zipcode[64];
|
|
char owner[64];
|
|
char isp[64];
|
|
char adcode[64];
|
|
char prov[64];
|
|
char city[64];
|
|
char district[64];
|
|
char region[64];
|
|
} Data;
|
|
|
|
// 定义主结构
|
|
typedef struct {
|
|
char code[32];
|
|
Data data;
|
|
char ip[64];
|
|
|
|
char continent_country[256];
|
|
} Response;
|
|
|
|
extern char *CurlGetIpArea(char *ip);
|
|
extern char *GetLocalAddr(char *url);
|
|
extern int parse_json_to_struct(const char *json_string, Response * response);
|
|
|
|
#endif
|