#include <string.h>
#include <stdarg.h>
#include <stdio.h>
+#include <dlog.h>
SclLog::SclLog() : m_flog(NULL) {
char *env = NULL;
"message", "warning", "debug", "error"
};
- if (m_flog == NULL) {
+ if (level >= MAX_LOG_LEVEL)
return;
- }
char str_log[128];
va_list ap;
vsnprintf(str_log, sizeof(str_log), fmt, ap);
va_end(ap);
- /*
- * log current time
- */
- time_t now;
- struct tm timenow;
-
- time(&now);
- localtime_r(&now, &timenow);
-
- char buf[64] = { 0 };
- asctime_r(&timenow, buf);
-
- fprintf(m_flog, "[ %s ] %s\n", log_message[level], buf);
- fprintf(m_flog, "\t%s\n", str_log);
-
- fflush(m_flog);
+ if (m_flog == NULL) {
+ switch (level) {
+ case WARNING:
+ {
+ LOGW("%s", str_log);
+ break;
+ }
+ case ERROR:
+ {
+ LOGE("%s", str_log);
+ break;
+ }
+ case DEBUG:
+ {
+ LOGD("%s", str_log);
+ break;
+ }
+ default:
+ {
+ LOGI("%s", str_log);
+ }
+ }
+ } else {
+ /*
+ * log current time
+ */
+ time_t now;
+ struct tm timenow;
+
+ time(&now);
+ localtime_r(&now, &timenow);
+
+ char buf[64] = { 0 };
+ asctime_r(&timenow, buf);
+
+ fprintf(m_flog, "[ %s ] %s\n", log_message[level], buf);
+ fprintf(m_flog, "\t%s\n", str_log);
+
+ fflush(m_flog);
+ }
}
void
#include <libxml/parser.h>
#include <glib.h>
+#include "scldebug.h"
#include "layout_parser.h"
#include "default_configure_parser.h" /* use data in default_configure.xml */
#include "xml_parser_utils.h"
void free_key_coordinate_table(const PSclLayoutKeyCoordinateTable curTable);
void parsing_layout_row_node(const xmlNodePtr cur_node, const PSclLayout cur_rec_layout,
- int *row_y, int *sub_layout_height, SclLayoutKeyCoordinatePointer **cur_key);
- void parsing_key_coordinate_record_node(const xmlNodePtr cur_node, Row* row, SclLayoutKeyCoordinatePointer *cur_key);
+ int *row_y, int *sub_layout_height, SclLayoutKeyCoordinatePointer **cur_key, int layout_no);
+ void parsing_key_coordinate_record_node(const xmlNodePtr cur_node, Row* row,
+ SclLayoutKeyCoordinatePointer *cur_key, int layout_no);
void parsing_label_record_node(const xmlNodePtr cur_node, const PSclLayoutKeyCoordinate cur_rec);
void parsing_label_image_record_node(const xmlNodePtr cur_node, const PSclLayoutKeyCoordinate cur_rec);
private:
int m_layout_size;
+ int m_num_keys[MAX_SCL_LAYOUT];
SclLayout m_layout_table[MAX_SCL_LAYOUT];
vector<string> m_file_names;
SclLayoutKeyCoordinate* m_key_coordinate_pointer_frame[MAX_SCL_LAYOUT][MAX_KEY];
LayoutParserImpl::LayoutParserImpl() {
m_layout_size = 0;
+ for (int i = 0; i < MAX_SCL_LAYOUT; ++i) {
+ m_num_keys[i] = 0;
+ }
memset(m_layout_table, 0x00, sizeof(SclLayout) * MAX_SCL_LAYOUT);
memset(m_key_coordinate_pointer_frame, 0x00, sizeof(SclLayoutKeyCoordinatePointer) * MAX_SCL_LAYOUT * MAX_KEY);
}
LayoutParserImpl::~LayoutParserImpl() {
+ m_layout_size = 0;
for (int i = 0; i < MAX_SCL_LAYOUT; ++i) {
+ m_num_keys[i] = 0;
for (int j = 0; j < MAX_KEY; ++j) {
free(m_key_coordinate_pointer_frame[i][j]);
m_key_coordinate_pointer_frame[i][j] = NULL;
void LayoutParserImpl::unload() {
for (int i = 0; i < MAX_SCL_LAYOUT; ++i) {
for (int j = 0; j < MAX_KEY; ++j) {
- free(m_key_coordinate_pointer_frame[i][j]);
- m_key_coordinate_pointer_frame[i][j] = NULL;
+ if (m_key_coordinate_pointer_frame[i][j]) {
+ free(m_key_coordinate_pointer_frame[i][j]);
+ m_key_coordinate_pointer_frame[i][j] = NULL;
+ }
}
}
SclLayoutKeyCoordinatePointer *cur_key = &m_key_coordinate_pointer_frame[layout_no][0];
+ if (scl_check_arrindex_unsigned(layout_no, MAX_SCL_LAYOUT)) {
+ m_num_keys[layout_no] = 0;
+ }
if (*cur_key == NULL) {
xmlNodePtr child_node = cur_node->xmlChildrenNode;
while (child_node != NULL) {
if (0 == xmlStrcmp(child_node->name, (const xmlChar*)LAYOUT_ROW_TAG)) {
- parsing_layout_row_node(child_node, cur_rec_layout, &row_y, &sub_layout_height, &cur_key);
+ parsing_layout_row_node(child_node, cur_rec_layout, &row_y, &sub_layout_height, &cur_key, layout_no);
}
child_node = child_node->next;
const xmlNodePtr cur_node,
const PSclLayout cur_rec_layout,
int *row_y, int *sub_layout_height,
- SclLayoutKeyCoordinatePointer **cur_key) {
+ SclLayoutKeyCoordinatePointer **cur_key,
+ int layout_no) {
assert(cur_node != NULL);
Row row = {0};
xmlNodePtr child_node = cur_node->xmlChildrenNode;
while (child_node != NULL) {
if (0 == xmlStrcmp(child_node->name, (const xmlChar*)LAYOUT_ROW_KEY_TAG)) {
- parsing_key_coordinate_record_node(child_node, &row, *cur_key);
- (*cur_key)++;
+ if (scl_check_arrindex_unsigned(layout_no, MAX_SCL_LAYOUT) && m_num_keys[layout_no] < MAX_KEY) {
+ parsing_key_coordinate_record_node(child_node, &row, *cur_key, layout_no);
+ (*cur_key)++;
+ m_num_keys[layout_no]++;
+ } else {
+ SCLLOG(SclLog::ERROR, "The number of keys exceeded %d (%d)\n", MAX_KEY, layout_no);
+ return;
+ }
}
child_node = child_node->next;
}
void
LayoutParserImpl::parsing_key_coordinate_record_node(
const xmlNodePtr cur_node, Row *row,
- SclLayoutKeyCoordinatePointer *cur_rec_coordinate) {
+ SclLayoutKeyCoordinatePointer *cur_rec_coordinate,
+ int layout_no) {
assert(cur_node != NULL);
assert(cur_rec_coordinate != NULL);
+ if (scl_check_arrindex_unsigned(layout_no, MAX_SCL_LAYOUT) && m_num_keys[layout_no] >= MAX_KEY) {
+ SCLLOG(SclLog::ERROR, "The number of keys exceeded %d (%d)\n", MAX_KEY, layout_no);
+ return;
+ }
*cur_rec_coordinate = (SclLayoutKeyCoordinatePointer)malloc(sizeof(SclLayoutKeyCoordinate));
if (*cur_rec_coordinate == NULL) {
SCLLOG(SclLog::ERROR, "LayoutParserImpl: memory malloc eror.\n");