增加libcurl库调用百度API,与原来的的go命令执行调用API两种。libcurl涉及静态链接,考虑使用哪种?

This commit is contained in:
2025-01-14 15:14:32 +08:00
parent b45c747ba4
commit e926ce3c0b
41 changed files with 7267 additions and 10 deletions

51
libcurl.h Normal file
View File

@@ -0,0 +1,51 @@
#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 *curl_get_area(char *URL);
extern int parse_json_to_struct(const char *json_string, Response *response);
#endif