indented using indent.sh script.
This commit is contained in:
@@ -236,7 +236,7 @@ int arf_ack_encode_apdu(
|
||||
for (i = 0; i < data->type.record.RecordCount; i++) {
|
||||
apdu_len +=
|
||||
encode_application_octet_string(&apdu[apdu_len],
|
||||
&data->fileData[i]);
|
||||
&data->fileData[i]);
|
||||
}
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len], 1);
|
||||
break;
|
||||
@@ -330,7 +330,7 @@ int arf_ack_decode_service_request(
|
||||
return -1;
|
||||
len +=
|
||||
decode_octet_string(&apdu[len], len_value_type,
|
||||
&data->fileData[i]);
|
||||
&data->fileData[i]);
|
||||
}
|
||||
if (!decode_is_closing_tag_number(&apdu[len], 1))
|
||||
return -1;
|
||||
|
||||
@@ -79,7 +79,7 @@ int awf_encode_apdu(
|
||||
for (i = 0; i < data->type.record.returnedRecordCount; i++) {
|
||||
apdu_len +=
|
||||
encode_application_octet_string(&apdu[apdu_len],
|
||||
&data->fileData[i]);
|
||||
&data->fileData[i]);
|
||||
}
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len], 1);
|
||||
break;
|
||||
@@ -175,7 +175,7 @@ int awf_decode_service_request(
|
||||
return -1;
|
||||
len +=
|
||||
decode_octet_string(&apdu[len], len_value_type,
|
||||
&data->fileData[i]);
|
||||
&data->fileData[i]);
|
||||
}
|
||||
if (!decode_is_closing_tag_number(&apdu[len], 1))
|
||||
return -1;
|
||||
|
||||
+111
-54
@@ -1014,7 +1014,7 @@ INDTEXT_DATA bacnet_property_names[] = {
|
||||
{PROP_LIGHTING_COMMAND, "lighting-command"}
|
||||
,
|
||||
{PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY,
|
||||
"lighting-command-default-priority"}
|
||||
"lighting-command-default-priority"}
|
||||
,
|
||||
{PROP_MAX_ACTUAL_VALUE, "max-actual-value"}
|
||||
,
|
||||
@@ -1735,59 +1735,116 @@ INDTEXT_DATA bacnet_error_code_names[] = {
|
||||
,
|
||||
{ERROR_CODE_COMMUNICATION_DISABLED, "access-denied"}
|
||||
,
|
||||
{ERROR_CODE_SUCCESS, "success"},
|
||||
{ERROR_CODE_ACCESS_DENIED, "access-denied"},
|
||||
{ERROR_CODE_BAD_DESTINATION_ADDRESS, "bad-destination-address"},
|
||||
{ERROR_CODE_BAD_DESTINATION_DEVICE_ID, "bad-destination-device-id"},
|
||||
{ERROR_CODE_BAD_SIGNATURE, "bad-signature"},
|
||||
{ERROR_CODE_BAD_SOURCE_ADDRESS, "bad-source-address"},
|
||||
{ERROR_CODE_BAD_TIMESTAMP, "bad-timestamp"},
|
||||
{ERROR_CODE_CANNOT_USE_KEY, "cannot-use-key"},
|
||||
{ERROR_CODE_CANNOT_VERIFY_MESSAGE_ID, "cannot-verify-message-id"},
|
||||
{ERROR_CODE_CORRECT_KEY_REVISION, "correct-key-revision"},
|
||||
{ERROR_CODE_DESTINATION_DEVICE_ID_REQUIRED, "destination-device-id-required"},
|
||||
{ERROR_CODE_DUPLICATE_MESSAGE, "duplicate-message"},
|
||||
{ERROR_CODE_ENCRYPTION_NOT_CONFIGURED, "encryption-not-configured"},
|
||||
{ERROR_CODE_ENCRYPTION_REQUIRED, "encryption-required"},
|
||||
{ERROR_CODE_INCORRECT_KEY, "incorrect-key"},
|
||||
{ERROR_CODE_INVALID_KEY_DATA, "invalid-key-data"},
|
||||
{ERROR_CODE_KEY_UPDATE_IN_PROGRESS, "key-update-in-progress"},
|
||||
{ERROR_CODE_MALFORMED_MESSAGE, "malformed-message"},
|
||||
{ERROR_CODE_NOT_KEY_SERVER, "not-key-server"},
|
||||
{ERROR_CODE_SECURITY_NOT_CONFIGURED, "security-not-configured"},
|
||||
{ERROR_CODE_SOURCE_SECURITY_REQUIRED, "source-security-required"},
|
||||
{ERROR_CODE_TOO_MANY_KEYS, "too-many-keys"},
|
||||
{ERROR_CODE_UNKNOWN_AUTHENTICATION_TYPE, "unknown-authentication-type"},
|
||||
{ERROR_CODE_UNKNOWN_KEY, "unknown-key"},
|
||||
{ERROR_CODE_UNKNOWN_KEY_REVISION, "unknown-key-revision"},
|
||||
{ERROR_CODE_UNKNOWN_SOURCE_MESSAGE, "unknown-source-message"},
|
||||
{ERROR_CODE_NOT_ROUTER_TO_DNET, "not-router-to-dnet"},
|
||||
{ERROR_CODE_ROUTER_BUSY, "router-busy"},
|
||||
{ERROR_CODE_UNKNOWN_NETWORK_MESSAGE, "unknown-network-message"},
|
||||
{ERROR_CODE_MESSAGE_TOO_LONG, "message-too-long"},
|
||||
{ERROR_CODE_SECURITY_ERROR, "security-error"},
|
||||
{ERROR_CODE_ADDRESSING_ERROR, "addressing-error"},
|
||||
{ERROR_CODE_WRITE_BDT_FAILED, "write-bdt-failed"},
|
||||
{ERROR_CODE_READ_BDT_FAILED, "read-bdt-failed"},
|
||||
{ERROR_CODE_REGISTER_FOREIGN_DEVICE_FAILED, "register-foreign-device-failed"},
|
||||
{ERROR_CODE_READ_FDT_FAILED, "read-fdt-failed"},
|
||||
{ERROR_CODE_DELETE_FDT_ENTRY_FAILED, "delete-fdt-entry-failed"},
|
||||
{ERROR_CODE_DISTRIBUTE_BROADCAST_FAILED, "distribute-broadcast-failed"},
|
||||
{ERROR_CODE_UNKNOWN_FILE_SIZE, "unknown-file-size"},
|
||||
{ERROR_CODE_ABORT_APDU_TOO_LONG, "abort-apdu-too-long"},
|
||||
{ERROR_CODE_ABORT_APPLICATION_EXCEEDED_REPLY_TIME, "abort-application-exceeded-reply-time"},
|
||||
{ERROR_CODE_ABORT_OUT_OF_RESOURCES, "abort-out-of-resources"},
|
||||
{ERROR_CODE_ABORT_TSM_TIMEOUT, "abort-tsm-timeout"},
|
||||
{ERROR_CODE_ABORT_WINDOW_SIZE_OUT_OF_RANGE, "abort-window-size-out-of-range"},
|
||||
{ERROR_CODE_FILE_FULL, "file-full"},
|
||||
{ERROR_CODE_INCONSISTENT_CONFIGURATION, "inconsistent-configuration"},
|
||||
{ERROR_CODE_INCONSISTENT_OBJECT_TYPE, "inconsistent-object-type"},
|
||||
{ERROR_CODE_INTERNAL_ERROR, "internal-error"},
|
||||
{ERROR_CODE_NOT_CONFIGURED, "not-configured"},
|
||||
{ERROR_CODE_OUT_OF_MEMORY, "out-of-memory"},
|
||||
{ERROR_CODE_VALUE_TOO_LONG, "value-too-long"},
|
||||
{ERROR_CODE_ABORT_INSUFFICIENT_SECURITY, "abort-insufficient-security"},
|
||||
{ERROR_CODE_ABORT_SECURITY_ERROR, "abort-security-error"},
|
||||
{ERROR_CODE_SUCCESS, "success"}
|
||||
,
|
||||
{ERROR_CODE_ACCESS_DENIED, "access-denied"}
|
||||
,
|
||||
{ERROR_CODE_BAD_DESTINATION_ADDRESS, "bad-destination-address"}
|
||||
,
|
||||
{ERROR_CODE_BAD_DESTINATION_DEVICE_ID, "bad-destination-device-id"}
|
||||
,
|
||||
{ERROR_CODE_BAD_SIGNATURE, "bad-signature"}
|
||||
,
|
||||
{ERROR_CODE_BAD_SOURCE_ADDRESS, "bad-source-address"}
|
||||
,
|
||||
{ERROR_CODE_BAD_TIMESTAMP, "bad-timestamp"}
|
||||
,
|
||||
{ERROR_CODE_CANNOT_USE_KEY, "cannot-use-key"}
|
||||
,
|
||||
{ERROR_CODE_CANNOT_VERIFY_MESSAGE_ID, "cannot-verify-message-id"}
|
||||
,
|
||||
{ERROR_CODE_CORRECT_KEY_REVISION, "correct-key-revision"}
|
||||
,
|
||||
{ERROR_CODE_DESTINATION_DEVICE_ID_REQUIRED,
|
||||
"destination-device-id-required"}
|
||||
,
|
||||
{ERROR_CODE_DUPLICATE_MESSAGE, "duplicate-message"}
|
||||
,
|
||||
{ERROR_CODE_ENCRYPTION_NOT_CONFIGURED, "encryption-not-configured"}
|
||||
,
|
||||
{ERROR_CODE_ENCRYPTION_REQUIRED, "encryption-required"}
|
||||
,
|
||||
{ERROR_CODE_INCORRECT_KEY, "incorrect-key"}
|
||||
,
|
||||
{ERROR_CODE_INVALID_KEY_DATA, "invalid-key-data"}
|
||||
,
|
||||
{ERROR_CODE_KEY_UPDATE_IN_PROGRESS, "key-update-in-progress"}
|
||||
,
|
||||
{ERROR_CODE_MALFORMED_MESSAGE, "malformed-message"}
|
||||
,
|
||||
{ERROR_CODE_NOT_KEY_SERVER, "not-key-server"}
|
||||
,
|
||||
{ERROR_CODE_SECURITY_NOT_CONFIGURED, "security-not-configured"}
|
||||
,
|
||||
{ERROR_CODE_SOURCE_SECURITY_REQUIRED, "source-security-required"}
|
||||
,
|
||||
{ERROR_CODE_TOO_MANY_KEYS, "too-many-keys"}
|
||||
,
|
||||
{ERROR_CODE_UNKNOWN_AUTHENTICATION_TYPE, "unknown-authentication-type"}
|
||||
,
|
||||
{ERROR_CODE_UNKNOWN_KEY, "unknown-key"}
|
||||
,
|
||||
{ERROR_CODE_UNKNOWN_KEY_REVISION, "unknown-key-revision"}
|
||||
,
|
||||
{ERROR_CODE_UNKNOWN_SOURCE_MESSAGE, "unknown-source-message"}
|
||||
,
|
||||
{ERROR_CODE_NOT_ROUTER_TO_DNET, "not-router-to-dnet"}
|
||||
,
|
||||
{ERROR_CODE_ROUTER_BUSY, "router-busy"}
|
||||
,
|
||||
{ERROR_CODE_UNKNOWN_NETWORK_MESSAGE, "unknown-network-message"}
|
||||
,
|
||||
{ERROR_CODE_MESSAGE_TOO_LONG, "message-too-long"}
|
||||
,
|
||||
{ERROR_CODE_SECURITY_ERROR, "security-error"}
|
||||
,
|
||||
{ERROR_CODE_ADDRESSING_ERROR, "addressing-error"}
|
||||
,
|
||||
{ERROR_CODE_WRITE_BDT_FAILED, "write-bdt-failed"}
|
||||
,
|
||||
{ERROR_CODE_READ_BDT_FAILED, "read-bdt-failed"}
|
||||
,
|
||||
{ERROR_CODE_REGISTER_FOREIGN_DEVICE_FAILED,
|
||||
"register-foreign-device-failed"}
|
||||
,
|
||||
{ERROR_CODE_READ_FDT_FAILED, "read-fdt-failed"}
|
||||
,
|
||||
{ERROR_CODE_DELETE_FDT_ENTRY_FAILED, "delete-fdt-entry-failed"}
|
||||
,
|
||||
{ERROR_CODE_DISTRIBUTE_BROADCAST_FAILED, "distribute-broadcast-failed"}
|
||||
,
|
||||
{ERROR_CODE_UNKNOWN_FILE_SIZE, "unknown-file-size"}
|
||||
,
|
||||
{ERROR_CODE_ABORT_APDU_TOO_LONG, "abort-apdu-too-long"}
|
||||
,
|
||||
{ERROR_CODE_ABORT_APPLICATION_EXCEEDED_REPLY_TIME,
|
||||
"abort-application-exceeded-reply-time"}
|
||||
,
|
||||
{ERROR_CODE_ABORT_OUT_OF_RESOURCES, "abort-out-of-resources"}
|
||||
,
|
||||
{ERROR_CODE_ABORT_TSM_TIMEOUT, "abort-tsm-timeout"}
|
||||
,
|
||||
{ERROR_CODE_ABORT_WINDOW_SIZE_OUT_OF_RANGE,
|
||||
"abort-window-size-out-of-range"}
|
||||
,
|
||||
{ERROR_CODE_FILE_FULL, "file-full"}
|
||||
,
|
||||
{ERROR_CODE_INCONSISTENT_CONFIGURATION, "inconsistent-configuration"}
|
||||
,
|
||||
{ERROR_CODE_INCONSISTENT_OBJECT_TYPE, "inconsistent-object-type"}
|
||||
,
|
||||
{ERROR_CODE_INTERNAL_ERROR, "internal-error"}
|
||||
,
|
||||
{ERROR_CODE_NOT_CONFIGURED, "not-configured"}
|
||||
,
|
||||
{ERROR_CODE_OUT_OF_MEMORY, "out-of-memory"}
|
||||
,
|
||||
{ERROR_CODE_VALUE_TOO_LONG, "value-too-long"}
|
||||
,
|
||||
{ERROR_CODE_ABORT_INSUFFICIENT_SECURITY, "abort-insufficient-security"}
|
||||
,
|
||||
{ERROR_CODE_ABORT_SECURITY_ERROR, "abort-security-error"}
|
||||
,
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
|
||||
+16
-22
@@ -89,12 +89,11 @@ bool datetime_ymd_is_valid(
|
||||
uint8_t month,
|
||||
uint8_t day)
|
||||
{
|
||||
bool status = false; /* true if value date */
|
||||
uint8_t monthdays = 0; /* days in a month */
|
||||
bool status = false; /* true if value date */
|
||||
uint8_t monthdays = 0; /* days in a month */
|
||||
|
||||
monthdays = datetime_month_days(year, month);
|
||||
if ((year >= 1900) && (monthdays > 0) &&
|
||||
(day >= 1) && (day <= monthdays)) {
|
||||
if ((year >= 1900) && (monthdays > 0) && (day >= 1) && (day <= monthdays)) {
|
||||
status = true;
|
||||
}
|
||||
|
||||
@@ -102,10 +101,10 @@ bool datetime_ymd_is_valid(
|
||||
}
|
||||
|
||||
bool datetime_date_is_valid(
|
||||
BACNET_DATE *bdate)
|
||||
BACNET_DATE * bdate)
|
||||
{
|
||||
|
||||
bool status = false; /* true if value date */
|
||||
bool status = false; /* true if value date */
|
||||
|
||||
if (bdate) {
|
||||
status = datetime_ymd_is_valid(bdate->year, bdate->month, bdate->day);
|
||||
@@ -139,7 +138,7 @@ static uint32_t days_since_epoch(
|
||||
}
|
||||
|
||||
uint32_t datetime_days_since_epoch(
|
||||
BACNET_DATE *bdate)
|
||||
BACNET_DATE * bdate)
|
||||
{
|
||||
uint32_t days = 0;
|
||||
|
||||
@@ -188,7 +187,7 @@ static void days_since_epoch_into_ymd(
|
||||
|
||||
void datetime_days_since_epoch_into_date(
|
||||
uint32_t days,
|
||||
BACNET_DATE *bdate)
|
||||
BACNET_DATE * bdate)
|
||||
{
|
||||
uint16_t year = 0;
|
||||
uint8_t month = 0;
|
||||
@@ -209,7 +208,7 @@ uint8_t datetime_day_of_week(
|
||||
}
|
||||
|
||||
bool datetime_time_is_valid(
|
||||
BACNET_TIME *btime)
|
||||
BACNET_TIME * btime)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -232,8 +231,8 @@ bool datetime_time_is_valid(
|
||||
* @return true if the date and time are valid
|
||||
*/
|
||||
bool datetime_is_valid(
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime)
|
||||
BACNET_DATE * bdate,
|
||||
BACNET_TIME * btime)
|
||||
{
|
||||
return datetime_date_is_valid(bdate) && datetime_time_is_valid(btime);
|
||||
}
|
||||
@@ -447,15 +446,12 @@ static void seconds_since_midnight_into_hms(
|
||||
* @return seconds since midnight
|
||||
*/
|
||||
uint32_t datetime_seconds_since_midnight(
|
||||
BACNET_TIME *btime)
|
||||
BACNET_TIME * btime)
|
||||
{
|
||||
uint32_t seconds = 0;
|
||||
|
||||
if (btime) {
|
||||
seconds = seconds_since_midnight(
|
||||
btime->hour,
|
||||
btime->min,
|
||||
btime->sec);
|
||||
seconds = seconds_since_midnight(btime->hour, btime->min, btime->sec);
|
||||
}
|
||||
|
||||
return seconds;
|
||||
@@ -468,14 +464,12 @@ uint32_t datetime_seconds_since_midnight(
|
||||
* @return minutes since midnight
|
||||
*/
|
||||
uint16_t datetime_minutes_since_midnight(
|
||||
BACNET_TIME *btime)
|
||||
BACNET_TIME * btime)
|
||||
{
|
||||
uint32_t minutes = 0;
|
||||
|
||||
if (btime) {
|
||||
minutes = minutes_since_midnight(
|
||||
btime->hour,
|
||||
btime->min);
|
||||
minutes = minutes_since_midnight(btime->hour, btime->min);
|
||||
}
|
||||
|
||||
return minutes;
|
||||
@@ -983,8 +977,8 @@ void testDateEpoch(
|
||||
for (month = 1; month <= 12; month++) {
|
||||
for (day = 1; day <= datetime_month_days(year, month); day++) {
|
||||
days = days_since_epoch(year, month, day);
|
||||
days_since_epoch_into_ymd(days,
|
||||
&test_year, &test_month, &test_day);
|
||||
days_since_epoch_into_ymd(days, &test_year, &test_month,
|
||||
&test_day);
|
||||
ct_test(pTest, year == test_year);
|
||||
ct_test(pTest, month == test_month);
|
||||
ct_test(pTest, day == test_day);
|
||||
|
||||
@@ -923,7 +923,7 @@ BACNET_PROPERTY_ID property_list_special_property(
|
||||
{
|
||||
int property = -1; /* return value */
|
||||
unsigned required, optional, proprietary;
|
||||
struct special_property_list_t PropertyList = {{0}};
|
||||
struct special_property_list_t PropertyList = { {0} };
|
||||
|
||||
property_list_special(object_type, &PropertyList);
|
||||
required = PropertyList.Required.count;
|
||||
@@ -967,7 +967,7 @@ unsigned property_list_special_count(
|
||||
BACNET_PROPERTY_ID special_property)
|
||||
{
|
||||
unsigned count = 0; /* return value */
|
||||
struct special_property_list_t PropertyList = {{0}};
|
||||
struct special_property_list_t PropertyList = { {0} };
|
||||
|
||||
property_list_special(object_type, &PropertyList);
|
||||
if (special_property == PROP_ALL) {
|
||||
@@ -997,16 +997,15 @@ void testPropList(
|
||||
unsigned object_id = 0, object_name = 0, object_type = 0;
|
||||
|
||||
for (i = 0; i < OBJECT_PROPRIETARY_MIN; i++) {
|
||||
count = property_list_special_count((BACNET_OBJECT_TYPE)i, PROP_ALL);
|
||||
count = property_list_special_count((BACNET_OBJECT_TYPE) i, PROP_ALL);
|
||||
ct_test(pTest, count >= 3);
|
||||
object_id = 0;
|
||||
object_name = 0;
|
||||
object_type = 0;
|
||||
for (j = 0; j < count; j++) {
|
||||
property = property_list_special_property(
|
||||
(BACNET_OBJECT_TYPE)i,
|
||||
PROP_ALL,
|
||||
j);
|
||||
property =
|
||||
property_list_special_property((BACNET_OBJECT_TYPE) i,
|
||||
PROP_ALL, j);
|
||||
if (property == PROP_OBJECT_TYPE) {
|
||||
object_type++;
|
||||
}
|
||||
|
||||
+146
-100
@@ -27,149 +27,195 @@
|
||||
|
||||
static struct uci_ptr ptr;
|
||||
|
||||
static inline int ucix_get_ptr(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
||||
static inline int ucix_get_ptr(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o,
|
||||
const char *t)
|
||||
{
|
||||
memset(&ptr, 0, sizeof(ptr));
|
||||
ptr.package = p;
|
||||
ptr.section = s;
|
||||
ptr.option = o;
|
||||
ptr.value = t;
|
||||
return uci_lookup_ptr(ctx, &ptr, NULL, true);
|
||||
memset(&ptr, 0, sizeof(ptr));
|
||||
ptr.package = p;
|
||||
ptr.section = s;
|
||||
ptr.option = o;
|
||||
ptr.value = t;
|
||||
return uci_lookup_ptr(ctx, &ptr, NULL, true);
|
||||
}
|
||||
|
||||
struct uci_context* ucix_init(const char *config_file)
|
||||
struct uci_context *ucix_init(
|
||||
const char *config_file)
|
||||
{
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
// uci_add_history_path(ctx, "/var/state");
|
||||
uci_add_delta_path(ctx, "/var/state");
|
||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
||||
{
|
||||
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
// uci_add_history_path(ctx, "/var/state");
|
||||
uci_add_delta_path(ctx, "/var/state");
|
||||
if (uci_load(ctx, config_file, NULL) != UCI_OK) {
|
||||
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir,
|
||||
config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
struct uci_context* ucix_init_path(const char *path, const char *config_file)
|
||||
struct uci_context *ucix_init_path(
|
||||
const char *path,
|
||||
const char *config_file)
|
||||
{
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
if(path)
|
||||
uci_set_confdir(ctx, path);
|
||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
||||
{
|
||||
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
if (path)
|
||||
uci_set_confdir(ctx, path);
|
||||
if (uci_load(ctx, config_file, NULL) != UCI_OK) {
|
||||
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir,
|
||||
config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void ucix_cleanup(struct uci_context *ctx)
|
||||
void ucix_cleanup(
|
||||
struct uci_context *ctx)
|
||||
{
|
||||
uci_free_context(ctx);
|
||||
uci_free_context(ctx);
|
||||
}
|
||||
|
||||
void ucix_save(struct uci_context *ctx)
|
||||
void ucix_save(
|
||||
struct uci_context *ctx)
|
||||
{
|
||||
uci_set_savedir(ctx, "/tmp/.uci/");
|
||||
uci_save(ctx, NULL);
|
||||
uci_set_savedir(ctx, "/tmp/.uci/");
|
||||
uci_save(ctx, NULL);
|
||||
}
|
||||
|
||||
void ucix_save_state(struct uci_context *ctx)
|
||||
void ucix_save_state(
|
||||
struct uci_context *ctx)
|
||||
{
|
||||
uci_set_savedir(ctx, "/var/state/");
|
||||
uci_save(ctx, NULL);
|
||||
uci_set_savedir(ctx, "/var/state/");
|
||||
uci_save(ctx, NULL);
|
||||
}
|
||||
|
||||
const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
const char *ucix_get_option(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o)
|
||||
{
|
||||
struct uci_element *e = NULL;
|
||||
const char *value = NULL;
|
||||
if(ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
return NULL;
|
||||
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
|
||||
return NULL;
|
||||
e = ptr.last;
|
||||
switch (e->type)
|
||||
{
|
||||
case UCI_TYPE_SECTION:
|
||||
value = uci_to_section(e)->type;
|
||||
break;
|
||||
case UCI_TYPE_OPTION:
|
||||
switch(ptr.o->type) {
|
||||
case UCI_TYPE_STRING:
|
||||
value = ptr.o->v.string;
|
||||
break;
|
||||
default:
|
||||
value = NULL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
struct uci_element *e = NULL;
|
||||
const char *value = NULL;
|
||||
if (ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
return NULL;
|
||||
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
|
||||
return NULL;
|
||||
e = ptr.last;
|
||||
switch (e->type) {
|
||||
case UCI_TYPE_SECTION:
|
||||
value = uci_to_section(e)->type;
|
||||
break;
|
||||
case UCI_TYPE_OPTION:
|
||||
switch (ptr.o->type) {
|
||||
case UCI_TYPE_STRING:
|
||||
value = ptr.o->v.string;
|
||||
break;
|
||||
default:
|
||||
value = NULL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return value;
|
||||
return value;
|
||||
}
|
||||
|
||||
int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int def)
|
||||
int ucix_get_option_int(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o,
|
||||
int def)
|
||||
{
|
||||
const char *tmp = ucix_get_option(ctx, p, s, o);
|
||||
int ret = def;
|
||||
const char *tmp = ucix_get_option(ctx, p, s, o);
|
||||
int ret = def;
|
||||
|
||||
if (tmp)
|
||||
ret = atoi(tmp);
|
||||
return ret;
|
||||
if (tmp)
|
||||
ret = atoi(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ucix_add_section(struct uci_context *ctx, const char *p, const char *s, const char *t)
|
||||
void ucix_add_section(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *t)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, s, NULL, t))
|
||||
return;
|
||||
uci_set(ctx, &ptr);
|
||||
if (ucix_get_ptr(ctx, p, s, NULL, t))
|
||||
return;
|
||||
uci_set(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_add_option(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
||||
void ucix_add_option(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o,
|
||||
const char *t)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, s, o, (t)?(t):("")))
|
||||
return;
|
||||
uci_set(ctx, &ptr);
|
||||
if (ucix_get_ptr(ctx, p, s, o, (t) ? (t) : ("")))
|
||||
return;
|
||||
uci_set(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_add_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int t)
|
||||
void ucix_add_option_int(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o,
|
||||
int t)
|
||||
{
|
||||
char tmp[64];
|
||||
snprintf(tmp, 64, "%d", t);
|
||||
ucix_add_option(ctx, p, s, o, tmp);
|
||||
char tmp[64];
|
||||
snprintf(tmp, 64, "%d", t);
|
||||
ucix_add_option(ctx, p, s, o, tmp);
|
||||
}
|
||||
|
||||
void ucix_del(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
void ucix_del(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o)
|
||||
{
|
||||
if(!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_delete(ctx, &ptr);
|
||||
if (!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_delete(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_revert(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
void ucix_revert(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *s,
|
||||
const char *o)
|
||||
{
|
||||
if(!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_revert(ctx, &ptr);
|
||||
if (!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_revert(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_for_each_section_type(struct uci_context *ctx,
|
||||
const char *p, const char *t,
|
||||
void (*cb)(const char*, void*), void *priv)
|
||||
void ucix_for_each_section_type(
|
||||
struct uci_context *ctx,
|
||||
const char *p,
|
||||
const char *t,
|
||||
void (*cb) (const char *,
|
||||
void *),
|
||||
void *priv)
|
||||
{
|
||||
struct uci_element *e;
|
||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return;
|
||||
uci_foreach_element(&ptr.p->sections, e)
|
||||
if (!strcmp(t, uci_to_section(e)->type))
|
||||
cb(e->name, priv);
|
||||
struct uci_element *e;
|
||||
if (ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return;
|
||||
uci_foreach_element(&ptr.p->sections, e)
|
||||
if (!strcmp(t, uci_to_section(e)->type))
|
||||
cb(e->name, priv);
|
||||
}
|
||||
|
||||
int ucix_commit(struct uci_context *ctx, const char *p)
|
||||
int ucix_commit(
|
||||
struct uci_context *ctx,
|
||||
const char *p)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return 1;
|
||||
return uci_commit(ctx, &ptr.p, false);
|
||||
if (ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return 1;
|
||||
return uci_commit(ctx, &ptr.p, false);
|
||||
}
|
||||
|
||||
|
||||
+39
-37
@@ -256,56 +256,58 @@ int wpm_encode_apdu_object_property(
|
||||
}
|
||||
|
||||
int wpm_encode_apdu(
|
||||
uint8_t * apdu,
|
||||
size_t max_apdu,
|
||||
uint8_t invoke_id,
|
||||
BACNET_WRITE_ACCESS_DATA * write_access_data)
|
||||
uint8_t * apdu,
|
||||
size_t max_apdu,
|
||||
uint8_t invoke_id,
|
||||
BACNET_WRITE_ACCESS_DATA * write_access_data)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len = 0;
|
||||
BACNET_WRITE_ACCESS_DATA *wpm_object; /* current object */
|
||||
uint8_t apdu_temp[MAX_APDU]; /* temp for data before copy */
|
||||
BACNET_PROPERTY_VALUE *wpm_property; /* current property */
|
||||
BACNET_WRITE_PROPERTY_DATA wpdata; /* for compatibility with wpm_encode_apdu_object_property function */
|
||||
int apdu_len = 0;
|
||||
int len = 0;
|
||||
BACNET_WRITE_ACCESS_DATA *wpm_object; /* current object */
|
||||
uint8_t apdu_temp[MAX_APDU]; /* temp for data before copy */
|
||||
BACNET_PROPERTY_VALUE *wpm_property; /* current property */
|
||||
BACNET_WRITE_PROPERTY_DATA wpdata; /* for compatibility with wpm_encode_apdu_object_property function */
|
||||
|
||||
if (apdu) {
|
||||
len = wpm_encode_apdu_init(&apdu[0], invoke_id);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
len = wpm_encode_apdu_init(&apdu[0], invoke_id);
|
||||
apdu_len += len;
|
||||
|
||||
wpm_object = write_access_data;
|
||||
wpm_object = write_access_data;
|
||||
|
||||
while(wpm_object){
|
||||
while (wpm_object) {
|
||||
|
||||
len = wpm_encode_apdu_object_begin(&apdu[apdu_len],
|
||||
wpm_object->object_type, wpm_object->object_instance);
|
||||
apdu_len += len;
|
||||
len =
|
||||
wpm_encode_apdu_object_begin(&apdu[apdu_len],
|
||||
wpm_object->object_type, wpm_object->object_instance);
|
||||
apdu_len += len;
|
||||
|
||||
wpm_property = wpm_object->listOfProperties;
|
||||
wpm_property = wpm_object->listOfProperties;
|
||||
|
||||
while(wpm_property){
|
||||
wpdata.object_property = wpm_property->propertyIdentifier;
|
||||
wpdata.array_index = wpm_property->propertyArrayIndex;
|
||||
wpdata.priority = wpm_property->priority;
|
||||
while (wpm_property) {
|
||||
wpdata.object_property = wpm_property->propertyIdentifier;
|
||||
wpdata.array_index = wpm_property->propertyArrayIndex;
|
||||
wpdata.priority = wpm_property->priority;
|
||||
|
||||
wpdata.application_data_len = bacapp_encode_data(&apdu_temp[0],
|
||||
&wpm_property->value);
|
||||
memcpy(&wpdata.application_data[0], &apdu_temp[0],
|
||||
wpdata.application_data_len);
|
||||
wpdata.application_data_len =
|
||||
bacapp_encode_data(&apdu_temp[0], &wpm_property->value);
|
||||
memcpy(&wpdata.application_data[0], &apdu_temp[0],
|
||||
wpdata.application_data_len);
|
||||
|
||||
len = wpm_encode_apdu_object_property(&apdu[apdu_len], &wpdata);
|
||||
apdu_len += len;
|
||||
len =
|
||||
wpm_encode_apdu_object_property(&apdu[apdu_len], &wpdata);
|
||||
apdu_len += len;
|
||||
|
||||
wpm_property = wpm_property->next;
|
||||
}
|
||||
wpm_property = wpm_property->next;
|
||||
}
|
||||
|
||||
len = wpm_encode_apdu_object_end(&apdu[apdu_len]);
|
||||
apdu_len += len;
|
||||
len = wpm_encode_apdu_object_end(&apdu[apdu_len]);
|
||||
apdu_len += len;
|
||||
|
||||
wpm_object = wpm_object->next;
|
||||
}
|
||||
}
|
||||
wpm_object = wpm_object->next;
|
||||
}
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int wpm_ack_encode_apdu_init(
|
||||
|
||||
Reference in New Issue
Block a user