|
|
@ -53,7 +53,7 @@ static int check_format(const char *str)
|
|
|
|
for(i=0; i<len; i++){
|
|
|
|
for(i=0; i<len; i++){
|
|
|
|
if(str[i] == '%'){
|
|
|
|
if(str[i] == '%'){
|
|
|
|
if(i == len-1){
|
|
|
|
if(i == len-1){
|
|
|
|
// error
|
|
|
|
/* error */
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
@ -61,7 +61,7 @@ static int check_format(const char *str)
|
|
|
|
/* Flag characters */
|
|
|
|
/* Flag characters */
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
if(i == len-1){
|
|
|
|
if(i == len-1){
|
|
|
|
// error
|
|
|
|
/* error */
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -71,7 +71,7 @@ static int check_format(const char *str)
|
|
|
|
while(str[i+1] >= '0' && str[i+1] <= '9'){
|
|
|
|
while(str[i+1] >= '0' && str[i+1] <= '9'){
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
if(i == len-1){
|
|
|
|
if(i == len-1){
|
|
|
|
// error
|
|
|
|
/* error */
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -81,7 +81,7 @@ static int check_format(const char *str)
|
|
|
|
/* Precision specifier */
|
|
|
|
/* Precision specifier */
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
if(i == len-1){
|
|
|
|
if(i == len-1){
|
|
|
|
// error
|
|
|
|
/* error */
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -89,7 +89,7 @@ static int check_format(const char *str)
|
|
|
|
while(str[i+1] >= '0' && str[i+1] <= '9'){
|
|
|
|
while(str[i+1] >= '0' && str[i+1] <= '9'){
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
if(i == len-1){
|
|
|
|
if(i == len-1){
|
|
|
|
// error
|
|
|
|
/* error */
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -97,49 +97,49 @@ static int check_format(const char *str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(str[i+1] == '%'){
|
|
|
|
if(str[i+1] == '%'){
|
|
|
|
// Print %, ignore
|
|
|
|
/* Print %, ignore */
|
|
|
|
}else if(str[i+1] == 'A'){
|
|
|
|
}else if(str[i+1] == 'A'){
|
|
|
|
// MQTT v5 property topic-alias
|
|
|
|
/* MQTT v5 property topic-alias */
|
|
|
|
}else if(str[i+1] == 'C'){
|
|
|
|
}else if(str[i+1] == 'C'){
|
|
|
|
// MQTT v5 property content-type
|
|
|
|
/* MQTT v5 property content-type */
|
|
|
|
}else if(str[i+1] == 'D'){
|
|
|
|
}else if(str[i+1] == 'D'){
|
|
|
|
// MQTT v5 property correlation-data
|
|
|
|
/* MQTT v5 property correlation-data */
|
|
|
|
}else if(str[i+1] == 'E'){
|
|
|
|
}else if(str[i+1] == 'E'){
|
|
|
|
// MQTT v5 property message-expiry-interval
|
|
|
|
/* MQTT v5 property message-expiry-interval */
|
|
|
|
}else if(str[i+1] == 'F'){
|
|
|
|
}else if(str[i+1] == 'F'){
|
|
|
|
// MQTT v5 property payload-format-indicator
|
|
|
|
/* MQTT v5 property payload-format-indicator */
|
|
|
|
}else if(str[i+1] == 'I'){
|
|
|
|
}else if(str[i+1] == 'I'){
|
|
|
|
// ISO 8601 date+time
|
|
|
|
/* ISO 8601 date+time */
|
|
|
|
}else if(str[i+1] == 'l'){
|
|
|
|
}else if(str[i+1] == 'l'){
|
|
|
|
// payload length
|
|
|
|
/* payload length */
|
|
|
|
}else if(str[i+1] == 'm'){
|
|
|
|
}else if(str[i+1] == 'm'){
|
|
|
|
// mid
|
|
|
|
/* mid */
|
|
|
|
}else if(str[i+1] == 'P'){
|
|
|
|
}else if(str[i+1] == 'P'){
|
|
|
|
// MQTT v5 property user-property
|
|
|
|
/* MQTT v5 property user-property */
|
|
|
|
}else if(str[i+1] == 'p'){
|
|
|
|
}else if(str[i+1] == 'p'){
|
|
|
|
// payload
|
|
|
|
/* payload */
|
|
|
|
}else if(str[i+1] == 'q'){
|
|
|
|
}else if(str[i+1] == 'q'){
|
|
|
|
// qos
|
|
|
|
/* qos */
|
|
|
|
}else if(str[i+1] == 'R'){
|
|
|
|
}else if(str[i+1] == 'R'){
|
|
|
|
// MQTT v5 property response-topic
|
|
|
|
/* MQTT v5 property response-topic */
|
|
|
|
}else if(str[i+1] == 'S'){
|
|
|
|
}else if(str[i+1] == 'S'){
|
|
|
|
// MQTT v5 property subscription-identifier
|
|
|
|
/* MQTT v5 property subscription-identifier */
|
|
|
|
}else if(str[i+1] == 'r'){
|
|
|
|
}else if(str[i+1] == 'r'){
|
|
|
|
// retain
|
|
|
|
/* retain */
|
|
|
|
}else if(str[i+1] == 't'){
|
|
|
|
}else if(str[i+1] == 't'){
|
|
|
|
// topic
|
|
|
|
/* topic */
|
|
|
|
}else if(str[i+1] == 'j'){
|
|
|
|
}else if(str[i+1] == 'j'){
|
|
|
|
// JSON output, escaped payload
|
|
|
|
/* JSON output, escaped payload */
|
|
|
|
}else if(str[i+1] == 'J'){
|
|
|
|
}else if(str[i+1] == 'J'){
|
|
|
|
// JSON output, assuming JSON payload
|
|
|
|
/* JSON output, assuming JSON payload */
|
|
|
|
}else if(str[i+1] == 'U'){
|
|
|
|
}else if(str[i+1] == 'U'){
|
|
|
|
// Unix time+nanoseconds
|
|
|
|
/* Unix time+nanoseconds */
|
|
|
|
#ifdef WIN32
|
|
|
|
#ifdef WIN32
|
|
|
|
fprintf(stderr, "Error: The %%U format option is not supported on Windows.\n");
|
|
|
|
fprintf(stderr, "Error: The %%U format option is not supported on Windows.\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}else if(str[i+1] == 'x' || str[i+1] == 'X'){
|
|
|
|
}else if(str[i+1] == 'x' || str[i+1] == 'X'){
|
|
|
|
// payload in hex
|
|
|
|
/* payload in hex */
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
fprintf(stderr, "Error: Invalid format specifier '%c'.\n", str[i+1]);
|
|
|
|
fprintf(stderr, "Error: Invalid format specifier '%c'.\n", str[i+1]);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
@ -148,26 +148,26 @@ static int check_format(const char *str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if(str[i] == '@'){
|
|
|
|
}else if(str[i] == '@'){
|
|
|
|
if(i == len-1){
|
|
|
|
if(i == len-1){
|
|
|
|
// error
|
|
|
|
/* error */
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
fprintf(stderr, "Error: Incomplete format specifier.\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
}else if(str[i] == '\\'){
|
|
|
|
}else if(str[i] == '\\'){
|
|
|
|
if(i == len-1){
|
|
|
|
if(i == len-1){
|
|
|
|
// error
|
|
|
|
/* error */
|
|
|
|
fprintf(stderr, "Error: Incomplete escape specifier.\n");
|
|
|
|
fprintf(stderr, "Error: Incomplete escape specifier.\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
switch(str[i+1]){
|
|
|
|
switch(str[i+1]){
|
|
|
|
case '\\': // '\'
|
|
|
|
case '\\': /* '\' */
|
|
|
|
case '0': // 0 (NULL)
|
|
|
|
case '0': /* 0 (NULL) */
|
|
|
|
case 'a': // alert
|
|
|
|
case 'a': /* alert */
|
|
|
|
case 'e': // escape
|
|
|
|
case 'e': /* escape */
|
|
|
|
case 'n': // new line
|
|
|
|
case 'n': /* new line */
|
|
|
|
case 'r': // carriage return
|
|
|
|
case 'r': /* carriage return */
|
|
|
|
case 't': // horizontal tab
|
|
|
|
case 't': /* horizontal tab */
|
|
|
|
case 'v': // vertical tab
|
|
|
|
case 'v': /* vertical tab */
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -1463,12 +1463,13 @@ static int mosquitto__parse_socks_url(struct mosq_config *cfg, char *url)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// socks5h://username:password@host:1883
|
|
|
|
/* socks5h://username:password@host:1883
|
|
|
|
// socks5h://username:password@host
|
|
|
|
* socks5h://username:password@host
|
|
|
|
// socks5h://username@host:1883
|
|
|
|
* socks5h://username@host:1883
|
|
|
|
// socks5h://username@host
|
|
|
|
* socks5h://username@host
|
|
|
|
// socks5h://host:1883
|
|
|
|
* socks5h://host:1883
|
|
|
|
// socks5h://host
|
|
|
|
* socks5h://host
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
start = 0;
|
|
|
|
for(i=0; i<strlen(str); i++){
|
|
|
|
for(i=0; i<strlen(str); i++){
|
|
|
|