Commit 3e5337a1 authored by 陈伟灿's avatar 陈伟灿

Merge branch 'cwc' into 'master'

Cwc

See merge request chenweican/k-sdk!158
parents 45649b1a 04ee3b76
......@@ -8,19 +8,27 @@ CFLAGS += -I$(TOP_DIR)/common/api
CFLAGS += -I$(TOP_DIR)/common/json
CFLAGS += -I$(TOP_DIR)/common/nanomsg/include
CFLAGS += -I$(TOP_DIR)/common/ev/include
CFLAGS += -I$(TOP_DIR)/common/curl/include
LDFLAGS += -lkk_tsl
LDFLAGS += -lapi_com
ifeq ($(CONFIG_MODEL),x86)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_ubuntu
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_ubuntu
else ifeq ($(CONFIG_MODEL),nx5)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_nx5
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_nx5 -lcurl
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_nx5
else ifeq ($(CONFIG_MODEL),8197)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_8197 -lubacktrace
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_8197
else ifeq ($(CONFIG_MODEL),a133)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_a133
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_a133
LDFLAGS += -L$(TOP_DIR)/common/curl -lcurl_a133
else
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg
LDFLAGS += -L$(TOP_DIR)/common/ev -lev
endif
LDFLAGS += -liot_cjson -liot_mqtt -ldl -lm -lanl -lkk_hal
LDFLAGS += -liot_cjson -liot_mqtt -ldl -lm -lkk_hal
......@@ -22,5 +22,8 @@ typedef enum {
#define MQTT_AUTH_HOST_NAME "test.dev.nj-ikonke.site"
int KK_Get_ccuid( char *device_code);
int kk_check_config_file(char* path,char **config);
int kk_cloud_get_pid(char *productId);
int kk_cloud_get_key(char *key);
#endif
......@@ -199,6 +199,9 @@ char * g_filerToCloudTable[] =
(char *){"/thing/service/delAlarm_reply"},
(char *){"/thing/service/syncinfo_reply"},
(char *){"/thing/service/syncinfopush_reply"},
(char *){"/thing/service/clientReport_reply"},
(char *){"/thing/service/clientOnlinePush"},
(char *){"/thing/service/getClientInfo_reply"},
};
/************************************************************
*功能描述:过滤不需要下发给网关的消息
......
......@@ -47,6 +47,31 @@ static int KK_Ccuid_init(void)
char ccuid[DEVICE_CODE_LEN] = {0};
char ccuidTmp[DEVICE_CODE_LEN] = {0};
int ccuid_len = 0;
#ifdef CONFIG_A133_PLATFORM
uint8_t data[128] = {0};
int data_len = 0;
char *pstart = NULL;
char *pEnd = NULL;
HAL_Execel_cmd(GET_CCUID_CMD,(char *)data,sizeof(data),&data_len);
printf("---GET_CCUID_CMD:%s\n",data);
if(data_len > 0 && data_len <= 128){
pstart = data;
pEnd = strstr(data,"-");
if(pstart != NULL && pEnd != NULL){
printf("-------123---------------------\n");
memcpy(ccuidTmp,pstart,pEnd-pstart);
_setDevice_Code(ccuidTmp,pEnd-pstart);
}else{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT("KK_Ccuid_init get ccuid error\n");
return -1;
}
}else{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT("KK_Ccuid_init get ccuid error\n");
return -1;
}
#else
HAL_Execel_cmd(GET_CCUID_CMD,(char *)ccuid,sizeof(ccuid),&ccuid_len);
printf("GET_CCUID_CMD:%s\n",ccuid);
if(ccuid_len > 0 && ccuid_len <= DEVICE_CODE_LEN){
......@@ -54,10 +79,102 @@ static int KK_Ccuid_init(void)
_setDevice_Code(ccuidTmp,strlen(ccuidTmp)-1);//减一是因为最后有一个换行
}else{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT("KK_Ccuid_init get ccuid error\n");
return -1;
}
#endif
return 0;
}
char s_pid[PRODUCT_CODE_LEN] = {0};
static int kk_cloud_pid_init(void)
{
#ifdef CONFIG_A133_PLATFORM
uint8_t data[128] = {0};
int data_len = 0;
char *pstart = NULL;
char *pEnd = NULL;
HAL_Execel_cmd(GET_CCUID_CMD,(char *)data,sizeof(data),&data_len);
printf("---GET_CCUID_CMD:%s\n",data);
if(data_len > 0 && data_len <= 128){
pstart = data;
pEnd = strstr(data,"pid_");
if(pstart != NULL && pEnd != NULL){
memcpy(s_pid,pEnd+4,data_len-1-(pEnd-pstart+4));
INFO_PRINT("kk_cloud_pid_init s_pid:%s\n",s_pid);
}else{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT("KK_Ccuid_init get ccuid error\n");
return -1;
}
}else{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT("KK_Ccuid_init get ccuid error\n");
return -1;
}
#else
char pid[PRODUCT_CODE_LEN] = {0};
int pid_len = 0;
HAL_Execel_cmd(GET_PRODUCTID_CMD,(char *)pid,sizeof(pid),&pid_len);
if(pid_len > 0 && pid_len <= PRODUCT_CODE_LEN){
memcpy(s_pid,pid,pid_len-1);
INFO_PRINT("s_pid:%s\n",s_pid);
}else{
return -1;
}
#endif
return 0;
}
int kk_cloud_get_pid(char *productId)
{
strncpy(productId, s_pid, strlen(s_pid));
printf("kk_cloud_get_pid:%s\n",s_pid);
return strlen(s_pid);
}
char s_key[128] = {0};
static int kk_cloud_key_init(void)
{
uint8_t key[128] = {0};
int key_len = 0;
#ifdef CONFIG_A133_PLATFORM
char *pstart = NULL;
char *pEnd = NULL;
HAL_Execel_cmd(GET_CCUID_CMD,(char *)key,sizeof(key),&key_len);
printf("---productSecret:%s\n",key);
if(key_len > 0 && key_len <= 128){
pstart = strstr(key,"key_");;
pEnd = strstr(key,"-pid_");
if(pstart != NULL && pEnd != NULL){
memcpy(s_key,pstart+4,pEnd-pstart+4);
INFO_PRINT("kk_cloud_key_init s_key:%s\n",s_key);
}else{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT("kk_cloud_key_init error\n");
return -1;
}
}else{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT("kk_cloud_key_init error\n");
return -1;
}
#else
HAL_Execel_cmd(GET_KEY_CMD,(char *)key,sizeof(key),&key_len);
if(key_len > 0 && key_len <= 128){
memcpy(s_key,key,key_len-1);
INFO_PRINT("s_key:%s\n",s_key);
}else{
return -1;
}
#endif
return 0;
}
int kk_cloud_get_key(char *key)
{
strncpy(key, s_key, strlen(s_key));
printf("kk_cloud_get_key:%s\n",s_key);
return strlen(s_key);
}
static int mqtt_start(void)
{
int count = 0;
......@@ -94,9 +211,55 @@ static int mqtt_start(void)
MQTTAsync_destroy(&mqttClient);
return -1;
}
extern MQTTAsync kk_mqtt_connect();
extern MQTTAsync kk_connect_default(void);
static int mqtt_start_ex(int isdefault)
{
int count = 0;
MQTTAsync mqttClient;
int rc = 0;
if(isdefault){
mqttClient = kk_connect_default();
}else{
mqttClient = kk_mqtt_connect();
}
if(mqttClient == NULL){
WARNING_PRINT("KK_MQTT_Connect FAIL!!!\n");
return -1;
}
while(1)
{
usleep(100000L);
if(kk_get_cloud_status() == 0){
//printf("------------------------------>count:%d\n",count);
count++;
if(count>500)
{
count = 0;
WARNING_PRINT("---------------------------------->CONNECT FAIL!!!\n");
break;
//INFO_PRINT("i am send now\n");
//KK_MQTT_SendMsg(TOPIC,"hello my world",2);
}
}else{
if(count > 0){
count = 0;
}
}
//INFO_PRINT(" %s \n",testStr);
}
INFO_PRINT("MQTTAsync_destroy\n");
MQTTAsync_destroy(&mqttClient);
return -1;
}
int kk_start_ccu_register(void);
extern int kk_info_report_start(void);
extern int kk_dl_config();
extern int kk_register_auth_get();
int main(int argc, char* argv[])
{
int rc = 0;
......@@ -107,8 +270,38 @@ int main(int argc, char* argv[])
ERROR_PRINT("CCUID GET FAIL!!!!!!!!!!!\n");
return 0;
}
kk_cloud_pid_init();
kk_cloud_key_init();
kk_ipc_init(IPC_APP2MID,(ipc_cb*)KK_Data_FromDev,NULL,NULL);
//kk_info_report_start();
//
#ifdef CONFIG_NX5_PLATFORM
//adlakdlkf
#endif
#if 1
kk_dl_config();
again:
rc = kk_register_auth_get();
if(rc == 0){
rc = mqtt_start_ex(0);
if(rc < 0){
kk_write_disconnect_flag();
sleep(2);
goto again;
}
}else if(rc == -2){
rc = mqtt_start_ex(1);
if(rc < 0){
kk_write_disconnect_flag();
sleep(2);
goto again;
}
}else{
kk_write_disconnect_flag();
sleep(2);
goto again;
}
#else
again:
rc = kk_start_ccu_register();
if(rc == 0){
......@@ -123,6 +316,6 @@ again:
sleep(2);
goto again;
}
#endif
return rc;
}
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <time.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "cJSON.h"
#include "com_api.h"
#include "kk_hal.h"
#include "kk_product.h"
#include "kcloud_config.h"
#include "infra_sha256.h"
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include "kk_log.h"
#include "../../common/curl/include/curl/curl.h"
int kk_check_config_file(char* path,char **config)
{
FILE *fp;
int filesize = 0;
char *buf = NULL;
if((access(path,F_OK)) == 0){
fp = fopen(path, "r");
if(fp != NULL){
fseek(fp, 0L, SEEK_END);
filesize = ftell(fp);
buf = malloc(filesize+1);
if(buf == NULL){
ERROR_PRINT("MALLOC FAIL!!!\n");
fclose(fp);
return -1;
}
memset(buf,0x0,filesize+1);
fseek(fp, 0L, SEEK_SET);
fread(buf, 1, filesize, fp);
INFO_PRINT("buf:%s\n",buf);
*config = buf;
fclose(fp);
return 0;
}
}else{
return -1;
}
}
static int _kk_parse_config_dl_host(cJSON *configInfo,char *url){
char ccuid[32] = {0};
if(configInfo == NULL ||url == NULL){
return -1;
}
KK_Get_ccuid(ccuid);
cJSON *host = cJSON_GetObjectItem(configInfo,"host");
cJSON *proto = cJSON_GetObjectItem(configInfo,"proto");
cJSON *port = cJSON_GetObjectItem(configInfo,"port");
if(host != NULL && proto != NULL && port != NULL){
sprintf(url,"%s://%s:%d/api/1.0/ccu/%s/cloud_entry",proto->valuestring,host->valuestring,port->valueint,&ccuid[4]);
INFO_PRINT("%s\n",url);
return 0;
}
return -1;
}
static int _kk_get_config_dl_host(char *buf,char *url){
cJSON *configInfo = NULL;
if(buf == NULL || url == NULL){
ERROR_PRINT("param error\n");
return -1;
}
cJSON* configObj = cJSON_Parse(buf);
if(configObj == NULL){
ERROR_PRINT("cJSON_Parse error\n");
return -2;
}
cJSON *data = cJSON_GetObjectItem(configObj,"data");
if(data == NULL){
configInfo = cJSON_GetObjectItem(configObj,"iot_ops_entry");
}else{
configInfo = cJSON_GetObjectItem(data,"iot_ops_entry");
}
_kk_parse_config_dl_host(configInfo,url);
cJSON_Delete(configObj);
return 0;
}
static int s_getSize = 0;
size_t receive_config_data(void *buffer, size_t size, size_t nmemb, FILE *file){
INFO_PRINT("buffer:%s\n",buffer);
size_t s_getSize = fwrite(buffer, size, nmemb, file);
return s_getSize;
}
int kk_dl_config(){
int ret = 0;
char *configData = NULL;
int defaultFlag = 0;
char url[512] = {0};
FILE *file;
CURLcode res;
CURL* curl;
char ccuid[32] = {0};
char sds[128] = {0};
static int s_count = 0;
KK_Get_ccuid(ccuid);
//ret = kk_check_config_file(KK_CONFIG_FILE_PATH,&configData);
//defaultCon:
//if(ret != 0){
//defaultFlag = 1;
ret = kk_check_config_file(KK_DEFAULT_CONFIG_FILE_PATH,&configData);
//}
if(ret == 0){
ret = _kk_get_config_dl_host(configData,url);
//if(ret == -2 && defaultFlag == 0){
//goto defaultCon;
//}
if(ret == 0){
again:
s_count++;
curl = curl_easy_init();
if (NULL == curl){
if(configData != NULL){
free(configData);
configData = NULL;
}
return -1;
}
if(access(KK_CONFIG_FILE_PATH,F_OK) != 0){
char cmd[128] = {0};
sprintf(cmd,"touch %s",KK_CONFIG_FILE_PATH);
system(cmd);
}
file = fopen(KK_CONFIG_FILE_PATH,"r+");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(curl, CURLOPT_URL, url);
//curl_easy_setopt(curl, CURLOPT_POSTFIELDS, WEATHER_DATA);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, receive_config_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)file);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 30000);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 100);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); //支持服务器跳转
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); // enable TCP keep-alive for this transfer
curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); // keep-alive idle time to 120 seconds
curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); // interval time between keep-alive probes: 60 seconds
struct curl_slist* headers = NULL;
sprintf(sds,"sds_ccu_id:%s",&ccuid[4]);
INFO_PRINT("sds:%s\n",sds);
headers = curl_slist_append(headers, "Content-Type:application/json");
headers = curl_slist_append(headers, sds);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POST, 0);//设置为非0表示本次操作为POST
res = curl_easy_perform(curl);
if(res != CURLE_OK){
curl_easy_cleanup(curl);
fclose(file);
ERROR_PRINT("WCHEN[%s][%d]res:%d\n",__FUNCTION__,__LINE__,res);
if(configData != NULL){
free(configData);
configData = NULL;
}
if(s_count < 15){
sleep(3);
ERROR_PRINT("get config again\n");
goto again;
}else{
ERROR_PRINT("get config timeout\n");
return -1;
}
}
curl_easy_cleanup(curl);
fclose(file);
}
}
if(configData != NULL){
free(configData);
configData = NULL;
}
return 0;
}
\ No newline at end of file
......@@ -41,12 +41,14 @@ static int kk_info_get(char *str)
char version[VERSION_MAXLEN] = {0};
char *str_tmp = NULL;
char ccuid[32] = {0};
char pid[32] = {0};
if(str == NULL){
return -1;
}
//HAL_GetVersion(version);
KK_Get_ccuid(ccuid);
kk_cloud_get_pid(pid);
cJSON *root = cJSON_CreateObject();
if (root)
{
......@@ -87,7 +89,7 @@ static int kk_info_get(char *str)
char s_IP[NETWORK_ADDR_LEN] = {0};
HAL_Get_IP(s_IP,NULL);
cJSON_AddItemToObject(args, "net", net);
cJSON_AddStringToObject(net, "interface", CCU_LAN);
cJSON_AddStringToObject(net, "interface", "eth0");
cJSON_AddStringToObject(net, "ip", s_IP);
}
cJSON *lsc_status = cJSON_CreateObject();
......@@ -100,7 +102,7 @@ static int kk_info_get(char *str)
if (qr_code)
{
char qrcodeStr[256] = {0};
sprintf(qrcodeStr,"KONKE-CCU:%s:%s:BBE3C5A5FC1FDB6CA1A386AB321D02AB",KK_CCU_PRODUCTID,&ccuid[4]);
sprintf(qrcodeStr,"KONKE-CCU:%s:%s:BBE3C5A5FC1FDB6CA1A386AB321D02AB",pid,&ccuid[4]);
cJSON_AddItemToObject(args, "qr_code", qr_code);
cJSON_AddStringToObject(qr_code, "string", qrcodeStr);
cJSON_AddBoolToObject(qr_code, "show", 1);
......
......@@ -17,18 +17,41 @@
#include "kk_product.h"
#include "kcloud_config.h"
#include "infra_sha256.h"
#include <string.h>
#include <stdlib.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include "kk_log.h"
//#include <curl/curl.h>
#include "../../common/curl/include/curl/curl.h"
#include "MQTTAsync.h"
#include "mqtt_api.h"
#define BUFSIZE 1024
#define PRODUCTSECRET "123456"
static int isIpV4Addr(const char *ipAddr)
{
int ip_part_1 = 0;
int ip_part_2 = 0;
int ip_part_3 = 0;
int ip_part_4 = 0;
char end_char = 0;
if((NULL == ipAddr) || (0 == strlen(ipAddr))){
return -1;
}
if(4 == sscanf(ipAddr,"%d.%d.%d.%d%c",&ip_part_1,&ip_part_2,&ip_part_3,&ip_part_4,&end_char)){
if((ip_part_1 >= 0) && (ip_part_1 <= 255) &&
(ip_part_2 >= 0) && (ip_part_2 <= 255) &&
(ip_part_3 >= 0) && (ip_part_3 <= 255) &&
(ip_part_4 >= 0) && (ip_part_4 <= 255)
){
return 0;
}
}
return -1;
}
int kk_execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len)
{
if(cmd == NULL || buf == NULL || buf_len == 0)
......@@ -95,8 +118,13 @@ int kk_parse_token(char *info){
fp = fopen(KK_TOKEN_PATH, "w+");
if(fp != NULL){
fwrite(jwt->valuestring,strlen(jwt->valuestring),1,fp);
#ifdef CONFIG_A133_PLATFORM
fsync(fp);
fclose(fp);
#else
fclose(fp);
system("sync");
system("sync;sync;sync");
#endif
}
//cJSON *ccuid = cJSON_GetObjectItem(infoObj,"ccu_id");
//if(ccuid == NULL) return -1;
......@@ -209,7 +237,6 @@ static char * kk_create_register_info()
{
cJSON *root;
char *out = NULL;
char *productCode = KK_CCU_PRODUCTID;
char *signSource,*base64Out = NULL;
char mac[16] = {0};
char ramdonId[16] = {0};
......@@ -217,23 +244,19 @@ static char * kk_create_register_info()
char sign_hex_str[65] = {0};
uint8_t productSecret[64] = {0};
char ccuid[32] = {0};
char pid[32] = {0};
int productSecret_len = 0;
char keyTmp[64] = {0};
root=cJSON_CreateObject();
HAL_Get_mac(mac);
HAL_GetTime_s(ramdonId);
KK_Get_ccuid(ccuid);
kk_cloud_get_pid(pid);
kk_cloud_get_key(keyTmp);
cJSON_AddStringToObject(root, "deviceCode", ccuid);
cJSON_AddStringToObject(root, "productCode",productCode);
signSource = kk_dictionary_order(ccuid,productCode,KK_CCU_RANDOM);
HAL_Execel_cmd(GET_KEY_CMD,(char *)productSecret,sizeof(productSecret),&productSecret_len);
if(productSecret_len == 0){
utils_hmac_sha256((const uint8_t *)signSource, strlen(signSource), (const uint8_t *)PRODUCTSECRET, strlen(PRODUCTSECRET), sign_hex);
}else{
memcpy(keyTmp,productSecret,productSecret_len-1);
cJSON_AddStringToObject(root, "productCode",pid);
signSource = kk_dictionary_order(ccuid,pid,KK_CCU_RANDOM);
utils_hmac_sha256((const uint8_t *)signSource, strlen(signSource), (const uint8_t *)keyTmp, strlen((const char*)keyTmp), sign_hex);
}
arrayToStr(sign_hex,32,sign_hex_str);
base64Out = malloc(128);
......@@ -264,12 +287,14 @@ static char * kk_create_get_jwt_info()
char timestamp[16] = {0};
char deviceSecret[64] = {0};
char ccuid[32] = {0};
char pid[32] = {0};
HAL_GetTime_s(timestamp);
KK_Get_ccuid(ccuid);
kk_cloud_get_pid(pid);
sprintf(g_clientId, CLIENTID, ccuid,timestamp);
root=cJSON_CreateObject();
cJSON_AddStringToObject(root, "deviceCode", ccuid);
cJSON_AddStringToObject(root, "productCode",KK_CCU_PRODUCTID);
cJSON_AddStringToObject(root, "productCode",pid);
cJSON_AddStringToObject(root, "clientId",g_clientId);
fp = fopen(KK_DEVICESECRET_PATH, "r");
if(fp != NULL){
......@@ -436,3 +461,264 @@ int kk_start_ccu_register(void)
close(sockfd);
return -1;
}
static int _kk_parse_auth_dl_host(cJSON *authInfo,char *url){
if(authInfo == NULL ||url == NULL){
return -1;
}
cJSON *host = cJSON_GetObjectItem(authInfo,"host");
cJSON *proto = cJSON_GetObjectItem(authInfo,"proto");
cJSON *port = cJSON_GetObjectItem(authInfo,"port");
if(host != NULL && proto != NULL && port != NULL){
sprintf(url,"%s://%s:%d/auth-server/1.0/ccu_std/auth",proto->valuestring,host->valuestring,port->valueint);
INFO_PRINT("%s\n",url);
return 0;
}
return -1;
}
static int _kk_get_auth_dl_host(char *buf,char *url){
cJSON *authInfo = NULL;
if(buf == NULL || url == NULL){
return -1;
}
cJSON* configObj = cJSON_Parse(buf);
if(configObj == NULL){
return -2;
}
cJSON *data = cJSON_GetObjectItem(configObj,"data");
if(data == NULL){
authInfo = cJSON_GetObjectItem(configObj,"mqtt_auth_entry");
}else{
authInfo = cJSON_GetObjectItem(data,"mqtt_auth_entry");
}
_kk_parse_auth_dl_host(authInfo,url);
cJSON_Delete(configObj);
return 0;
}
static int s_getAuthSize = 0;
size_t receive_auth_data(void *buffer, size_t size, size_t nmemb, FILE *file){
INFO_PRINT("buffer:%s\n",buffer);
size_t s_getAuthSize = fwrite(buffer, size, nmemb, file);
return s_getAuthSize;
}
static int _kk_auth_param_get(char *param){
char productId[32] = {0};
char key[128] = {0};
char ccuid[32] = {0};
int productid_len = 0;
int key_len = 0;
if(param == NULL){
return -1;
}
KK_Get_ccuid(ccuid);
kk_cloud_get_pid(productId);
kk_cloud_get_key(key);
sprintf(param, "{\"username\":\"%s\",\"password\":\"%s\",\"productid\":\"%s\"}",
ccuid, key, productId);
//sprintf(param, "{\"username\":\"%s\",\"password\":\"%s\",\"productid\":\"%s\"}",
//"CCU_17199", "AD4C58175AC4029B9B63EC88656FE61D", "ccu_n12");
INFO_PRINT("param:%s\n",param);
return 0;
}
int kk_register_auth_get(){
int ret = 0;
char *configData = NULL;
char url[512] = {0};
char param[512] = {0};
FILE *file;
int defaultFlag = 0;
CURLcode res;
static int s_count = 0;
CURL* curl;
ret = kk_check_config_file(KK_CONFIG_FILE_PATH,&configData);
defaultCon:
if(ret != 0){
defaultFlag = 1;
ret = kk_check_config_file(KK_DEFAULT_CONFIG_FILE_PATH,&configData);
}
if(ret == 0){
ret = _kk_get_auth_dl_host(configData,url);
if(ret == -2 && defaultFlag == 0){
goto defaultCon;
}
if(ret == 0){
again:
s_count++;
curl = curl_easy_init();
if (NULL == curl){
if(configData != NULL){
free(configData);
configData = NULL;
}
return -1;
}
_kk_auth_param_get(param);
file = fopen(KK_AUTH_CONFIG_FILE_PATH,"w+");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, param);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, receive_auth_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)file);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 3000);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 100);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); //支持服务器跳转
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); // enable TCP keep-alive for this transfer
curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); // keep-alive idle time to 120 seconds
curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); // interval time between keep-alive probes: 60 seconds
res = curl_easy_perform(curl);
if(res != CURLE_OK){
curl_easy_cleanup(curl);
fclose(file);
if(configData != NULL){
free(configData);
configData = NULL;
}
if(s_count < 3){
sleep(2);
goto again;
}else{
return -2;
}
}
curl_easy_cleanup(curl);
fclose(file);
}
}
if(configData != NULL){
free(configData);
configData = NULL;
}
return 0;
}
static int _kk_parse_mq_info(char *data,char *mqhost,char *mqport,char *mqclientId,char *mqpwd,char *mqusr){
cJSON* configObj = NULL;
char tmpIP[17] = {0};
if(data == NULL){
return -1;
}
configObj = cJSON_Parse(data);
if(configObj == NULL){
return -1;
}
cJSON *authdata = cJSON_GetObjectItem(configObj,"data");
if(authdata == NULL) {cJSON_Delete(configObj);return -1;}
cJSON *hostJson = cJSON_GetObjectItem(authdata,"host");
if(hostJson == NULL) {cJSON_Delete(configObj);return -1;}
if(isIpV4Addr(hostJson->valuestring) != 0){
struct hostent *host = gethostbyname(hostJson->valuestring);
if(NULL == host){
ERROR_PRINT("gethostbyname h_errno\n");
cJSON_Delete(configObj);
return -1;
}
memcpy(tmpIP,inet_ntoa(*(struct in_addr*)(host->h_addr_list[0])),strlen(inet_ntoa(*(struct in_addr*)(host->h_addr_list[0]))));
}else{
memcpy(tmpIP,hostJson->valuestring,strlen(hostJson->valuestring));
}
cJSON *port = cJSON_GetObjectItem(authdata,"port");
if(port == NULL) {cJSON_Delete(configObj);return -1;}
cJSON *clientId = cJSON_GetObjectItem(authdata,"clientId");
if(clientId == NULL) {cJSON_Delete(configObj);return -1;}
cJSON *password = cJSON_GetObjectItem(authdata,"password");
if(password == NULL) {cJSON_Delete(configObj);return -1;}
cJSON *username = cJSON_GetObjectItem(authdata,"username");
if(username == NULL) {cJSON_Delete(configObj);return -1;}
strncpy(mqhost,tmpIP,strlen(tmpIP));
strncpy(mqport,port->valuestring,strlen(port->valuestring));
strncpy(mqclientId,clientId->valuestring,strlen(clientId->valuestring));
strncpy(mqpwd,password->valuestring,strlen(password->valuestring));
strncpy(mqusr,username->valuestring,strlen(username->valuestring));
cJSON_Delete(configObj);
return 0;
}
MQTTAsync kk_connect_default(void)
{
int ret = 0;
char *configData = NULL;
char tmpIP[17] = {0};
char key[128] = {0};
char usrname[32] = {0};
char clientId[128] = {0};
int key_len = 0;
char portStr[16] = {0};
KK_Get_ccuid(usrname);
HAL_Execel_cmd(GET_KEY_CMD,(char *)key,sizeof(key),&key_len);
key[key_len-1] = '\0';
ret = kk_check_config_file(KK_DEFAULT_CONFIG_FILE_PATH,&configData);
cJSON* configObj = cJSON_Parse(configData);
if(configObj == NULL){
goto error;
}
cJSON *mqttentry = cJSON_GetObjectItem(configObj,"mqtt_entry");
if(mqttentry == NULL) goto error;
cJSON *hostJson = cJSON_GetObjectItem(mqttentry,"host");
if(hostJson == NULL) goto error;
cJSON *port = cJSON_GetObjectItem(mqttentry,"port");
if(port == NULL) goto error;
cJSON *proto = cJSON_GetObjectItem(mqttentry,"proto");
if(proto == NULL) goto error;
if(isIpV4Addr(hostJson->valuestring) != 0){
struct hostent *host = gethostbyname(hostJson->valuestring);
if(NULL == host){
INFO_PRINT("gethostbyname h_errno\n");
goto error;
}
memcpy(tmpIP,inet_ntoa(*(struct in_addr*)(host->h_addr_list[0])),strlen(inet_ntoa(*(struct in_addr*)(host->h_addr_list[0]))));
}else{
memcpy(tmpIP,hostJson->valuestring,strlen(hostJson->valuestring));
}
sprintf(clientId,"GID_CCU@KONKE@CCU_STD@%s@1",usrname);
if(configObj != NULL){
cJSON_Delete(configObj);
}
if(configData != NULL){
free(configData);
configData = NULL;
}
sprintf(portStr,"%d",port->valueint);
return KK_MQTT_Connect_ex(usrname,key,clientId,tmpIP,portStr);
error:
if(configObj != NULL){
cJSON_Delete(configObj);
}
if(configData != NULL){
free(configData);
configData = NULL;
}
return NULL;
}
MQTTAsync kk_mqtt_connect(){
char *configData = NULL;
char host[128] = {0};
char port[8] = {0};
char pwd[512] = {0};
char usrname[32] = {0};
char clientId[128] = {0};
int ret = 0;
int defaultFlag = 0;
cJSON* configObj = NULL;
ret = kk_check_config_file(KK_AUTH_CONFIG_FILE_PATH,&configData);
if(ret == 0){
//defaultFlag = 1;
//ret = kk_check_config_file(KK_DEFAULT_CONFIG_FILE_PATH,&configData);
ret = _kk_parse_mq_info(configData,host,port,clientId,pwd,usrname);
if(ret == 0){
if(configData != NULL){
free(configData);
configData = NULL;
}
return KK_MQTT_Connect_ex(usrname,pwd,clientId,host,port);
}else{
return kk_connect_default();
}
}else{
return kk_connect_default();
}
}
\ No newline at end of file
......@@ -114,17 +114,17 @@ void KK_reset_sub_flag(void)
}
int KK_CCU_TOPIC_Subscribe(void)
{
char productCode[PRODUCT_CODE_LEN] = {0};
if(s_ccu_topic_sub == 1){
INFO_PRINT("[%s][%d] already Subscribe\n",__FUNCTION__,__LINE__);
//return -1;
}
char ccuid[32] = {0};
KK_Get_ccuid(ccuid);
char pid[32] = {0};
kk_cloud_get_pid(pid);
s_ccu_topic_sub = 1;
HAL_GetProduct_Code(productCode);
return _kk_ccu_topic_subscribe(productCode,ccuid);
return _kk_ccu_topic_subscribe(pid,ccuid);
}
static int _kk_utils_topic(_IN_ const char *name, _IN_ char *product_code,
......@@ -241,8 +241,9 @@ char* KK_Make_Topic(cJSON *info,cJSON *data)
{
cJSON *type,*product_code,*device_code;
char *topic = NULL;
char pid[32] = {0};
//root=cJSON_Parse((char*)info->valuestring);
kk_cloud_get_pid(pid);
type = cJSON_GetObjectItem(info, MSG_TYPE_STR);
if(type == NULL){
goto errorreturn;
......@@ -256,7 +257,7 @@ char* KK_Make_Topic(cJSON *info,cJSON *data)
if(device_code == NULL){
goto errorreturn;
}
if((!strcmp(product_code->valuestring,"15") || !strcmp(product_code->valuestring,KK_CCU_PRODUCTID)) && \
if((!strcmp(product_code->valuestring,pid)) && \
(strstr(type->valuestring,"thing/status/online") != NULL)){
KK_CCU_TOPIC_Subscribe();
}
......
......@@ -232,8 +232,10 @@ MQTTAsync KK_MQTT_Connect(void)
}
HAL_Get_mac(mac);
char ccuid[32] = {0};
char pid[32] = {0};
KK_Get_ccuid(ccuid);
sprintf(usrname, "%s.%s", ccuid,KK_CCU_PRODUCTID);
kk_cloud_get_pid(pid);
sprintf(usrname, "%s.%s", ccuid,pid);
INFO_PRINT("cliendid:%s,usrname:%s\n",g_clientId,usrname);
INFO_PRINT("------------>token:%s\n",token);
sprintf(temp_address,"tcp://%s:1983",s_ServerIp);
......@@ -266,7 +268,45 @@ MQTTAsync KK_MQTT_Connect(void)
}
return s_Client;
}
MQTTAsync KK_MQTT_Connect_ex(char *usrname,char*pwd,char*cliendId,char*host,char*port)
{
int rc = 0;
char temp_address[256] = {0};
FILE *fp;
MQTTAsync_createOptions opts = MQTTAsync_createOptions_initializer;
MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;
MQTTAsync_setTraceCallback(mqttTraceCallback);
opts.MQTTVersion = MQTTVERSION_3_1_1;
sprintf(temp_address,"tcp://%s:%s",host,port);
INFO_PRINT("------------>temp_address:%s\n",temp_address);
if ((rc = MQTTAsync_createWithOptions(&s_Client, temp_address, cliendId, MQTTCLIENT_PERSISTENCE_NONE, NULL,&opts)) != MQTTASYNC_SUCCESS)
{
ERROR_PRINT("Failed to create client object, return code %d\n", rc);
return NULL;
}
/*Set the mqtt callback*/
mqtt_set_callbacks();
conn_opts.keepAliveInterval = 30;
conn_opts.connectTimeout = CONNECT_TIMEOUT;
conn_opts.automaticReconnect = AUTO_CONN;
conn_opts.minRetryInterval = 1;
conn_opts.maxRetryInterval = 32;
//conn_opts.username = USRNAME;
//conn_opts.password = PASSWORD;
conn_opts.username = usrname;
conn_opts.password = pwd;
conn_opts.cleansession = 1;
conn_opts.onSuccess = onConnect;
conn_opts.onFailure = onConnectFailure;
conn_opts.context = s_Client;
if ((rc = MQTTAsync_connect(s_Client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
ERROR_PRINT("Failed to start connect, return code %d\n", rc);
return NULL;
}
return s_Client;
}
int KK_MQTT_SubTopic(char *topicName)
{
INFO_PRINT("to subtopic:%s \n",topicName);
......
......@@ -17,5 +17,6 @@ extern int KK_MQTT_UnsubTopic(const char *topicName);
extern MQTTAsync KK_MQTT_Connect(void);
int kk_get_cloud_status(void);
void kk_write_disconnect_flag(void);
MQTTAsync KK_MQTT_Connect_ex(char *usrname,char*pwd,char*cliendId,char*host,char*port);
#endif
LIBA_TARGET := libiot_luoma.a
$(call Append_Conditional, LIB_SRCS_EXCLUDE, kk_luoma_main.c)
$(call Append_Conditional, SRCS_kk_luoma, kk_luoma_main.c)
$(call Append_Conditional, TARGET, kk_luoma)
CFLAGS += -I$(TOP_DIR)/common/api
CFLAGS += -I$(TOP_DIR)/common/json
CFLAGS += -I$(TOP_DIR)/common/nanomsg/include
CFLAGS += -I$(TOP_DIR)/common/ev/include
LDFLAGS += -lkk_tsl
LDFLAGS += -lapi_com
ifeq ($(CONFIG_VENDOR),ubuntu)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_ubuntu
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_ubuntu
else
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg
LDFLAGS += -L$(TOP_DIR)/common/ev -lev
endif
LDFLAGS += -liot_cjson -liot_mqtt -ldl -lm -lanl -lkk_hal
/*******************************************************************************
* Copyright (c) 2012, 2020 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* https://www.eclipse.org/legal/epl-2.0/
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial contribution
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "MQTTAsync.h"
#include "mqtt_api.h"
#include "com_api.h"
#include "kk_product.h"
//#include "kcloud_log.h"
int main(int argc, char* argv[])
{
int rc = 0;
adasd
return rc;
}
......@@ -19,11 +19,18 @@ ifeq ($(CONFIG_MODEL),x86)
else ifeq ($(CONFIG_MODEL),nx5)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_nx5
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_nx5
else ifeq ($(CONFIG_MODEL),8197)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_8197 -lubacktrace
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_8197
else ifeq ($(CONFIG_MODEL),a133)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_a133
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_a133
else
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg
LDFLAGS += -L$(TOP_DIR)/common/ev -lev
endif
LDFLAGS += -liot_cjson -ldl -lm -lanl -lkk_hal
LDFLAGS += -liot_cjson -ldl -lm -lkk_hal
......@@ -379,7 +379,9 @@ int kk_data_handle(cJSON *json,int sockfd)
if(key != NULL){
kk_handle_del_history_info(key->valuestring);
}
}else if(strcmp(opcode->valuestring,VOICE_VOLUME_CTRL) == 0){
}
#ifdef VOICE_SUPPORT
else if(strcmp(opcode->valuestring,VOICE_VOLUME_CTRL) == 0){
cJSON *vol = cJSON_GetObjectItem(json, "arg");
if(vol != NULL){
kk_voice_control(atoi(vol->valuestring));
......@@ -413,7 +415,9 @@ int kk_data_handle(cJSON *json,int sockfd)
}
}else if(strcmp(opcode->valuestring,EXIT_VOICE_FACTORY) == 0){
kk_voice_exit_factory_mode();
}else{
}
#endif
else{
kk_ccu_opcode_handle(json);
}
}
......@@ -469,9 +473,11 @@ static int kk_parse_syncinfo(cJSON *payload)
int is_ccu_msg(cJSON *productCode,cJSON *deviceCode)
{
char ccuid[33] = {0};
char pid[33] = {0};
kk_lan_get_ccuid(ccuid);
if((strlen(productCode->valuestring)==strlen(KK_CCU_PRODUCTID) &&
!strcmp(productCode->valuestring,KK_CCU_PRODUCTID)) &&
kk_lan_get_pid(pid);
if((strlen(productCode->valuestring)==strlen(pid) &&
!strcmp(productCode->valuestring,pid)) &&
(strlen(deviceCode->valuestring)==strlen(ccuid) &&
!strcmp(deviceCode->valuestring,ccuid))){
return 1;
......@@ -781,7 +787,82 @@ static int kk_lan_scene_handle(cJSON *payload,int isAdd)
}
static int kk_client_reoprt_reply_handle(cJSON *payload)
{
int nodeId = 0;
if(payload == NULL){
return -1;
}
cJSON *params = cJSON_GetObjectItem(payload,"params");
if(params == NULL){
return -1;
}
cJSON *serialId = cJSON_GetObjectItem(params, "serialId");
if(serialId == NULL){
return -1;
}
cJSON *arg = cJSON_CreateObject();
cJSON_AddStringToObject(arg, "serialId", serialId->valuestring);
cJSON *root=cJSON_CreateObject();
cJSON_AddStringToObject(root, "nodeid", "*");
cJSON_AddStringToObject(root, "opcode", "CCU_CLIENT_REPORT");
cJSON_AddStringToObject(root, "status", "success");
cJSON_AddItemToObject(root, "arg", arg);
send_msg_to_module(root);
cJSON_Delete(root);
return 0;
}
static int kk_client_online_push_handle(cJSON *payload)
{
int nodeId = 0;
if(payload == NULL){
return -1;
}
cJSON *params = cJSON_GetObjectItem(payload,"params");
if(params == NULL){
return -1;
}
cJSON *serialId = cJSON_GetObjectItem(params, "serialId");
if(serialId == NULL){
return -1;
}
cJSON *online = cJSON_GetObjectItem(params, "online");
if(online == NULL){
return -1;
}
cJSON *arg = cJSON_CreateObject();
cJSON_AddStringToObject(arg, "serialId", serialId->valuestring);
cJSON_AddNumberToObject(arg, "online", online->valueint);
cJSON *root=cJSON_CreateObject();
cJSON_AddStringToObject(root, "nodeid", "*");
cJSON_AddStringToObject(root, "opcode", "CCU_CLIENT_ONLINE_PUSH");
cJSON_AddStringToObject(root, "status", "success");
cJSON_AddItemToObject(root, "arg", arg);
send_msg_to_module(root);
cJSON_Delete(root);
return 0;
}
static int kk_client_info_push_handle(cJSON *payload)
{
int nodeId = 0;
if(payload == NULL){
return -1;
}
cJSON *params = cJSON_GetObjectItem(payload,"params");
if(params == NULL){
return -1;
}
char* pData = cJSON_Print(params);
cJSON *root=cJSON_CreateObject();
cJSON_AddStringToObject(root, "nodeid", "*");
cJSON_AddStringToObject(root, "opcode", "GET_CCU_CLIENT_INFO");
cJSON_AddStringToObject(root, "status", "success");
cJSON_AddItemToObject(root, "arg", cJSON_Parse(pData));
send_msg_to_module(root);
cJSON_Delete(root);
free(pData);
return 0;
}
void KK_Data_FromMid(void* str,int len)
{
cJSON *json = NULL;
......@@ -818,13 +899,17 @@ void KK_Data_FromMid(void* str,int len)
INFO_PRINT("syncinfo_reply handle!!!");
kk_parse_syncinfo(payload);
kk_create_syncinfo_to_sdk(payload,0);
#ifdef VOICE_SUPPORT
kk_vp_syncinfo_handle(payload);
#endif
}else if (strstr(msgtype->valuestring,SYNCPUSH_MSG_TYPE_REPLY) != NULL){
INFO_PRINT("syncinfopush_reply handle!!!");
kk_parse_syncinfo(payload);
kk_create_syncinfo_to_sdk(payload,1);
#ifdef VOICE_SUPPORT
kk_vp_syncinfo_handle(payload);
#endif
}
else if(strstr(msgtype->valuestring,"/thing/event/property/post")!= NULL){
INFO_PRINT("property post handle!!!");
......@@ -869,9 +954,16 @@ void KK_Data_FromMid(void* str,int len)
}else if(strstr(msgtype->valuestring,"/thing/event/deleteSceneNotification/post")!= NULL){
INFO_PRINT("deleteSceneNotification handle!!!");
kk_lan_scene_handle(payload,0);
}else if(strstr(msgtype->valuestring,"/thing/service/clientReport_reply")!= NULL){
INFO_PRINT("clientReport_reply handle!!!");
kk_client_reoprt_reply_handle(payload);
}else if(strstr(msgtype->valuestring,"/thing/service/clientOnlinePush")!= NULL){
INFO_PRINT("clientOnlinePush handle!!!");
kk_client_online_push_handle(payload);
}else if(strstr(msgtype->valuestring,"/thing/service/getClientInfo_reply")!= NULL){
INFO_PRINT("getClientInfo_reply handle!!!");
kk_client_info_push_handle(payload);
}
//
cJSON_Delete(json);
}
......
......@@ -34,9 +34,15 @@ static int kk_findccu_ack(int sockfd,struct sockaddr_in *addr){
args = cJSON_CreateObject();
if(args){
cJSON_AddItemToObject(json, "arg", args);
#ifdef CONFIG_A133_PLATFORM
cJSON_AddStringToObject(args, "zkid", ccuid);
cJSON_AddStringToObject(args, "zk", KK_CCU_NAME);
HAL_Get_IP(s_IP,"eth0");
#else
cJSON_AddStringToObject(args, "zkid", &ccuid[4]);
cJSON_AddStringToObject(args, "zk", KK_CCU_NAME);
HAL_Get_IP(s_IP,NULL);
#endif
cJSON_AddStringToObject(args, "ip", s_IP);
cJSON_AddBoolToObject(args, "ssl", FALSE);
}
......
......@@ -17,5 +17,5 @@
int kk_lan_get_ccuid(_OU_ char *device_code);
int kk_findccu_handle_init(void);
int kk_lan_get_pid(_OU_ char *productId);
#endif
\ No newline at end of file
......@@ -11,7 +11,7 @@
#include "kk_oldccu_msg.h"
#include "kk_newccu_msg.h"
#include "kk_lan_node_db.h"
#include "kk_findccu_handle.h"
extern int kk_lan_get_ccuid(_OU_ char *device_code);
......@@ -163,7 +163,9 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
static int kk_guard_ctrl_handle(int status)
{
char ccuid[33]={0};
char pid[33]={0};
kk_lan_get_ccuid(ccuid);
kk_lan_get_pid(pid);
cJSON *root = cJSON_CreateObject();
cJSON *params = cJSON_CreateObject();
cJSON_AddStringToObject(params,"epNum","1");
......@@ -174,13 +176,53 @@ static int kk_guard_ctrl_handle(int status)
}else{ //³··À
cJSON_AddStringToObject(params,"ArmingState","1");
}
cJSON *info = property_info_build("/thing/service/property/set",KK_CCU_PRODUCTID,ccuid);
cJSON *info = property_info_build("/thing/service/property/set",pid,ccuid);
cJSON *payload = property_payload_build("thing.service.property.set","1","v1.0",params);
cJSON_AddItemToObject(root,INFO_STRING,info);
cJSON_AddItemToObject(root,PAYLOAD_STRING,payload);
kk_ipc_send_json(root);
return 0;
}
static int kk_client_report_handle(cJSON *arg)
{
char ccuid[33]={0};
char pid[33]={0};
if(arg == NULL){
return -1;
}
char* pData = cJSON_Print(arg);
kk_lan_get_ccuid(ccuid);
kk_lan_get_pid(pid);
cJSON *root = cJSON_CreateObject();
cJSON *info = property_info_build("/thing/service/clientReport",pid,ccuid);
cJSON *payload = property_payload_build("thing.service.clientReport","1","v1.0",cJSON_Parse(pData));
cJSON_AddItemToObject(root,INFO_STRING,info);
cJSON_AddItemToObject(root,PAYLOAD_STRING,payload);
//printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
kk_ipc_send_json(root);
//printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
free(pData);
return 0;
}
static int kk_get_client_info_handle(cJSON *arg)
{
char ccuid[33]={0};
char pid[33]={0};
if(arg == NULL){
return -1;
}
char* pData = cJSON_Print(arg);
kk_lan_get_ccuid(ccuid);
kk_lan_get_pid(pid);
cJSON *root = cJSON_CreateObject();
cJSON *info = property_info_build("/thing/service/getClientInfo",pid,ccuid);
cJSON *payload = property_payload_build("thing.service.getClientInfo","1","v1.0",cJSON_Parse(pData));
cJSON_AddItemToObject(root,INFO_STRING,info);
cJSON_AddItemToObject(root,PAYLOAD_STRING,payload);
kk_ipc_send_json(root);
free(pData);
return 0;
}
static int kk_indoorAir_ctrl_handle(char *epNum,cJSON *arg)
{
kk_map_dev_node_t *dev = NULL;
......@@ -310,12 +352,9 @@ int kk_ccu_opcode_handle(cJSON *root)
if(opcode==NULL||opcode->type!=cJSON_String){
return -1;
}
if(nodeId==NULL||opcode==NULL||arg==NULL ){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return -1;
}
if(requester!=NULL){
WARNING_PRINT("[requester]%s\n",requester->valuestring);
if(strcmp(requester->valuestring,"HJ_CentralAC") == 0 &&
......@@ -337,13 +376,17 @@ int kk_ccu_opcode_handle(cJSON *root)
}else if(strcmp(opcode->valuestring,"DISARMING") == 0){
kk_guard_ctrl_handle(1);
return 0;
}else if(strcmp(opcode->valuestring,"CCU_CLIENT_REPORT") == 0){
kk_client_report_handle(arg);
return 0;
}else if(strcmp(opcode->valuestring,GET_CCU_CLIENT_INFO) == 0){
kk_get_client_info_handle(arg);
return 0;
}
}
}
kk_lan_db_deviceCode_get(atoi(nodeId->valuestring),deviceCode);
//execute scene
if((requester!=NULL) &&(strcmp(requester->valuestring,HJ_PROFILE)==0) &&
(strcmp(opcode->valuestring,"SWITCH")==0)){
......
......@@ -4,13 +4,6 @@
int kk_ccu_opcode_handle(cJSON *root);
void property_post_deal(const char *deviceCode,cJSON *payload);
......
......@@ -104,7 +104,7 @@ static const int g_syslog = 1;
//#define VOICE_SUPPORT
......
......@@ -35,7 +35,7 @@
#include "kk_data_mng.h"
#include "kk_lan_debug.h"
extern char * _kk_data_create(char *msgtype,const char *productCode,const char *deviceCode,const char *param);
extern int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len);
static char s_ccuid[DEVICE_CODE_LEN] = {0};
int kk_lan_get_ccuid(_OU_ char *device_code)
......@@ -51,7 +51,50 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
strncpy(s_ccuid, device_code, len);
return len;
}
extern int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len);
char s_pid[PRODUCT_CODE_LEN] = {0};
static int kk_lan_pid_init(void)
{
#ifdef CONFIG_A133_PLATFORM
uint8_t data[128] = {0};
int data_len = 0;
uint8_t uuid[32] = {0};
char *pstart = NULL;
char *pEnd = NULL;
HAL_Execel_cmd(GET_CCUID_CMD,(char *)data,sizeof(data),&data_len);
printf("GET_CCUID_CMD:%s\n",data);
if(data_len > 0 && data_len <= 128){
pstart = data;
pEnd = strstr(data,"pid_");
if(pstart != NULL && pEnd != NULL){
memcpy(s_pid,pEnd+4,data_len-1-(pEnd-pstart+4));
INFO_PRINT("s_pid:%s\n",s_pid);
}else{
return -1;
}
}else{
return -1;
}
#else
char pid[PRODUCT_CODE_LEN] = {0};
int pid_len = 0;
HAL_Execel_cmd(GET_PRODUCTID_CMD,(char *)pid,sizeof(pid),&pid_len);
if(pid_len > 0 && pid_len <= PRODUCT_CODE_LEN){
memcpy(s_pid,pid,pid_len-1);
INFO_PRINT("s_pid:%s\n",s_pid);
}else{
return -1;
}
#endif
return 0;
}
int kk_lan_get_pid(_OU_ char *productId)
{
strncpy(productId, s_pid, strlen(s_pid));
printf("kk_lan_get_ccuid:%s\n",s_pid);
return strlen(s_pid);
}
static void kk_lan_ccuid_init(void)
{
uint8_t ccuid[DEVICE_CODE_LEN] = {0};
......@@ -168,11 +211,11 @@ int main(int argc, char* argv[])
struct sigaction sa;
/* setup alarm signal handler */
#ifdef CONFIG_NX5_PLATFORM
for(int i=1;i<32;i++){
signal(i, handler);
}
#endif
//signal(SIGPIPE, SIG_IGN);
......@@ -188,7 +231,7 @@ int main(int argc, char* argv[])
//debug_log(LOG_CRITICAL_LEVEL,"[%s]run singleton fail!\n",argv[0]);
//return -1;
//}
kk_lan_pid_init();
kk_lan_ccuid_init();
/*set the callback to get the device date to cloud*/
......@@ -197,8 +240,9 @@ int main(int argc, char* argv[])
kk_map_dev_init();
kk_login_init();
#ifdef VOICE_SUPPORT
kk_voice_panel_init(argc,argv);
#endif
//lan_queue_init();
kk_lan_db_node_init();
......
......@@ -3,7 +3,11 @@
#include "sqlite3.h"
#ifdef CONFIG_A133_PLATFORM
#define KK_LAN_NODE_DB_FILE "/data/local/kk/kk_lan_node.db"
#else
#define KK_LAN_NODE_DB_FILE "/data/kk/kk_lan_node.db"
#endif
typedef struct {
void *mutex;
......
......@@ -811,7 +811,7 @@ int kk_sync_guard_to_sdk(cJSON *root,cJSON *data)
int i,num;
cJSON *item = NULL;
char roomIdStr[16] = {0};
RoomIdsAry = cJSON_GetObjectItem(properties,"RoomIds");
RoomIdsAry = cJSON_GetObjectItem(properties,"ccuRoomIds");
if(RoomIdsAry==NULL||RoomIdsAry->type!=cJSON_Array){
return -1;
}
......
......@@ -13,7 +13,7 @@
#include "Serial.h"
#include "uart_proto.h"
#ifdef VOICE_SUPPORT
static pthread_mutex_t v_mux;
......@@ -503,7 +503,7 @@ int kk_voice_panel_init(int argc, char* argv[])
return 0;
}
#endif
......
......@@ -4,7 +4,7 @@
#include "cJSON.h"
#include "kk_voice_panel_cfg.h"
#include "kk_lan_sync.h"
#ifdef VOICE_SUPPORT
typedef cJSON *(*dev_handle_func)(int ep,uint8_t *arg,uint8_t arg_len,kk_map_dev_node_t *node);
typedef struct {
......@@ -1251,7 +1251,7 @@ int kk_lan_vp_control(uint8_t num,uint32_t nodeIdAry[],uint8_t *arg,uint8_t arg_
return err;
}
#endif
......
#include "kk_log.h"
#include "klist.h"
#include "kk_product.h"
#include "com_api.h"
#include "kk_opcode.h"
#include "kk_lan_ctrl.h"
#include "kk_data_mng.h"
#include "kk_newccu_msg.h"
#include "kk_product.h"
#include "kk_lan_node_db.h"
#include "kk_findccu_handle.h"
static pthread_mutex_t *mutex = NULL;
int kk_new_msg_init(void)
......@@ -89,10 +85,12 @@ extern int kk_lan_get_ccuid(_OU_ char *device_code);
cJSON *scene_payload_build(const char*method,const char *msgId,cJSON *params)
{
char ccuid[33] = {0};
char pid[33] = {0};
cJSON *payload=cJSON_CreateObject();
kk_lan_get_ccuid(ccuid);
cJSON_AddStringToObject(payload, "productCode",KK_CCU_PRODUCTID);
kk_lan_get_pid(pid);
cJSON_AddStringToObject(payload, "productCode",pid);
cJSON_AddStringToObject(payload, "deviceCode",ccuid);
cJSON_AddStringToObject(payload, "identity","executeScene");
......@@ -111,16 +109,18 @@ cJSON * scene_execute(const char *sceneId)
{
char msgId[32] = {0};
char ccuid[33] = {0};
char pid[33] = {0};
cJSON *root=cJSON_CreateObject();
cJSON *params=cJSON_CreateObject();
cJSON *info,*payload;
kk_lan_get_ccuid(ccuid);
kk_lan_get_pid(pid);
printf("[execute scene]sceneId=%s\n",sceneId);
kk_lan_get_msg_id_str(msgId,sizeof(msgId));
cJSON_AddStringToObject(params,"sceneId",sceneId);
info = property_info_build("/thing/service/executeScene",KK_CCU_PRODUCTID,ccuid);
info = property_info_build("/thing/service/executeScene",pid,ccuid);
payload = scene_payload_build("thing.service.executeScene",msgId,params);
cJSON_AddItemToObject(root,INFO_STRING,info);
......@@ -136,6 +136,7 @@ int kk_ipc_send_json(cJSON *root)
char *msg;
if(root==NULL){
//printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
return -1;
}
......
......@@ -37,7 +37,7 @@
#define SWITCH_OPCODE "SWITCH"
#define GET_HISTORY_MSG_TYPE "/thing/service/historyAlarm"
#define DEL_HISTORY_MSG_TYPE "/thing/service/delAlarm"
#define GET_CCU_CLIENT_INFO "GET_CCU_CLIENT_INFO"
......
......@@ -3,15 +3,11 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "kk_voice_panel_cfg.h"
#include "kk_ccu_msg.h"
#include "kk_lan_node_db.h"
#include "kk_voice_panel_handle.h"
#ifdef VOICE_SUPPORT
static _OUT int node_id_check(_IN cJSON *zbDevsAry,_IN const char *id);
......@@ -1250,7 +1246,7 @@ _OUT int kk_vp_syncinfo(_IN cJSON *payload,_IN int ver,_OUT cJSON **root)
return -1;
}
#endif
......
......@@ -12,6 +12,7 @@
#include "Serial.h"
#include "kk_oldccu_msg.h"
#include <ctype.h>
#ifdef VOICE_SUPPORT
#define MK_VERSION(x) ((*x<<24) | (*(x+1)<<16) | (*(x+2)<<8) | *(x+3))
#define MK_UINT32(x) ((*x<<24) | (*(x+1)<<16) | (*(x+2)<<8) | *(x+3))
......@@ -1943,6 +1944,6 @@ static void kk_voice_volume_handle(pro_data_t *pro_data)
cJSON_Delete(root);
}
}
#endif
......@@ -2,10 +2,15 @@
#include <pthread.h>
#include "com_api.h"
#include "kk_log.h"
#ifdef CONFIG_A133_PLATFORM
#define APP2MID "ipc:///data/local/kk/etc/app2mid.ipc"
#define APP2MID_PUBSUB "ipc:///data/local/kk/etc/app2mid_pubsub.ipc"
#define PLAT2MID "ipc:///data/local/kk/etc/plat2mid.ipc"
#else
#define APP2MID "ipc:///tmp/app2mid.ipc"
#define APP2MID_PUBSUB "ipc:///tmp/app2mid_pubsub.ipc"
#define PLAT2MID "ipc:///tmp/plat2mid.ipc"
#endif
//#define GW2CCU_PIPE "tcp://%s:5555"
//#define GW2CCU_PUBSUB "tcp://%s:5557"
#define GW2CCU_PIPE "tcp://%s:35567"
......
......@@ -39,10 +39,12 @@ typedef enum {
#define MSG_INFO_STR "info"
#define MSG_INDENTIFIER_STR "identifier"
#define MSG_DATA_TYPE_STR "dataType"
#define MSG_DEVICE_IP "ip"
#define MSG_DEVICE_VERSION "version"
#define MSG_DEVICE_SERIALID "serialId"
#define MSG_DEVICE_DEVICEINFO "deviceInfo"
#define MSG_DEVICE_TYPE "type"
#define MSG_DEVICE_EXPAND "expand"
#define MSG_PARAMS_STR "params"
#define MSG_IOTClOUDSTATE_STR "IOTCloudState"
#define MSG_TOPO_CHANGE_TYPE_STR "changeType"
......@@ -52,6 +54,8 @@ typedef enum {
#define MSG_AREA_ADDROOM_DEVICENAME "name"
#define MSG_AREA_ADDROOM_ROOMNAME "roomName"
#define MSG_AREA_ROOM_ROOMID "roomId"
#define MSG_AREA_ROOM_CCUROOMIDS "ccuRoomIds"
#define MSG_AREA_ROOM_CCUROOMID "ccuRoomId"
#define MSG_AREA_ROOM_EPNUM "epNum"
#define MSG_AREA_ROOM_ACTION "action"
#define MSG_AREA_ADDROOM_NOTIFICATION "addRoomNotification"
......@@ -146,6 +150,7 @@ typedef enum {
#define BUFFER_SIZE 1024
#define MAX_LISTEN_NUM 10
#define MAX_IP_LEN 16
#define KK_DEVICE_SCREEN_MAX_SUPPORT 8
//#ifndef DEVICE_CODE_LEN
//#define DEVICE_CODE_LEN 33
//#endif
......
......@@ -8,6 +8,9 @@ ifeq ($(CONFIG_MODEL),x86)
else ifeq ($(CONFIG_MODEL),nx5)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_nx5
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_nx5
else ifeq ($(CONFIG_MODEL),a133)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_a133
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_a133
else
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg
LDFLAGS += -L$(TOP_DIR)/common/ev -lev
......
#ifndef CURLINC_CURL_H
#define CURLINC_CURL_H
#ifndef __CURL_CURL_H
#define __CURL_CURL_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
......@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
......@@ -38,12 +38,12 @@
#include "system.h" /* determine things run-time */
/*
* Define CURL_WIN32 when build target is Win32 API
* Define WIN32 when build target is Win32 API
*/
#if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && \
!defined(__SYMBIAN32__)
#define CURL_WIN32
#if (defined(_WIN32) || defined(__WIN32__)) && \
!defined(WIN32) && !defined(__SYMBIAN32__)
#define WIN32
#endif
#include <stdio.h>
......@@ -54,13 +54,11 @@
#include <osreldate.h>
#endif
#ifndef CURL_AVOID_SYS_TYPES_H
/* The include stuff here below is mainly for time_t! */
#include <sys/types.h>
#include <time.h>
#endif
#if defined(CURL_WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__)
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__)
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || \
defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H))
/* The check above prevents the winsock2 inclusion if winsock.h already was
......@@ -81,13 +79,11 @@
#include <sys/select.h>
#endif
#if !defined(CURL_WIN32) && !defined(_WIN32_WCE) && \
!defined(CURL_AVOID_SYS_SOCKET_H)
#if !defined(WIN32) && !defined(_WIN32_WCE)
#include <sys/socket.h>
#endif
#if !defined(CURL_WIN32) && !defined(__WATCOMC__) && !defined(__VXWORKS__) && \
!defined(CURL_AVOID_SYS_TIME_H)
#if !defined(WIN32) && !defined(__WATCOMC__) && !defined(__VXWORKS__)
#include <sys/time.h>
#endif
......@@ -118,7 +114,7 @@ typedef void CURLSH;
#ifdef CURL_STATICLIB
# define CURL_EXTERN
#elif defined(CURL_WIN32) || defined(__SYMBIAN32__) || \
#elif defined(WIN32) || defined(__SYMBIAN32__) || \
(__has_declspec_attribute(dllexport) && \
__has_declspec_attribute(dllimport))
# if defined(BUILDING_LIBCURL)
......@@ -134,10 +130,7 @@ typedef void CURLSH;
#ifndef curl_socket_typedef
/* socket typedef */
#ifdef FreeRTOS
typedef Socket_t curl_socket_t;
#define CURL_SOCKET_BAD FREERTOS_INVALID_SOCKET
#elif defined(CURL_WIN32) && !defined(__LWIP_OPT_H__) && !defined(LWIP_HDR_OPT_H)
#if defined(WIN32) && !defined(__LWIP_OPT_H__) && !defined(LWIP_HDR_OPT_H)
typedef SOCKET curl_socket_t;
#define CURL_SOCKET_BAD INVALID_SOCKET
#else
......@@ -161,8 +154,7 @@ typedef enum {
CURLSSLBACKEND_SECURETRANSPORT = 9,
CURLSSLBACKEND_AXTLS = 10, /* never used since 7.63.0 */
CURLSSLBACKEND_MBEDTLS = 11,
CURLSSLBACKEND_MESALINK = 12,
CURLSSLBACKEND_BEARSSL = 13
CURLSSLBACKEND_MESALINK = 12
} curl_sslbackend;
/* aliases for library clones and renames */
......@@ -217,11 +209,6 @@ struct curl_httppost {
set. Added in 7.46.0 */
};
/* This is a return code for the progress callback that, when returned, will
signal libcurl to continue executing the default progress function */
#define CURL_PROGRESSFUNC_CONTINUE 0x10000001
/* This is the CURLOPT_PROGRESSFUNCTION callback prototype. It is now
considered deprecated but was the only choice up until 7.31.0 */
typedef int (*curl_progress_callback)(void *clientp,
......@@ -297,7 +284,10 @@ typedef enum {
#define CURLFINFOFLAG_KNOWN_SIZE (1<<6)
#define CURLFINFOFLAG_KNOWN_HLINKCOUNT (1<<7)
/* Information about a single file, used when doing FTP wildcard matching */
/* Content of this structure depends on information which is known and is
achievable (e.g. by FTP LIST parsing). Please see the url_easy_setopt(3) man
page for callbacks returning this structure -- some fields are mandatory,
some others are optional. The FLAG field has special meaning. */
struct curl_fileinfo {
char *filename;
curlfiletype filetype;
......@@ -415,7 +405,7 @@ struct curl_sockaddr {
unsigned int addrlen; /* addrlen was a socklen_t type before 7.18.0 but it
turned really ugly and painful on the systems that
lack this type */
struct curl_struct_sockaddr addr;
struct sockaddr addr;
};
typedef curl_socket_t
......@@ -613,10 +603,6 @@ typedef enum {
*/
CURLE_RECURSIVE_API_CALL, /* 93 - an api function was called from
inside a callback */
CURLE_AUTH_ERROR, /* 94 - an authentication function returned an
error */
CURLE_HTTP3, /* 95 - An HTTP/3 layer problem */
CURLE_QUIC_CONNECT_ERROR, /* 96 - QUIC connection error */
CURL_LAST /* never use! */
} CURLcode;
......@@ -781,7 +767,7 @@ enum curl_khtype {
};
struct curl_khkey {
const char *key; /* points to a null-terminated string encoded with base64
const char *key; /* points to a zero-terminated string encoded with base64
if len is zero, otherwise to the "raw" data */
size_t len;
enum curl_khtype keytype;
......@@ -836,19 +822,6 @@ typedef enum {
SSL backends where such behavior is present. */
#define CURLSSLOPT_NO_REVOKE (1<<1)
/* - NO_PARTIALCHAIN tells libcurl to *NOT* accept a partial certificate chain
if possible. The OpenSSL backend has this ability. */
#define CURLSSLOPT_NO_PARTIALCHAIN (1<<2)
/* - REVOKE_BEST_EFFORT tells libcurl to ignore certificate revocation offline
checks and ignore missing revocation list for those SSL backends where such
behavior is present. */
#define CURLSSLOPT_REVOKE_BEST_EFFORT (1<<3)
/* - CURLSSLOPT_NATIVE_CA tells libcurl to use standard certificate store of
operating system. Currently implemented under MS-Windows. */
#define CURLSSLOPT_NATIVE_CA (1<<4)
/* The default connection attempt delay in milliseconds for happy eyeballs.
CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.3 and happy-eyeballs-timeout-ms.d document
this value, keep them in sync. */
......@@ -913,7 +886,7 @@ typedef enum {
/* CURLALTSVC_* are bits for the CURLOPT_ALTSVC_CTRL option */
#define CURLALTSVC_IMMEDIATELY (1<<0)
#define CURLALTSVC_ALTUSED (1<<1)
#define CURLALTSVC_READONLYFILE (1<<2)
#define CURLALTSVC_H1 (1<<3)
#define CURLALTSVC_H2 (1<<4)
......@@ -948,7 +921,6 @@ typedef enum {
#define CURLPROTO_GOPHER (1<<25)
#define CURLPROTO_SMB (1<<26)
#define CURLPROTO_SMBS (1<<27)
#define CURLPROTO_MQTT (1<<28)
#define CURLPROTO_ALL (~0) /* enable everything */
/* long may be 32 or 64 bits, but we should never depend on anything else
......@@ -957,63 +929,79 @@ typedef enum {
#define CURLOPTTYPE_OBJECTPOINT 10000
#define CURLOPTTYPE_FUNCTIONPOINT 20000
#define CURLOPTTYPE_OFF_T 30000
#define CURLOPTTYPE_BLOB 40000
/* *STRINGPOINT is an alias for OBJECTPOINT to allow tools to extract the
string options from the header file */
/* name is uppercase CURLOPT_<name>,
type is one of the defined CURLOPTTYPE_<type>
number is unique identifier */
#ifdef CINIT
#undef CINIT
#endif
#define CURLOPT(na,t,nu) na = t + nu
#ifdef CURL_ISOCPP
#define CINIT(na,t,nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu
#else
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
#define LONG CURLOPTTYPE_LONG
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
#define OFF_T CURLOPTTYPE_OFF_T
#define CINIT(name,type,number) CURLOPT_/**/name = type + number
#endif
/* handy aliases that make no run-time difference */
#define CURLOPTTYPE_STRINGPOINT CURLOPTTYPE_OBJECTPOINT
#define CURLOPTTYPE_SLISTPOINT CURLOPTTYPE_OBJECTPOINT
/*
* All CURLOPT_* values.
* This macro-mania below setups the CURLOPT_[what] enum, to be used with
* curl_easy_setopt(). The first argument in the CINIT() macro is the [what]
* word.
*/
typedef enum {
/* This is the FILE * or void * the regular output should be written to. */
CURLOPT(CURLOPT_WRITEDATA, CURLOPTTYPE_OBJECTPOINT, 1),
CINIT(WRITEDATA, OBJECTPOINT, 1),
/* The full URL to get/put */
CURLOPT(CURLOPT_URL, CURLOPTTYPE_STRINGPOINT, 2),
CINIT(URL, STRINGPOINT, 2),
/* Port number to connect to, if other than default. */
CURLOPT(CURLOPT_PORT, CURLOPTTYPE_LONG, 3),
CINIT(PORT, LONG, 3),
/* Name of proxy to use. */
CURLOPT(CURLOPT_PROXY, CURLOPTTYPE_STRINGPOINT, 4),
CINIT(PROXY, STRINGPOINT, 4),
/* "user:password;options" to use when fetching. */
CURLOPT(CURLOPT_USERPWD, CURLOPTTYPE_STRINGPOINT, 5),
CINIT(USERPWD, STRINGPOINT, 5),
/* "user:password" to use with proxy. */
CURLOPT(CURLOPT_PROXYUSERPWD, CURLOPTTYPE_STRINGPOINT, 6),
CINIT(PROXYUSERPWD, STRINGPOINT, 6),
/* Range to get, specified as an ASCII string. */
CURLOPT(CURLOPT_RANGE, CURLOPTTYPE_STRINGPOINT, 7),
CINIT(RANGE, STRINGPOINT, 7),
/* not used */
/* Specified file stream to upload from (use as input): */
CURLOPT(CURLOPT_READDATA, CURLOPTTYPE_OBJECTPOINT, 9),
CINIT(READDATA, OBJECTPOINT, 9),
/* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE
* bytes big. */
CURLOPT(CURLOPT_ERRORBUFFER, CURLOPTTYPE_OBJECTPOINT, 10),
CINIT(ERRORBUFFER, OBJECTPOINT, 10),
/* Function that will be called to store the output (instead of fwrite). The
* parameters will use fwrite() syntax, make sure to follow them. */
CURLOPT(CURLOPT_WRITEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 11),
CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11),
/* Function that will be called to read the input (instead of fread). The
* parameters will use fread() syntax, make sure to follow them. */
CURLOPT(CURLOPT_READFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 12),
CINIT(READFUNCTION, FUNCTIONPOINT, 12),
/* Time-out the read operation after this amount of seconds */
CURLOPT(CURLOPT_TIMEOUT, CURLOPTTYPE_LONG, 13),
CINIT(TIMEOUT, LONG, 13),
/* If the CURLOPT_INFILE is used, this can be used to inform libcurl about
* how large the file being sent really is. That allows better error
......@@ -1024,20 +1012,20 @@ typedef enum {
* which takes an off_t type, allowing platforms with larger off_t
* sizes to handle larger files. See below for INFILESIZE_LARGE.
*/
CURLOPT(CURLOPT_INFILESIZE, CURLOPTTYPE_LONG, 14),
CINIT(INFILESIZE, LONG, 14),
/* POST static input fields. */
CURLOPT(CURLOPT_POSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 15),
CINIT(POSTFIELDS, OBJECTPOINT, 15),
/* Set the referrer page (needed by some CGIs) */
CURLOPT(CURLOPT_REFERER, CURLOPTTYPE_STRINGPOINT, 16),
CINIT(REFERER, STRINGPOINT, 16),
/* Set the FTP PORT string (interface name, named or numerical IP address)
Use i.e '-' to use default address. */
CURLOPT(CURLOPT_FTPPORT, CURLOPTTYPE_STRINGPOINT, 17),
CINIT(FTPPORT, STRINGPOINT, 17),
/* Set the User-Agent string (examined by some CGIs) */
CURLOPT(CURLOPT_USERAGENT, CURLOPTTYPE_STRINGPOINT, 18),
CINIT(USERAGENT, STRINGPOINT, 18),
/* If the download receives less than "low speed limit" bytes/second
* during "low speed time" seconds, the operations is aborted.
......@@ -1046,10 +1034,10 @@ typedef enum {
*/
/* Set the "low speed limit" */
CURLOPT(CURLOPT_LOW_SPEED_LIMIT, CURLOPTTYPE_LONG, 19),
CINIT(LOW_SPEED_LIMIT, LONG, 19),
/* Set the "low speed time" */
CURLOPT(CURLOPT_LOW_SPEED_TIME, CURLOPTTYPE_LONG, 20),
CINIT(LOW_SPEED_TIME, LONG, 20),
/* Set the continuation offset.
*
......@@ -1057,48 +1045,48 @@ typedef enum {
* off_t types, allowing for large file offsets on platforms which
* use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE.
*/
CURLOPT(CURLOPT_RESUME_FROM, CURLOPTTYPE_LONG, 21),
CINIT(RESUME_FROM, LONG, 21),
/* Set cookie in request: */
CURLOPT(CURLOPT_COOKIE, CURLOPTTYPE_STRINGPOINT, 22),
CINIT(COOKIE, STRINGPOINT, 22),
/* This points to a linked list of headers, struct curl_slist kind. This
list is also used for RTSP (in spite of its name) */
CURLOPT(CURLOPT_HTTPHEADER, CURLOPTTYPE_SLISTPOINT, 23),
CINIT(HTTPHEADER, SLISTPOINT, 23),
/* This points to a linked list of post entries, struct curl_httppost */
CURLOPT(CURLOPT_HTTPPOST, CURLOPTTYPE_OBJECTPOINT, 24),
CINIT(HTTPPOST, OBJECTPOINT, 24),
/* name of the file keeping your private SSL-certificate */
CURLOPT(CURLOPT_SSLCERT, CURLOPTTYPE_STRINGPOINT, 25),
CINIT(SSLCERT, STRINGPOINT, 25),
/* password for the SSL or SSH private key */
CURLOPT(CURLOPT_KEYPASSWD, CURLOPTTYPE_STRINGPOINT, 26),
CINIT(KEYPASSWD, STRINGPOINT, 26),
/* send TYPE parameter? */
CURLOPT(CURLOPT_CRLF, CURLOPTTYPE_LONG, 27),
CINIT(CRLF, LONG, 27),
/* send linked-list of QUOTE commands */
CURLOPT(CURLOPT_QUOTE, CURLOPTTYPE_SLISTPOINT, 28),
CINIT(QUOTE, SLISTPOINT, 28),
/* send FILE * or void * to store headers to, if you use a callback it
is simply passed to the callback unmodified */
CURLOPT(CURLOPT_HEADERDATA, CURLOPTTYPE_OBJECTPOINT, 29),
CINIT(HEADERDATA, OBJECTPOINT, 29),
/* point to a file to read the initial cookies from, also enables
"cookie awareness" */
CURLOPT(CURLOPT_COOKIEFILE, CURLOPTTYPE_STRINGPOINT, 31),
CINIT(COOKIEFILE, STRINGPOINT, 31),
/* What version to specifically try to use.
See CURL_SSLVERSION defines below. */
CURLOPT(CURLOPT_SSLVERSION, CURLOPTTYPE_LONG, 32),
CINIT(SSLVERSION, LONG, 32),
/* What kind of HTTP time condition to use, see defines */
CURLOPT(CURLOPT_TIMECONDITION, CURLOPTTYPE_LONG, 33),
CINIT(TIMECONDITION, LONG, 33),
/* Time to use with the above condition. Specified in number of seconds
since 1 Jan 1970 */
CURLOPT(CURLOPT_TIMEVALUE, CURLOPTTYPE_LONG, 34),
CINIT(TIMEVALUE, LONG, 34),
/* 35 = OBSOLETE */
......@@ -1106,58 +1094,37 @@ typedef enum {
HTTP: DELETE, TRACE and others
FTP: to use a different list command
*/
CURLOPT(CURLOPT_CUSTOMREQUEST, CURLOPTTYPE_STRINGPOINT, 36),
CINIT(CUSTOMREQUEST, STRINGPOINT, 36),
/* FILE handle to use instead of stderr */
CURLOPT(CURLOPT_STDERR, CURLOPTTYPE_OBJECTPOINT, 37),
CINIT(STDERR, OBJECTPOINT, 37),
/* 38 is not used */
/* send linked-list of post-transfer QUOTE commands */
CURLOPT(CURLOPT_POSTQUOTE, CURLOPTTYPE_SLISTPOINT, 39),
/* OBSOLETE, do not use! */
CURLOPT(CURLOPT_OBSOLETE40, CURLOPTTYPE_OBJECTPOINT, 40),
/* talk a lot */
CURLOPT(CURLOPT_VERBOSE, CURLOPTTYPE_LONG, 41),
/* throw the header out too */
CURLOPT(CURLOPT_HEADER, CURLOPTTYPE_LONG, 42),
/* shut off the progress meter */
CURLOPT(CURLOPT_NOPROGRESS, CURLOPTTYPE_LONG, 43),
CINIT(POSTQUOTE, SLISTPOINT, 39),
/* use HEAD to get http document */
CURLOPT(CURLOPT_NOBODY, CURLOPTTYPE_LONG, 44),
CINIT(OBSOLETE40, OBJECTPOINT, 40), /* OBSOLETE, do not use! */
/* no output on http error codes >= 400 */
CURLOPT(CURLOPT_FAILONERROR, CURLOPTTYPE_LONG, 45),
CINIT(VERBOSE, LONG, 41), /* talk a lot */
CINIT(HEADER, LONG, 42), /* throw the header out too */
CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */
CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */
CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 400 */
CINIT(UPLOAD, LONG, 46), /* this is an upload */
CINIT(POST, LONG, 47), /* HTTP POST method */
CINIT(DIRLISTONLY, LONG, 48), /* bare names when listing directories */
/* this is an upload */
CURLOPT(CURLOPT_UPLOAD, CURLOPTTYPE_LONG, 46),
/* HTTP POST method */
CURLOPT(CURLOPT_POST, CURLOPTTYPE_LONG, 47),
/* bare names when listing directories */
CURLOPT(CURLOPT_DIRLISTONLY, CURLOPTTYPE_LONG, 48),
/* Append instead of overwrite on upload! */
CURLOPT(CURLOPT_APPEND, CURLOPTTYPE_LONG, 50),
CINIT(APPEND, LONG, 50), /* Append instead of overwrite on upload! */
/* Specify whether to read the user+password from the .netrc or the URL.
* This must be one of the CURL_NETRC_* enums below. */
CURLOPT(CURLOPT_NETRC, CURLOPTTYPE_LONG, 51),
/* use Location: Luke! */
CURLOPT(CURLOPT_FOLLOWLOCATION, CURLOPTTYPE_LONG, 52),
CINIT(NETRC, LONG, 51),
/* transfer data in text/ASCII format */
CURLOPT(CURLOPT_TRANSFERTEXT, CURLOPTTYPE_LONG, 53),
CINIT(FOLLOWLOCATION, LONG, 52), /* use Location: Luke! */
/* HTTP PUT */
CURLOPT(CURLOPT_PUT, CURLOPTTYPE_LONG, 54),
CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */
CINIT(PUT, LONG, 54), /* HTTP PUT */
/* 55 = OBSOLETE */
......@@ -1165,267 +1132,265 @@ typedef enum {
* Function that will be called instead of the internal progress display
* function. This function should be defined as the curl_progress_callback
* prototype defines. */
CURLOPT(CURLOPT_PROGRESSFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 56),
CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56),
/* Data passed to the CURLOPT_PROGRESSFUNCTION and CURLOPT_XFERINFOFUNCTION
callbacks */
CURLOPT(CURLOPT_PROGRESSDATA, CURLOPTTYPE_OBJECTPOINT, 57),
CINIT(PROGRESSDATA, OBJECTPOINT, 57),
#define CURLOPT_XFERINFODATA CURLOPT_PROGRESSDATA
/* We want the referrer field set automatically when following locations */
CURLOPT(CURLOPT_AUTOREFERER, CURLOPTTYPE_LONG, 58),
CINIT(AUTOREFERER, LONG, 58),
/* Port of the proxy, can be set in the proxy string as well with:
"[host]:[port]" */
CURLOPT(CURLOPT_PROXYPORT, CURLOPTTYPE_LONG, 59),
CINIT(PROXYPORT, LONG, 59),
/* size of the POST input data, if strlen() is not good to use */
CURLOPT(CURLOPT_POSTFIELDSIZE, CURLOPTTYPE_LONG, 60),
CINIT(POSTFIELDSIZE, LONG, 60),
/* tunnel non-http operations through a HTTP proxy */
CURLOPT(CURLOPT_HTTPPROXYTUNNEL, CURLOPTTYPE_LONG, 61),
CINIT(HTTPPROXYTUNNEL, LONG, 61),
/* Set the interface string to use as outgoing network interface */
CURLOPT(CURLOPT_INTERFACE, CURLOPTTYPE_STRINGPOINT, 62),
CINIT(INTERFACE, STRINGPOINT, 62),
/* Set the krb4/5 security level, this also enables krb4/5 awareness. This
* is a string, 'clear', 'safe', 'confidential' or 'private'. If the string
* is set but doesn't match one of these, 'private' will be used. */
CURLOPT(CURLOPT_KRBLEVEL, CURLOPTTYPE_STRINGPOINT, 63),
CINIT(KRBLEVEL, STRINGPOINT, 63),
/* Set if we should verify the peer in ssl handshake, set 1 to verify. */
CURLOPT(CURLOPT_SSL_VERIFYPEER, CURLOPTTYPE_LONG, 64),
CINIT(SSL_VERIFYPEER, LONG, 64),
/* The CApath or CAfile used to validate the peer certificate
this option is used only if SSL_VERIFYPEER is true */
CURLOPT(CURLOPT_CAINFO, CURLOPTTYPE_STRINGPOINT, 65),
CINIT(CAINFO, STRINGPOINT, 65),
/* 66 = OBSOLETE */
/* 67 = OBSOLETE */
/* Maximum number of http redirects to follow */
CURLOPT(CURLOPT_MAXREDIRS, CURLOPTTYPE_LONG, 68),
CINIT(MAXREDIRS, LONG, 68),
/* Pass a long set to 1 to get the date of the requested document (if
possible)! Pass a zero to shut it off. */
CURLOPT(CURLOPT_FILETIME, CURLOPTTYPE_LONG, 69),
CINIT(FILETIME, LONG, 69),
/* This points to a linked list of telnet options */
CURLOPT(CURLOPT_TELNETOPTIONS, CURLOPTTYPE_SLISTPOINT, 70),
CINIT(TELNETOPTIONS, SLISTPOINT, 70),
/* Max amount of cached alive connections */
CURLOPT(CURLOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 71),
CINIT(MAXCONNECTS, LONG, 71),
/* OBSOLETE, do not use! */
CURLOPT(CURLOPT_OBSOLETE72, CURLOPTTYPE_LONG, 72),
CINIT(OBSOLETE72, LONG, 72), /* OBSOLETE, do not use! */
/* 73 = OBSOLETE */
/* Set to explicitly use a new connection for the upcoming transfer.
Do not use this unless you're absolutely sure of this, as it makes the
operation slower and is less friendly for the network. */
CURLOPT(CURLOPT_FRESH_CONNECT, CURLOPTTYPE_LONG, 74),
CINIT(FRESH_CONNECT, LONG, 74),
/* Set to explicitly forbid the upcoming transfer's connection to be re-used
when done. Do not use this unless you're absolutely sure of this, as it
makes the operation slower and is less friendly for the network. */
CURLOPT(CURLOPT_FORBID_REUSE, CURLOPTTYPE_LONG, 75),
CINIT(FORBID_REUSE, LONG, 75),
/* Set to a file name that contains random data for libcurl to use to
seed the random engine when doing SSL connects. */
CURLOPT(CURLOPT_RANDOM_FILE, CURLOPTTYPE_STRINGPOINT, 76),
CINIT(RANDOM_FILE, STRINGPOINT, 76),
/* Set to the Entropy Gathering Daemon socket pathname */
CURLOPT(CURLOPT_EGDSOCKET, CURLOPTTYPE_STRINGPOINT, 77),
CINIT(EGDSOCKET, STRINGPOINT, 77),
/* Time-out connect operations after this amount of seconds, if connects are
OK within this time, then fine... This only aborts the connect phase. */
CURLOPT(CURLOPT_CONNECTTIMEOUT, CURLOPTTYPE_LONG, 78),
CINIT(CONNECTTIMEOUT, LONG, 78),
/* Function that will be called to store headers (instead of fwrite). The
* parameters will use fwrite() syntax, make sure to follow them. */
CURLOPT(CURLOPT_HEADERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 79),
CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
/* Set this to force the HTTP request to get back to GET. Only really usable
if POST, PUT or a custom request have been used first.
*/
CURLOPT(CURLOPT_HTTPGET, CURLOPTTYPE_LONG, 80),
CINIT(HTTPGET, LONG, 80),
/* Set if we should verify the Common name from the peer certificate in ssl
* handshake, set 1 to check existence, 2 to ensure that it matches the
* provided hostname. */
CURLOPT(CURLOPT_SSL_VERIFYHOST, CURLOPTTYPE_LONG, 81),
CINIT(SSL_VERIFYHOST, LONG, 81),
/* Specify which file name to write all known cookies in after completed
operation. Set file name to "-" (dash) to make it go to stdout. */
CURLOPT(CURLOPT_COOKIEJAR, CURLOPTTYPE_STRINGPOINT, 82),
CINIT(COOKIEJAR, STRINGPOINT, 82),
/* Specify which SSL ciphers to use */
CURLOPT(CURLOPT_SSL_CIPHER_LIST, CURLOPTTYPE_STRINGPOINT, 83),
CINIT(SSL_CIPHER_LIST, STRINGPOINT, 83),
/* Specify which HTTP version to use! This must be set to one of the
CURL_HTTP_VERSION* enums set below. */
CURLOPT(CURLOPT_HTTP_VERSION, CURLOPTTYPE_LONG, 84),
CINIT(HTTP_VERSION, LONG, 84),
/* Specifically switch on or off the FTP engine's use of the EPSV command. By
default, that one will always be attempted before the more traditional
PASV command. */
CURLOPT(CURLOPT_FTP_USE_EPSV, CURLOPTTYPE_LONG, 85),
CINIT(FTP_USE_EPSV, LONG, 85),
/* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */
CURLOPT(CURLOPT_SSLCERTTYPE, CURLOPTTYPE_STRINGPOINT, 86),
CINIT(SSLCERTTYPE, STRINGPOINT, 86),
/* name of the file keeping your private SSL-key */
CURLOPT(CURLOPT_SSLKEY, CURLOPTTYPE_STRINGPOINT, 87),
CINIT(SSLKEY, STRINGPOINT, 87),
/* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */
CURLOPT(CURLOPT_SSLKEYTYPE, CURLOPTTYPE_STRINGPOINT, 88),
CINIT(SSLKEYTYPE, STRINGPOINT, 88),
/* crypto engine for the SSL-sub system */
CURLOPT(CURLOPT_SSLENGINE, CURLOPTTYPE_STRINGPOINT, 89),
CINIT(SSLENGINE, STRINGPOINT, 89),
/* set the crypto engine for the SSL-sub system as default
the param has no meaning...
*/
CURLOPT(CURLOPT_SSLENGINE_DEFAULT, CURLOPTTYPE_LONG, 90),
CINIT(SSLENGINE_DEFAULT, LONG, 90),
/* Non-zero value means to use the global dns cache */
/* DEPRECATED, do not use! */
CURLOPT(CURLOPT_DNS_USE_GLOBAL_CACHE, CURLOPTTYPE_LONG, 91),
CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91), /* DEPRECATED, do not use! */
/* DNS cache timeout */
CURLOPT(CURLOPT_DNS_CACHE_TIMEOUT, CURLOPTTYPE_LONG, 92),
CINIT(DNS_CACHE_TIMEOUT, LONG, 92),
/* send linked-list of pre-transfer QUOTE commands */
CURLOPT(CURLOPT_PREQUOTE, CURLOPTTYPE_SLISTPOINT, 93),
CINIT(PREQUOTE, SLISTPOINT, 93),
/* set the debug function */
CURLOPT(CURLOPT_DEBUGFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 94),
CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94),
/* set the data for the debug function */
CURLOPT(CURLOPT_DEBUGDATA, CURLOPTTYPE_OBJECTPOINT, 95),
CINIT(DEBUGDATA, OBJECTPOINT, 95),
/* mark this as start of a cookie session */
CURLOPT(CURLOPT_COOKIESESSION, CURLOPTTYPE_LONG, 96),
CINIT(COOKIESESSION, LONG, 96),
/* The CApath directory used to validate the peer certificate
this option is used only if SSL_VERIFYPEER is true */
CURLOPT(CURLOPT_CAPATH, CURLOPTTYPE_STRINGPOINT, 97),
CINIT(CAPATH, STRINGPOINT, 97),
/* Instruct libcurl to use a smaller receive buffer */
CURLOPT(CURLOPT_BUFFERSIZE, CURLOPTTYPE_LONG, 98),
CINIT(BUFFERSIZE, LONG, 98),
/* Instruct libcurl to not use any signal/alarm handlers, even when using
timeouts. This option is useful for multi-threaded applications.
See libcurl-the-guide for more background information. */
CURLOPT(CURLOPT_NOSIGNAL, CURLOPTTYPE_LONG, 99),
CINIT(NOSIGNAL, LONG, 99),
/* Provide a CURLShare for mutexing non-ts data */
CURLOPT(CURLOPT_SHARE, CURLOPTTYPE_OBJECTPOINT, 100),
CINIT(SHARE, OBJECTPOINT, 100),
/* indicates type of proxy. accepted values are CURLPROXY_HTTP (default),
CURLPROXY_HTTPS, CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and
CURLPROXY_SOCKS5. */
CURLOPT(CURLOPT_PROXYTYPE, CURLOPTTYPE_LONG, 101),
CINIT(PROXYTYPE, LONG, 101),
/* Set the Accept-Encoding string. Use this to tell a server you would like
the response to be compressed. Before 7.21.6, this was known as
CURLOPT_ENCODING */
CURLOPT(CURLOPT_ACCEPT_ENCODING, CURLOPTTYPE_STRINGPOINT, 102),
CINIT(ACCEPT_ENCODING, STRINGPOINT, 102),
/* Set pointer to private data */
CURLOPT(CURLOPT_PRIVATE, CURLOPTTYPE_OBJECTPOINT, 103),
CINIT(PRIVATE, OBJECTPOINT, 103),
/* Set aliases for HTTP 200 in the HTTP Response header */
CURLOPT(CURLOPT_HTTP200ALIASES, CURLOPTTYPE_SLISTPOINT, 104),
CINIT(HTTP200ALIASES, SLISTPOINT, 104),
/* Continue to send authentication (user+password) when following locations,
even when hostname changed. This can potentially send off the name
and password to whatever host the server decides. */
CURLOPT(CURLOPT_UNRESTRICTED_AUTH, CURLOPTTYPE_LONG, 105),
CINIT(UNRESTRICTED_AUTH, LONG, 105),
/* Specifically switch on or off the FTP engine's use of the EPRT command (
it also disables the LPRT attempt). By default, those ones will always be
attempted before the good old traditional PORT command. */
CURLOPT(CURLOPT_FTP_USE_EPRT, CURLOPTTYPE_LONG, 106),
CINIT(FTP_USE_EPRT, LONG, 106),
/* Set this to a bitmask value to enable the particular authentications
methods you like. Use this in combination with CURLOPT_USERPWD.
Note that setting multiple bits may cause extra network round-trips. */
CURLOPT(CURLOPT_HTTPAUTH, CURLOPTTYPE_LONG, 107),
CINIT(HTTPAUTH, LONG, 107),
/* Set the ssl context callback function, currently only for OpenSSL or
WolfSSL ssl_ctx, or mbedTLS mbedtls_ssl_config in the second argument.
The function must match the curl_ssl_ctx_callback prototype. */
CURLOPT(CURLOPT_SSL_CTX_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 108),
CINIT(SSL_CTX_FUNCTION, FUNCTIONPOINT, 108),
/* Set the userdata for the ssl context callback function's third
argument */
CURLOPT(CURLOPT_SSL_CTX_DATA, CURLOPTTYPE_OBJECTPOINT, 109),
CINIT(SSL_CTX_DATA, OBJECTPOINT, 109),
/* FTP Option that causes missing dirs to be created on the remote server.
In 7.19.4 we introduced the convenience enums for this option using the
CURLFTP_CREATE_DIR prefix.
*/
CURLOPT(CURLOPT_FTP_CREATE_MISSING_DIRS, CURLOPTTYPE_LONG, 110),
CINIT(FTP_CREATE_MISSING_DIRS, LONG, 110),
/* Set this to a bitmask value to enable the particular authentications
methods you like. Use this in combination with CURLOPT_PROXYUSERPWD.
Note that setting multiple bits may cause extra network round-trips. */
CURLOPT(CURLOPT_PROXYAUTH, CURLOPTTYPE_LONG, 111),
CINIT(PROXYAUTH, LONG, 111),
/* FTP option that changes the timeout, in seconds, associated with
getting a response. This is different from transfer timeout time and
essentially places a demand on the FTP server to acknowledge commands
in a timely manner. */
CURLOPT(CURLOPT_FTP_RESPONSE_TIMEOUT, CURLOPTTYPE_LONG, 112),
CINIT(FTP_RESPONSE_TIMEOUT, LONG, 112),
#define CURLOPT_SERVER_RESPONSE_TIMEOUT CURLOPT_FTP_RESPONSE_TIMEOUT
/* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to
tell libcurl to resolve names to those IP versions only. This only has
affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */
CURLOPT(CURLOPT_IPRESOLVE, CURLOPTTYPE_LONG, 113),
CINIT(IPRESOLVE, LONG, 113),
/* Set this option to limit the size of a file that will be downloaded from
an HTTP or FTP server.
Note there is also _LARGE version which adds large file support for
platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */
CURLOPT(CURLOPT_MAXFILESIZE, CURLOPTTYPE_LONG, 114),
CINIT(MAXFILESIZE, LONG, 114),
/* See the comment for INFILESIZE above, but in short, specifies
* the size of the file being uploaded. -1 means unknown.
*/
CURLOPT(CURLOPT_INFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 115),
CINIT(INFILESIZE_LARGE, OFF_T, 115),
/* Sets the continuation offset. There is also a CURLOPTTYPE_LONG version
* of this; look above for RESUME_FROM.
/* Sets the continuation offset. There is also a LONG version of this;
* look above for RESUME_FROM.
*/
CURLOPT(CURLOPT_RESUME_FROM_LARGE, CURLOPTTYPE_OFF_T, 116),
CINIT(RESUME_FROM_LARGE, OFF_T, 116),
/* Sets the maximum size of data that will be downloaded from
* an HTTP or FTP server. See MAXFILESIZE above for the LONG version.
*/
CURLOPT(CURLOPT_MAXFILESIZE_LARGE, CURLOPTTYPE_OFF_T, 117),
CINIT(MAXFILESIZE_LARGE, OFF_T, 117),
/* Set this option to the file name of your .netrc file you want libcurl
to parse (using the CURLOPT_NETRC option). If not set, libcurl will do
a poor attempt to find the user's home directory and check for a .netrc
file in there. */
CURLOPT(CURLOPT_NETRC_FILE, CURLOPTTYPE_STRINGPOINT, 118),
CINIT(NETRC_FILE, STRINGPOINT, 118),
/* Enable SSL/TLS for FTP, pick one of:
CURLUSESSL_TRY - try using SSL, proceed anyway otherwise
CURLUSESSL_CONTROL - SSL for the control connection or fail
CURLUSESSL_ALL - SSL for all communication or fail
*/
CURLOPT(CURLOPT_USE_SSL, CURLOPTTYPE_LONG, 119),
CINIT(USE_SSL, LONG, 119),
/* The _LARGE version of the standard POSTFIELDSIZE option */
CURLOPT(CURLOPT_POSTFIELDSIZE_LARGE, CURLOPTTYPE_OFF_T, 120),
CINIT(POSTFIELDSIZE_LARGE, OFF_T, 120),
/* Enable/disable the TCP Nagle algorithm */
CURLOPT(CURLOPT_TCP_NODELAY, CURLOPTTYPE_LONG, 121),
CINIT(TCP_NODELAY, LONG, 121),
/* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */
/* 123 OBSOLETE. Gone in 7.16.0 */
......@@ -1445,143 +1410,143 @@ typedef enum {
CURLFTPAUTH_SSL - try "AUTH SSL" first, then TLS
CURLFTPAUTH_TLS - try "AUTH TLS" first, then SSL
*/
CURLOPT(CURLOPT_FTPSSLAUTH, CURLOPTTYPE_LONG, 129),
CINIT(FTPSSLAUTH, LONG, 129),
CURLOPT(CURLOPT_IOCTLFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 130),
CURLOPT(CURLOPT_IOCTLDATA, CURLOPTTYPE_OBJECTPOINT, 131),
CINIT(IOCTLFUNCTION, FUNCTIONPOINT, 130),
CINIT(IOCTLDATA, OBJECTPOINT, 131),
/* 132 OBSOLETE. Gone in 7.16.0 */
/* 133 OBSOLETE. Gone in 7.16.0 */
/* null-terminated string for pass on to the FTP server when asked for
/* zero terminated string for pass on to the FTP server when asked for
"account" info */
CURLOPT(CURLOPT_FTP_ACCOUNT, CURLOPTTYPE_STRINGPOINT, 134),
CINIT(FTP_ACCOUNT, STRINGPOINT, 134),
/* feed cookie into cookie engine */
CURLOPT(CURLOPT_COOKIELIST, CURLOPTTYPE_STRINGPOINT, 135),
CINIT(COOKIELIST, STRINGPOINT, 135),
/* ignore Content-Length */
CURLOPT(CURLOPT_IGNORE_CONTENT_LENGTH, CURLOPTTYPE_LONG, 136),
CINIT(IGNORE_CONTENT_LENGTH, LONG, 136),
/* Set to non-zero to skip the IP address received in a 227 PASV FTP server
response. Typically used for FTP-SSL purposes but is not restricted to
that. libcurl will then instead use the same IP address it used for the
control connection. */
CURLOPT(CURLOPT_FTP_SKIP_PASV_IP, CURLOPTTYPE_LONG, 137),
CINIT(FTP_SKIP_PASV_IP, LONG, 137),
/* Select "file method" to use when doing FTP, see the curl_ftpmethod
above. */
CURLOPT(CURLOPT_FTP_FILEMETHOD, CURLOPTTYPE_LONG, 138),
CINIT(FTP_FILEMETHOD, LONG, 138),
/* Local port number to bind the socket to */
CURLOPT(CURLOPT_LOCALPORT, CURLOPTTYPE_LONG, 139),
CINIT(LOCALPORT, LONG, 139),
/* Number of ports to try, including the first one set with LOCALPORT.
Thus, setting it to 1 will make no additional attempts but the first.
*/
CURLOPT(CURLOPT_LOCALPORTRANGE, CURLOPTTYPE_LONG, 140),
CINIT(LOCALPORTRANGE, LONG, 140),
/* no transfer, set up connection and let application use the socket by
extracting it with CURLINFO_LASTSOCKET */
CURLOPT(CURLOPT_CONNECT_ONLY, CURLOPTTYPE_LONG, 141),
CINIT(CONNECT_ONLY, LONG, 141),
/* Function that will be called to convert from the
network encoding (instead of using the iconv calls in libcurl) */
CURLOPT(CURLOPT_CONV_FROM_NETWORK_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 142),
CINIT(CONV_FROM_NETWORK_FUNCTION, FUNCTIONPOINT, 142),
/* Function that will be called to convert to the
network encoding (instead of using the iconv calls in libcurl) */
CURLOPT(CURLOPT_CONV_TO_NETWORK_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 143),
CINIT(CONV_TO_NETWORK_FUNCTION, FUNCTIONPOINT, 143),
/* Function that will be called to convert from UTF8
(instead of using the iconv calls in libcurl)
Note that this is used only for SSL certificate processing */
CURLOPT(CURLOPT_CONV_FROM_UTF8_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 144),
CINIT(CONV_FROM_UTF8_FUNCTION, FUNCTIONPOINT, 144),
/* if the connection proceeds too quickly then need to slow it down */
/* limit-rate: maximum number of bytes per second to send or receive */
CURLOPT(CURLOPT_MAX_SEND_SPEED_LARGE, CURLOPTTYPE_OFF_T, 145),
CURLOPT(CURLOPT_MAX_RECV_SPEED_LARGE, CURLOPTTYPE_OFF_T, 146),
CINIT(MAX_SEND_SPEED_LARGE, OFF_T, 145),
CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146),
/* Pointer to command string to send if USER/PASS fails. */
CURLOPT(CURLOPT_FTP_ALTERNATIVE_TO_USER, CURLOPTTYPE_STRINGPOINT, 147),
CINIT(FTP_ALTERNATIVE_TO_USER, STRINGPOINT, 147),
/* callback function for setting socket options */
CURLOPT(CURLOPT_SOCKOPTFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 148),
CURLOPT(CURLOPT_SOCKOPTDATA, CURLOPTTYPE_OBJECTPOINT, 149),
CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148),
CINIT(SOCKOPTDATA, OBJECTPOINT, 149),
/* set to 0 to disable session ID re-use for this transfer, default is
enabled (== 1) */
CURLOPT(CURLOPT_SSL_SESSIONID_CACHE, CURLOPTTYPE_LONG, 150),
CINIT(SSL_SESSIONID_CACHE, LONG, 150),
/* allowed SSH authentication methods */
CURLOPT(CURLOPT_SSH_AUTH_TYPES, CURLOPTTYPE_LONG, 151),
CINIT(SSH_AUTH_TYPES, LONG, 151),
/* Used by scp/sftp to do public/private key authentication */
CURLOPT(CURLOPT_SSH_PUBLIC_KEYFILE, CURLOPTTYPE_STRINGPOINT, 152),
CURLOPT(CURLOPT_SSH_PRIVATE_KEYFILE, CURLOPTTYPE_STRINGPOINT, 153),
CINIT(SSH_PUBLIC_KEYFILE, STRINGPOINT, 152),
CINIT(SSH_PRIVATE_KEYFILE, STRINGPOINT, 153),
/* Send CCC (Clear Command Channel) after authentication */
CURLOPT(CURLOPT_FTP_SSL_CCC, CURLOPTTYPE_LONG, 154),
CINIT(FTP_SSL_CCC, LONG, 154),
/* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */
CURLOPT(CURLOPT_TIMEOUT_MS, CURLOPTTYPE_LONG, 155),
CURLOPT(CURLOPT_CONNECTTIMEOUT_MS, CURLOPTTYPE_LONG, 156),
CINIT(TIMEOUT_MS, LONG, 155),
CINIT(CONNECTTIMEOUT_MS, LONG, 156),
/* set to zero to disable the libcurl's decoding and thus pass the raw body
data to the application even when it is encoded/compressed */
CURLOPT(CURLOPT_HTTP_TRANSFER_DECODING, CURLOPTTYPE_LONG, 157),
CURLOPT(CURLOPT_HTTP_CONTENT_DECODING, CURLOPTTYPE_LONG, 158),
CINIT(HTTP_TRANSFER_DECODING, LONG, 157),
CINIT(HTTP_CONTENT_DECODING, LONG, 158),
/* Permission used when creating new files and directories on the remote
server for protocols that support it, SFTP/SCP/FILE */
CURLOPT(CURLOPT_NEW_FILE_PERMS, CURLOPTTYPE_LONG, 159),
CURLOPT(CURLOPT_NEW_DIRECTORY_PERMS, CURLOPTTYPE_LONG, 160),
CINIT(NEW_FILE_PERMS, LONG, 159),
CINIT(NEW_DIRECTORY_PERMS, LONG, 160),
/* Set the behaviour of POST when redirecting. Values must be set to one
of CURL_REDIR* defines below. This used to be called CURLOPT_POST301 */
CURLOPT(CURLOPT_POSTREDIR, CURLOPTTYPE_LONG, 161),
CINIT(POSTREDIR, LONG, 161),
/* used by scp/sftp to verify the host's public key */
CURLOPT(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, CURLOPTTYPE_STRINGPOINT, 162),
CINIT(SSH_HOST_PUBLIC_KEY_MD5, STRINGPOINT, 162),
/* Callback function for opening socket (instead of socket(2)). Optionally,
callback is able change the address or refuse to connect returning
CURL_SOCKET_BAD. The callback should have type
curl_opensocket_callback */
CURLOPT(CURLOPT_OPENSOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 163),
CURLOPT(CURLOPT_OPENSOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 164),
CINIT(OPENSOCKETFUNCTION, FUNCTIONPOINT, 163),
CINIT(OPENSOCKETDATA, OBJECTPOINT, 164),
/* POST volatile input fields. */
CURLOPT(CURLOPT_COPYPOSTFIELDS, CURLOPTTYPE_OBJECTPOINT, 165),
CINIT(COPYPOSTFIELDS, OBJECTPOINT, 165),
/* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */
CURLOPT(CURLOPT_PROXY_TRANSFER_MODE, CURLOPTTYPE_LONG, 166),
CINIT(PROXY_TRANSFER_MODE, LONG, 166),
/* Callback function for seeking in the input stream */
CURLOPT(CURLOPT_SEEKFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 167),
CURLOPT(CURLOPT_SEEKDATA, CURLOPTTYPE_OBJECTPOINT, 168),
CINIT(SEEKFUNCTION, FUNCTIONPOINT, 167),
CINIT(SEEKDATA, OBJECTPOINT, 168),
/* CRL file */
CURLOPT(CURLOPT_CRLFILE, CURLOPTTYPE_STRINGPOINT, 169),
CINIT(CRLFILE, STRINGPOINT, 169),
/* Issuer certificate */
CURLOPT(CURLOPT_ISSUERCERT, CURLOPTTYPE_STRINGPOINT, 170),
CINIT(ISSUERCERT, STRINGPOINT, 170),
/* (IPv6) Address scope */
CURLOPT(CURLOPT_ADDRESS_SCOPE, CURLOPTTYPE_LONG, 171),
CINIT(ADDRESS_SCOPE, LONG, 171),
/* Collect certificate chain info and allow it to get retrievable with
CURLINFO_CERTINFO after the transfer is complete. */
CURLOPT(CURLOPT_CERTINFO, CURLOPTTYPE_LONG, 172),
CINIT(CERTINFO, LONG, 172),
/* "name" and "pwd" to use when fetching. */
CURLOPT(CURLOPT_USERNAME, CURLOPTTYPE_STRINGPOINT, 173),
CURLOPT(CURLOPT_PASSWORD, CURLOPTTYPE_STRINGPOINT, 174),
CINIT(USERNAME, STRINGPOINT, 173),
CINIT(PASSWORD, STRINGPOINT, 174),
/* "name" and "pwd" to use with Proxy when fetching. */
CURLOPT(CURLOPT_PROXYUSERNAME, CURLOPTTYPE_STRINGPOINT, 175),
CURLOPT(CURLOPT_PROXYPASSWORD, CURLOPTTYPE_STRINGPOINT, 176),
CINIT(PROXYUSERNAME, STRINGPOINT, 175),
CINIT(PROXYPASSWORD, STRINGPOINT, 176),
/* Comma separated list of hostnames defining no-proxy zones. These should
match both hostnames directly, and hostnames within a domain. For
......@@ -1590,103 +1555,102 @@ typedef enum {
implementations of this, .local.com will be considered to be the same as
local.com. A single * is the only valid wildcard, and effectively
disables the use of proxy. */
CURLOPT(CURLOPT_NOPROXY, CURLOPTTYPE_STRINGPOINT, 177),
CINIT(NOPROXY, STRINGPOINT, 177),
/* block size for TFTP transfers */
CURLOPT(CURLOPT_TFTP_BLKSIZE, CURLOPTTYPE_LONG, 178),
CINIT(TFTP_BLKSIZE, LONG, 178),
/* Socks Service */
/* DEPRECATED, do not use! */
CURLOPT(CURLOPT_SOCKS5_GSSAPI_SERVICE, CURLOPTTYPE_STRINGPOINT, 179),
CINIT(SOCKS5_GSSAPI_SERVICE, STRINGPOINT, 179), /* DEPRECATED, do not use! */
/* Socks Service */
CURLOPT(CURLOPT_SOCKS5_GSSAPI_NEC, CURLOPTTYPE_LONG, 180),
CINIT(SOCKS5_GSSAPI_NEC, LONG, 180),
/* set the bitmask for the protocols that are allowed to be used for the
transfer, which thus helps the app which takes URLs from users or other
external inputs and want to restrict what protocol(s) to deal
with. Defaults to CURLPROTO_ALL. */
CURLOPT(CURLOPT_PROTOCOLS, CURLOPTTYPE_LONG, 181),
CINIT(PROTOCOLS, LONG, 181),
/* set the bitmask for the protocols that libcurl is allowed to follow to,
as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs
to be set in both bitmasks to be allowed to get redirected to. */
CURLOPT(CURLOPT_REDIR_PROTOCOLS, CURLOPTTYPE_LONG, 182),
CINIT(REDIR_PROTOCOLS, LONG, 182),
/* set the SSH knownhost file name to use */
CURLOPT(CURLOPT_SSH_KNOWNHOSTS, CURLOPTTYPE_STRINGPOINT, 183),
CINIT(SSH_KNOWNHOSTS, STRINGPOINT, 183),
/* set the SSH host key callback, must point to a curl_sshkeycallback
function */
CURLOPT(CURLOPT_SSH_KEYFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 184),
CINIT(SSH_KEYFUNCTION, FUNCTIONPOINT, 184),
/* set the SSH host key callback custom pointer */
CURLOPT(CURLOPT_SSH_KEYDATA, CURLOPTTYPE_OBJECTPOINT, 185),
CINIT(SSH_KEYDATA, OBJECTPOINT, 185),
/* set the SMTP mail originator */
CURLOPT(CURLOPT_MAIL_FROM, CURLOPTTYPE_STRINGPOINT, 186),
CINIT(MAIL_FROM, STRINGPOINT, 186),
/* set the list of SMTP mail receiver(s) */
CURLOPT(CURLOPT_MAIL_RCPT, CURLOPTTYPE_SLISTPOINT, 187),
CINIT(MAIL_RCPT, SLISTPOINT, 187),
/* FTP: send PRET before PASV */
CURLOPT(CURLOPT_FTP_USE_PRET, CURLOPTTYPE_LONG, 188),
CINIT(FTP_USE_PRET, LONG, 188),
/* RTSP request method (OPTIONS, SETUP, PLAY, etc...) */
CURLOPT(CURLOPT_RTSP_REQUEST, CURLOPTTYPE_LONG, 189),
CINIT(RTSP_REQUEST, LONG, 189),
/* The RTSP session identifier */
CURLOPT(CURLOPT_RTSP_SESSION_ID, CURLOPTTYPE_STRINGPOINT, 190),
CINIT(RTSP_SESSION_ID, STRINGPOINT, 190),
/* The RTSP stream URI */
CURLOPT(CURLOPT_RTSP_STREAM_URI, CURLOPTTYPE_STRINGPOINT, 191),
CINIT(RTSP_STREAM_URI, STRINGPOINT, 191),
/* The Transport: header to use in RTSP requests */
CURLOPT(CURLOPT_RTSP_TRANSPORT, CURLOPTTYPE_STRINGPOINT, 192),
CINIT(RTSP_TRANSPORT, STRINGPOINT, 192),
/* Manually initialize the client RTSP CSeq for this handle */
CURLOPT(CURLOPT_RTSP_CLIENT_CSEQ, CURLOPTTYPE_LONG, 193),
CINIT(RTSP_CLIENT_CSEQ, LONG, 193),
/* Manually initialize the server RTSP CSeq for this handle */
CURLOPT(CURLOPT_RTSP_SERVER_CSEQ, CURLOPTTYPE_LONG, 194),
CINIT(RTSP_SERVER_CSEQ, LONG, 194),
/* The stream to pass to INTERLEAVEFUNCTION. */
CURLOPT(CURLOPT_INTERLEAVEDATA, CURLOPTTYPE_OBJECTPOINT, 195),
CINIT(INTERLEAVEDATA, OBJECTPOINT, 195),
/* Let the application define a custom write method for RTP data */
CURLOPT(CURLOPT_INTERLEAVEFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 196),
CINIT(INTERLEAVEFUNCTION, FUNCTIONPOINT, 196),
/* Turn on wildcard matching */
CURLOPT(CURLOPT_WILDCARDMATCH, CURLOPTTYPE_LONG, 197),
CINIT(WILDCARDMATCH, LONG, 197),
/* Directory matching callback called before downloading of an
individual file (chunk) started */
CURLOPT(CURLOPT_CHUNK_BGN_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 198),
CINIT(CHUNK_BGN_FUNCTION, FUNCTIONPOINT, 198),
/* Directory matching callback called after the file (chunk)
was downloaded, or skipped */
CURLOPT(CURLOPT_CHUNK_END_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 199),
CINIT(CHUNK_END_FUNCTION, FUNCTIONPOINT, 199),
/* Change match (fnmatch-like) callback for wildcard matching */
CURLOPT(CURLOPT_FNMATCH_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 200),
CINIT(FNMATCH_FUNCTION, FUNCTIONPOINT, 200),
/* Let the application define custom chunk data pointer */
CURLOPT(CURLOPT_CHUNK_DATA, CURLOPTTYPE_OBJECTPOINT, 201),
CINIT(CHUNK_DATA, OBJECTPOINT, 201),
/* FNMATCH_FUNCTION user pointer */
CURLOPT(CURLOPT_FNMATCH_DATA, CURLOPTTYPE_OBJECTPOINT, 202),
CINIT(FNMATCH_DATA, OBJECTPOINT, 202),
/* send linked-list of name:port:address sets */
CURLOPT(CURLOPT_RESOLVE, CURLOPTTYPE_SLISTPOINT, 203),
CINIT(RESOLVE, SLISTPOINT, 203),
/* Set a username for authenticated TLS */
CURLOPT(CURLOPT_TLSAUTH_USERNAME, CURLOPTTYPE_STRINGPOINT, 204),
CINIT(TLSAUTH_USERNAME, STRINGPOINT, 204),
/* Set a password for authenticated TLS */
CURLOPT(CURLOPT_TLSAUTH_PASSWORD, CURLOPTTYPE_STRINGPOINT, 205),
CINIT(TLSAUTH_PASSWORD, STRINGPOINT, 205),
/* Set authentication type for authenticated TLS */
CURLOPT(CURLOPT_TLSAUTH_TYPE, CURLOPTTYPE_STRINGPOINT, 206),
CINIT(TLSAUTH_TYPE, STRINGPOINT, 206),
/* Set to 1 to enable the "TE:" header in HTTP requests to ask for
compressed transfer-encoded responses. Set to 0 to disable the use of TE:
......@@ -1698,285 +1662,268 @@ typedef enum {
option is set to 1.
*/
CURLOPT(CURLOPT_TRANSFER_ENCODING, CURLOPTTYPE_LONG, 207),
CINIT(TRANSFER_ENCODING, LONG, 207),
/* Callback function for closing socket (instead of close(2)). The callback
should have type curl_closesocket_callback */
CURLOPT(CURLOPT_CLOSESOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 208),
CURLOPT(CURLOPT_CLOSESOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 209),
CINIT(CLOSESOCKETFUNCTION, FUNCTIONPOINT, 208),
CINIT(CLOSESOCKETDATA, OBJECTPOINT, 209),
/* allow GSSAPI credential delegation */
CURLOPT(CURLOPT_GSSAPI_DELEGATION, CURLOPTTYPE_LONG, 210),
CINIT(GSSAPI_DELEGATION, LONG, 210),
/* Set the name servers to use for DNS resolution */
CURLOPT(CURLOPT_DNS_SERVERS, CURLOPTTYPE_STRINGPOINT, 211),
CINIT(DNS_SERVERS, STRINGPOINT, 211),
/* Time-out accept operations (currently for FTP only) after this amount
of milliseconds. */
CURLOPT(CURLOPT_ACCEPTTIMEOUT_MS, CURLOPTTYPE_LONG, 212),
CINIT(ACCEPTTIMEOUT_MS, LONG, 212),
/* Set TCP keepalive */
CURLOPT(CURLOPT_TCP_KEEPALIVE, CURLOPTTYPE_LONG, 213),
CINIT(TCP_KEEPALIVE, LONG, 213),
/* non-universal keepalive knobs (Linux, AIX, HP-UX, more) */
CURLOPT(CURLOPT_TCP_KEEPIDLE, CURLOPTTYPE_LONG, 214),
CURLOPT(CURLOPT_TCP_KEEPINTVL, CURLOPTTYPE_LONG, 215),
CINIT(TCP_KEEPIDLE, LONG, 214),
CINIT(TCP_KEEPINTVL, LONG, 215),
/* Enable/disable specific SSL features with a bitmask, see CURLSSLOPT_* */
CURLOPT(CURLOPT_SSL_OPTIONS, CURLOPTTYPE_LONG, 216),
CINIT(SSL_OPTIONS, LONG, 216),
/* Set the SMTP auth originator */
CURLOPT(CURLOPT_MAIL_AUTH, CURLOPTTYPE_STRINGPOINT, 217),
CINIT(MAIL_AUTH, STRINGPOINT, 217),
/* Enable/disable SASL initial response */
CURLOPT(CURLOPT_SASL_IR, CURLOPTTYPE_LONG, 218),
CINIT(SASL_IR, LONG, 218),
/* Function that will be called instead of the internal progress display
* function. This function should be defined as the curl_xferinfo_callback
* prototype defines. (Deprecates CURLOPT_PROGRESSFUNCTION) */
CURLOPT(CURLOPT_XFERINFOFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 219),
CINIT(XFERINFOFUNCTION, FUNCTIONPOINT, 219),
/* The XOAUTH2 bearer token */
CURLOPT(CURLOPT_XOAUTH2_BEARER, CURLOPTTYPE_STRINGPOINT, 220),
CINIT(XOAUTH2_BEARER, STRINGPOINT, 220),
/* Set the interface string to use as outgoing network
* interface for DNS requests.
* Only supported by the c-ares DNS backend */
CURLOPT(CURLOPT_DNS_INTERFACE, CURLOPTTYPE_STRINGPOINT, 221),
CINIT(DNS_INTERFACE, STRINGPOINT, 221),
/* Set the local IPv4 address to use for outgoing DNS requests.
* Only supported by the c-ares DNS backend */
CURLOPT(CURLOPT_DNS_LOCAL_IP4, CURLOPTTYPE_STRINGPOINT, 222),
CINIT(DNS_LOCAL_IP4, STRINGPOINT, 222),
/* Set the local IPv6 address to use for outgoing DNS requests.
* Only supported by the c-ares DNS backend */
CURLOPT(CURLOPT_DNS_LOCAL_IP6, CURLOPTTYPE_STRINGPOINT, 223),
CINIT(DNS_LOCAL_IP6, STRINGPOINT, 223),
/* Set authentication options directly */
CURLOPT(CURLOPT_LOGIN_OPTIONS, CURLOPTTYPE_STRINGPOINT, 224),
CINIT(LOGIN_OPTIONS, STRINGPOINT, 224),
/* Enable/disable TLS NPN extension (http2 over ssl might fail without) */
CURLOPT(CURLOPT_SSL_ENABLE_NPN, CURLOPTTYPE_LONG, 225),
CINIT(SSL_ENABLE_NPN, LONG, 225),
/* Enable/disable TLS ALPN extension (http2 over ssl might fail without) */
CURLOPT(CURLOPT_SSL_ENABLE_ALPN, CURLOPTTYPE_LONG, 226),
CINIT(SSL_ENABLE_ALPN, LONG, 226),
/* Time to wait for a response to a HTTP request containing an
* Expect: 100-continue header before sending the data anyway. */
CURLOPT(CURLOPT_EXPECT_100_TIMEOUT_MS, CURLOPTTYPE_LONG, 227),
CINIT(EXPECT_100_TIMEOUT_MS, LONG, 227),
/* This points to a linked list of headers used for proxy requests only,
struct curl_slist kind */
CURLOPT(CURLOPT_PROXYHEADER, CURLOPTTYPE_SLISTPOINT, 228),
CINIT(PROXYHEADER, SLISTPOINT, 228),
/* Pass in a bitmask of "header options" */
CURLOPT(CURLOPT_HEADEROPT, CURLOPTTYPE_LONG, 229),
CINIT(HEADEROPT, LONG, 229),
/* The public key in DER form used to validate the peer public key
this option is used only if SSL_VERIFYPEER is true */
CURLOPT(CURLOPT_PINNEDPUBLICKEY, CURLOPTTYPE_STRINGPOINT, 230),
CINIT(PINNEDPUBLICKEY, STRINGPOINT, 230),
/* Path to Unix domain socket */
CURLOPT(CURLOPT_UNIX_SOCKET_PATH, CURLOPTTYPE_STRINGPOINT, 231),
CINIT(UNIX_SOCKET_PATH, STRINGPOINT, 231),
/* Set if we should verify the certificate status. */
CURLOPT(CURLOPT_SSL_VERIFYSTATUS, CURLOPTTYPE_LONG, 232),
CINIT(SSL_VERIFYSTATUS, LONG, 232),
/* Set if we should enable TLS false start. */
CURLOPT(CURLOPT_SSL_FALSESTART, CURLOPTTYPE_LONG, 233),
CINIT(SSL_FALSESTART, LONG, 233),
/* Do not squash dot-dot sequences */
CURLOPT(CURLOPT_PATH_AS_IS, CURLOPTTYPE_LONG, 234),
CINIT(PATH_AS_IS, LONG, 234),
/* Proxy Service Name */
CURLOPT(CURLOPT_PROXY_SERVICE_NAME, CURLOPTTYPE_STRINGPOINT, 235),
CINIT(PROXY_SERVICE_NAME, STRINGPOINT, 235),
/* Service Name */
CURLOPT(CURLOPT_SERVICE_NAME, CURLOPTTYPE_STRINGPOINT, 236),
CINIT(SERVICE_NAME, STRINGPOINT, 236),
/* Wait/don't wait for pipe/mutex to clarify */
CURLOPT(CURLOPT_PIPEWAIT, CURLOPTTYPE_LONG, 237),
CINIT(PIPEWAIT, LONG, 237),
/* Set the protocol used when curl is given a URL without a protocol */
CURLOPT(CURLOPT_DEFAULT_PROTOCOL, CURLOPTTYPE_STRINGPOINT, 238),
CINIT(DEFAULT_PROTOCOL, STRINGPOINT, 238),
/* Set stream weight, 1 - 256 (default is 16) */
CURLOPT(CURLOPT_STREAM_WEIGHT, CURLOPTTYPE_LONG, 239),
CINIT(STREAM_WEIGHT, LONG, 239),
/* Set stream dependency on another CURL handle */
CURLOPT(CURLOPT_STREAM_DEPENDS, CURLOPTTYPE_OBJECTPOINT, 240),
CINIT(STREAM_DEPENDS, OBJECTPOINT, 240),
/* Set E-xclusive stream dependency on another CURL handle */
CURLOPT(CURLOPT_STREAM_DEPENDS_E, CURLOPTTYPE_OBJECTPOINT, 241),
CINIT(STREAM_DEPENDS_E, OBJECTPOINT, 241),
/* Do not send any tftp option requests to the server */
CURLOPT(CURLOPT_TFTP_NO_OPTIONS, CURLOPTTYPE_LONG, 242),
CINIT(TFTP_NO_OPTIONS, LONG, 242),
/* Linked-list of host:port:connect-to-host:connect-to-port,
overrides the URL's host:port (only for the network layer) */
CURLOPT(CURLOPT_CONNECT_TO, CURLOPTTYPE_SLISTPOINT, 243),
CINIT(CONNECT_TO, SLISTPOINT, 243),
/* Set TCP Fast Open */
CURLOPT(CURLOPT_TCP_FASTOPEN, CURLOPTTYPE_LONG, 244),
CINIT(TCP_FASTOPEN, LONG, 244),
/* Continue to send data if the server responds early with an
* HTTP status code >= 300 */
CURLOPT(CURLOPT_KEEP_SENDING_ON_ERROR, CURLOPTTYPE_LONG, 245),
CINIT(KEEP_SENDING_ON_ERROR, LONG, 245),
/* The CApath or CAfile used to validate the proxy certificate
this option is used only if PROXY_SSL_VERIFYPEER is true */
CURLOPT(CURLOPT_PROXY_CAINFO, CURLOPTTYPE_STRINGPOINT, 246),
CINIT(PROXY_CAINFO, STRINGPOINT, 246),
/* The CApath directory used to validate the proxy certificate
this option is used only if PROXY_SSL_VERIFYPEER is true */
CURLOPT(CURLOPT_PROXY_CAPATH, CURLOPTTYPE_STRINGPOINT, 247),
CINIT(PROXY_CAPATH, STRINGPOINT, 247),
/* Set if we should verify the proxy in ssl handshake,
set 1 to verify. */
CURLOPT(CURLOPT_PROXY_SSL_VERIFYPEER, CURLOPTTYPE_LONG, 248),
CINIT(PROXY_SSL_VERIFYPEER, LONG, 248),
/* Set if we should verify the Common name from the proxy certificate in ssl
* handshake, set 1 to check existence, 2 to ensure that it matches
* the provided hostname. */
CURLOPT(CURLOPT_PROXY_SSL_VERIFYHOST, CURLOPTTYPE_LONG, 249),
CINIT(PROXY_SSL_VERIFYHOST, LONG, 249),
/* What version to specifically try to use for proxy.
See CURL_SSLVERSION defines below. */
CURLOPT(CURLOPT_PROXY_SSLVERSION, CURLOPTTYPE_LONG, 250),
CINIT(PROXY_SSLVERSION, LONG, 250),
/* Set a username for authenticated TLS for proxy */
CURLOPT(CURLOPT_PROXY_TLSAUTH_USERNAME, CURLOPTTYPE_STRINGPOINT, 251),
CINIT(PROXY_TLSAUTH_USERNAME, STRINGPOINT, 251),
/* Set a password for authenticated TLS for proxy */
CURLOPT(CURLOPT_PROXY_TLSAUTH_PASSWORD, CURLOPTTYPE_STRINGPOINT, 252),
CINIT(PROXY_TLSAUTH_PASSWORD, STRINGPOINT, 252),
/* Set authentication type for authenticated TLS for proxy */
CURLOPT(CURLOPT_PROXY_TLSAUTH_TYPE, CURLOPTTYPE_STRINGPOINT, 253),
CINIT(PROXY_TLSAUTH_TYPE, STRINGPOINT, 253),
/* name of the file keeping your private SSL-certificate for proxy */
CURLOPT(CURLOPT_PROXY_SSLCERT, CURLOPTTYPE_STRINGPOINT, 254),
CINIT(PROXY_SSLCERT, STRINGPOINT, 254),
/* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") for
proxy */
CURLOPT(CURLOPT_PROXY_SSLCERTTYPE, CURLOPTTYPE_STRINGPOINT, 255),
CINIT(PROXY_SSLCERTTYPE, STRINGPOINT, 255),
/* name of the file keeping your private SSL-key for proxy */
CURLOPT(CURLOPT_PROXY_SSLKEY, CURLOPTTYPE_STRINGPOINT, 256),
CINIT(PROXY_SSLKEY, STRINGPOINT, 256),
/* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") for
proxy */
CURLOPT(CURLOPT_PROXY_SSLKEYTYPE, CURLOPTTYPE_STRINGPOINT, 257),
CINIT(PROXY_SSLKEYTYPE, STRINGPOINT, 257),
/* password for the SSL private key for proxy */
CURLOPT(CURLOPT_PROXY_KEYPASSWD, CURLOPTTYPE_STRINGPOINT, 258),
CINIT(PROXY_KEYPASSWD, STRINGPOINT, 258),
/* Specify which SSL ciphers to use for proxy */
CURLOPT(CURLOPT_PROXY_SSL_CIPHER_LIST, CURLOPTTYPE_STRINGPOINT, 259),
CINIT(PROXY_SSL_CIPHER_LIST, STRINGPOINT, 259),
/* CRL file for proxy */
CURLOPT(CURLOPT_PROXY_CRLFILE, CURLOPTTYPE_STRINGPOINT, 260),
CINIT(PROXY_CRLFILE, STRINGPOINT, 260),
/* Enable/disable specific SSL features with a bitmask for proxy, see
CURLSSLOPT_* */
CURLOPT(CURLOPT_PROXY_SSL_OPTIONS, CURLOPTTYPE_LONG, 261),
CINIT(PROXY_SSL_OPTIONS, LONG, 261),
/* Name of pre proxy to use. */
CURLOPT(CURLOPT_PRE_PROXY, CURLOPTTYPE_STRINGPOINT, 262),
CINIT(PRE_PROXY, STRINGPOINT, 262),
/* The public key in DER form used to validate the proxy public key
this option is used only if PROXY_SSL_VERIFYPEER is true */
CURLOPT(CURLOPT_PROXY_PINNEDPUBLICKEY, CURLOPTTYPE_STRINGPOINT, 263),
CINIT(PROXY_PINNEDPUBLICKEY, STRINGPOINT, 263),
/* Path to an abstract Unix domain socket */
CURLOPT(CURLOPT_ABSTRACT_UNIX_SOCKET, CURLOPTTYPE_STRINGPOINT, 264),
CINIT(ABSTRACT_UNIX_SOCKET, STRINGPOINT, 264),
/* Suppress proxy CONNECT response headers from user callbacks */
CURLOPT(CURLOPT_SUPPRESS_CONNECT_HEADERS, CURLOPTTYPE_LONG, 265),
CINIT(SUPPRESS_CONNECT_HEADERS, LONG, 265),
/* The request target, instead of extracted from the URL */
CURLOPT(CURLOPT_REQUEST_TARGET, CURLOPTTYPE_STRINGPOINT, 266),
CINIT(REQUEST_TARGET, STRINGPOINT, 266),
/* bitmask of allowed auth methods for connections to SOCKS5 proxies */
CURLOPT(CURLOPT_SOCKS5_AUTH, CURLOPTTYPE_LONG, 267),
CINIT(SOCKS5_AUTH, LONG, 267),
/* Enable/disable SSH compression */
CURLOPT(CURLOPT_SSH_COMPRESSION, CURLOPTTYPE_LONG, 268),
CINIT(SSH_COMPRESSION, LONG, 268),
/* Post MIME data. */
CURLOPT(CURLOPT_MIMEPOST, CURLOPTTYPE_OBJECTPOINT, 269),
CINIT(MIMEPOST, OBJECTPOINT, 269),
/* Time to use with the CURLOPT_TIMECONDITION. Specified in number of
seconds since 1 Jan 1970. */
CURLOPT(CURLOPT_TIMEVALUE_LARGE, CURLOPTTYPE_OFF_T, 270),
CINIT(TIMEVALUE_LARGE, OFF_T, 270),
/* Head start in milliseconds to give happy eyeballs. */
CURLOPT(CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, CURLOPTTYPE_LONG, 271),
CINIT(HAPPY_EYEBALLS_TIMEOUT_MS, LONG, 271),
/* Function that will be called before a resolver request is made */
CURLOPT(CURLOPT_RESOLVER_START_FUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 272),
CINIT(RESOLVER_START_FUNCTION, FUNCTIONPOINT, 272),
/* User data to pass to the resolver start callback. */
CURLOPT(CURLOPT_RESOLVER_START_DATA, CURLOPTTYPE_OBJECTPOINT, 273),
CINIT(RESOLVER_START_DATA, OBJECTPOINT, 273),
/* send HAProxy PROXY protocol header? */
CURLOPT(CURLOPT_HAPROXYPROTOCOL, CURLOPTTYPE_LONG, 274),
CINIT(HAPROXYPROTOCOL, LONG, 274),
/* shuffle addresses before use when DNS returns multiple */
CURLOPT(CURLOPT_DNS_SHUFFLE_ADDRESSES, CURLOPTTYPE_LONG, 275),
CINIT(DNS_SHUFFLE_ADDRESSES, LONG, 275),
/* Specify which TLS 1.3 ciphers suites to use */
CURLOPT(CURLOPT_TLS13_CIPHERS, CURLOPTTYPE_STRINGPOINT, 276),
CURLOPT(CURLOPT_PROXY_TLS13_CIPHERS, CURLOPTTYPE_STRINGPOINT, 277),
CINIT(TLS13_CIPHERS, STRINGPOINT, 276),
CINIT(PROXY_TLS13_CIPHERS, STRINGPOINT, 277),
/* Disallow specifying username/login in URL. */
CURLOPT(CURLOPT_DISALLOW_USERNAME_IN_URL, CURLOPTTYPE_LONG, 278),
CINIT(DISALLOW_USERNAME_IN_URL, LONG, 278),
/* DNS-over-HTTPS URL */
CURLOPT(CURLOPT_DOH_URL, CURLOPTTYPE_STRINGPOINT, 279),
CINIT(DOH_URL, STRINGPOINT, 279),
/* Preferred buffer size to use for uploads */
CURLOPT(CURLOPT_UPLOAD_BUFFERSIZE, CURLOPTTYPE_LONG, 280),
CINIT(UPLOAD_BUFFERSIZE, LONG, 280),
/* Time in ms between connection upkeep calls for long-lived connections. */
CURLOPT(CURLOPT_UPKEEP_INTERVAL_MS, CURLOPTTYPE_LONG, 281),
CINIT(UPKEEP_INTERVAL_MS, LONG, 281),
/* Specify URL using CURL URL API. */
CURLOPT(CURLOPT_CURLU, CURLOPTTYPE_OBJECTPOINT, 282),
CINIT(CURLU, OBJECTPOINT, 282),
/* add trailing data just after no more data is available */
CURLOPT(CURLOPT_TRAILERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 283),
CINIT(TRAILERFUNCTION, FUNCTIONPOINT, 283),
/* pointer to be passed to HTTP_TRAILER_FUNCTION */
CURLOPT(CURLOPT_TRAILERDATA, CURLOPTTYPE_OBJECTPOINT, 284),
CINIT(TRAILERDATA, OBJECTPOINT, 284),
/* set this to 1L to allow HTTP/0.9 responses or 0L to disallow */
CURLOPT(CURLOPT_HTTP09_ALLOWED, CURLOPTTYPE_LONG, 285),
CINIT(HTTP09_ALLOWED, LONG, 285),
/* alt-svc control bitmask */
CURLOPT(CURLOPT_ALTSVC_CTRL, CURLOPTTYPE_LONG, 286),
CINIT(ALTSVC_CTRL, LONG, 286),
/* alt-svc cache file name to possibly read from/write to */
CURLOPT(CURLOPT_ALTSVC, CURLOPTTYPE_STRINGPOINT, 287),
CINIT(ALTSVC, STRINGPOINT, 287),
/* maximum age of a connection to consider it for reuse (in seconds) */
CURLOPT(CURLOPT_MAXAGE_CONN, CURLOPTTYPE_LONG, 288),
/* SASL authorisation identity */
CURLOPT(CURLOPT_SASL_AUTHZID, CURLOPTTYPE_STRINGPOINT, 289),
/* allow RCPT TO command to fail for some recipients */
CURLOPT(CURLOPT_MAIL_RCPT_ALLLOWFAILS, CURLOPTTYPE_LONG, 290),
/* the private SSL-certificate as a "blob" */
CURLOPT(CURLOPT_SSLCERT_BLOB, CURLOPTTYPE_BLOB, 291),
CURLOPT(CURLOPT_SSLKEY_BLOB, CURLOPTTYPE_BLOB, 292),
CURLOPT(CURLOPT_PROXY_SSLCERT_BLOB, CURLOPTTYPE_BLOB, 293),
CURLOPT(CURLOPT_PROXY_SSLKEY_BLOB, CURLOPTTYPE_BLOB, 294),
CURLOPT(CURLOPT_ISSUERCERT_BLOB, CURLOPTTYPE_BLOB, 295),
/* Issuer certificate for proxy */
CURLOPT(CURLOPT_PROXY_ISSUERCERT, CURLOPTTYPE_STRINGPOINT, 296),
CURLOPT(CURLOPT_PROXY_ISSUERCERT_BLOB, CURLOPTTYPE_BLOB, 297),
CINIT(MAXAGE_CONN, LONG, 288),
CURLOPT_LASTENTRY /* the last unused */
} CURLoption;
......@@ -2031,8 +1978,7 @@ enum {
CURL_HTTP_VERSION_2TLS, /* use version 2 for HTTPS, version 1.1 for HTTP */
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE, /* please use HTTP 2 without HTTP/1.1
Upgrade */
CURL_HTTP_VERSION_3 = 30, /* Makes use of explicit HTTP/3 without fallback.
Use CURLOPT_ALTSVC to enable HTTP/3 upgrade */
CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */
};
......@@ -2125,7 +2071,7 @@ typedef enum {
CURL_TIMECOND_LAST
} curl_TimeCond;
/* Special size_t value signaling a null-terminated string. */
/* Special size_t value signaling a zero-terminated string. */
#define CURL_ZERO_TERMINATED ((size_t) -1)
/* curl_strequal() and curl_strnequal() are subject for removal in a future
......@@ -2134,8 +2080,8 @@ CURL_EXTERN int curl_strequal(const char *s1, const char *s2);
CURL_EXTERN int curl_strnequal(const char *s1, const char *s2, size_t n);
/* Mime/form handling support. */
typedef struct curl_mime curl_mime; /* Mime context. */
typedef struct curl_mimepart curl_mimepart; /* Mime part context. */
typedef struct curl_mime_s curl_mime; /* Mime context. */
typedef struct curl_mimepart_s curl_mimepart; /* Mime part context. */
/*
* NAME curl_mime_init()
......@@ -2258,35 +2204,52 @@ CURL_EXTERN CURLcode curl_mime_headers(curl_mimepart *part,
struct curl_slist *headers,
int take_ownership);
/* Old form API. */
/* name is uppercase CURLFORM_<name> */
#ifdef CFINIT
#undef CFINIT
#endif
#ifdef CURL_ISOCPP
#define CFINIT(name) CURLFORM_ ## name
#else
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
#define CFINIT(name) CURLFORM_/**/name
#endif
typedef enum {
CURLFORM_NOTHING, /********* the first one is unused ************/
CURLFORM_COPYNAME,
CURLFORM_PTRNAME,
CURLFORM_NAMELENGTH,
CURLFORM_COPYCONTENTS,
CURLFORM_PTRCONTENTS,
CURLFORM_CONTENTSLENGTH,
CURLFORM_FILECONTENT,
CURLFORM_ARRAY,
CURLFORM_OBSOLETE,
CURLFORM_FILE,
CURLFORM_BUFFER,
CURLFORM_BUFFERPTR,
CURLFORM_BUFFERLENGTH,
CURLFORM_CONTENTTYPE,
CURLFORM_CONTENTHEADER,
CURLFORM_FILENAME,
CURLFORM_END,
CURLFORM_OBSOLETE2,
CURLFORM_STREAM,
CURLFORM_CONTENTLEN, /* added in 7.46.0, provide a curl_off_t length */
CFINIT(NOTHING), /********* the first one is unused ************/
/* */
CFINIT(COPYNAME),
CFINIT(PTRNAME),
CFINIT(NAMELENGTH),
CFINIT(COPYCONTENTS),
CFINIT(PTRCONTENTS),
CFINIT(CONTENTSLENGTH),
CFINIT(FILECONTENT),
CFINIT(ARRAY),
CFINIT(OBSOLETE),
CFINIT(FILE),
CFINIT(BUFFER),
CFINIT(BUFFERPTR),
CFINIT(BUFFERLENGTH),
CFINIT(CONTENTTYPE),
CFINIT(CONTENTHEADER),
CFINIT(FILENAME),
CFINIT(END),
CFINIT(OBSOLETE2),
CFINIT(STREAM),
CFINIT(CONTENTLEN), /* added in 7.46.0, provide a curl_off_t length */
CURLFORM_LASTENTRY /* the last unused */
} CURLformoption;
#undef CFINIT /* done */
/* structure to be used as parameter for CURLFORM_ARRAY */
struct curl_forms {
CURLformoption option;
......@@ -2457,7 +2420,7 @@ CURL_EXTERN CURLcode curl_global_init(long flags);
* initialize libcurl and set user defined memory management callback
* functions. Users can implement memory management routines to check for
* memory leaks, check for mis-use of the curl library etc. User registered
* callback routines will be invoked by this library instead of the system
* callback routines with be invoked by this library instead of the system
* memory management routines like malloc, free etc.
*/
CURL_EXTERN CURLcode curl_global_init_mem(long flags,
......@@ -2509,11 +2472,10 @@ struct curl_slist {
* subsequent attempt to change it will result in a CURLSSLSET_TOO_LATE.
*/
struct curl_ssl_backend {
typedef struct {
curl_sslbackend id;
const char *name;
};
typedef struct curl_ssl_backend curl_ssl_backend;
} curl_ssl_backend;
typedef enum {
CURLSSLSET_OK = 0,
......@@ -2641,6 +2603,10 @@ typedef enum {
CURLINFO_PROXY_SSL_VERIFYRESULT = CURLINFO_LONG + 47,
CURLINFO_PROTOCOL = CURLINFO_LONG + 48,
CURLINFO_SCHEME = CURLINFO_STRING + 49,
/* Fill in new entries below here! */
/* Preferably these would be defined conditionally based on the
sizeof curl_off_t being 64-bits */
CURLINFO_TOTAL_TIME_T = CURLINFO_OFF_T + 50,
CURLINFO_NAMELOOKUP_TIME_T = CURLINFO_OFF_T + 51,
CURLINFO_CONNECT_TIME_T = CURLINFO_OFF_T + 52,
......@@ -2648,10 +2614,8 @@ typedef enum {
CURLINFO_STARTTRANSFER_TIME_T = CURLINFO_OFF_T + 54,
CURLINFO_REDIRECT_TIME_T = CURLINFO_OFF_T + 55,
CURLINFO_APPCONNECT_TIME_T = CURLINFO_OFF_T + 56,
CURLINFO_RETRY_AFTER = CURLINFO_OFF_T + 57,
CURLINFO_EFFECTIVE_METHOD = CURLINFO_STRING + 58,
CURLINFO_LASTONE = 58
CURLINFO_LASTONE = 56
} CURLINFO;
/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
......@@ -2750,9 +2714,6 @@ typedef enum {
CURLVERSION_THIRD,
CURLVERSION_FOURTH,
CURLVERSION_FIFTH,
CURLVERSION_SIXTH,
CURLVERSION_SEVENTH,
CURLVERSION_EIGHTH,
CURLVERSION_LAST /* never actually use this */
} CURLversion;
......@@ -2761,9 +2722,9 @@ typedef enum {
meant to be a built-in version number for what kind of struct the caller
expects. If the struct ever changes, we redefine the NOW to another enum
from above. */
#define CURLVERSION_NOW CURLVERSION_EIGHTH
#define CURLVERSION_NOW CURLVERSION_FIFTH
struct curl_version_info_data {
typedef struct {
CURLversion age; /* age of the returned struct */
const char *version; /* LIBCURL_VERSION */
unsigned int version_num; /* LIBCURL_VERSION_NUM */
......@@ -2790,30 +2751,12 @@ struct curl_version_info_data {
const char *libssh_version; /* human readable string */
/* These fields were added in CURLVERSION_FIFTH */
unsigned int brotli_ver_num; /* Numeric Brotli version
(MAJOR << 24) | (MINOR << 12) | PATCH */
const char *brotli_version; /* human readable string. */
/* These fields were added in CURLVERSION_SIXTH */
unsigned int nghttp2_ver_num; /* Numeric nghttp2 version
(MAJOR << 16) | (MINOR << 8) | PATCH */
const char *nghttp2_version; /* human readable string. */
const char *quic_version; /* human readable quic (+ HTTP/3) library +
version or NULL */
/* These fields were added in CURLVERSION_SEVENTH */
const char *cainfo; /* the built-in default CURLOPT_CAINFO, might
be NULL */
const char *capath; /* the built-in default CURLOPT_CAPATH, might
be NULL */
/* These fields were added in CURLVERSION_EIGHTH */
unsigned int zstd_ver_num; /* Numeric Zstd version
(MAJOR << 24) | (MINOR << 12) | PATCH */
const char *zstd_version; /* human readable string. */
};
typedef struct curl_version_info_data curl_version_info_data;
} curl_version_info_data;
#define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */
#define CURL_VERSION_KERBEROS4 (1<<1) /* Kerberos V4 auth is supported
......@@ -2845,9 +2788,6 @@ typedef struct curl_version_info_data curl_version_info_data;
#define CURL_VERSION_MULTI_SSL (1<<22) /* Multiple SSL backends available */
#define CURL_VERSION_BROTLI (1<<23) /* Brotli features are present. */
#define CURL_VERSION_ALTSVC (1<<24) /* Alt-Svc handling built-in */
#define CURL_VERSION_HTTP3 (1<<25) /* HTTP3 support built-in */
#define CURL_VERSION_ZSTD (1<<26) /* zstd features are present */
#define CURL_VERSION_UNICODE (1<<27) /* Unicode support on Windows */
/*
* NAME curl_version_info()
......@@ -2928,4 +2868,4 @@ CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);
#endif /* __STDC__ >= 1 */
#endif /* gcc >= 4.3 && !__cplusplus */
#endif /* CURLINC_CURL_H */
#endif /* __CURL_CURL_H */
#ifndef CURLINC_CURLVER_H
#define CURLINC_CURLVER_H
#ifndef __CURL_CURLVER_H
#define __CURL_CURLVER_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
......@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
......@@ -26,20 +26,20 @@
a script at release-time. This was made its own header file in 7.11.2 */
/* This is the global package copyright */
#define LIBCURL_COPYRIGHT "1996 - 2020 Daniel Stenberg, <daniel@haxx.se>."
#define LIBCURL_COPYRIGHT "1996 - 2019 Daniel Stenberg, <daniel@haxx.se>."
/* This is the version number of the libcurl package from which this header
file origins: */
#define LIBCURL_VERSION "7.72.0"
#define LIBCURL_VERSION "7.65.3"
/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 7
#define LIBCURL_VERSION_MINOR 72
#define LIBCURL_VERSION_PATCH 0
#define LIBCURL_VERSION_MINOR 65
#define LIBCURL_VERSION_PATCH 3
/* This is the numeric version of the libcurl version number, meant for easier
parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
always follow this syntax:
0xXXYYZZ
......@@ -57,7 +57,7 @@
CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number.
*/
#define LIBCURL_VERSION_NUM 0x074800
#define LIBCURL_VERSION_NUM 0x074103
/*
* This is the date and time when the full source package was created. The
......@@ -68,10 +68,10 @@
*
* "2007-11-23"
*/
#define LIBCURL_TIMESTAMP "2020-08-27"
#define LIBCURL_TIMESTAMP "2019-07-19"
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
#define CURL_AT_LEAST_VERSION(x,y,z) \
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
#endif /* CURLINC_CURLVER_H */
#endif /* __CURL_CURLVER_H */
#ifndef CURLINC_EASY_H
#define CURLINC_EASY_H
#ifndef __CURL_EASY_H
#define __CURL_EASY_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
......@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
......@@ -25,17 +25,6 @@
extern "C" {
#endif
/* Flag bits in the curl_blob struct: */
#define CURL_BLOB_COPY 1 /* tell libcurl to copy the data */
#define CURL_BLOB_NOCOPY 0 /* tell libcurl to NOT copy the data */
struct curl_blob {
void *data;
size_t len;
unsigned int flags; /* bit 0 is defined, the rest are reserved and should be
left zeroes */
};
CURL_EXTERN CURL *curl_easy_init(void);
CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
......
#ifndef CURLINC_MPRINTF_H
#define CURLINC_MPRINTF_H
#ifndef __CURL_MPRINTF_H
#define __CURL_MPRINTF_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
......@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
......@@ -47,4 +47,4 @@ CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
}
#endif
#endif /* CURLINC_MPRINTF_H */
#endif /* __CURL_MPRINTF_H */
#ifndef CURLINC_MULTI_H
#define CURLINC_MULTI_H
#ifndef __CURL_MULTI_H
#define __CURL_MULTI_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
......@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
......@@ -72,8 +72,6 @@ typedef enum {
attempted to get added - again */
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
callback */
CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */
CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */
CURLM_LAST
} CURLMcode;
......@@ -156,9 +154,9 @@ CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
curl_fd_set *read_fd_set,
curl_fd_set *write_fd_set,
curl_fd_set *exc_fd_set,
fd_set *read_fd_set,
fd_set *write_fd_set,
fd_set *exc_fd_set,
int *max_fd);
/*
......@@ -175,29 +173,6 @@ CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
int timeout_ms,
int *ret);
/*
* Name: curl_multi_poll()
*
* Desc: Poll on all fds within a CURLM set as well as any
* additional fds passed to the function.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
struct curl_waitfd extra_fds[],
unsigned int extra_nfds,
int timeout_ms,
int *ret);
/*
* Name: curl_multi_wakeup()
*
* Desc: wakes up a sleeping curl_multi_poll call.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
/*
* Name: curl_multi_perform()
*
......@@ -267,7 +242,7 @@ CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
* value into the equivalent human readable error string. This is
* useful for printing meaningful error messages.
*
* Returns: A pointer to a null-terminated error message.
* Returns: A pointer to a zero-terminated error message.
*/
CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
......@@ -344,56 +319,68 @@ CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
long *milliseconds);
#undef CINIT /* re-using the same name as in curl.h */
#ifdef CURL_ISOCPP
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
#else
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
#define LONG CURLOPTTYPE_LONG
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
#define OFF_T CURLOPTTYPE_OFF_T
#define CINIT(name,type,number) CURLMOPT_/**/name = type + number
#endif
typedef enum {
/* This is the socket callback function pointer */
CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1),
CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
/* This is the argument passed to the socket callback */
CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2),
CINIT(SOCKETDATA, OBJECTPOINT, 2),
/* set to 1 to enable pipelining for this multi handle */
CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3),
CINIT(PIPELINING, LONG, 3),
/* This is the timer callback function pointer */
CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4),
CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
/* This is the argument passed to the timer callback */
CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5),
CINIT(TIMERDATA, OBJECTPOINT, 5),
/* maximum number of entries in the connection cache */
CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6),
CINIT(MAXCONNECTS, LONG, 6),
/* maximum number of (pipelining) connections to one host */
CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7),
CINIT(MAX_HOST_CONNECTIONS, LONG, 7),
/* maximum number of requests in a pipeline */
CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8),
CINIT(MAX_PIPELINE_LENGTH, LONG, 8),
/* a connection with a content-length longer than this
will not be considered for pipelining */
CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9),
CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9),
/* a connection with a chunk length longer than this
will not be considered for pipelining */
CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10),
CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10),
/* a list of site names(+port) that are blocked from pipelining */
CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11),
/* a list of site names(+port) that are blacklisted from
pipelining */
CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11),
/* a list of server types that are blocked from pipelining */
CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12),
/* a list of server types that are blacklisted from
pipelining */
CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12),
/* maximum number of open connections in total */
CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13),
CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13),
/* This is the server push callback function pointer */
CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14),
CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14),
/* This is the argument passed to the server push callback */
CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15),
/* maximum number of concurrent streams to support on a connection */
CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16),
CINIT(PUSHDATA, OBJECTPOINT, 15),
CURLMOPT_LASTENTRY /* the last unused */
} CURLMoption;
......@@ -427,14 +414,12 @@ CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
* Name: curl_push_callback
*
* Desc: This callback gets called when a new stream is being pushed by the
* server. It approves or denies the new stream. It can also decide
* to completely fail the connection.
* server. It approves or denies the new stream.
*
* Returns: CURL_PUSH_OK, CURL_PUSH_DENY or CURL_PUSH_ERROROUT
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
*/
#define CURL_PUSH_OK 0
#define CURL_PUSH_DENY 1
#define CURL_PUSH_ERROROUT 2 /* added in 7.72.0 */
struct curl_pushheaders; /* forward declaration only */
......
#ifndef CURLINC_STDCHEADERS_H
#define CURLINC_STDCHEADERS_H
#ifndef __STDC_HEADERS_H
#define __STDC_HEADERS_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
......@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
......@@ -30,4 +30,4 @@ size_t fwrite(const void *, size_t, size_t, FILE *);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
#endif /* CURLINC_STDCHEADERS_H */
#endif /* __STDC_HEADERS_H */
#ifndef CURLINC_SYSTEM_H
#define CURLINC_SYSTEM_H
#ifndef __CURL_SYSTEM_H
#define __CURL_SYSTEM_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
......@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
......@@ -137,23 +137,12 @@
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__LCC__)
# if defined(__e2k__) /* MCST eLbrus C Compiler */
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# else /* Local (or Little) C Compiler */
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
# endif
#elif defined(__SYMBIAN32__)
# if defined(__EABI__) /* Treat all ARM compilers equally */
......@@ -299,6 +288,7 @@
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__TINYC__) /* also known as tcc */
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
......@@ -348,48 +338,6 @@
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
#elif defined(FreeRTOS) /* Life on FreeRTOS */
#if (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
#else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_FREERTOS_SOCKETS_H 1
# define CURL_TYPEOF_CURL_SOCKLEN_T uint32_t
# define CURL_AVOID_SYS_TYPES_H 1
# define CURL_AVOID_SYS_SOCKET_H 1
#elif defined(MICRIUM)
#if (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
#else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T CPU_INT32S
# define CURL_AVOID_SYS_TYPES_H 1
# define CURL_AVOID_SYS_SOCKET_H 1
# define CURL_AVOID_SYS_TIME_H 1
/* ===================================== */
/* KEEP MSVC THE PENULTIMATE ENTRY */
/* ===================================== */
......@@ -429,7 +377,6 @@
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__LP64__) || \
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
defined(__e2k__) || \
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
# define CURL_TYPEOF_CURL_OFF_T long
......@@ -472,40 +419,6 @@
# include <sys/types.h>
#endif
#ifdef CURL_FREERTOS_SOCKETS_H
# include <FreeRTOS.h>
# include <FreeRTOS_Sockets.h>
#include <stdint.h>
#include <stddef.h>
/* for the base type etc */
#include "portmacro.h"
#define curl_fd_set_typedefed
typedef SocketSet_t curl_fd_set;
#define curl_struct_sockaddr freertos_sockaddr
#define curl_setsockopt(a,b,c,d,e) FreeRTOS_setsockopt(a,b,c,d,e)
#define curl_connect(a,b,c) FreeRTOS_connect(a,b,c)
#define curl_bind(a,b,c) FreeRTOS_bind(a,b,c)
#define curl_recv(a,b,c,d) FreeRTOS_recv(a,b,c,d)
#define curl_socket(a,b,c) FreeRTOS_socket(a,b,c)
/* not quite socket-style API */
#define CURL_FD_SET(a,b,c) FreeRTOS_FD_SET(a,b,c)
/* struct sockaddr "fix" */
#define sa_family sin_family
/* use our private pollfd struct alternative */
#define curl_pollfd curl_waitfd
#elif defined(MICRIUM)
#include <net/include/net_bsd.h>
/* make use of the types from net_bsd.h */
typedef _size_t size_t;
typedef _time_t time_t;
#define curl_fd_set_typedefed
typedef struct fd_set curl_fd_set;
#endif
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
/* sys/socket.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_SOCKET_H
......@@ -555,58 +468,26 @@ typedef struct fd_set curl_fd_set;
#undef CURL_ISOCPP
#endif
/*
* For the standard systems
*/
#ifndef curl_struct_sockaddr
#define curl_struct_sockaddr sockaddr
#endif
#ifndef curl_fd_set_typedefed
#define curl_fd_set_typedefed
typedef fd_set curl_fd_set;
#endif
#ifndef curl_pollfd
#define curl_pollfd pollfd
#endif
#ifndef curl_setsockopt
#define curl_setsockopt(a,b,c,d,e) setsockopt(a,b,c,d,e)
#endif
#ifndef curl_bind
#define curl_bind(a,b,c) bind(a,b,c)
#endif
#ifndef curl_connect
#define curl_connect(a,b,c) connect(a,b,c)
#endif
#ifndef curl_recv
#define curl_recv(a,b,c,d) recv(a,b,c,d)
#endif
#ifndef curl_socket
#define curl_socket(a,b,c) socket(a,b,c)
#endif
#ifndef CURL_FD_SET
#define CURL_FD_SET(a,b,c) FD_SET(a,b)
#endif
/*
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
*/
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
# define CURLINC_OFF_T_C_HLPR2(x) x
# define CURLINC_OFF_T_C_HLPR1(x) CURLINC_OFF_T_C_HLPR2(x)
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
# define __CURL_OFF_T_C_HLPR2(x) x
# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
#else
# ifdef CURL_ISOCPP
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
# else
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
# endif
# define CURLINC_OFF_T_C_HLPR1(Val,Suffix) CURLINC_OFF_T_C_HLPR2(Val,Suffix)
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
#endif
#endif /* CURLINC_SYSTEM_H */
#endif /* __CURL_SYSTEM_H */
#ifndef CURLINC_TYPECHECK_GCC_H
#define CURLINC_TYPECHECK_GCC_H
#ifndef __CURL_TYPECHECK_GCC_H
#define __CURL_TYPECHECK_GCC_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
......@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
......@@ -25,10 +25,10 @@
/* wraps curl_easy_setopt() with typechecking */
/* To add a new kind of warning, add an
* if(curlcheck_sometype_option(_curl_opt))
* if(!curlcheck_sometype(value))
* if(_curl_is_sometype_option(_curl_opt))
* if(!_curl_is_sometype(value))
* _curl_easy_setopt_err_sometype();
* block and define curlcheck_sometype_option, curlcheck_sometype and
* block and define _curl_is_sometype_option, _curl_is_sometype and
* _curl_easy_setopt_err_sometype below
*
* NOTE: We use two nested 'if' statements here instead of the && operator, in
......@@ -39,111 +39,111 @@
* need to extend the appropriate _curl_*_option macro
*/
#define curl_easy_setopt(handle, option, value) \
__extension__({ \
__extension__ ({ \
__typeof__(option) _curl_opt = option; \
if(__builtin_constant_p(_curl_opt)) { \
if(curlcheck_long_option(_curl_opt)) \
if(!curlcheck_long(value)) \
if(_curl_is_long_option(_curl_opt)) \
if(!_curl_is_long(value)) \
_curl_easy_setopt_err_long(); \
if(curlcheck_off_t_option(_curl_opt)) \
if(!curlcheck_off_t(value)) \
if(_curl_is_off_t_option(_curl_opt)) \
if(!_curl_is_off_t(value)) \
_curl_easy_setopt_err_curl_off_t(); \
if(curlcheck_string_option(_curl_opt)) \
if(!curlcheck_string(value)) \
if(_curl_is_string_option(_curl_opt)) \
if(!_curl_is_string(value)) \
_curl_easy_setopt_err_string(); \
if(curlcheck_write_cb_option(_curl_opt)) \
if(!curlcheck_write_cb(value)) \
if(_curl_is_write_cb_option(_curl_opt)) \
if(!_curl_is_write_cb(value)) \
_curl_easy_setopt_err_write_callback(); \
if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
if(!curlcheck_resolver_start_callback(value)) \
if(!_curl_is_resolver_start_callback(value)) \
_curl_easy_setopt_err_resolver_start_callback(); \
if((_curl_opt) == CURLOPT_READFUNCTION) \
if(!curlcheck_read_cb(value)) \
if(!_curl_is_read_cb(value)) \
_curl_easy_setopt_err_read_cb(); \
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
if(!curlcheck_ioctl_cb(value)) \
if(!_curl_is_ioctl_cb(value)) \
_curl_easy_setopt_err_ioctl_cb(); \
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
if(!curlcheck_sockopt_cb(value)) \
if(!_curl_is_sockopt_cb(value)) \
_curl_easy_setopt_err_sockopt_cb(); \
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
if(!curlcheck_opensocket_cb(value)) \
if(!_curl_is_opensocket_cb(value)) \
_curl_easy_setopt_err_opensocket_cb(); \
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
if(!curlcheck_progress_cb(value)) \
if(!_curl_is_progress_cb(value)) \
_curl_easy_setopt_err_progress_cb(); \
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
if(!curlcheck_debug_cb(value)) \
if(!_curl_is_debug_cb(value)) \
_curl_easy_setopt_err_debug_cb(); \
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
if(!curlcheck_ssl_ctx_cb(value)) \
if(!_curl_is_ssl_ctx_cb(value)) \
_curl_easy_setopt_err_ssl_ctx_cb(); \
if(curlcheck_conv_cb_option(_curl_opt)) \
if(!curlcheck_conv_cb(value)) \
if(_curl_is_conv_cb_option(_curl_opt)) \
if(!_curl_is_conv_cb(value)) \
_curl_easy_setopt_err_conv_cb(); \
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
if(!curlcheck_seek_cb(value)) \
if(!_curl_is_seek_cb(value)) \
_curl_easy_setopt_err_seek_cb(); \
if(curlcheck_cb_data_option(_curl_opt)) \
if(!curlcheck_cb_data(value)) \
if(_curl_is_cb_data_option(_curl_opt)) \
if(!_curl_is_cb_data(value)) \
_curl_easy_setopt_err_cb_data(); \
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
if(!curlcheck_error_buffer(value)) \
if(!_curl_is_error_buffer(value)) \
_curl_easy_setopt_err_error_buffer(); \
if((_curl_opt) == CURLOPT_STDERR) \
if(!curlcheck_FILE(value)) \
if(!_curl_is_FILE(value)) \
_curl_easy_setopt_err_FILE(); \
if(curlcheck_postfields_option(_curl_opt)) \
if(!curlcheck_postfields(value)) \
if(_curl_is_postfields_option(_curl_opt)) \
if(!_curl_is_postfields(value)) \
_curl_easy_setopt_err_postfields(); \
if((_curl_opt) == CURLOPT_HTTPPOST) \
if(!curlcheck_arr((value), struct curl_httppost)) \
if(!_curl_is_arr((value), struct curl_httppost)) \
_curl_easy_setopt_err_curl_httpost(); \
if((_curl_opt) == CURLOPT_MIMEPOST) \
if(!curlcheck_ptr((value), curl_mime)) \
if(!_curl_is_ptr((value), curl_mime)) \
_curl_easy_setopt_err_curl_mimepost(); \
if(curlcheck_slist_option(_curl_opt)) \
if(!curlcheck_arr((value), struct curl_slist)) \
if(_curl_is_slist_option(_curl_opt)) \
if(!_curl_is_arr((value), struct curl_slist)) \
_curl_easy_setopt_err_curl_slist(); \
if((_curl_opt) == CURLOPT_SHARE) \
if(!curlcheck_ptr((value), CURLSH)) \
if(!_curl_is_ptr((value), CURLSH)) \
_curl_easy_setopt_err_CURLSH(); \
} \
curl_easy_setopt(handle, _curl_opt, value); \
})
})
/* wraps curl_easy_getinfo() with typechecking */
#define curl_easy_getinfo(handle, info, arg) \
__extension__({ \
__extension__ ({ \
__typeof__(info) _curl_info = info; \
if(__builtin_constant_p(_curl_info)) { \
if(curlcheck_string_info(_curl_info)) \
if(!curlcheck_arr((arg), char *)) \
if(_curl_is_string_info(_curl_info)) \
if(!_curl_is_arr((arg), char *)) \
_curl_easy_getinfo_err_string(); \
if(curlcheck_long_info(_curl_info)) \
if(!curlcheck_arr((arg), long)) \
if(_curl_is_long_info(_curl_info)) \
if(!_curl_is_arr((arg), long)) \
_curl_easy_getinfo_err_long(); \
if(curlcheck_double_info(_curl_info)) \
if(!curlcheck_arr((arg), double)) \
if(_curl_is_double_info(_curl_info)) \
if(!_curl_is_arr((arg), double)) \
_curl_easy_getinfo_err_double(); \
if(curlcheck_slist_info(_curl_info)) \
if(!curlcheck_arr((arg), struct curl_slist *)) \
if(_curl_is_slist_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_slist *)) \
_curl_easy_getinfo_err_curl_slist(); \
if(curlcheck_tlssessioninfo_info(_curl_info)) \
if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \
if(_curl_is_tlssessioninfo_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_tlssessioninfo *)) \
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
if(curlcheck_certinfo_info(_curl_info)) \
if(!curlcheck_arr((arg), struct curl_certinfo *)) \
if(_curl_is_certinfo_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_certinfo *)) \
_curl_easy_getinfo_err_curl_certinfo(); \
if(curlcheck_socket_info(_curl_info)) \
if(!curlcheck_arr((arg), curl_socket_t)) \
if(_curl_is_socket_info(_curl_info)) \
if(!_curl_is_arr((arg), curl_socket_t)) \
_curl_easy_getinfo_err_curl_socket(); \
if(curlcheck_off_t_info(_curl_info)) \
if(!curlcheck_arr((arg), curl_off_t)) \
if(_curl_is_off_t_info(_curl_info)) \
if(!_curl_is_arr((arg), curl_off_t)) \
_curl_easy_getinfo_err_curl_off_t(); \
} \
curl_easy_getinfo(handle, _curl_info, arg); \
})
})
/*
* For now, just make sure that the functions are called with three arguments
......@@ -156,83 +156,83 @@
* functions */
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
#define CURLWARNING(id, message) \
#define _CURL_WARNING(id, message) \
static void __attribute__((__warning__(message))) \
__attribute__((__unused__)) __attribute__((__noinline__)) \
id(void) { __asm__(""); }
CURLWARNING(_curl_easy_setopt_err_long,
_CURL_WARNING(_curl_easy_setopt_err_long,
"curl_easy_setopt expects a long argument for this option")
CURLWARNING(_curl_easy_setopt_err_curl_off_t,
_CURL_WARNING(_curl_easy_setopt_err_curl_off_t,
"curl_easy_setopt expects a curl_off_t argument for this option")
CURLWARNING(_curl_easy_setopt_err_string,
_CURL_WARNING(_curl_easy_setopt_err_string,
"curl_easy_setopt expects a "
"string ('char *' or char[]) argument for this option"
)
CURLWARNING(_curl_easy_setopt_err_write_callback,
_CURL_WARNING(_curl_easy_setopt_err_write_callback,
"curl_easy_setopt expects a curl_write_callback argument for this option")
CURLWARNING(_curl_easy_setopt_err_resolver_start_callback,
_CURL_WARNING(_curl_easy_setopt_err_resolver_start_callback,
"curl_easy_setopt expects a "
"curl_resolver_start_callback argument for this option"
)
CURLWARNING(_curl_easy_setopt_err_read_cb,
_CURL_WARNING(_curl_easy_setopt_err_read_cb,
"curl_easy_setopt expects a curl_read_callback argument for this option")
CURLWARNING(_curl_easy_setopt_err_ioctl_cb,
_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
CURLWARNING(_curl_easy_setopt_err_sockopt_cb,
_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
CURLWARNING(_curl_easy_setopt_err_opensocket_cb,
_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,
"curl_easy_setopt expects a "
"curl_opensocket_callback argument for this option"
)
CURLWARNING(_curl_easy_setopt_err_progress_cb,
_CURL_WARNING(_curl_easy_setopt_err_progress_cb,
"curl_easy_setopt expects a curl_progress_callback argument for this option")
CURLWARNING(_curl_easy_setopt_err_debug_cb,
_CURL_WARNING(_curl_easy_setopt_err_debug_cb,
"curl_easy_setopt expects a curl_debug_callback argument for this option")
CURLWARNING(_curl_easy_setopt_err_ssl_ctx_cb,
_CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb,
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
CURLWARNING(_curl_easy_setopt_err_conv_cb,
_CURL_WARNING(_curl_easy_setopt_err_conv_cb,
"curl_easy_setopt expects a curl_conv_callback argument for this option")
CURLWARNING(_curl_easy_setopt_err_seek_cb,
_CURL_WARNING(_curl_easy_setopt_err_seek_cb,
"curl_easy_setopt expects a curl_seek_callback argument for this option")
CURLWARNING(_curl_easy_setopt_err_cb_data,
_CURL_WARNING(_curl_easy_setopt_err_cb_data,
"curl_easy_setopt expects a "
"private data pointer as argument for this option")
CURLWARNING(_curl_easy_setopt_err_error_buffer,
_CURL_WARNING(_curl_easy_setopt_err_error_buffer,
"curl_easy_setopt expects a "
"char buffer of CURL_ERROR_SIZE as argument for this option")
CURLWARNING(_curl_easy_setopt_err_FILE,
_CURL_WARNING(_curl_easy_setopt_err_FILE,
"curl_easy_setopt expects a 'FILE *' argument for this option")
CURLWARNING(_curl_easy_setopt_err_postfields,
_CURL_WARNING(_curl_easy_setopt_err_postfields,
"curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
CURLWARNING(_curl_easy_setopt_err_curl_httpost,
_CURL_WARNING(_curl_easy_setopt_err_curl_httpost,
"curl_easy_setopt expects a 'struct curl_httppost *' "
"argument for this option")
CURLWARNING(_curl_easy_setopt_err_curl_mimepost,
_CURL_WARNING(_curl_easy_setopt_err_curl_mimepost,
"curl_easy_setopt expects a 'curl_mime *' "
"argument for this option")
CURLWARNING(_curl_easy_setopt_err_curl_slist,
_CURL_WARNING(_curl_easy_setopt_err_curl_slist,
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
CURLWARNING(_curl_easy_setopt_err_CURLSH,
_CURL_WARNING(_curl_easy_setopt_err_CURLSH,
"curl_easy_setopt expects a CURLSH* argument for this option")
CURLWARNING(_curl_easy_getinfo_err_string,
_CURL_WARNING(_curl_easy_getinfo_err_string,
"curl_easy_getinfo expects a pointer to 'char *' for this info")
CURLWARNING(_curl_easy_getinfo_err_long,
_CURL_WARNING(_curl_easy_getinfo_err_long,
"curl_easy_getinfo expects a pointer to long for this info")
CURLWARNING(_curl_easy_getinfo_err_double,
_CURL_WARNING(_curl_easy_getinfo_err_double,
"curl_easy_getinfo expects a pointer to double for this info")
CURLWARNING(_curl_easy_getinfo_err_curl_slist,
_CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
"curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
CURLWARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
_CURL_WARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
"curl_easy_getinfo expects a pointer to "
"'struct curl_tlssessioninfo *' for this info")
CURLWARNING(_curl_easy_getinfo_err_curl_certinfo,
_CURL_WARNING(_curl_easy_getinfo_err_curl_certinfo,
"curl_easy_getinfo expects a pointer to "
"'struct curl_certinfo *' for this info")
CURLWARNING(_curl_easy_getinfo_err_curl_socket,
_CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
_CURL_WARNING(_curl_easy_getinfo_err_curl_off_t,
"curl_easy_getinfo expects a pointer to curl_off_t for this info")
/* groups of curl_easy_setops options that take the same type of argument */
......@@ -244,14 +244,14 @@ CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
*/
/* evaluates to true if option takes a long argument */
#define curlcheck_long_option(option) \
#define _curl_is_long_option(option) \
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
#define curlcheck_off_t_option(option) \
(((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB))
#define _curl_is_off_t_option(option) \
((option) > CURLOPTTYPE_OFF_T)
/* evaluates to true if option takes a char* argument */
#define curlcheck_string_option(option) \
#define _curl_is_string_option(option) \
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
(option) == CURLOPT_ACCEPT_ENCODING || \
(option) == CURLOPT_ALTSVC || \
......@@ -311,7 +311,6 @@ CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
(option) == CURLOPT_RTSP_SESSION_ID || \
(option) == CURLOPT_RTSP_STREAM_URI || \
(option) == CURLOPT_RTSP_TRANSPORT || \
(option) == CURLOPT_SASL_AUTHZID || \
(option) == CURLOPT_SERVICE_NAME || \
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
......@@ -337,18 +336,18 @@ CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
0)
/* evaluates to true if option takes a curl_write_callback argument */
#define curlcheck_write_cb_option(option) \
#define _curl_is_write_cb_option(option) \
((option) == CURLOPT_HEADERFUNCTION || \
(option) == CURLOPT_WRITEFUNCTION)
/* evaluates to true if option takes a curl_conv_callback argument */
#define curlcheck_conv_cb_option(option) \
#define _curl_is_conv_cb_option(option) \
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
/* evaluates to true if option takes a data argument to pass to a callback */
#define curlcheck_cb_data_option(option) \
#define _curl_is_cb_data_option(option) \
((option) == CURLOPT_CHUNK_DATA || \
(option) == CURLOPT_CLOSESOCKETDATA || \
(option) == CURLOPT_DEBUGDATA || \
......@@ -370,13 +369,13 @@ CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
0)
/* evaluates to true if option takes a POST data argument (void* or char*) */
#define curlcheck_postfields_option(option) \
#define _curl_is_postfields_option(option) \
((option) == CURLOPT_POSTFIELDS || \
(option) == CURLOPT_COPYPOSTFIELDS || \
0)
/* evaluates to true if option takes a struct curl_slist * argument */
#define curlcheck_slist_option(option) \
#define _curl_is_slist_option(option) \
((option) == CURLOPT_HTTP200ALIASES || \
(option) == CURLOPT_HTTPHEADER || \
(option) == CURLOPT_MAIL_RCPT || \
......@@ -392,41 +391,40 @@ CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
/* groups of curl_easy_getinfo infos that take the same type of argument */
/* evaluates to true if info expects a pointer to char * argument */
#define curlcheck_string_info(info) \
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG && \
(info) != CURLINFO_PRIVATE)
#define _curl_is_string_info(info) \
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)
/* evaluates to true if info expects a pointer to long argument */
#define curlcheck_long_info(info) \
#define _curl_is_long_info(info) \
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
/* evaluates to true if info expects a pointer to double argument */
#define curlcheck_double_info(info) \
#define _curl_is_double_info(info) \
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
/* true if info expects a pointer to struct curl_slist * argument */
#define curlcheck_slist_info(info) \
#define _curl_is_slist_info(info) \
(((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
#define curlcheck_tlssessioninfo_info(info) \
#define _curl_is_tlssessioninfo_info(info) \
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
/* true if info expects a pointer to struct curl_certinfo * argument */
#define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
#define _curl_is_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
/* true if info expects a pointer to struct curl_socket_t argument */
#define curlcheck_socket_info(info) \
#define _curl_is_socket_info(info) \
(CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
/* true if info expects a pointer to curl_off_t argument */
#define curlcheck_off_t_info(info) \
#define _curl_is_off_t_info(info) \
(CURLINFO_OFF_T < (info))
/* typecheck helpers -- check whether given expression has requested type*/
/* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros,
/* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros,
* otherwise define a new macro. Search for __builtin_types_compatible_p
* in the GCC manual.
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
......@@ -436,35 +434,35 @@ CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
*/
/* XXX: should evaluate to true if expr is a pointer */
#define curlcheck_any_ptr(expr) \
#define _curl_is_any_ptr(expr) \
(sizeof(expr) == sizeof(void *))
/* evaluates to true if expr is NULL */
/* XXX: must not evaluate expr, so this check is not accurate */
#define curlcheck_NULL(expr) \
#define _curl_is_NULL(expr) \
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
/* evaluates to true if expr is type*, const type* or NULL */
#define curlcheck_ptr(expr, type) \
(curlcheck_NULL(expr) || \
#define _curl_is_ptr(expr, type) \
(_curl_is_NULL(expr) || \
__builtin_types_compatible_p(__typeof__(expr), type *) || \
__builtin_types_compatible_p(__typeof__(expr), const type *))
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
#define curlcheck_arr(expr, type) \
(curlcheck_ptr((expr), type) || \
#define _curl_is_arr(expr, type) \
(_curl_is_ptr((expr), type) || \
__builtin_types_compatible_p(__typeof__(expr), type []))
/* evaluates to true if expr is a string */
#define curlcheck_string(expr) \
(curlcheck_arr((expr), char) || \
curlcheck_arr((expr), signed char) || \
curlcheck_arr((expr), unsigned char))
#define _curl_is_string(expr) \
(_curl_is_arr((expr), char) || \
_curl_is_arr((expr), signed char) || \
_curl_is_arr((expr), unsigned char))
/* evaluates to true if expr is a long (no matter the signedness)
* XXX: for now, int is also accepted (and therefore short and char, which
* are promoted to int when passed to a variadic function) */
#define curlcheck_long(expr) \
#define _curl_is_long(expr) \
(__builtin_types_compatible_p(__typeof__(expr), long) || \
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
......@@ -479,59 +477,59 @@ CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
/* evaluates to true if expr is of type curl_off_t */
#define curlcheck_off_t(expr) \
#define _curl_is_off_t(expr) \
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
/* XXX: also check size of an char[] array? */
#define curlcheck_error_buffer(expr) \
(curlcheck_NULL(expr) || \
#define _curl_is_error_buffer(expr) \
(_curl_is_NULL(expr) || \
__builtin_types_compatible_p(__typeof__(expr), char *) || \
__builtin_types_compatible_p(__typeof__(expr), char[]))
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
#if 0
#define curlcheck_cb_data(expr) \
(curlcheck_ptr((expr), void) || \
curlcheck_ptr((expr), FILE))
#define _curl_is_cb_data(expr) \
(_curl_is_ptr((expr), void) || \
_curl_is_ptr((expr), FILE))
#else /* be less strict */
#define curlcheck_cb_data(expr) \
curlcheck_any_ptr(expr)
#define _curl_is_cb_data(expr) \
_curl_is_any_ptr(expr)
#endif
/* evaluates to true if expr is of type FILE* */
#define curlcheck_FILE(expr) \
(curlcheck_NULL(expr) || \
#define _curl_is_FILE(expr) \
(_curl_is_NULL(expr) || \
(__builtin_types_compatible_p(__typeof__(expr), FILE *)))
/* evaluates to true if expr can be passed as POST data (void* or char*) */
#define curlcheck_postfields(expr) \
(curlcheck_ptr((expr), void) || \
curlcheck_arr((expr), char) || \
curlcheck_arr((expr), unsigned char))
#define _curl_is_postfields(expr) \
(_curl_is_ptr((expr), void) || \
_curl_is_arr((expr), char) || \
_curl_is_arr((expr), unsigned char))
/* helper: __builtin_types_compatible_p distinguishes between functions and
* function pointers, hide it */
#define curlcheck_cb_compatible(func, type) \
#define _curl_callback_compatible(func, type) \
(__builtin_types_compatible_p(__typeof__(func), type) || \
__builtin_types_compatible_p(__typeof__(func) *, type))
/* evaluates to true if expr is of type curl_resolver_start_callback */
#define curlcheck_resolver_start_callback(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), curl_resolver_start_callback))
#define _curl_is_resolver_start_callback(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_resolver_start_callback))
/* evaluates to true if expr is of type curl_read_callback or "similar" */
#define curlcheck_read_cb(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), __typeof__(fread) *) || \
curlcheck_cb_compatible((expr), curl_read_callback) || \
curlcheck_cb_compatible((expr), _curl_read_callback1) || \
curlcheck_cb_compatible((expr), _curl_read_callback2) || \
curlcheck_cb_compatible((expr), _curl_read_callback3) || \
curlcheck_cb_compatible((expr), _curl_read_callback4) || \
curlcheck_cb_compatible((expr), _curl_read_callback5) || \
curlcheck_cb_compatible((expr), _curl_read_callback6))
#define _curl_is_read_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), __typeof__(fread) *) || \
_curl_callback_compatible((expr), curl_read_callback) || \
_curl_callback_compatible((expr), _curl_read_callback1) || \
_curl_callback_compatible((expr), _curl_read_callback2) || \
_curl_callback_compatible((expr), _curl_read_callback3) || \
_curl_callback_compatible((expr), _curl_read_callback4) || \
_curl_callback_compatible((expr), _curl_read_callback5) || \
_curl_callback_compatible((expr), _curl_read_callback6))
typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *);
......@@ -540,16 +538,16 @@ typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *);
/* evaluates to true if expr is of type curl_write_callback or "similar" */
#define curlcheck_write_cb(expr) \
(curlcheck_read_cb(expr) || \
curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \
curlcheck_cb_compatible((expr), curl_write_callback) || \
curlcheck_cb_compatible((expr), _curl_write_callback1) || \
curlcheck_cb_compatible((expr), _curl_write_callback2) || \
curlcheck_cb_compatible((expr), _curl_write_callback3) || \
curlcheck_cb_compatible((expr), _curl_write_callback4) || \
curlcheck_cb_compatible((expr), _curl_write_callback5) || \
curlcheck_cb_compatible((expr), _curl_write_callback6))
#define _curl_is_write_cb(expr) \
(_curl_is_read_cb(expr) || \
_curl_callback_compatible((expr), __typeof__(fwrite) *) || \
_curl_callback_compatible((expr), curl_write_callback) || \
_curl_callback_compatible((expr), _curl_write_callback1) || \
_curl_callback_compatible((expr), _curl_write_callback2) || \
_curl_callback_compatible((expr), _curl_write_callback3) || \
_curl_callback_compatible((expr), _curl_write_callback4) || \
_curl_callback_compatible((expr), _curl_write_callback5) || \
_curl_callback_compatible((expr), _curl_write_callback6))
typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
const void *);
......@@ -560,37 +558,37 @@ typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
#define curlcheck_ioctl_cb(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), curl_ioctl_callback) || \
curlcheck_cb_compatible((expr), _curl_ioctl_callback1) || \
curlcheck_cb_compatible((expr), _curl_ioctl_callback2) || \
curlcheck_cb_compatible((expr), _curl_ioctl_callback3) || \
curlcheck_cb_compatible((expr), _curl_ioctl_callback4))
#define _curl_is_ioctl_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_ioctl_callback) || \
_curl_callback_compatible((expr), _curl_ioctl_callback1) || \
_curl_callback_compatible((expr), _curl_ioctl_callback2) || \
_curl_callback_compatible((expr), _curl_ioctl_callback3) || \
_curl_callback_compatible((expr), _curl_ioctl_callback4))
typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *);
typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *);
typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
#define curlcheck_sockopt_cb(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), curl_sockopt_callback) || \
curlcheck_cb_compatible((expr), _curl_sockopt_callback1) || \
curlcheck_cb_compatible((expr), _curl_sockopt_callback2))
#define _curl_is_sockopt_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_sockopt_callback) || \
_curl_callback_compatible((expr), _curl_sockopt_callback1) || \
_curl_callback_compatible((expr), _curl_sockopt_callback2))
typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t,
curlsocktype);
/* evaluates to true if expr is of type curl_opensocket_callback or
"similar" */
#define curlcheck_opensocket_cb(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), curl_opensocket_callback) || \
curlcheck_cb_compatible((expr), _curl_opensocket_callback1) || \
curlcheck_cb_compatible((expr), _curl_opensocket_callback2) || \
curlcheck_cb_compatible((expr), _curl_opensocket_callback3) || \
curlcheck_cb_compatible((expr), _curl_opensocket_callback4))
#define _curl_is_opensocket_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_opensocket_callback) || \
_curl_callback_compatible((expr), _curl_opensocket_callback1) || \
_curl_callback_compatible((expr), _curl_opensocket_callback2) || \
_curl_callback_compatible((expr), _curl_opensocket_callback3) || \
_curl_callback_compatible((expr), _curl_opensocket_callback4))
typedef curl_socket_t (*_curl_opensocket_callback1)
(void *, curlsocktype, struct curl_sockaddr *);
typedef curl_socket_t (*_curl_opensocket_callback2)
......@@ -601,28 +599,28 @@ typedef curl_socket_t (*_curl_opensocket_callback4)
(const void *, curlsocktype, const struct curl_sockaddr *);
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
#define curlcheck_progress_cb(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), curl_progress_callback) || \
curlcheck_cb_compatible((expr), _curl_progress_callback1) || \
curlcheck_cb_compatible((expr), _curl_progress_callback2))
#define _curl_is_progress_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_progress_callback) || \
_curl_callback_compatible((expr), _curl_progress_callback1) || \
_curl_callback_compatible((expr), _curl_progress_callback2))
typedef int (*_curl_progress_callback1)(void *,
double, double, double, double);
typedef int (*_curl_progress_callback2)(const void *,
double, double, double, double);
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
#define curlcheck_debug_cb(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), curl_debug_callback) || \
curlcheck_cb_compatible((expr), _curl_debug_callback1) || \
curlcheck_cb_compatible((expr), _curl_debug_callback2) || \
curlcheck_cb_compatible((expr), _curl_debug_callback3) || \
curlcheck_cb_compatible((expr), _curl_debug_callback4) || \
curlcheck_cb_compatible((expr), _curl_debug_callback5) || \
curlcheck_cb_compatible((expr), _curl_debug_callback6) || \
curlcheck_cb_compatible((expr), _curl_debug_callback7) || \
curlcheck_cb_compatible((expr), _curl_debug_callback8))
#define _curl_is_debug_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_debug_callback) || \
_curl_callback_compatible((expr), _curl_debug_callback1) || \
_curl_callback_compatible((expr), _curl_debug_callback2) || \
_curl_callback_compatible((expr), _curl_debug_callback3) || \
_curl_callback_compatible((expr), _curl_debug_callback4) || \
_curl_callback_compatible((expr), _curl_debug_callback5) || \
_curl_callback_compatible((expr), _curl_debug_callback6) || \
_curl_callback_compatible((expr), _curl_debug_callback7) || \
_curl_callback_compatible((expr), _curl_debug_callback8))
typedef int (*_curl_debug_callback1) (CURL *,
curl_infotype, char *, size_t, void *);
typedef int (*_curl_debug_callback2) (CURL *,
......@@ -642,17 +640,17 @@ typedef int (*_curl_debug_callback8) (CURL *,
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
/* this is getting even messier... */
#define curlcheck_ssl_ctx_cb(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback1) || \
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback2) || \
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback3) || \
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback4) || \
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback5) || \
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback6) || \
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback7) || \
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback8))
#define _curl_is_ssl_ctx_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_ssl_ctx_callback) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback8))
typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
......@@ -675,26 +673,26 @@ typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
#endif
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
#define curlcheck_conv_cb(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), curl_conv_callback) || \
curlcheck_cb_compatible((expr), _curl_conv_callback1) || \
curlcheck_cb_compatible((expr), _curl_conv_callback2) || \
curlcheck_cb_compatible((expr), _curl_conv_callback3) || \
curlcheck_cb_compatible((expr), _curl_conv_callback4))
#define _curl_is_conv_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_conv_callback) || \
_curl_callback_compatible((expr), _curl_conv_callback1) || \
_curl_callback_compatible((expr), _curl_conv_callback2) || \
_curl_callback_compatible((expr), _curl_conv_callback3) || \
_curl_callback_compatible((expr), _curl_conv_callback4))
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
#define curlcheck_seek_cb(expr) \
(curlcheck_NULL(expr) || \
curlcheck_cb_compatible((expr), curl_seek_callback) || \
curlcheck_cb_compatible((expr), _curl_seek_callback1) || \
curlcheck_cb_compatible((expr), _curl_seek_callback2))
#define _curl_is_seek_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_seek_callback) || \
_curl_callback_compatible((expr), _curl_seek_callback1) || \
_curl_callback_compatible((expr), _curl_seek_callback2))
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
#endif /* CURLINC_TYPECHECK_GCC_H */
#endif /* __CURL_TYPECHECK_GCC_H */
#ifndef CURLINC_URLAPI_H
#define CURLINC_URLAPI_H
#ifndef __CURL_URLAPI_H
#define __CURL_URLAPI_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
......@@ -77,8 +77,6 @@ typedef enum {
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
#define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the
scheme is unknown. */
typedef struct Curl_URL CURLU;
......@@ -122,4 +120,4 @@ CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
} /* end of extern "C" */
#endif
#endif /* CURLINC_URLAPI_H */
#endif
......@@ -273,27 +273,6 @@ int HAL_SetProduct_Type(_IN_ char *product_type)
return len;
}
int HAL_SetProduct_Code(_IN_ char *product_code)
{
int len = strlen(product_code);
if (len > PRODUCT_CODE_LEN) {
return -1;
}
memset(g_product_code, 0x0, PRODUCT_CODE_LEN);
strncpy(g_product_code, product_code, len);
return len;
}
int HAL_GetProduct_Code(_OU_ char *product_code)
{
strncpy(product_code, KK_CCU_PRODUCTID, strlen(KK_CCU_PRODUCTID));
product_code[strlen(KK_CCU_PRODUCTID)] = '\0';
return strlen(KK_CCU_PRODUCTID);
}
/*
* This need to be same with app version as in uOTA module (ota_version.h)
......@@ -392,7 +371,11 @@ void HAL_ThreadDelete(_IN_ void *thread_handle)
pthread_exit(0);
} else {
/*main thread delete child thread*/
#ifdef CONFIG_A133_PLATFORM
pthread_kill((pthread_t)thread_handle,SIGALRM);
#else
pthread_cancel((pthread_t)thread_handle);
#endif
pthread_join((pthread_t)thread_handle, 0);
}
}
......
......@@ -55,7 +55,11 @@ uintptr_t HAL_TCP_Establish(const char *host, uint16_t port)
hints.ai_family = AF_INET; /* only IPv4 */
hints.ai_socktype = SOCK_STREAM;
#ifdef CONFIG_A133_PLATFORM
hints.ai_protocol = 0;
#else
hints.ai_protocol = IPPROTO_TCP;
#endif
sprintf(service, "%u", port);
while(dns_retry++ < 8) {
......
......@@ -2,6 +2,7 @@
#ifndef __KK_HAL_H__
#define __KK_HAL_H__
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
#include <time.h>
#include "kk_product.h"
......@@ -42,8 +43,6 @@ int HAL_Get_SN(char sn[SN_ADDR_LEN]);
int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len);
int HAL_SetProduct_Type(_IN_ char *product_type);
int HAL_SetProduct_Code(_IN_ char *product_code);
int HAL_GetProduct_Code(_OU_ char *product_code);
void HAL_Firmware_Persistence_Start(void* fileName);
int HAL_Firmware_Persistence_Write(_IN_ char *buffer, _IN_ uint32_t length);
int HAL_Firmware_Persistence_Stop(void);
......
......@@ -29,15 +29,35 @@
#define SN_ADDR_LEN (32+1)
#define PRODUCT_TPYE "kk"
#define CCU_LAN "eth0"
#define KK_CCU_ID "CCU_77771"
#define KK_CCU_PRODUCTID "ccu_n12"
#define KK_GW_PRODUCTID "gateway_2"
#define KK_CCU_RANDOM "0000000000"
#define KK_CCU_NAME "NEW_CCU"
#ifdef CONFIG_A133_PLATFORM
#define KK_DEVICESECRET_PATH "/data/local/kk/kk_deviceSecret.txt"
#define KK_TOKEN_PATH "/data/local/kk/kk_token.txt"
#define KK_DEVICE_MAP_FILE_PATH "/data/local/kk/map/device_%s.json"
#define GET_CCUID_CMD "getprop ro.ccuinfo"
#define GET_KEY_CMD "getprop ro.ccuinfo"
#define KK_DB_FILE "/data/local/kk/etc/kk_database.db"
#define TSL_SUBDEVICE_PATH_FILE "/data/local/kk/tsl/product_%s.json"
#define TSL_GATEWAY_PATH_FILE "/data/local/kk/tsl/gateway_%s.json"
#define TSL_CCU_PATH_FILE "/data/local/kk/tsl/ccu_%s.json"
#define TSL_SCENE_PATH_FILE "/data/local/kk/tsl/ccu_%s_scene.json"
#define OTA_IMG_PATH "/data/local/OTA/"
#define OTA_IMG_FILE "/data/local/OTA/app_squashfs.img"
#define OTA_IMG_FILE_MD5 "/data/local/OTA/app_squashfs.img.md5"
#define KK_CONFIG_FILE_PATH "/data/local/kk/kk_cloud_conf.json"
#define KK_DEFAULT_CONFIG_FILE_PATH "/data/local/kk/cloud_default_config.json"
#define KK_AUTH_CONFIG_FILE_PATH "/data/local/kk/auth_conf.json"
#else
#define KK_DEVICESECRET_PATH "/data/kk/kk_deviceSecret.txt"
#define KK_TOKEN_PATH "/data/kk/kk_token.txt"
#define KK_DEVICE_MAP_FILE_PATH "/data/kk/map/device_%s.json"
#define GET_CCUID_CMD "fw_printenv uuid -n"
#define GET_KEY_CMD "fw_printenv key -n"
#define GET_PRODUCTID_CMD "fw_printenv pid -n"
#define KK_DB_FILE "/data/kk/kk_database.db"
#define TSL_SUBDEVICE_PATH_FILE "/data/kk/tsl/product_%s.json"
#define TSL_GATEWAY_PATH_FILE "/data/kk/tsl/gateway_%s.json"
......@@ -46,8 +66,11 @@
#define OTA_IMG_PATH "/data/OTA/"
#define OTA_IMG_FILE "/data/OTA/app_squashfs.img"
#define OTA_IMG_FILE_MD5 "/data/OTA/app_squashfs.img.md5"
#define KK_DEVICESECRET_PATH "/data/kk/kk_deviceSecret.txt"
#define KK_TOKEN_PATH "/data/kk/kk_token.txt"
#define KK_CONFIG_FILE_PATH "/data/kk/kk_cloud_conf.json"
#define KK_DEFAULT_CONFIG_FILE_PATH "/app/ccuApps/config/cloud_default_config.json"
#define KK_AUTH_CONFIG_FILE_PATH "/tmp/auth_conf.json"
#endif
enum {
DEVICE_OFFLINE = 0,
DEVICE_ONLINE,
......
{
"lsc_entry": {
"port": 8079,
"proto": "tcp",
"host": "ddc.cloud.hijaytech.com"
},
"rsyslog_entry": {
"port": 514,
"host": "120.55.149.201"
},
"mqtt_entry": {
"port": 1883,
"proto": "tcp",
"host": "hub-mqtt.iot.ikonke.com"
},
"biz_entry": {
"port": 4481,
"proto": "https",
"host": "smarthome.ikonke.com"
},
"iot_ops_entry": {
"port": 8750,
"proto": "https",
"host": "iot-ops.ikonke.com"
},
"ops_entry": {
"port": 8563,
"proto": "https",
"host": "dev.ismartflat.com"
},
"mqtt_auth_entry": {
"port": 4436,
"proto": "https",
"host": "auth-iot.ikonke.com"
},
"ccu_upgrade_entry": {
"host": "upgrade.cloud.hijaytech.com"
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
#include "cJSON.h"
#include "kk_dm_api.h"
#include "kk_dm_msg.h"
#include <curl/curl.h>
#include "../../common/curl/include/curl/curl.h"
#include "com_api.h"
#include "kk_log.h"
#include "kk_hal.h"
......@@ -24,7 +24,7 @@ int dm_ota_init(void)
dm_ota_ctx_t *ctx = _dm_ota_get_ctx();
memset(ctx, 0, sizeof(dm_ota_ctx_t));
HAL_GetProduct_Code(ctx->deviceCode);
kk_get_pid(ctx->deviceCode);
return SUCCESS_RETURN;
}
......@@ -186,7 +186,7 @@ int kk_publishProgress(int process,int state)
char productCode[PRODUCT_CODE_LEN] = {0};
char ccuID[PRODUCT_CODE_LEN] = {0};
char msgId[MSG_MAX_LEN] = {0};
HAL_GetProduct_Code(productCode);
kk_get_pid(productCode);
HAL_Get_ccuid(ccuID);
iotx_report_id(msgId);
cJSON *info = cJSON_CreateObject();
......
......@@ -594,6 +594,51 @@ static void _dm_mgr_destroy_devlist(void)
free(del_node);
}
}
char s_pid[PRODUCT_CODE_LEN] = {0};
static int kk_pid_init(void)
{
#ifdef CONFIG_A133_PLATFORM
uint8_t data[128] = {0};
int data_len = 0;
char *pstart = NULL;
char *pEnd = NULL;
HAL_Execel_cmd(GET_CCUID_CMD,(char *)data,sizeof(data),&data_len);
printf("---GET_CCUID_CMD:%s\n",data);
if(data_len > 0 && data_len <= 128){
pstart = data;
pEnd = strstr(data,"pid_");
if(pstart != NULL && pEnd != NULL){
memcpy(s_pid,pEnd+4,data_len-1-(pEnd-pstart+4));
INFO_PRINT("kk_cloud_pid_init s_pid:%s\n",s_pid);
}else{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT("KK_Ccuid_init get ccuid error\n");
return -1;
}
}else{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT("KK_Ccuid_init get ccuid error\n");
return -1;
}
#else
char pid[PRODUCT_CODE_LEN] = {0};
int pid_len = 0;
HAL_Execel_cmd(GET_PRODUCTID_CMD,(char *)pid,sizeof(pid),&pid_len);
if(pid_len > 0 && pid_len <= PRODUCT_CODE_LEN){
memcpy(s_pid,pid,pid_len-1);
INFO_PRINT("s_pid:%s\n",s_pid);
}else{
return -1;
}
#endif
return 0;
}
int kk_get_pid(char *productId)
{
strncpy(productId, s_pid, strlen(s_pid));
printf("kk_lan_get_ccuid:%s\n",s_pid);
return strlen(s_pid);
}
extern char *kk_sync_get_info();
int dm_mgr_init(void)
{
......@@ -614,12 +659,13 @@ int dm_mgr_init(void)
ctx->global_devid = 1;
kk_property_db_init();
HAL_Get_ccuid(ccuid);
kk_pid_init();
/* Init Device List */
INIT_LIST_HEAD(&ctx->dev_list);
HAL_Get_mac(mac);
kk_sync_init();
//kk_sync_get_info();
res = dm_mgr_device_create(KK_DM_DEVICE_CCU,KK_DM_CCU_DEVICE_PRODUCT_CODE,ccuid,mac,"",KK_DEV_UNKNOW,&devId,&heartbeat);
res = dm_mgr_device_create(KK_DM_DEVICE_CCU,s_pid,ccuid,mac,"",KK_DEV_UNKNOW,&devId,&heartbeat);
if (res != SUCCESS_RETURN) {
goto ERROR;
}
......@@ -1687,6 +1733,9 @@ int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN])
if(strcmp(node->productType,KK_DM_AIR_SWITCH_GATEWAY_TYPE) == 0){
kk_subAirSwitch_delete_by_dcode(deviceCode);
}
if(strcmp(node->productType,KK_DM_FRESHAIR_GATEWAY_TYPE) == 0){
kk_subFreshAir_delete_by_dcode(deviceCode);
}
if(node->dev_type == KK_DM_DEVICE_CCU){
ERROR_PRINT("ERROR [%s][%d]\n",__FUNCTION__,__LINE__);
return FAIL_RETURN;
......
......@@ -12,11 +12,11 @@
#define KK_MID_SYNC_DEFAULT_TIMEOUT_MS (200)
#define IDENTIFY_MAXLEN (64 + 1)
#define KK_DM_CCU_DEVICE_PRODUCT_TYPE "ccu"
#define KK_DM_CCU_DEVICE_PRODUCT_CODE KK_CCU_PRODUCTID
#define KK_DM_GW_DEVICE_PRODUCT_TYPE "gw"
#define KK_DM_GW_DEVICE_PRODUCT_CODE "2"
#define KK_DM_AIR_GATEWAY_TYPE "air conditioning gateway"
#define KK_DM_AIR_SWITCH_GATEWAY_TYPE "airswitch gateway"
#define KK_DM_FRESHAIR_GATEWAY_TYPE "freshAir Gateway"
#define KK_DM_DEVICE_CCU_DEVICEID (0x00)
#define MSG_MAX_LEN (64)
......@@ -124,4 +124,5 @@ int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN]);
int dm_msg_thing_property_post_all(char *deviceCode);
int dm_mgr_get_gw_deviceCode(_OU_ dm_mgr_dev_node_t **node);
void dm_mgr_resubscribe(void);
int kk_get_pid(char *productId);
#endif
......@@ -60,15 +60,15 @@ typedef struct {
#define KK_THING_SERVICE_REBOOT "/thing/service/reboot"
#define KK_THING_SERVICE_ADDROOM "/thing/service/addRoom"
#define KK_THING_SERVICE_ADDROOM_REPLY "/thing/service/addRoom_reply"
#define KK_THING_SERVICE_UPDATEROOM "/thing/service/updateRoom"
#define KK_THING_SERVICE_UPDATEROOM_REPLY "/thing/service/updateRoom_reply"
#define KK_THING_SERVICE_UPDATEROOM "/thing/service/updateRoomName"
#define KK_THING_SERVICE_UPDATEROOM_REPLY "/thing/service/updateRoomName_reply"
#define KK_THING_SERVICE_DELETEROOM "/thing/service/deleteRoom"
#define KK_THING_SERVICE_DELETEROOM_REPLY "/thing/service/deleteRoom_reply"
#define KK_THING_SERVICE_ADDDEVICETOROOM "/thing/service/addDeviceToRoom"
#define KK_THING_SERVICE_ADDDEVICETOROOM_REPLY "/thing/service/addDeviceToRoom_reply"
#define KK_THING_SERVICE_REMOVEDEVICEFROMROOM "/thing/service/removeDeviceFromRoom"
#define KK_THING_SERVICE_REMOVEDEVICEFROMROOM_REPLY "/thing/service/removeDeviceFromRoom_reply"
#define KK_THING_SERVICE_EXECUTEROOM "/thing/service/executeRoom"
#define KK_THING_SERVICE_SETLOCALTIMER "/thing/service/setLocalTimer"
#define KK_THING_SERVICE_GETLOCALTIMER "/thing/service/getLocalTimer"
#define KK_THING_SERVICE_SETCOUNTDOWN "/thing/service/setCountDown"
......@@ -103,8 +103,8 @@ typedef struct {
#define KK_THING_SERVICE_GETFLOOR_REPLY "/thing/service/getAllFloors_reply"
#define KK_THING_SERVICE_SYNCINFO_REPLY "/thing/service/syncinfo_reply"
#define KK_THING_SERVICE_SYNCINFOPUSH_REPLY "/thing/service/syncinfopush_reply"
#define KK_THING_SERVICE_ADDFLOORS "/thing/service/addFloors"
#define KK_THING_SERVICE_ADDFLOORS_REPLY "/thing/service/addFloors_reply"
#define KK_THING_SERVICE_ADDFLOORS "/thing/service/addFloor"
#define KK_THING_SERVICE_ADDFLOORS_REPLY "/thing/service/addFloor_reply"
#define KK_THING_EVENT_MESSAGE "/thing/event/"
#define KK_THING_SERVICE_GETGUARDSENSORS "/thing/service/getGuardSensors"
#define KK_THING_EVENT_POST "/post"
......@@ -116,10 +116,23 @@ typedef struct {
#define KK_THING_SERVICE_HISTORYALARM_REPLY "/thing/service/historyAlarm_reply"
#define KK_THING_SERVICE_DEL_HISTORYALARM "/thing/service/delAlarm"
#define KK_THING_SERVICE_DEL_HISTORYALARM_REPLY "/thing/service/delAlarm_reply"
#define KK_THING_SERVICE_DELETEFLOORS "/thing/service/deleteFloors"
#define KK_THING_SERVICE_DELETEFLOORS_REPLY "/thing/service/deleteFloors_reply"
#define KK_THING_SERVICE_UPDATEFLOORS "/thing/service/updateFloors"
#define KK_THING_SERVICE_UPDATEFLOORS_REPLY "/thing/service/updateFloors_reply"
#define KK_THING_SERVICE_DELETEFLOORS "/thing/service/deleteFloor"
#define KK_THING_SERVICE_DELETEFLOORS_REPLY "/thing/service/deleteFloor_reply"
#define KK_THING_SERVICE_UPDATEFLOORS "/thing/service/modifyFloor"
#define KK_THING_SERVICE_UPDATEFLOORS_REPLY "/thing/service/modifyFloor_reply"
#define KK_THING_SERVICE_CLIENTREPORT "/thing/service/clientReport"
#define KK_THING_SERVICE_CLIENTREPORT_REPLY "/thing/service/clientReport_reply"
#define KK_THING_SERVICE_SPECIALDEVTOROOM "/thing/service/addSpecialDeviceToRoom"
#define KK_THING_SERVICE_SPECIALDEVTOROOM_REPLY "/thing/service/addSpecialDeviceToRoom_reply"
#define KK_THING_SERVICE_RMSPECIALDEVFROMROOM "/thing/service/removeSpecialDeviceFromRoom"
#define KK_THING_SERVICE_RMSPECIALDEVFROM_REPLY "/thing/service/removeSpecialDeviceFromRoom_reply"
#define KK_THING_SERVICE_DELETESPECIALDEV "/thing/service/relieveMooreDevice"
#define KK_THING_SERVICE_DELETESPECIALDEV_REPLY "/thing/service/relieveMooreDevice_reply"
#define KK_THING_SERVICE_GETMOORELIST "/thing/service/getMooreList"
#define KK_THING_SERVICE_GETMOORELIST_REPLY "/thing/service/getMooreList_reply"
#define KK_THING_SERVICE_CLIENTONLINEPUSH "/thing/service/clientOnlinePush"
#define KK_THING_SERVICE_GETCLIENTINFO "/thing/service/getClientInfo"
#define KK_THING_SERVICE_GETCLIENTINFO_REPLY "/thing/service/getClientInfo_reply"
void kk_sendData2app(void *info, void *payload,int isAsync);
int dm_msg_thing_sub_register(_IN_ char productCode[DEVICE_CODE_MAXLEN], _IN_ char deviceCode[DEVICE_CODE_MAXLEN],
......
......@@ -481,7 +481,6 @@ static int kk_service_addRoom_handle(const char *deviceCode, cJSON *params,cJSON
return res;
}
cJSON *roomInfoStr = cJSON_GetObjectItem(params, MSG_AREA_ADDROOM_ROOMNAME);
//cJSON *roomIdStr = cJSON_GetObjectItem(params, MSG_AREA_ROOM_ROOMID);
if(roomInfoStr == NULL){
return FAIL_RETURN;
}
......@@ -508,7 +507,7 @@ static int kk_service_updateRoom_handle(const char *deviceCode, cJSON *params,cJ
return INVALID_PARAMETER;
}
cJSON *roomInfoStr = cJSON_GetObjectItem(params, MSG_AREA_ADDROOM_ROOMNAME);
cJSON *roomIdStr = cJSON_GetObjectItem(params, MSG_AREA_ROOM_ROOMID);
cJSON *roomIdStr = cJSON_GetObjectItem(params, MSG_AREA_ROOM_CCUROOMID);
if(roomInfoStr == NULL || roomIdStr == NULL){
return FAIL_RETURN;
}
......@@ -569,7 +568,7 @@ static int kk_service_deleteRoom_handle(cJSON *params)
return INVALID_PARAMETER;
}
cJSON *roomInfoStr = cJSON_GetObjectItem(params, MSG_AREA_ROOM_ROOMID);
cJSON *roomInfoStr = cJSON_GetObjectItem(params, MSG_AREA_ROOM_CCUROOMID);
if(roomInfoStr == NULL){
return FAIL_RETURN;
}
......@@ -603,7 +602,7 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
if(room_name == NULL){
return FAIL_RETURN;
}
cJSON *roomId = cJSON_GetObjectItem(params, MSG_AREA_ROOM_ROOMID);
cJSON *roomId = cJSON_GetObjectItem(params, MSG_AREA_ROOM_CCUROOMID);
if(roomId == NULL){
return FAIL_RETURN;
}
......@@ -623,6 +622,8 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
isAirGwFlag = 1;
}else if(strcmp(node->productType,KK_DM_AIR_SWITCH_GATEWAY_TYPE) == 0){
isAirGwFlag = 2;
}else if(strcmp(node->productType,KK_DM_FRESHAIR_GATEWAY_TYPE) == 0){
isAirGwFlag = 3;
}
strcpy(epNumStr,"1");
}else{
......@@ -657,6 +658,19 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
kk_room_dev_add(roomId->valuestring,room_name->valuestring,deviceCode->valuestring,epNumStr,name);
}
}
if(strcmp(node->productType,KK_DM_FRESHAIR_GATEWAY_TYPE) == 0 && isAirGwFlag == 3){
int eplist[64] = {0};
char name[128] = {0};
int i = 0;
int count = kk_subFreshAir_query_epnums(deviceCode->valuestring,eplist);
for(i = 0; i < count; i++){
memset(epNumStr,0x0,sizeof(epNumStr));
memset(name,0x0,sizeof(name));
sprintf(epNumStr,"%d",eplist[i]);
sprintf(name,"新风%d",eplist[i]);
kk_room_dev_add(roomId->valuestring,room_name->valuestring,deviceCode->valuestring,epNumStr,name);
}
}
return SUCCESS_RETURN;
}
/************************************************************
......@@ -729,12 +743,16 @@ static int kk_service_executeDNDMode_handle(cJSON *params)
if(params == NULL){
return INVALID_PARAMETER;
}
cJSON *roomId = cJSON_GetObjectItem(params, MSG_AREA_ROOM_ROOMID);
if(roomId == NULL || roomId->type != cJSON_Number){
ERROR_PRINT("DATA ERROR!!!\n");
cJSON *roomId = cJSON_GetObjectItem(params, MSG_AREA_ROOM_CCUROOMID);
if(roomId == NULL){
ERROR_PRINT(" DND DATA ERROR !!!\n");
return INVALID_PARAMETER;
}
if(roomId->type == cJSON_Number){
sprintf(roomIdStr,"%d",roomId->valueint);
}else{
strcpy(roomIdStr,roomId->valuestring);
}
pList = kk_get_room_deviceCode(roomIdStr);
while(pList != NULL){
......@@ -793,7 +811,7 @@ static int kk_service_setFloor_handle(cJSON *params)
if(rooms == NULL) return INVALID_PARAMETER;
cJSON * itemroom = rooms->child;
while(itemroom != NULL){
cJSON * roomid = cJSON_GetObjectItem(itemroom,MSG_AREA_ROOM_ROOMID);
cJSON * roomid = cJSON_GetObjectItem(itemroom,MSG_AREA_ROOM_CCUROOMID);
if(roomid == NULL){
return INVALID_PARAMETER;
}
......@@ -855,14 +873,8 @@ static int kk_service_addFloor_reply(cJSON *root,cJSON *msgId,char *floorId,char
cJSON_AddStringToObject(payload, "code", "0");
cJSON_AddStringToObject(payload, "msgId", msgId->valuestring);
cJSON *paramInfo = cJSON_CreateObject();
cJSON *floorIdsAry = cJSON_CreateArray();
cJSON *Item = cJSON_CreateObject();
cJSON_AddStringToObject(Item, "floorId", floorId);
cJSON_AddStringToObject(Item, "name", name);
cJSON_AddItemToObject(Item, "rooms", kk_get_roomids_by_floorId(floorId));
cJSON_AddItemToArray(floorIdsAry,Item);
cJSON_AddItemToObject(paramInfo, "floors", floorIdsAry);
cJSON_AddStringToObject(paramInfo, "floorId", floorId);
cJSON_AddStringToObject(paramInfo, "name", name);
cJSON_AddItemToObject(payload, "params", paramInfo);
char *payload11=cJSON_Print(payload);
printf("------------------------------>payload11:%s\n",payload11);
......@@ -967,54 +979,327 @@ static int kk_service_getFloor_handle(cJSON *param,cJSON *msgId)
kk_free_floor_list();
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:添加屏类设备REPLY
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static int kk_service_addScreen_handle_reply(cJSON *param,cJSON *msgId,char *serialId)
{
if(param == NULL || msgId == NULL || serialId == NULL){
return INVALID_PARAMETER;
}
cJSON *deviceCode = cJSON_GetObjectItem(param, MSG_DEVICE_CODE_STR);
if(deviceCode == NULL){
return FAIL_RETURN;
}
cJSON *productCode = cJSON_GetObjectItem(param, MSG_PRODUCT_CODE_STR);
if(productCode == NULL){
return FAIL_RETURN;
}
cJSON *info = cJSON_CreateObject();
cJSON_AddStringToObject(info, MSG_TYPE_STR, KK_THING_SERVICE_CLIENTREPORT_REPLY);
cJSON_AddStringToObject(info, MSG_DEVICE_CODE_STR, deviceCode->valuestring);
cJSON_AddStringToObject(info, MSG_PRODUCT_CODE_STR, productCode->valuestring);
char *infff=cJSON_Print(info);
cJSON *payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "desc", "success");
cJSON_AddStringToObject(payload, "version", "1.0");
cJSON_AddStringToObject(payload, "code", "0");
cJSON_AddStringToObject(payload, "msgId", msgId->valuestring);
cJSON *paramInfo = cJSON_CreateObject();
cJSON_AddStringToObject(paramInfo, "serialId", serialId);
cJSON_AddItemToObject(payload, "params", paramInfo);
char *payload11=cJSON_Print(payload);
printf("------------------------------>payload11:%s\n",payload11);
kk_sendData2app(infff,payload11,0);
free(payload11);
free(infff);
cJSON_Delete(payload);
cJSON_Delete(info);
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:批量执行房间设备处理
*输入参数:params:云端下发数据,包含房间号,productCode
*功能描述:添加屏类设备REPLY
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static int kk_service_executeRoom_handle(cJSON *params)
static int kk_service_client_online_push(cJSON *param,cJSON *msgId,char *serialId)
{
int res = 0;
kk_dev_list_t *pList = NULL;
dm_mgr_dev_node_t *search_node = NULL;
if(param == NULL || msgId == NULL || serialId == NULL){
return INVALID_PARAMETER;
}
cJSON *deviceCode = cJSON_GetObjectItem(param, MSG_DEVICE_CODE_STR);
if(deviceCode == NULL){
return FAIL_RETURN;
}
cJSON *productCode = cJSON_GetObjectItem(param, MSG_PRODUCT_CODE_STR);
if(productCode == NULL){
return FAIL_RETURN;
}
cJSON *info = cJSON_CreateObject();
cJSON_AddStringToObject(info, MSG_TYPE_STR, KK_THING_SERVICE_CLIENTONLINEPUSH);
cJSON_AddStringToObject(info, MSG_DEVICE_CODE_STR, deviceCode->valuestring);
cJSON_AddStringToObject(info, MSG_PRODUCT_CODE_STR, productCode->valuestring);
char *infff=cJSON_Print(info);
cJSON *payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "desc", "success");
cJSON_AddStringToObject(payload, "version", "1.0");
cJSON_AddStringToObject(payload, "code", "0");
cJSON_AddStringToObject(payload, "msgId", msgId->valuestring);
cJSON *paramInfo = cJSON_CreateObject();
cJSON_AddStringToObject(paramInfo, "serialId", serialId);
cJSON_AddNumberToObject(paramInfo, "online", 1);
cJSON_AddItemToObject(payload, "params", paramInfo);
char *payload11=cJSON_Print(payload);
printf("------------------------------>payload11:%s\n",payload11);
kk_sendData2app(infff,payload11,0);
free(payload11);
free(infff);
cJSON_Delete(payload);
cJSON_Delete(info);
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:添加屏类设备
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static int kk_service_addScreen_handle(cJSON *info,cJSON *msgId,cJSON *params)
{
if(params == NULL){
return INVALID_PARAMETER;
}
cJSON *roomId = cJSON_GetObjectItem(params, MSG_AREA_ROOM_ROOMID);
if(roomId == NULL){
return FAIL_RETURN;
cJSON *mac = cJSON_GetObjectItem(params,MSG_DEVICE_MAC);
if(mac == NULL) return INVALID_PARAMETER;
cJSON *ip = cJSON_GetObjectItem(params,MSG_DEVICE_IP);
if(ip == NULL) return INVALID_PARAMETER;
cJSON *version = cJSON_GetObjectItem(params,MSG_DEVICE_VERSION);
if(version == NULL) return INVALID_PARAMETER;
cJSON *serialid = cJSON_GetObjectItem(params,MSG_DEVICE_SERIALID);
if(serialid == NULL) return INVALID_PARAMETER;
cJSON *devtype = cJSON_GetObjectItem(params,MSG_DEVICE_TYPE);
if(devtype == NULL) return INVALID_PARAMETER;
cJSON *expand = cJSON_GetObjectItem(params,MSG_DEVICE_EXPAND);
if(expand == NULL) return INVALID_PARAMETER;
kk_service_addScreen_handle_reply(info,msgId,serialid->valuestring);
kk_screenDev_insert_db(devtype->valueint,serialid->valuestring,ip->valuestring,mac->valuestring,version->valuestring,expand->valuestring);
kk_service_client_online_push(info,msgId,serialid->valuestring);
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:添加屏类到房间
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static int kk_service_addScreenToRoom_handle(cJSON *params)
{
if(params == NULL){
return INVALID_PARAMETER;
}
cJSON *serialid = cJSON_GetObjectItem(params,MSG_DEVICE_DEVICEINFO);
if(serialid == NULL) return INVALID_PARAMETER;
cJSON *roomname = cJSON_GetObjectItem(params,MSG_AREA_ADDROOM_ROOMNAME);
if(roomname == NULL) return INVALID_PARAMETER;
cJSON *roomId = cJSON_GetObjectItem(params,MSG_AREA_ROOM_CCUROOMID);
if(roomId == NULL) return INVALID_PARAMETER;
cJSON *name = cJSON_GetObjectItem(params,MSG_AREA_ADDROOM_DEVICENAME);
if(name == NULL) return INVALID_PARAMETER;
kk_screenDev_update_room(serialid->valuestring,roomId->valuestring,roomname->valuestring,name->valuestring);
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:删除屏类到房间
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static int kk_service_removeScreenToRoom_handle(cJSON *params)
{
if(params == NULL){
return INVALID_PARAMETER;
}
cJSON *serialid = cJSON_GetObjectItem(params,MSG_DEVICE_DEVICEINFO);
if(serialid == NULL) return INVALID_PARAMETER;
kk_screenDev_update_room(serialid->valuestring,"","","");
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:删除屏类
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static int kk_service_deleteScreen_handle(cJSON *params)
{
if(params == NULL){
return INVALID_PARAMETER;
}
cJSON *serialid = cJSON_GetObjectItem(params,MSG_DEVICE_DEVICEINFO);
if(serialid == NULL) return INVALID_PARAMETER;
kk_screenDev_delete_by_serialId(serialid->valuestring);
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:获取屏类列表
*输入参数:params:云端下发数据,包含场景Id等
msgId:消息Id
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static int kk_service_getScreenList_handle(cJSON *param,cJSON *msgId)
{
int res = 0;
int i = 0,num = 0;
ScreenDevInfo_t *pList = NULL;
printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON *productCodeStr = cJSON_GetObjectItem(params, MSG_PRODUCT_TYPE_STR);
if(productCodeStr == NULL){
if(param == NULL || msgId == NULL){
return INVALID_PARAMETER;
}
cJSON *deviceCode = cJSON_GetObjectItem(param, MSG_DEVICE_CODE_STR);
if(deviceCode == NULL){
return FAIL_RETURN;
}
cJSON *productCode = cJSON_GetObjectItem(param, MSG_PRODUCT_CODE_STR);
if(productCode == NULL){
return FAIL_RETURN;
}
printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
pList = kk_get_room_deviceCode(roomId->valuestring);
if(pList != NULL){
while(pList != NULL){
res = dm_mgr_get_device_by_devicecode(pList->deviceCode,&search_node);
if (res != SUCCESS_RETURN) {
pList = pList->next;
continue;
cJSON *info = cJSON_CreateObject();
cJSON_AddStringToObject(info, MSG_TYPE_STR, KK_THING_SERVICE_GETMOORELIST_REPLY);
cJSON_AddStringToObject(info, MSG_DEVICE_CODE_STR, deviceCode->valuestring);
cJSON_AddStringToObject(info, MSG_PRODUCT_CODE_STR, productCode->valuestring);
char *infff=cJSON_Print(info);
cJSON *payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "desc", "success");
cJSON_AddStringToObject(payload, "version", "1.0");
cJSON_AddStringToObject(payload, "code", "0");
cJSON_AddStringToObject(payload, "msgId", msgId->valuestring);
pList = (ScreenDevInfo_t*)malloc(sizeof(ScreenDevInfo_t)*KK_DEVICE_SCREEN_MAX_SUPPORT);
if(pList == NULL){
ERROR_PRINT("MALLOC ERROR!!!");
cJSON_Delete(payload);
cJSON_Delete(info);
free(infff);
return -1;
}
if(strcmp(search_node->productCode,productCodeStr->valuestring) == 0){
cJSON *action = cJSON_GetObjectItem(params, MSG_AREA_ROOM_ACTION);
if(action != NULL){
kk_service_execute_action(action,search_node);
memset(pList,0x0, sizeof(ScreenDevInfo_t)*KK_DEVICE_SCREEN_MAX_SUPPORT);
cJSON *paramArray = cJSON_CreateArray();
num = kk_get_screenDev_list(pList);
for(i = 0; i < num; i++){
cJSON *Item = cJSON_CreateObject();
cJSON_AddNumberToObject(Item, "deviceType", pList[i].type);
cJSON_AddStringToObject(Item, MSG_DEVICE_SERIALID, pList[i].serialId);
cJSON_AddStringToObject(Item, MSG_DEVICE_IP, pList[i].ip);
cJSON_AddStringToObject(Item, "deviceName", pList[i].name);
cJSON_AddStringToObject(Item, MSG_DEVICE_VERSION, pList[i].version);
cJSON_AddStringToObject(Item, MSG_AREA_ROOM_ROOMID, pList[i].roomid);
cJSON_AddStringToObject(Item, MSG_DEVICE_MAC, pList[i].mac);
cJSON_AddItemToArray(paramArray, Item);
}
cJSON_AddItemToObject(payload, "params", paramArray);
char *payload11=cJSON_Print(payload);
kk_sendData2app(infff,payload11,0);
free(payload11);
free(infff);
free(pList);
cJSON_Delete(payload);
cJSON_Delete(info);
return res;
}
/************************************************************
*功能描述:获取指定屏类数据
*输入参数:params:云端下发数据,包含场景Id等
msgId:消息Id
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static int kk_service_getScreenInfo_handle(cJSON *inforoot,cJSON *param,cJSON *msgId)
{
int res = 0;
int i = 0,num = 0;
ScreenDevInfo_t pInfo = {0};
if(param == NULL || msgId == NULL){
return INVALID_PARAMETER;
}
pList = pList->next;
printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON *serialid = cJSON_GetObjectItem(param,MSG_DEVICE_SERIALID);
if(serialid == NULL) return INVALID_PARAMETER;
cJSON *deviceCode = cJSON_GetObjectItem(inforoot, MSG_DEVICE_CODE_STR);
if(deviceCode == NULL){
return FAIL_RETURN;
}
cJSON *productCode = cJSON_GetObjectItem(inforoot, MSG_PRODUCT_CODE_STR);
if(productCode == NULL){
return FAIL_RETURN;
}
kk_free_room_dev_list();
return SUCCESS_RETURN;
}
printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON *info = cJSON_CreateObject();
cJSON_AddStringToObject(info, MSG_TYPE_STR, KK_THING_SERVICE_GETCLIENTINFO_REPLY);
cJSON_AddStringToObject(info, MSG_DEVICE_CODE_STR, deviceCode->valuestring);
cJSON_AddStringToObject(info, MSG_PRODUCT_CODE_STR, productCode->valuestring);
char *infff=cJSON_Print(info);
cJSON *payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "desc", "success");
cJSON_AddStringToObject(payload, "version", "1.0");
cJSON_AddStringToObject(payload, "code", "0");
cJSON_AddStringToObject(payload, "msgId", msgId->valuestring);
printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON *paramInfo = cJSON_CreateObject();
kk_get_screenDev_info(&pInfo,serialid->valuestring);
{
cJSON_AddNumberToObject(paramInfo, "type", pInfo.type);
cJSON_AddStringToObject(paramInfo, MSG_DEVICE_SERIALID, pInfo.serialId);
cJSON_AddStringToObject(paramInfo, MSG_DEVICE_IP, pInfo.ip);
cJSON_AddStringToObject(paramInfo, "name", pInfo.name);
cJSON_AddStringToObject(paramInfo, MSG_DEVICE_VERSION, pInfo.version);
cJSON_AddStringToObject(paramInfo, "room_id", pInfo.roomid);
cJSON_AddStringToObject(paramInfo, MSG_DEVICE_MAC, pInfo.mac);
cJSON_AddStringToObject(paramInfo, "id", pInfo.serialId);
cJSON_AddNumberToObject(paramInfo, "online", 1);
cJSON *expand = cJSON_CreateObject();
cJSON_AddItemToObject(paramInfo, "expand", expand);
}
printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddItemToObject(payload, "params", paramInfo);
char *payload11=cJSON_Print(payload);
printf("------------------------------>payload11:%s\n",payload11);
kk_sendData2app(infff,payload11,0);
free(payload11);
free(infff);
cJSON_Delete(payload);
cJSON_Delete(info);
return res;
}
/************************************************************
*功能描述:添加场景处理
*输入参数:params:云端下发数据,包含场景名称,场景类型,场景使能等
......@@ -1577,7 +1862,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
cJSON *paramStr = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
cJSON *state = cJSON_GetObjectItem(paramStr, KK_TSL_CCU_ARMINGSTATE_IDENTIFIER);
if(state != NULL){
cJSON *RoomIds = cJSON_GetObjectItem(paramStr, "RoomIds");
cJSON *RoomIds = cJSON_GetObjectItem(paramStr, MSG_AREA_ROOM_CCUROOMIDS);
if(RoomIds != NULL){
kk_room_reset_armingstate();
int array_size = cJSON_GetArraySize ( RoomIds );
......@@ -1681,11 +1966,6 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
//kk_service_addDeviceToRoom_reply(info_root,msgId,1);
kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_REMOVEDEVICEFROMROOM_REPLY);
}
else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_EXECUTEROOM) == 0){
INFO_PRINT(" executeroom \n");
cJSON *paramStr = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
kk_service_executeRoom_handle(paramStr);
}
else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_ADDSCENC) == 0){
INFO_PRINT(" add scene \n");
cJSON *paramStr = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
......@@ -1855,6 +2135,44 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
kk_service_updateFloor_handle(paramStr);
kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_UPDATEFLOORS_REPLY);
}
else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_CLIENTREPORT) == 0){
INFO_PRINT("CLIENTREPORT \n");
cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID);
cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR);
kk_service_addScreen_handle(info_root,msgId,paramStr);
}
else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_SPECIALDEVTOROOM) == 0){
INFO_PRINT("SPECIALDEV TO ROOM \n");
cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID);
cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR);
kk_service_addScreenToRoom_handle(paramStr);
kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_SPECIALDEVTOROOM_REPLY);
}
else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_RMSPECIALDEVFROMROOM) == 0){
INFO_PRINT("RM SPECIALDEV FROM ROOM \n");
cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID);
cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR);
kk_service_removeScreenToRoom_handle(paramStr);
kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_RMSPECIALDEVFROM_REPLY);
}
else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_DELETESPECIALDEV) == 0){
INFO_PRINT("DELETE SPECIALDEV\n");
cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID);
cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR);
kk_service_deleteScreen_handle(paramStr);
kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_DELETESPECIALDEV_REPLY);
}
else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_GETMOORELIST) == 0){
INFO_PRINT("SPECIALDEV GETLIST\n");
cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID);
kk_service_getScreenList_handle(info_root,msgId);
}
else if(strcmp(typeJson->valuestring,KK_THING_SERVICE_GETCLIENTINFO) == 0){
INFO_PRINT("GETCLIENTINFO \n");
cJSON *msgId = cJSON_GetObjectItem(payload, MSG_COMMON_MSGID);
cJSON *paramStr = cJSON_GetObjectItem(payload,MSG_PARAMS_STR);
kk_service_getScreenInfo_handle(info_root,paramStr,msgId);
}
else{
INFO_PRINT("Error msgtype!!! \n");
}
......@@ -2176,41 +2494,6 @@ static int _iotx_linkkit_subdev_login(int devid)
if (res < SUCCESS_RETURN) {
return FAIL_RETURN;
}
#ifdef MSG_NEED_RESP
msgid = res;
semaphore = HAL_SemaphoreCreate();
if (semaphore == NULL) {
return FAIL_RETURN;
}
_iotx_linkkit_upstream_mutex_lock();
res = _iotx_linkkit_upstream_sync_callback_list_insert(msgid, semaphore, &node);
if (res != SUCCESS_RETURN) {
HAL_SemaphoreDestroy(semaphore);
_iotx_linkkit_upstream_mutex_unlock();
return FAIL_RETURN;
}
_iotx_linkkit_upstream_mutex_unlock();
res = HAL_SemaphoreWait(semaphore, IOTX_LINKKIT_SYNC_DEFAULT_TIMEOUT_MS);
if (res < SUCCESS_RETURN) {
_iotx_linkkit_upstream_mutex_lock();
_iotx_linkkit_upstream_sync_callback_list_remove(msgid);
_iotx_linkkit_upstream_mutex_unlock();
return FAIL_RETURN;
}
_iotx_linkkit_upstream_mutex_lock();
code = node->code;
_iotx_linkkit_upstream_sync_callback_list_remove(msgid);
if (code != SUCCESS_RETURN) {
_iotx_linkkit_upstream_mutex_unlock();
return FAIL_RETURN;
}
_iotx_linkkit_upstream_mutex_unlock();
#endif
res = iotx_dm_subscribe(devid);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
......
......@@ -122,7 +122,6 @@ static int _kk_property_db_Init(void)
value varchar(33), \
valueType INTEGER, \
epNum INTEGER)";
if (sqlite3_exec(ctx->pDb, pSubAirSwitchtable, NULL, NULL, &pcErr) != SQLITE_OK)
{
ERROR_PRINT("Error creating table (%s)\n", pcErr);
......@@ -131,6 +130,22 @@ static int _kk_property_db_Init(void)
_kk_property_db_unlock();
return FAIL_RETURN;
}
const char *pSubFreshAirtable = "CREATE TABLE IF NOT EXISTS subFreshAirProperties( \
idx INTEGER PRIMARY KEY, \
deviceCode varchar(33), \
identifier varchar(33), \
value varchar(33), \
valueType INTEGER, \
epNum INTEGER)";
if (sqlite3_exec(ctx->pDb, pSubFreshAirtable, NULL, NULL, &pcErr) != SQLITE_OK)
{
ERROR_PRINT("Error creating table (%s)\n", pcErr);
sqlite3_free(pcErr);
//eUtils_LockUnlock(&sLock);
_kk_property_db_unlock();
return FAIL_RETURN;
}
//eUtils_LockUnlock(&sLock);
_kk_property_db_unlock();
return SUCCESS_RETURN;
......@@ -504,6 +519,167 @@ int kk_subAirSwitch_db_update_value(const char *deviceCode,const char *identifie
_kk_property_db_unlock();
return SUCCESS_RETURN;
}
static int _kk_check_subFreshAir_exist(const char* deviceCode,const char *identifier,int epNum)
{
int isExist = 0;
sqlite3_stmt *stmt;
char *pDeviceCode = NULL;
char *pIdentifier = NULL;
int epNumDb = 0;
kk_property_db_ctx_t *ctx = _kk_property_db_get_ctx();
const char *searchCmd = "select * from subFreshAirProperties;";
_kk_property_db_lock();
sqlite3_prepare_v2(ctx->pDb, searchCmd, strlen(searchCmd), &stmt, NULL);
//INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
while(sqlite3_step(stmt) == SQLITE_ROW){
pDeviceCode = (char*)sqlite3_column_text(stmt, DB_SUBFRESHAIR_DEVICECODE);
pIdentifier = (char*)sqlite3_column_text(stmt, DB_SUBFRESHAIR_IDENTIFITER);
epNumDb = sqlite3_column_int(stmt, DB_SUBFRESHAIR_EPNUM);
if((strcmp(deviceCode,pDeviceCode) == 0) && (strcmp(identifier,pIdentifier) == 0)&& (epNumDb == epNum))
{
isExist = 1;
break;
}
}
//INFO_PRINT("\n");
sqlite3_finalize(stmt);
_kk_property_db_unlock();
return isExist;
}
/************************************************************
*功能描述: 插入新风子设备属性到数据库
*输入参数: deviceCode:设备deviceCode
epNum:端点
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:属性的值插入的时候先置空,后续再update
*************************************************************/
int kk_subFreshAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_data_type_e valuetype,int epNum)
{
const char *insertCmd = "insert into subFreshAirProperties (deviceCode,identifier,value,valueType,epNum) \
values ('%s','%s','%s','%d','%d');";
char *sqlCmd = NULL;
int rc = 0;
char *zErrMsg = 0;
kk_property_db_ctx_t *ctx = _kk_property_db_get_ctx();
if(_kk_check_subFreshAir_exist(deviceCode,identifier,epNum) == 1){
return SUCCESS_RETURN;
}
_kk_property_db_lock();
sqlCmd = sqlite3_mprintf(insertCmd,deviceCode,identifier,"",valuetype,epNum);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
//INFO_PRINT("sub device insert data successfully\n");
}
sqlite3_free(sqlCmd);
_kk_property_db_unlock();
return SUCCESS_RETURN;
}
/************************************************************
*功能描述: 查询新风子设备数量
*输入参数: deviceCode:设备deviceCode
epList:端点列表
*输出参数: 子设备个数
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_subFreshAir_query_epnums(const char *deviceCode,int epList[])
{
char *sqlCmd = NULL;
//int rc = 0;
//char *zErrMsg = 0;
sqlite3_stmt *stmt;
char *valueStr = NULL;
int count = 0;
kk_property_db_ctx_t *ctx = _kk_property_db_get_ctx();
_kk_property_db_lock();
sqlCmd = sqlite3_mprintf("select * from subFreshAirProperties WHERE deviceCode= '%s' and identifier = '%s'",deviceCode,"PowerSwitch");
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
if(count > 32){
return count;
}
epList[count] = sqlite3_column_int(stmt, DB_SUBFRESHAIR_EPNUM);
printf("epList[count] :%d\n",epList[count]);
count++;
}
sqlite3_free(sqlCmd);
_kk_property_db_unlock();
sqlite3_finalize(stmt);
return count;
}
/************************************************************
*功能描述:通过deviceCode删除新风子设备
*输入参数: deviceCode:设备deviceCode
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_subFreshAir_delete_by_dcode(char deviceCode[DEVICE_CODE_MAXLEN])
{
const char *deleteCmd = "delete from subFreshAirProperties where deviceCode = '%s';";
char *sqlCmd = NULL;
int rc = 0;
char *zErrMsg = 0;
kk_property_db_ctx_t *ctx = _kk_property_db_get_ctx();
_kk_property_db_lock();
sqlCmd = sqlite3_mprintf(deleteCmd,deviceCode);
INFO_PRINT("Table delete data sqlCmd:%s\n",sqlCmd);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
INFO_PRINT("Table delete data successfully\n");
}
sqlite3_free(sqlCmd);
_kk_property_db_unlock();
return SUCCESS_RETURN;
}
/************************************************************
*功能描述: 更新属性值
*输入参数: deviceCode:设备deviceCode
identifier:属性名称
value:属性值
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_subFreshAir_db_update_value(const char *deviceCode,const char *identifier,const char* value,int epNum)
{
char *sqlCmd = NULL;
int rc = 0;
char *zErrMsg = 0;
kk_property_db_ctx_t *ctx = _kk_property_db_get_ctx();
_kk_property_db_lock();
//if()
sqlCmd = sqlite3_mprintf("UPDATE subFreshAirProperties SET value='%s' WHERE (deviceCode= '%s' and epNum = '%d') and (identifier = '%s') ",value,deviceCode,epNum,identifier);
//DEBUG_PRINT("kk_property_db_update_value sqlCmd:%s\n",sqlCmd);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
//DEBUG_PRINT("kk_property_db_update_value successfully\n");
}
sqlite3_free(sqlCmd);
_kk_property_db_unlock();
return SUCCESS_RETURN;
}
/************************************************************
*功能描述: 插入空调内机属性到数据库
*输入参数: deviceCode:设备deviceCode
......
......@@ -48,6 +48,14 @@ enum{
DB_SUBAIRSWITCH_VALUETYPE,
DB_SUBAIRSWITCH_EPNUM
};
enum{
DB_SUBFRESHAIR_IDX = 0,
DB_SUBFRESHAIR_DEVICECODE,
DB_SUBFRESHAIR_IDENTIFITER,
DB_SUBFRESHAIR_VALUE,
DB_SUBFRESHAIR_VALUETYPE,
DB_SUBFRESHAIR_EPNUM
};
int kk_property_db_init(void);
int kk_property_db_get_rawdata(const char *identifier,const int dev_type, kk_prop_raw_struct_t* raw, int count);
int kk_property_db_update_value(const char *deviceCode,const char *identifier,const char* value);
......@@ -69,5 +77,9 @@ int kk_subAirSwitch_db_update_value(const char *deviceCode,const char *identifie
int kk_subAirSwitch_delete_by_dcode(char deviceCode[DEVICE_CODE_MAXLEN]);
int kk_subAirSwitch_query_epnums(const char *deviceCode,int epList[]);
int kk_subAirSwitch_db_insert(const char *deviceCode,const char *identifier,kk_tsl_data_type_e valuetype,int epNum);
int kk_subFreshAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_data_type_e valuetype,int epNum);
int kk_subFreshAir_query_epnums(const char *deviceCode,int epList[]);
int kk_subFreshAir_delete_by_dcode(char deviceCode[DEVICE_CODE_MAXLEN]);
int kk_subFreshAir_db_update_value(const char *deviceCode,const char *identifier,const char* value,int epNum);
#endif
......@@ -67,8 +67,7 @@ static int kk_subDev_db_Init(void)
ctx->pDb = g_kk_pDb;
INFO_PRINT("sub db Database opened\n");
{
const char *pSubDevTable = "CREATE TABLE IF NOT EXISTS SubDeviceInfo( \
idx INTEGER, \
isOffline INTEGER, \
......@@ -95,8 +94,26 @@ static int kk_subDev_db_Init(void)
_kk_subDb_unlock();
return FAIL_RETURN;
}
}
const char *pScreenDevTable = "CREATE TABLE IF NOT EXISTS ScreenDeviceInfo( \
idx INTEGER PRIMARY KEY , \
isOffline INTEGER, \
type INTEGER, \
serialId varchar(128), \
deviceIp varchar(32), \
deviceName varchar(128), \
mac varchar(33), \
version varchar(33), \
roomId varchar(33), \
roomName varchar(128), \
expand varchar(256))";
if (sqlite3_exec(ctx->pDb, pScreenDevTable, NULL, NULL, &pcErr) != SQLITE_OK)
{
ERROR_PRINT("Error creating table (%s)\n", pcErr);
sqlite3_free(pcErr);
return FAIL_RETURN;
}
//eUtils_LockUnlock(&sLock);
_kk_subDb_unlock();
return SUCCESS_RETURN;
......@@ -810,3 +827,242 @@ int kk_subDev_getSensors_reply(SensorType_t*list)
/************************************************************
*功能描述:检查屏类设备是否有重复
*输入参数:deviceCode:设备deviceCode
*输出参数:无
*返 回 值:1:存在;0:不存在
*其他说明:
*************************************************************/
static int _kk_check_screenDev_exist(const char* sId)
{
int isExist = 0;
sqlite3_stmt *stmt;
char *serialId = NULL;
kk_subDb_ctx_t *ctx = _kk_subDb_get_ctx();
const char *searchCmd = "select * from ScreenDeviceInfo;";
_kk_subDb_lock();
sqlite3_prepare_v2(ctx->pDb, searchCmd, strlen(searchCmd), &stmt, NULL);
//INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
while(sqlite3_step(stmt) == SQLITE_ROW){
serialId = (char*)sqlite3_column_text(stmt, DB_SCREEN_SERIALID);
if(!strcmp(sId,serialId))
{
isExist = 1;
break;
}
}
sqlite3_finalize(stmt);
_kk_subDb_unlock();
return isExist;
}
/************************************************************
*功能描述:保存设备信息到数据库
*输入参数:devType:设备类型
serialId:产品Id
ip:设备ip
mac: mac地址
version:版本号
expand:预留
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_screenDev_insert_db(int devType,char *serialId, \
char *ip,char *mac,char *version,char *expand)
{
const char *insertCmd = "insert into ScreenDeviceInfo (isOffline,type,serialId,deviceIp,deviceName,mac,version,roomId,roomName,expand) \
values ('%d','%d','%s','%s','%s','%s','%s','%s','%s','%s');";
char *sqlCmd = NULL;
int rc = 0;
char *zErrMsg = 0;
kk_subDb_ctx_t *ctx = _kk_subDb_get_ctx();
if(_kk_check_screenDev_exist((const char*)serialId) == 1)
{
WARNING_PRINT("[%s][%d] DATA ALREADY EXIST!!!\n",__FUNCTION__,__LINE__);
return SUCCESS_RETURN;
}
_kk_subDb_lock();
sqlCmd = sqlite3_mprintf(insertCmd,1,devType,serialId,ip,"MOOR4C",mac,version,"","",expand);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
//INFO_PRINT("sub device insert data successfully\n");
}
sqlite3_free(sqlCmd);
_kk_subDb_unlock();
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:更新设备信息到数据库
*输入参数:devType:设备类型
serialId:产品Id
ip:设备ip
mac: mac地址
version:版本号
expand:预留
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_screenDev_update_room(char *serialId,char *roomid,char *roomname,char* name)
{
char *sqlCmd = NULL;
int rc = 0;
char *zErrMsg = 0;
kk_subDb_ctx_t *ctx = _kk_subDb_get_ctx();
_kk_subDb_lock();
sqlCmd = sqlite3_mprintf("UPDATE ScreenDeviceInfo SET roomId= '%s',roomName ='%s',deviceName = '%s' WHERE serialId= '%s'",roomid,roomname,name,serialId);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
INFO_PRINT("Table updata data successfully\n");
}
sqlite3_free(sqlCmd);
_kk_subDb_unlock();
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:删除设备信息到数据库
*输入参数:devType:设备类型
serialId:产品Id
ip:设备ip
mac: mac地址
version:版本号
expand:预留
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_screenDev_delete_by_serialId(char *serialId)
{
const char *deleteCmd = "delete from ScreenDeviceInfo where serialId = '%s';";
char *sqlCmd = NULL;
int rc = 0;
char *zErrMsg = 0;
kk_subDb_ctx_t *ctx = _kk_subDb_get_ctx();
_kk_subDb_lock();
sqlCmd = sqlite3_mprintf(deleteCmd,serialId);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
//INFO_PRINT("Table delete data successfully\n");
}
sqlite3_free(sqlCmd);
_kk_subDb_unlock();
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:获取屏类列表
*输入参数:deviceCode:设备deviceCode
isAuth:1,已注册;0,未注册
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_get_screenDev_list(ScreenDevInfo_t*list)
{
const char *searchCmd = "select * from ScreenDeviceInfo";
char *zErrMsg = 0;
sqlite3_stmt *stmt;
kk_subDb_ctx_t *ctx = _kk_subDb_get_ctx();
char *pSerialId = NULL;
char *pIp = NULL;
char *pDevName = NULL;
char *pMac = NULL;
char *pRoomId = NULL;
char *pVer = NULL;
int type = 0;
int count = 0;
_kk_subDb_lock();
sqlite3_prepare_v2(ctx->pDb, searchCmd, strlen(searchCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
pSerialId = (char*)sqlite3_column_text(stmt, DB_SCREEN_SERIALID);
pIp = (char*)sqlite3_column_text(stmt, DB_SCREEN_IP);
pDevName = (char*)sqlite3_column_text(stmt, DB_SCREEN_NAME);
pRoomId = (char*)sqlite3_column_text(stmt, DB_SCREEN_ROOMID);
pMac = (char*)sqlite3_column_text(stmt, DB_SCREEN_MAC);
pVer = (char*)sqlite3_column_text(stmt, DB_SCREEN_VERSION);
type = sqlite3_column_int(stmt, DB_SCREEN_TYPE);
//printf("currentValue:%d\n",currentValue);
memcpy(list[count].serialId,pSerialId,strlen(pSerialId));
memcpy(list[count].ip,pIp,strlen(pIp));
memcpy(list[count].mac,pMac,strlen(pMac));
memcpy(list[count].name,pDevName,strlen(pDevName));
memcpy(list[count].roomid,pRoomId,strlen(pRoomId));
memcpy(list[count].version,pVer,strlen(pVer));
list[count].type = type;
count++;
}
sqlite3_finalize(stmt);
_kk_subDb_unlock();
return count;
}
/************************************************************
*功能描述:获取屏类信息
*输入参数:deviceCode:设备deviceCode
isAuth:1,已注册;0,未注册
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_get_screenDev_info(ScreenDevInfo_t *devInfo,char*serialId)
{
const char *searchCmd = "select * from ScreenDeviceInfo where serialId = '%s';";
char *zErrMsg = 0;
sqlite3_stmt *stmt;
kk_subDb_ctx_t *ctx = _kk_subDb_get_ctx();
char *pSerialId = NULL;
char *pIp = NULL;
char *pDevName = NULL;
char *pMac = NULL;
char *pRoomId = NULL;
char *pVer = NULL;
int type = 0;
char *sqlCmd = NULL;
if(devInfo == NULL || serialId == NULL){
return -1;
}
_kk_subDb_lock();
sqlCmd = sqlite3_mprintf(searchCmd,serialId);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
pSerialId = (char*)sqlite3_column_text(stmt, DB_SCREEN_SERIALID);
pIp = (char*)sqlite3_column_text(stmt, DB_SCREEN_IP);
pDevName = (char*)sqlite3_column_text(stmt, DB_SCREEN_NAME);
pRoomId = (char*)sqlite3_column_text(stmt, DB_SCREEN_ROOMID);
pMac = (char*)sqlite3_column_text(stmt, DB_SCREEN_MAC);
pVer = (char*)sqlite3_column_text(stmt, DB_SCREEN_VERSION);
type = sqlite3_column_int(stmt, DB_SCREEN_TYPE);
//printf("currentValue:%d\n",currentValue);
memcpy(devInfo->serialId,pSerialId,strlen(pSerialId));
memcpy(devInfo->ip,pIp,strlen(pIp));
memcpy(devInfo->mac,pMac,strlen(pMac));
memcpy(devInfo->name,pDevName,strlen(pDevName));
memcpy(devInfo->roomid,pRoomId,strlen(pRoomId));
memcpy(devInfo->version,pVer,strlen(pVer));
devInfo->type = type;
break;
}
sqlite3_finalize(stmt);
_kk_subDb_unlock();
sqlite3_free(sqlCmd);
return 0;
}
\ No newline at end of file
......@@ -6,6 +6,15 @@ typedef struct {
char deviceCode[DEVICE_CODE_MAXLEN];
int SensorType;
} SensorType_t;
typedef struct {
char ip[17];
char name[128];
char serialId[128];
char roomid[32];
char version[32];
char mac[32];
int type;
} ScreenDevInfo_t;
int kk_subDb_init(void);
int kk_subDev_insert_db(int devType,char productCode[PRODUCT_CODE_MAXLEN], \
char deviceCode[DEVICE_CODE_MAXLEN],char fatherMac[DEVICE_MAC_MAXLEN],char mac[DEVICE_MAC_MAXLEN], char version[DEVICE_VERSION_MAXLEN],int heartbeat);
......@@ -24,6 +33,12 @@ int kk_subDev_update_offline(int isOffline,const char *deviceCode);
int kk_subDev_getSensors_reply(SensorType_t*list);
int kk_load_subDevice(void);
int kk_subDev_check_auth(int devType);
int kk_screenDev_insert_db(int devType,char *serialId, \
char *ip,char *mac,char *version,char *expand);
int kk_screenDev_update_room(char *serialId,char *roomid,char *roomname,char* name);
int kk_screenDev_delete_by_serialId(char *serialId);
int kk_get_screenDev_list(ScreenDevInfo_t*list);
int kk_get_screenDev_info(ScreenDevInfo_t *devInfo,char*serialId);
enum{
DB_SUB_IDX = 0,
DB_SUB_ONLINE,
......@@ -38,5 +53,17 @@ enum{
DB_SUB_PRODUCTTYPE,
DB_SUB_SCENESUPPORT
};
enum{
DB_SCREEN_IDX = 0,
DB_SCREEN_ONLINE,
DB_SCREEN_TYPE,
DB_SCREEN_SERIALID,
DB_SCREEN_IP,
DB_SCREEN_NAME,
DB_SCREEN_MAC,
DB_SCREEN_VERSION,
DB_SCREEN_ROOMID,
DB_SCREEN_ROOMNAME,
DB_SCREEN_EXPAND,
};
#endif
......@@ -106,12 +106,8 @@ static cJSON * kk_get_room_devices(const char *roomId)
}
if(kk_check_multi_ep_num(deviceCode)){
cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
}else if(strcmp(node->productType,KK_DM_AIR_GATEWAY_TYPE) == 0){
//if(atoi(epNum) == 1){//epNum为1的是空调网关
// continue;
//}else{
}else if(strcmp(node->productType,KK_DM_AIR_GATEWAY_TYPE) == 0 || strcmp(node->productType,KK_DM_FRESHAIR_GATEWAY_TYPE) == 0){
cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
//}
}
cJSON_AddStringToObject(dev,KK_SYNC_DEVICECODE_STR,deviceCode);
//cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
......@@ -464,6 +460,53 @@ static cJSON *kk_get_indoor_properties_info(char *deviceCode)
sqlite3_finalize(stmt);
return obj;
}
static cJSON *kk_get_subfreshair_properties_info(char *deviceCode)
{
char *sqlCmd = NULL;
//char *zErrMsg = 0;
sqlite3_stmt *stmt;
char *propertyStr = NULL;
char *valueStr = NULL;
int valueType = 0;
int eplist[65] = {0};
int count = 0,i = 0;
char *ptr = NULL;
kk_sync_ctx_t *ctx = _kk_sync_get_ctx();
if(deviceCode == NULL){
return NULL;
}
cJSON *obj = cJSON_CreateObject();
cJSON *eps = cJSON_CreateArray();
count = kk_subFreshAir_query_epnums(deviceCode,eplist);
for(i = 0; i < count; i++){
sqlCmd = sqlite3_mprintf("select * from subFreshAirProperties WHERE deviceCode = '%s' and epNum=%d;",deviceCode,eplist[i]);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
cJSON *propertyItem = cJSON_CreateObject();
cJSON_AddNumberToObject(propertyItem, "epNum",eplist[i]);
while(sqlite3_step(stmt) == SQLITE_ROW){
propertyStr = (char*)sqlite3_column_text(stmt, DB_SUBFRESHAIR_IDENTIFITER);
valueType = sqlite3_column_int(stmt, DB_SUBFRESHAIR_VALUETYPE);
valueStr = (char*)sqlite3_column_text(stmt, DB_SUBFRESHAIR_VALUE);
if(valueType == KK_TSL_DATA_TYPE_TEXT){
cJSON_AddStringToObject(propertyItem, propertyStr, valueStr);
}else if(valueType == KK_TSL_DATA_TYPE_INT||
valueType == KK_TSL_DATA_TYPE_ENUM||
valueType == KK_TSL_DATA_TYPE_BOOL){
cJSON_AddNumberToObject(propertyItem, propertyStr, atoi(valueStr));
}else if(valueType == KK_TSL_DATA_TYPE_DOUBLE){
cJSON_AddNumberToObject(propertyItem, propertyStr, atof(valueStr));
}
}
cJSON_AddItemToArray(eps,propertyItem);
}
cJSON_AddItemToObject(obj, "eps", eps);
cJSON_AddNumberToObject(obj, "EpTotal", count);
cJSON_AddNumberToObject(obj, "CombineDeviceFlag", 1);
sqlite3_free(sqlCmd);
sqlite3_finalize(stmt);
return obj;
}
static cJSON * kk_get_properties_info_obj(char *deviceCode)
{
char *sqlCmd = NULL;
......@@ -638,8 +681,9 @@ static int kk_get_sub_devices_info(cJSON *gwdevicesItem,char *deviceCode)
properties=kk_get_properties_info(subDeviceCode,KK_DM_DEVICE_SUBDEV);
}else if(strcmp(subproductType,KK_DM_AIR_GATEWAY_TYPE) == 0){
properties=kk_get_indoor_properties_info(subDeviceCode);
}
else{
}else if(strcmp(subproductType,KK_DM_FRESHAIR_GATEWAY_TYPE) == 0){
properties=kk_get_subfreshair_properties_info(subDeviceCode);
}else{
properties=kk_get_properties_info_obj(subDeviceCode);
}
......@@ -1202,7 +1246,7 @@ char *kk_sync_get_info()
kk_get_devices_info(data);
kk_get_scenes_info(data);
HAL_Get_ccuid(ccu_deviceCode);
HAL_GetProduct_Code(ccu_productCode);
kk_get_pid(ccu_productCode);
HAL_GetVersion(version);
cJSON_AddStringToObject(data, KK_SYNC_DEVICECODE_STR,ccu_deviceCode);
cJSON_AddStringToObject(data, KK_SYNC_NANE_STR, "newccu");
......
......@@ -11,14 +11,21 @@ CFLAGS += -I$(TOP_DIR)/common/sqlite
CFLAGS += -I$(TOP_DIR)/src/tsl/tsl_handle
LDFLAGS += -lapi_com -liot_cjson -lkk_tsl
LDFLAGS += -lm -lkk_hal
LDFLAGS += -lsqlite -ldl -lcurl
LDFLAGS += -lsqlite -ldl
ifeq ($(CONFIG_MODEL),x86)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_ubuntu -lanl
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_ubuntu
else ifeq ($(CONFIG_MODEL),nx5)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_nx5 -lanl
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_nx5 -lanl -lcurl
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_nx5
else ifeq ($(CONFIG_MODEL),8197)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_8197 -lubacktrace
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_8197
else ifeq ($(CONFIG_MODEL),a133)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_a133
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_a133
LDFLAGS += -L$(TOP_DIR)/common/curl -lcurl_a133
else
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg -lanl
LDFLAGS += -L$(TOP_DIR)/common/ev -lev
......
......@@ -102,6 +102,29 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
}
static int HAL_Ccuid_init(void)
{
#ifdef CONFIG_A133_PLATFORM
uint8_t data[128] = {0};
int data_len = 0;
uint8_t uuid[32] = {0};
char *pstart = NULL;
char *pEnd = NULL;
HAL_Execel_cmd(GET_CCUID_CMD,(char *)data,sizeof(data),&data_len);
printf("GET_CCUID_CMD:%s\n",data);
if(data_len > 0 && data_len <= 128){
pstart = data;
pEnd = strstr(data,"-");
if(pstart != NULL && pEnd != NULL){
printf("-------123---------------------\n");
memcpy(uuid,pstart,pEnd-pstart);
_setDevice_Code(uuid,pEnd-pstart);
}else{
return -1;
}
}else{
return -1;
}
#else
char ccuid[DEVICE_CODE_LEN] = {0};
char ccuidTmp[DEVICE_CODE_LEN] = {0};
int ccuid_len = 0;
......@@ -114,6 +137,7 @@ static int HAL_Ccuid_init(void)
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
return -1;
}
#endif
return 0;
}
/************************************************************
......@@ -702,6 +726,8 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
kk_indoorAir_db_update_value(deviceCode,property->identifier,valBuf,epNumInt);
}else if(type == 1){
kk_subAirSwitch_db_update_value(deviceCode,property->identifier,valBuf,epNumInt);
}else if(type == 2){
kk_subFreshAir_db_update_value(deviceCode,property->identifier,valBuf,epNumInt);
}
}else if(property->data_value.type == KK_TSL_DATA_TYPE_FLOAT || property->data_value.type == KK_TSL_DATA_TYPE_DOUBLE){
char valBuf[16] = {0};
......@@ -710,15 +736,17 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
kk_indoorAir_db_update_value(deviceCode,property->identifier,valBuf,epNumInt);
}else if(type == 1){
kk_subAirSwitch_db_update_value(deviceCode,property->identifier,valBuf,epNumInt);
}else if(type == 2){
kk_subFreshAir_db_update_value(deviceCode,property->identifier,valBuf,epNumInt);
}
}else if(property->data_value.type == KK_TSL_DATA_TYPE_TEXT ){
if(type == 0){
kk_indoorAir_db_update_value(deviceCode,property->identifier,propertyItem->valuestring,epNumInt);
}else if(type == 1){
kk_subAirSwitch_db_update_value(deviceCode,property->identifier,propertyItem->valuestring,epNumInt);
}else if(type == 2){
kk_subFreshAir_db_update_value(deviceCode,property->identifier,propertyItem->valuestring,epNumInt);
}
}
}
......@@ -727,7 +755,7 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
}
return 0;
}
/*type : 0,air condition gw;1,air switch gw*/
/*type : 0,air condition gw;1,air switch gw;2,fresh air switch*/
static int kk_subDevice_property_handle(cJSON *info,cJSON *payload,char *deviceCode,int type)
{
kk_subDevice_property_save(payload,deviceCode,type);
......@@ -795,6 +823,34 @@ static int kk_subAirSwitch_online_handle(dm_mgr_dev_node_t *node ,char *deviceCo
}
return 0;
}
static int kk_subFreshair_online_handle(dm_mgr_dev_node_t *node ,char *deviceCode,int epNum)
{
int idx = 0;
int gwExist = 0;
char roomId[32] = {0};
char roomName[256] = {0};
char epNumStr[10] = {0};
kk_tsl_data_t *property = NULL;
if(node == NULL){
return -1;
}
for(idx = 0; idx < node->dev_shadow->property_number; idx++){
property = (kk_tsl_data_t *)(node->dev_shadow->properties + idx);
if(property == NULL){
continue;
}
kk_subFreshAir_db_insert(deviceCode,property->identifier,property->data_value.type,epNum);
}
gwExist = kk_get_device_roomInfo(deviceCode,1,roomName,roomId);//获取网关房间信息
if(gwExist){
char name[128] = {0};
sprintf(name,"新风%d",epNum);
sprintf(epNumStr,"%d",epNum);
kk_room_dev_add(roomId,roomName,deviceCode,epNumStr,name);
}
return 0;
}
void kk_platMsg_handle(void* data, char* chalMark){
int res = 0;
cJSON *json;
......@@ -875,6 +931,10 @@ void kk_platMsg_handle(void* data, char* chalMark){
cJSON *epNumJson = cJSON_GetObjectItem(jsonPay, "epNum");
if(epNumJson == NULL) goto error;
kk_subAirSwitch_online_handle(search_node,devCode->valuestring,epNumJson->valueint);
}else if(strcmp(search_node->productType,KK_DM_FRESHAIR_GATEWAY_TYPE) == 0){
cJSON *epNumJson = cJSON_GetObjectItem(jsonPay, "epNum");
if(epNumJson == NULL) goto error;
kk_subFreshair_online_handle(search_node,devCode->valuestring,epNumJson->valueint);
}
}
else if (strstr(msgType->valuestring, KK_THING_TOPO_BATCH_ADD_MSG) != NULL){
......@@ -909,6 +969,8 @@ void kk_platMsg_handle(void* data, char* chalMark){
kk_subDevice_property_handle(info,payload,info_dcode->valuestring,0);
}else if(strcmp(search_node->productType ,KK_DM_AIR_SWITCH_GATEWAY_TYPE) == 0){
kk_subDevice_property_handle(info,payload,info_dcode->valuestring,1);
}else if(strcmp(search_node->productType ,KK_DM_FRESHAIR_GATEWAY_TYPE) == 0){
kk_subDevice_property_handle(info,payload,info_dcode->valuestring,2);
}
else{
/*插座类设备保存功率历史记录*/
......@@ -1296,7 +1358,11 @@ void *udp_dispatch_yield(void *args){
memset(host_ip, 0, sizeof(host_ip));
memset(mac, 0, sizeof(mac));
memset(szOut, 0, sizeof(szOut));
#ifdef CONFIG_A133_PLATFORM
HAL_Get_IP(host_ip,"eth0");
#else
HAL_Get_IP(host_ip,NULL);
#endif
HAL_Get_ccuid(device_code);
// printf("[%s][%d]inet_ntoa(from.sin_addr):%s\n",__FUNCTION__,__LINE__,inet_ntoa(from.sin_addr));
// printf("[%s][%d]host_ip:%s\n",__FUNCTION__,__LINE__,host_ip);
......@@ -1360,7 +1426,11 @@ void *ccu_property_monitor(void *args)
dm_mgr_search_dev_by_devid(KK_DM_DEVICE_CCU_DEVICEID,&node);
//dm_mgr_update_timestamp_by_devicecode(node->deviceCode,HAL_GetTime());
node->timestamp = HAL_Uptimes();
#ifdef CONFIG_A133_PLATFORM
HAL_Get_IP(s_IP,"eth0");
#else
HAL_Get_IP(s_IP,NULL);
#endif
res = kk_tsl_get_value(kk_tsl_get_property_value,node->dev_shadow,KK_TSL_CCU_WANIP_IDENTIFIER,s_IP_TSL,NULL);
if(res != SUCCESS_RETURN){
ERROR_PRINT("kk_tsl_get_value Failed\n");
......
......@@ -1173,7 +1173,7 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
propertyValue = cJSON_GetObjectItem(item,MSG_SCENE_PROPERTYVALUE);
if(propertyValue == NULL) return FAIL_RETURN;
productType = cJSON_GetObjectItem(item,MSG_PRODUCT_TYPE_STR);
roomId = cJSON_GetObjectItem(item,MSG_AREA_ROOM_ROOMID);
roomId = cJSON_GetObjectItem(item,MSG_AREA_ROOM_CCUROOMID);
if(productType != NULL){
delay = cJSON_GetObjectItem(item,MSG_SCENE_DELAY);
if(delay == NULL) return FAIL_RETURN;
......@@ -1349,7 +1349,7 @@ int kk_scene_parse_addscene(const cJSON* args,char *sceneId,int isUpdate,const c
ERROR_PRINT("[%d]kk_scene_parse_addscene fail!!!\n",__LINE__);
return INVALID_PARAMETER;
}
cJSON *room_id = cJSON_GetObjectItem(args,MSG_SCENE_ROOM_ID);
cJSON *room_id = cJSON_GetObjectItem(args,MSG_AREA_ROOM_CCUROOMID);
if(room_id == NULL)
{
INFO_PRINT("NOT Contain the room info\n");
......@@ -1372,9 +1372,9 @@ int kk_scene_parse_addscene(const cJSON* args,char *sceneId,int isUpdate,const c
//多合一面板绑定的时候可能不带roomid
if(room_id != NULL){
char roomIdStr[32] = {0};
snprintf(roomIdStr,32,"%d",room_id->valueint);
res = kk_scene_insert_scene_info(roomIdStr,name->valuestring,sceneType->valueint,enable->valueint,sceneId);
//char roomIdStr[32] = {0};
//snprintf(roomIdStr,32,"%d",room_id->valuestring);
res = kk_scene_insert_scene_info(room_id->valuestring,name->valuestring,sceneType->valueint,enable->valueint,sceneId);
}else{
res = kk_scene_insert_scene_info("-1",name->valuestring,sceneType->valueint,enable->valueint,sceneId);
}
......
......@@ -1953,7 +1953,7 @@
]
},
{
"pid": "00800000",
"pid": "00803122",
"name": "BL Fresh Air Gateway",
"type": "ZR",
"ota": true,
......@@ -2067,6 +2067,25 @@
}
]
},
{
"pid": "01021000",
"name": "YY Dimmalbe Light 5W",
"type": "ZR",
"ota": true,
"b_pid": 3137,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "01000004",
"name": "Four Lamp Control Module",
......@@ -2447,6 +2466,234 @@
}
]
},
{
"pid": "01010004",
"name": "YY Linear Dimmalbe Light Model G4 With Level",
"type": "ZR",
"ota": true,
"b_pid": 3166,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "010C0002",
"name": "YY Linear Dimmalbe Light Model G4 With ColorTemp",
"type": "ZR",
"ota": true,
"b_pid": 3167,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "010C0021",
"name": "YY Dimmalbe Light Controler 12W With ColorTemp",
"type": "ZR",
"ota": true,
"b_pid": 3169,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "01010021",
"name": "YY Dimmalbe Light Controler 12W With Level",
"type": "ZR",
"ota": true,
"b_pid": 3170,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "010C0031",
"name": "YY Dimmalbe Light Controler 20W With ColorTemp",
"type": "ZR",
"ota": true,
"b_pid": 3171,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "01010031",
"name": "YY Dimmalbe Light Controler 20W With Level",
"type": "ZR",
"ota": true,
"b_pid": 3172,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "010C0041",
"name": "YY Dimmalbe Light Controler 8W With ColorTemp",
"type": "ZR",
"ota": true,
"b_pid": 3173,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "01010041",
"name": "YY Dimmalbe Light Controler 8W With Level",
"type": "ZR",
"ota": true,
"b_pid": 3174,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "010C0051",
"name": "YY Dimmalbe Light Controler 14W With ColorTemp",
"type": "ZR",
"ota": true,
"b_pid": 3175,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "01010051",
"name": "YY Dimmalbe Light Controler 14W With Level",
"type": "ZR",
"ota": true,
"b_pid": 3176,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "010D0062",
"name": "YY RGBCW Light Belt Controller",
"type": "ZR",
"ota": true,
"b_pid": 3177,
"productType": "colorDimmableLight",
"eps": [
{
"zid": "0102",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "010D0061",
"name": "YY CW Light Belt Controller",
"type": "ZR",
"ota": true,
"b_pid": 3178,
"productType":"lightPanel",
"eps": [
{
"zid": "0103",
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid": "00041002",
"name": "XB KeyBord Panel G3",
......
{
"productCode":"3094",
"operateType":"512",
"operateType":"501",
"channel":1,
"syn_type":1,
"syn_opcode":"DIMMABLE_LIGHT_STATUS",
......
......@@ -88,10 +88,10 @@ $filepath/bin/kk_lan --uart=/dev/ttyS3&
sleep 2
$filepath/bin/kk_cloud &
sleep 5
$filepath/bin/smarthome_z3gw_nx5 -r0 -l3 --device-def=$filepath/kk_device_def.json --db=/data/kk/kk_z3gw.db --uart=/dev/ttyS1&
$filepath/bin/smarthome_z3gw_nx5 -r0 -l3 --device-def=$filepath/config/kk_device_def.json --db=/data/kk/kk_z3gw.db --uart=/dev/ttyS1&
sleep 1
if [ ! -f /etc/cron.d/ccu ]; then
echo "*/1 * * * * /app/ccuApps/process_check.sh" > /etc/cron.d/ccu || { echo "ERROR:add ccu crontab rule failed."; exit 1;}
echo "*/1 * * * * /app/ccuApps/script/process_check.sh" > /etc/cron.d/ccu || { echo "ERROR:add ccu crontab rule failed."; exit 1;}
fi
/etc/init.d/S90dcron restart
ntpd -n -q -d -p stdtime.gov.hk &
......
......@@ -4,7 +4,7 @@
ccuApps="/app/ccuApps"
restart_process()
{
$ccuApps/killall.sh
$ccuApps/script/killall.sh
$ccuApps/onboot.sh
}
PIDS=`ps|grep kk_midware |grep -v grep | awk '{print $1}'`
......
CONFIG_ENV_CFLAGS += \
-DBOARD_ESP8266 -u call_user_start \
-fno-inline-functions \
-ffunction-sections \
-fdata-sections \
-mlongcalls \
-DESPOS_FOR_ESP8266 -Wl,-static \
-DXT_USE_THREAD_SAFE_CLIB=0 \
CONFIG_ENV_CFLAGS += \
-Os \
-DCONFIG_HTTP_AUTH_TIMEOUT=500 \
-DCONFIG_MID_HTTP_TIMEOUT=500 \
-DCONFIG_GUIDER_AUTH_TIMEOUT=500 \
-DCONFIG_MQTT_TX_MAXLEN=640 \
-DCONFIG_MQTT_RX_MAXLEN=1200 \
CONFIG_external_libs/mbedtls :=
CONFIG_tests :=
CROSS_PREFIX := xtensa-lx106-elf-
CONFIG_ENV_CFLAGS += \
-Os -Wall\
-g3 --coverage \
-D_PLATFORM_IS_LINUX_ \
CONFIG_ENV_CFLAGS += \
-DWITH_MQTT_DYN_BUF=1 \
-DWITH_MEM_STATS=0 \
-DWITH_MEM_STATS_PER_MODULE=0 \
-DWITH_MQTT_JSON_FLOW=1 \
-DWITH_MQTT_ZIP_TOPIC=1 \
-DWITH_MQTT_SUB_SHORTCUT=1 \
-DSDK_TEAM_TEST \
-D_GNU_SOURCE \
CONFIG_ENV_CFLAGS += \
-DCONFIG_HTTP_AUTH_TIMEOUT=500 \
-DCONFIG_MID_HTTP_TIMEOUT=500 \
-DCONFIG_GUIDER_AUTH_TIMEOUT=500 \
-DCONFIG_MQTT_RX_MAXLEN=5000 \
-DCONFIG_MBEDTLS_DEBUG_LEVEL=0 \
-DCONFIG_A133_PLATFORM \
CONFIG_ENV_CFLAGS += -rdynamic
CONFIG_ENV_CFLAGS += -Wno-unused -std=c99
CONFIG_ENV_LDFLAGS += -pthread
OVERRIDE_CC = arm-linux-androideabi-gcc
OVERRIDE_AR = arm-linux-androideabi-ar
OVERRIDE_LD = arm-linux-androideabi-ld
CROSS_PREFIX = arm-linux-androideabi-
OVERRIDE_STRIP := strip
CONFIG_ENV_CFLAGS += \
-Os -Wall \
-g3 --coverage \
-D_PLATFORM_IS_LINUX_ \
CONFIG_ENV_CFLAGS += \
-DWITH_MQTT_DYN_BUF=1 \
-DWITH_MEM_STATS=0 \
-DWITH_MEM_STATS_PER_MODULE=0 \
-DWITH_MQTT_JSON_FLOW=1 \
-DWITH_MQTT_ZIP_TOPIC=1 \
-DWITH_MQTT_SUB_SHORTCUT=1 \
-DSDK_TEAM_TEST \
-D_GNU_SOURCE \
CONFIG_ENV_CFLAGS += \
-DCONFIG_HTTP_AUTH_TIMEOUT=500 \
-DCONFIG_MID_HTTP_TIMEOUT=500 \
-DCONFIG_GUIDER_AUTH_TIMEOUT=500 \
-DCONFIG_MQTT_RX_MAXLEN=5000 \
-DCONFIG_MBEDTLS_DEBUG_LEVEL=0 \
CONFIG_ENV_CFLAGS += -rdynamic
CONFIG_ENV_CFLAGS += -Wno-unused -std=c99
CONFIG_ENV_LDFLAGS += -lpthread -lrt
OVERRIDE_CC = mipsel-buildroot-linux-uclibc-gcc
OVERRIDE_AR = mipsel-buildroot-linux-uclibc-ar
OVERRIDE_LD = mipsel-buildroot-linux-uclibc-ld
CROSS_PREFIX = mipsel-buildroot-linux-uclibc-
OVERRIDE_STRIP := strip
......@@ -19,6 +19,7 @@ CONFIG_ENV_CFLAGS += \
-DCONFIG_GUIDER_AUTH_TIMEOUT=500 \
-DCONFIG_MQTT_RX_MAXLEN=5000 \
-DCONFIG_MBEDTLS_DEBUG_LEVEL=0 \
-DCONFIG_NX5_PLATFORM \
CONFIG_ENV_CFLAGS += -rdynamic
......
......@@ -204,15 +204,17 @@ package:
mkdir $(releaseDir)/lib
mkdir $(releaseDir)/bin
mkdir $(releaseDir)/map
mkdir $(releaseDir)/config
mkdir $(releaseDir)/script
cp -rf $(TOP_DIR)/tsl $(TOP_DIR)/$(releaseDir)
cp -rf $(TOP_DIR)/output/release/lib/*.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/output/release/bin/* $(TOP_DIR)/$(releaseDir)/bin
cp -rf $(TOP_DIR)/process_check.sh $(TOP_DIR)/$(releaseDir)/
cp -rf $(TOP_DIR)/onboot.sh $(TOP_DIR)/$(releaseDir)/
cp -rf $(TOP_DIR)/killall.sh $(TOP_DIR)/$(releaseDir)/
cp -rf $(TOP_DIR)/script/* $(TOP_DIR)/$(releaseDir)/script
mv $(TOP_DIR)/$(releaseDir)/script/onboot.sh $(TOP_DIR)/$(releaseDir)/
cp -rf $(TOP_DIR)/VERSION $(TOP_DIR)/$(releaseDir)/
cp -rf $(TOP_DIR)/opcodeMapCfg/* $(TOP_DIR)/$(releaseDir)/map
cp -rf $(TOP_DIR)/config/* $(TOP_DIR)/$(releaseDir)/config
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table $(TOP_DIR)/$(releaseDir)/
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_map_table.json $(TOP_DIR)/$(releaseDir)/dev_config_table/
ifeq ($(CONFIG_MODEL),ubuntu)
......@@ -224,7 +226,7 @@ else ifeq ($(CONFIG_MODEL),nx5)
cp -rf $(TOP_DIR)/common/ev/libev_nx5.so $(TOP_DIR)/$(releaseDir)/lib/libev.so
cp -rf $(TOP_DIR)/common/sqlite/libsqlite3_nx5.so $(TOP_DIR)/$(releaseDir)/lib/libsqlite3.so
cp -rf $(TOP_DIR)/nx5_soc_gw/smarthome_z3gw_nx5 $(TOP_DIR)/$(releaseDir)/bin/
cp -rf $(TOP_DIR)/nx5_soc_gw/kk_device_def.json $(TOP_DIR)/$(releaseDir)/
cp -rf $(TOP_DIR)/nx5_soc_gw/kk_device_def.json $(TOP_DIR)/$(releaseDir)/config/
cp -rf $(TOP_DIR)/upgrade $(TOP_DIR)/$(releaseDir)/
else
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg.so $(TOP_DIR)/$(releaseDir)/lib
......@@ -232,7 +234,7 @@ else
cp -rf $(TOP_DIR)/common/sqlite/libsqlite3.so $(TOP_DIR)/$(releaseDir)/lib
endif
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/build/exe/Z3GatewayHost $(TOP_DIR)/$(releaseDir)/
fromdos $(releaseDir)/*.sh
fromdos $(releaseDir)/script/*.sh
echo $(PWD)
squashfs: package
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3122.json",
"productType": "freshAir Gateway",
"version": "1.1",
"profile": {
"heartbeat": "300",
"productCode": "3122",
"productName": "新风控制器Z3S(百朗)"
},
"services": [
{
"identifier": "set",
"name": "set",
"required": true,
"callType": "async",
"desc": "属性设置",
"method": "thing.service.property.set",
"inputData": [
{
"identifier": "PowerSwitch",
"name": "电源开关",
"dataType": {
"type": "bool",
"specs": {
"0": "关闭",
"1": "开启"
}
}
},
{
"identifier": "WindSpeed",
"name": "风速",
"dataType": {
"type": "enum",
"specs": {
"1": "低风",
"2": "中风",
"3": "高风"
}
}
},
{
"identifier": "WorkMode",
"name": "工作模式",
"dataType": {
"type": "enum",
"specs": {
"1": "节能",
"2": "舒适",
"3": "自动",
"4": "新风",
"5": "凉风",
"6": "智能",
"7": "强劲",
"8": "睡眠",
"9": "速净"
}
}
}
],
"outputData": []
},
{
"identifier": "get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取",
"method": "thing.service.property.get",
"inputData": [
"PowerSwitch",
"WindSpeed",
"WorkMode",
"CurrentTemperature"
],
"outputData": []
}
],
"properties": [
{
"identifier": "PowerSwitch",
"name": "电源开关",
"accessMode": "rw",
"required": true,
"dataType": {
"type": "enum",
"specs": {
"0": "关闭",
"1": "开启"
}
}
},
{
"identifier": "CurrentTemperature",
"name": "当前温度",
"accessMode": "r",
"required": true,
"dataType": {
"type": "double",
"specs": {
"min": "-30",
"max": "50",
"unit": "°C",
"unitName": "摄氏度",
"step": "1"
}
}
},
{
"identifier": "WindSpeed",
"name": "风速",
"accessMode": "rw",
"required": true,
"dataType": {
"type": "enum",
"specs": {
"1": "低风",
"2": "中风",
"3": "高风"
}
}
},
{
"identifier": "WorkMode",
"name": "工作模式",
"accessMode": "rw",
"required": true,
"dataType": {
"type": "enum",
"specs": {
"1": "节能",
"2": "舒适",
"3": "自动",
"4": "新风",
"5": "凉风",
"6": "智能",
"7": "强劲",
"8": "睡眠",
"9": "速净"
}
}
}
],
"events": [
{
"identifier": "post",
"name": "post",
"type": "info",
"required": true,
"desc": "属性上报",
"method": "thing.event.property.post",
"outputData": [
{
"identifier": "CombineDeviceFlag",
"name": "复合设备标识",
"dataType": {
"type": "int",
"specs": {
"value": 1
}
}
},
{
"identifier": "EpTotal",
"name": "内机数+1",
"dataType": {
"type": "int",
"specs": {
"desc": "内机+网关 的数量"
}
}
},
{
"identifier": "eps",
"name": "内机属性集",
"dataType": {
"type": "array",
"specs": {
"item": [
{
"identifier": "CurrentTemperature",
"name": "当前温度",
"dataType": {
"type": "double",
"specs": {
"min": "-30",
"max": "50",
"unit": "°C",
"unitName": "摄氏度",
"step": "1"
}
}
},
{
"identifier": "PowerSwitch",
"name": "电源开关",
"dataType": {
"type": "bool",
"specs": {
"0": "关闭",
"1": "开启"
}
}
},
{
"identifier": "WindSpeed",
"name": "风速",
"dataType": {
"type": "enum",
"specs": {
"1": "低风",
"2": "中风",
"3": "高风"
}
}
},
{
"identifier": "WorkMode",
"name": "工作模式",
"dataType": {
"type": "enum",
"specs": {
"1": "节能",
"2": "舒适",
"3": "自动",
"4": "新风",
"5": "凉风",
"6": "智能",
"7": "强劲",
"8": "睡眠",
"9": "速净"
}
}
}
]
}
}
}
]
},
{
"identifier": "post",
"name": "post",
"type": "info",
"required": true,
"desc": "属性上报",
"method": "thing.event.property.post",
"outputData": [
{
"identifier": "CurrentTemperature",
"name": "当前温度",
"dataType": {
"type": "double",
"specs": {
"min": "-30",
"max": "50",
"unit": "°C",
"unitName": "摄氏度",
"step": "1"
}
}
},
{
"identifier": "PowerSwitch",
"name": "电源开关",
"dataType": {
"type": "bool",
"specs": {
"0": "关闭",
"1": "开启"
}
}
},
{
"identifier": "WindSpeed",
"name": "风速",
"dataType": {
"type": "enum",
"specs": {
"1": "低风",
"2": "中风",
"3": "高风"
}
}
},
{
"identifier": "WorkMode",
"name": "工作模式",
"dataType": {
"type": "enum",
"specs": {
"1": "节能",
"2": "舒适",
"3": "自动",
"4": "新风",
"5": "凉风",
"6": "智能",
"7": "强劲",
"8": "睡眠",
"9": "速净"
}
}
}
]
}
]
}
\ No newline at end of file
1.1.5
\ No newline at end of file
1.1.0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment