31 #include <sys/socket.h>
34 #include <sys/types.h>
38 #include "include/media/lirc.h"
39 #include "lirc/lirc_log.h"
40 #include "lirc/lirc_options.h"
41 #include "lirc/ir_remote.h"
42 #include "lirc/config_file.h"
43 #include "lirc/transmit.h"
44 #include "lirc/config_flags.h"
47 enum directive { ID_none, ID_remote, ID_codes, ID_raw_codes, ID_raw_name };
64 #define MAX_INCLUDES 10
66 const char *whitespace =
" \t";
69 static int parse_error;
71 static struct ir_remote *read_config_recursive(FILE * f,
const char *
name,
int depth);
72 static void calculate_signal_lengths(
struct ir_remote *remote);
74 void **init_void_array(
struct void_array *ar,
size_t chunk_size,
size_t item_size)
76 ar->chunk_size = chunk_size;
77 ar->item_size = item_size;
79 if (!(ar->ptr = calloc(chunk_size, ar->item_size))) {
80 logprintf(LIRC_ERROR,
"out of memory");
101 {
"REVERSE", REVERSE},
111 int add_void_array(
struct void_array *ar,
void *dataptr)
115 if ((ar->nr_items % ar->chunk_size) == (ar->chunk_size) - 1) {
118 if (!(ptr = realloc(ar->ptr, ar->item_size * ((ar->nr_items) + (ar->chunk_size + 1))))) {
119 logprintf(LIRC_ERROR,
"out of memory");
125 memcpy((ar->ptr) + (ar->item_size * ar->nr_items), dataptr, ar->item_size);
126 ar->nr_items = (ar->nr_items) + 1;
127 memset((ar->ptr) + (ar->item_size * ar->nr_items), 0, ar->item_size);
131 void *get_void_array(
struct void_array *ar)
136 void *s_malloc(
size_t size)
139 if ((ptr = malloc(size)) == NULL) {
140 logprintf(LIRC_ERROR,
"out of memory");
144 memset(ptr, 0, size);
148 char *s_strdup(
char *
string)
151 if (!(ptr = strdup(
string))) {
152 logprintf(LIRC_ERROR,
"out of memory");
159 ir_code s_strtocode(
const char *val)
165 code = strtoull(val, &endptr, 0);
166 if ((code == (__u64) - 1 && errno == ERANGE) || strlen(endptr) != 0 || strlen(val) == 0) {
167 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
168 logprintf(LIRC_ERROR,
"\"%s\": must be a valid (__u64) number", val);
175 __u32 s_strtou32(
char *val)
180 n = strtoul(val, &endptr, 0);
181 if (!*val || *endptr) {
182 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
183 logprintf(LIRC_ERROR,
"\"%s\": must be a valid (__u32) number", val);
190 int s_strtoi(
char *val)
196 n = strtol(val, &endptr, 0);
198 if (!*val || *endptr || n != ((
long)h)) {
199 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
200 logprintf(LIRC_ERROR,
"\"%s\": must be a valid (int) number", val);
207 unsigned int s_strtoui(
char *val)
213 n = strtoul(val, &endptr, 0);
215 if (!*val || *endptr || n != ((__u32) h)) {
216 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
217 logprintf(LIRC_ERROR,
"\"%s\": must be a valid (unsigned int) number", val);
224 lirc_t s_strtolirc_t(
char *val)
230 n = strtoul(val, &endptr, 0);
232 if (!*val || *endptr || n != ((__u32) h)) {
233 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
234 logprintf(LIRC_ERROR,
"\"%s\": must be a valid (lirc_t) number", val);
239 logprintf(LIRC_WARNING,
"error in configfile line %d:", line);
240 logprintf(LIRC_WARNING,
"\"%s\" is out of range", val);
245 int checkMode(
int is_mode,
int c_mode,
char *error)
247 if (is_mode != c_mode) {
248 logprintf(LIRC_ERROR,
"fatal error in configfile line %d:", line);
249 logprintf(LIRC_ERROR,
"\"%s\" isn't valid at this position", error);
256 int addSignal(
struct void_array *signals,
char *val)
263 if (!add_void_array(signals, &t))
271 memset(code, 0,
sizeof(*code));
272 code->
name = s_strdup(key);
273 code->
code = s_strtocode(val);
282 node = s_malloc(
sizeof(*node));
286 node->code = s_strtocode(val);
301 int parseFlags(
char *val)
308 while (flag != NULL) {
309 while (*help !=
'|' && *help != 0)
319 while (flaglptr->
name != NULL) {
320 if (strcasecmp(flaglptr->
name, flag) == 0) {
321 if (flaglptr->
flag & IR_PROTOCOL_MASK && flags & IR_PROTOCOL_MASK) {
322 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
323 logprintf(LIRC_ERROR,
"multiple protocols given in flags: \"%s\"", flag);
327 flags = flags | flaglptr->
flag;
333 if (flaglptr->
name == NULL) {
334 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
335 logprintf(LIRC_ERROR,
"unknown flag: \"%s\"", flag);
346 int defineRemote(
char *key,
char *val,
char *val2,
struct ir_remote *rem)
348 if ((strcasecmp(
"name", key)) == 0) {
349 if (rem->
name != NULL)
350 free((
void*) (rem->
name));
351 rem->
name = s_strdup(val);
352 logprintf(LIRC_INFO,
"Using remote: %s.", val);
355 if (options_getboolean(
"lircd:dynamic-codes")) {
356 if ((strcasecmp(
"dyncodes_name", key)) == 0) {
364 else if (strcasecmp(
"driver", key) == 0) {
365 if (rem->
driver != NULL) {
366 free((
void*)(rem->
driver));
368 rem->
driver = s_strdup(val);
371 else if ((strcasecmp(
"bits", key)) == 0) {
372 rem->
bits = s_strtoi(val);
374 }
else if (strcasecmp(
"flags", key) == 0) {
375 rem->
flags |= parseFlags(val);
377 }
else if (strcasecmp(
"eps", key) == 0) {
378 rem->
eps = s_strtoi(val);
380 }
else if (strcasecmp(
"aeps", key) == 0) {
381 rem->
aeps = s_strtoi(val);
383 }
else if (strcasecmp(
"plead", key) == 0) {
384 rem->
plead = s_strtolirc_t(val);
386 }
else if (strcasecmp(
"ptrail", key) == 0) {
387 rem->
ptrail = s_strtolirc_t(val);
389 }
else if (strcasecmp(
"pre_data_bits", key) == 0) {
392 }
else if (strcasecmp(
"pre_data", key) == 0) {
395 }
else if (strcasecmp(
"post_data_bits", key) == 0) {
398 }
else if (strcasecmp(
"post_data", key) == 0) {
401 }
else if (strcasecmp(
"gap", key) == 0) {
403 rem->
gap2 = s_strtou32(val2);
405 rem->
gap = s_strtou32(val);
406 return (val2 != NULL ? 2 : 1);
407 }
else if (strcasecmp(
"repeat_gap", key) == 0) {
410 }
else if (strcasecmp(
"repeat_mask", key) == 0) {
415 else if (strcasecmp(
"toggle_bit", key) == 0) {
418 }
else if (strcasecmp(
"toggle_bit_mask", key) == 0) {
421 }
else if (strcasecmp(
"toggle_mask", key) == 0) {
424 }
else if (strcasecmp(
"rc6_mask", key) == 0) {
427 }
else if (strcasecmp(
"ignore_mask", key) == 0) {
430 }
else if (strcasecmp(
"manual_sort", key) == 0) {
435 else if (strcasecmp(
"repeat_bit", key) == 0) {
438 }
else if (strcasecmp(
"suppress_repeat", key) == 0) {
441 }
else if (strcasecmp(
"min_repeat", key) == 0) {
444 }
else if (strcasecmp(
"min_code_repeat", key) == 0) {
447 }
else if (strcasecmp(
"frequency", key) == 0) {
448 rem->
freq = s_strtoui(val);
450 }
else if (strcasecmp(
"duty_cycle", key) == 0) {
453 }
else if (strcasecmp(
"baud", key) == 0) {
454 rem->
baud = s_strtoui(val);
456 }
else if (strcasecmp(
"serial_mode", key) == 0) {
457 if (val[0] <
'5' || val[0] >
'9') {
458 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
459 logprintf(LIRC_ERROR,
"bad bit count");
464 switch (toupper(val[1])) {
466 rem->
parity = IR_PARITY_NONE;
469 rem->
parity = IR_PARITY_EVEN;
472 rem->
parity = IR_PARITY_ODD;
475 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
476 logprintf(LIRC_ERROR,
"unsupported parity mode");
480 if (strcmp(val + 2,
"1.5") == 0) {
486 }
else if (val2 != NULL) {
487 if (strcasecmp(
"header", key) == 0) {
488 rem->phead = s_strtolirc_t(val);
489 rem->
shead = s_strtolirc_t(val2);
491 }
else if (strcasecmp(
"three", key) == 0) {
492 rem->pthree = s_strtolirc_t(val);
493 rem->
sthree = s_strtolirc_t(val2);
495 }
else if (strcasecmp(
"two", key) == 0) {
496 rem->ptwo = s_strtolirc_t(val);
497 rem->
stwo = s_strtolirc_t(val2);
499 }
else if (strcasecmp(
"one", key) == 0) {
500 rem->pone = s_strtolirc_t(val);
501 rem->
sone = s_strtolirc_t(val2);
503 }
else if (strcasecmp(
"zero", key) == 0) {
504 rem->pzero = s_strtolirc_t(val);
505 rem->
szero = s_strtolirc_t(val2);
507 }
else if (strcasecmp(
"foot", key) == 0) {
508 rem->pfoot = s_strtolirc_t(val);
509 rem->
sfoot = s_strtolirc_t(val2);
511 }
else if (strcasecmp(
"repeat", key) == 0) {
512 rem->prepeat = s_strtolirc_t(val);
513 rem->
srepeat = s_strtolirc_t(val2);
515 }
else if (strcasecmp(
"pre", key) == 0) {
516 rem->pre_p = s_strtolirc_t(val);
517 rem->
pre_s = s_strtolirc_t(val2);
519 }
else if (strcasecmp(
"post", key) == 0) {
520 rem->post_p = s_strtolirc_t(val);
521 rem->
post_s = s_strtolirc_t(val2);
526 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
527 logprintf(LIRC_ERROR,
"unknown definiton: \"%s %s %s\"", key, val, val2);
529 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
530 logprintf(LIRC_ERROR,
"unknown definiton or too few arguments: \"%s %s\"", key, val);
536 static int sanityChecks(
struct ir_remote *rem)
542 logprintf(LIRC_ERROR,
"you must specify a remote name");
546 logprintf(LIRC_WARNING,
547 "%s: you should specify a valid gap value",
550 if (has_repeat_gap(rem) && is_const(rem)) {
551 logprintf(LIRC_WARNING,
552 "%s: repeat_gap will be ignored if CONST_LENGTH flag is set",
560 logprintf(LIRC_WARNING,
"invalid pre_data found for %s", rem->
name);
564 logprintf(LIRC_WARNING,
"invalid post_data found for %s", rem->
name);
567 for (codes = rem->codes; codes->
name != NULL; codes++) {
568 if ((codes->
code & gen_mask(rem->
bits)) != codes->
code) {
569 logprintf(LIRC_WARNING,
"invalid code found for %s: %s", rem->
name, codes->
name);
572 for (node = codes->
next; node != NULL; node = node->next) {
573 if ((node->code & gen_mask(rem->
bits)) != node->code) {
574 logprintf(LIRC_WARNING,
"invalid code found for %s: %s", rem->
name, codes->
name);
575 node->code &= gen_mask(rem->
bits);
595 int r1_is_raw = is_raw(r1);
596 int r2_is_raw = is_raw(r2);
598 if (!r1_is_raw && r2_is_raw)
return -1;
599 if (r1_is_raw && !r2_is_raw)
return 1;
601 if (r1_is_raw && r2_is_raw){
602 for (c = r1->codes, r1_size = 0; c->
name != NULL; c++)
604 for (c = r2->codes, r2_size = 0; c->
name != NULL; c++)
607 r1_size = bit_count(r1);
608 r2_size = bit_count(r2);
610 if (r1_size == r2_size)
return 0;
611 return r1_size < r2_size ? -1 : 1;
622 struct ir_remote *top, *rem, *next, *prev, *scan, *r;
624 for (r = remotes; r != NULL && r != (
void*)-1; r = r->next) {
631 while (rem != NULL && rem != (
void*)-1) {
636 while (scan && remote_bits_cmp(scan, rem) <= 0) {
657 static const char *lirc_parse_include(
char *s)
667 while (last > s && strchr(whitespace, *last) != NULL) {
673 if (*s !=
'"' && *s !=
'<') {
676 if (*s ==
'"' && *last !=
'"') {
678 }
else if (*s ==
'<' && *last !=
'>') {
682 memmove(s, s + 1, len - 2 + 1);
689 static const char *lirc_parse_relative(
char *dst,
704 if (strlen(current) >= dst_size) {
707 strcpy(dst, current);
709 dirlen = strlen(dir);
711 memmove(dst, dir, dirlen + 1);
714 if (dirlen + 1 + strlen(child) + 1 > dst_size) {
734 if (root == NULL && what != NULL)
738 for (r = root; r->next != NULL; r = r->next)
750 head = read_config_recursive(f, name, 0);
751 head = sort_by_bit_count(head);
767 read_included(
const char*
name,
int depth,
char* val,
struct ir_remote* top_rem)
770 const char *childName;
773 if (depth > MAX_INCLUDES) {
774 logprintf(LIRC_ERROR,
"error opening child file defined at %s:%d", name, line);
775 logprintf(LIRC_ERROR,
"too many files included");
778 childName = lirc_parse_include(val);
780 logprintf(LIRC_ERROR,
"error parsing child file value defined at line %d:", line);
781 logprintf(LIRC_ERROR,
"invalid quoting");
784 childFile = fopen(childName,
"r");
785 if (childFile == NULL) {
786 logprintf(LIRC_ERROR,
"error opening child file '%s' defined at line %d:",
788 logprintf(LIRC_ERROR,
"ignoring this child file for now.");
791 rem = read_config_recursive(childFile, childName, depth + 1);
792 top_rem = ir_remotes_append(top_rem, rem);
809 static struct ir_remote* read_all_included(
const char* name,
816 char buff[256] = {
'\0'};
818 memset(&globbuf, 0,
sizeof(globbuf));
820 val[strlen(val) - 1] =
'\0';
821 lirc_parse_relative(buff,
sizeof(buff), val, name);
822 glob(buff, 0, NULL, &globbuf);
823 for (i = 0; i < globbuf.gl_pathc; i +=1) {
824 snprintf(buff,
sizeof(buff),
"\"%s\"", globbuf.gl_pathv[i]);
825 top_rem = read_included(name, depth, buff, top_rem);
832 read_config_recursive(FILE * f,
const char *name,
int depth)
834 char buf[LINE_LEN + 1], *key, *val, *val2;
836 struct ir_remote *top_rem = NULL, *rem = NULL;
837 struct void_array codes_list, raw_codes, signals;
838 struct ir_ncode raw_code = { NULL, 0, 0, NULL };
839 struct ir_ncode name_code = { NULL, 0, 0, NULL };
847 while (fgets(buf, LINE_LEN, f) != NULL) {
850 if (len == LINE_LEN && buf[len - 1] !=
'\n') {
851 logprintf(LIRC_ERROR,
"line %d too long in config file", line);
858 if (buf[len] ==
'\n')
863 if (buf[len] ==
'\r')
870 key = strtok(buf, whitespace);
874 val = strtok(NULL, whitespace);
876 val2 = strtok(NULL, whitespace);
877 LOGPRINTF(3,
"Tokens: \"%s\" \"%s\" \"%s\"", key, val, (val2 == NULL ?
"(null)" : val));
878 if (strcasecmp(
"include", key) == 0) {
879 int save_line = line;
880 top_rem = read_all_included(name,
885 }
else if (strcasecmp(
"begin", key) == 0) {
886 if (strcasecmp(
"codes", val) == 0) {
889 if (!checkMode(mode, ID_remote,
"begin codes"))
892 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
893 logprintf(LIRC_ERROR,
"codes are already defined");
898 init_void_array(&codes_list, 30,
sizeof(
struct ir_ncode));
900 }
else if (strcasecmp(
"raw_codes", val) == 0) {
903 if (!checkMode(mode, ID_remote,
"begin raw_codes"))
906 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
907 logprintf(LIRC_ERROR,
"codes are already defined");
913 init_void_array(&raw_codes, 30,
sizeof(
struct ir_ncode));
915 }
else if (strcasecmp(
"remote", val) == 0) {
918 if (!checkMode(mode, ID_none,
"begin remote"))
924 rem = top_rem = s_malloc(
sizeof(
struct ir_remote));
928 rem = s_malloc(
sizeof(
struct ir_remote));
929 ir_remotes_append(top_rem, rem);
932 }
else if (mode == ID_codes) {
933 code = defineCode(key, val, &name_code);
934 while (!parse_error && val2 != NULL) {
937 defineNode(code, val2);
938 val2 = strtok(NULL, whitespace);
941 add_void_array(&codes_list, code);
943 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
944 logprintf(LIRC_ERROR,
"unknown section \"%s\"", val);
947 if (!parse_error && val2 != NULL) {
948 logprintf(LIRC_WARNING,
949 "%s: garbage after '%s' token "
950 "in line %d ignored",
951 rem->name, val, line);
953 }
else if (strcasecmp(
"end", key) == 0) {
955 if (strcasecmp(
"codes", val) == 0) {
958 if (!checkMode(mode, ID_codes,
"end codes"))
960 rem->codes = get_void_array(&codes_list);
963 }
else if (strcasecmp(
"raw_codes", val) == 0) {
967 if (mode == ID_raw_name) {
968 raw_code.
signals = get_void_array(&signals);
969 raw_code.
length = signals.nr_items;
970 if (raw_code.
length % 2 == 0) {
971 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
972 logprintf(LIRC_ERROR,
"bad signal length");
975 if (!add_void_array(&raw_codes, &raw_code))
979 if (!checkMode(mode, ID_raw_codes,
"end raw_codes"))
981 rem->codes = get_void_array(&raw_codes);
983 }
else if (strcasecmp(
"remote", val) == 0) {
987 if (!checkMode(mode, ID_remote,
"end remote"))
989 if (!sanityChecks(rem)) {
993 if (options_getboolean(
"lircd:dynamic-codes")) {
994 if (rem->dyncodes_name == NULL) {
995 rem->dyncodes_name = s_strdup(
"unknown");
997 rem->dyncodes[0].name = rem->dyncodes_name;
998 rem->dyncodes[1].name = rem->dyncodes_name;
1003 rem->last_code = NULL;
1005 }
else if (mode == ID_codes) {
1006 code = defineCode(key, val, &name_code);
1007 while (!parse_error && val2 != NULL) {
1010 defineNode(code, val2);
1011 val2 = strtok(NULL, whitespace);
1014 add_void_array(&codes_list, code);
1016 logprintf(LIRC_ERROR,
"error in configfile line %d:", line);
1017 logprintf(LIRC_ERROR,
"unknown section %s", val);
1020 if (!parse_error && val2 != NULL) {
1021 logprintf(LIRC_WARNING,
1022 "%s: garbage after '%s'"
1023 " token in line %d ignored",
1024 rem->name, val, line);
1029 argc = defineRemote(key, val, val2, rem);
1031 && ((argc == 1 && val2 != NULL)
1032 || (argc == 2 && val2 != NULL && strtok(NULL, whitespace) != NULL))) {
1033 logprintf(LIRC_WARNING,
1034 "%s: garbage after '%s'"
1035 " token in line %d ignored",
1036 rem->name, key, line);
1040 code = defineCode(key, val, &name_code);
1041 while (!parse_error && val2 != NULL) {
1044 defineNode(code, val2);
1045 val2 = strtok(NULL, whitespace);
1048 add_void_array(&codes_list, code);
1052 if (strcasecmp(
"name", key) == 0) {
1054 if (mode == ID_raw_name) {
1055 raw_code.
signals = get_void_array(&signals);
1056 raw_code.
length = signals.nr_items;
1057 if (raw_code.
length % 2 == 0) {
1058 logprintf(LIRC_ERROR,
"error in configfile line %d:",
1060 logprintf(LIRC_ERROR,
"bad signal length");
1063 if (!add_void_array(&raw_codes, &raw_code))
1066 if (!(raw_code.
name = s_strdup(val))) {
1070 init_void_array(&signals, 50,
sizeof(lirc_t));
1072 if (!parse_error && val2 != NULL) {
1073 logprintf(LIRC_WARNING,
1074 "%s: garbage after '%s'"
1075 " token in line %d ignored",
1076 rem->name, key, line);
1079 if (mode == ID_raw_codes) {
1080 logprintf(LIRC_ERROR,
"no name for signal defined at line %d",
1085 if (!addSignal(&signals, key))
1087 if (!addSignal(&signals, val))
1090 if (!addSignal(&signals, val2)) {
1094 while ((val = strtok(NULL, whitespace))) {
1095 if (!addSignal(&signals, val))
1102 }
else if (mode == ID_raw_name) {
1103 if (!addSignal(&signals, key)) {
1107 logprintf(LIRC_ERROR,
"error in configfile line %d", line);
1115 if (mode != ID_none) {
1118 if (raw_code.
name != NULL) {
1119 free(raw_code.
name);
1120 if (get_void_array(&signals) != NULL)
1121 free(get_void_array(&signals));
1124 rem->codes = get_void_array(&raw_codes);
1127 rem->codes = get_void_array(&codes_list);
1131 logprintf(LIRC_ERROR,
"unexpected end of file");
1136 static int print_error = 1;
1139 logprintf(LIRC_ERROR,
"reading of file '%s' failed", name);
1145 return ((
void *)-1);
1151 while (rem != NULL) {
1152 if ((!is_raw(rem)) && rem->flags & REVERSE) {
1156 rem->pre_data = reverse(rem->pre_data, rem->pre_data_bits);
1158 if (has_post(rem)) {
1159 rem->post_data = reverse(rem->post_data, rem->post_data_bits);
1162 while (codes->
name != NULL) {
1163 codes->
code = reverse(codes->
code, rem->bits);
1166 rem->flags = rem->flags & (~REVERSE);
1172 if (rem->flags &
RC6 && rem->rc6_mask == 0 && rem->toggle_bit > 0) {
1173 int all_bits = bit_count(rem);
1175 rem->rc6_mask = ((
ir_code) 1) << (all_bits - rem->toggle_bit);
1177 if (rem->toggle_bit > 0) {
1178 int all_bits = bit_count(rem);
1180 if (has_toggle_bit_mask(rem)) {
1181 logprintf(LIRC_WARNING,
"%s uses both toggle_bit and toggle_bit_mask", rem->name);
1183 rem->toggle_bit_mask = ((
ir_code) 1) << (all_bits - rem->toggle_bit);
1185 rem->toggle_bit = 0;
1187 if (has_toggle_bit_mask(rem)) {
1188 if (!is_raw(rem) && rem->codes) {
1189 rem->toggle_bit_mask_state = (rem->codes->code & rem->toggle_bit_mask);
1190 if (rem->toggle_bit_mask_state) {
1192 rem->toggle_bit_mask_state ^= rem->toggle_bit_mask;
1196 if (is_serial(rem)) {
1199 if (rem->baud > 0) {
1200 base = 1000000 / rem->baud;
1201 if (rem->pzero == 0 && rem->szero == 0) {
1204 if (rem->pone == 0 && rem->sone == 0) {
1208 if (rem->bits_in_byte == 0) {
1209 rem->bits_in_byte = 8;
1212 if (rem->min_code_repeat > 0) {
1213 if (!has_repeat(rem) || rem->min_code_repeat > rem->min_repeat) {
1214 logprintf(LIRC_WARNING,
"invalid min_code_repeat value");
1215 rem->min_code_repeat = 0;
1218 calculate_signal_lengths(rem);
1225 void calculate_signal_lengths(
struct ir_remote *remote)
1227 if (is_const(remote)) {
1235 lirc_t min_signal_length = 0, max_signal_length = 0;
1236 lirc_t max_pulse = 0, max_space = 0;
1238 struct ir_ncode *c = remote->codes;
1250 code.
code = next->code;
1253 for (repeat = 0; repeat < 2; repeat++) {
1254 if (init_sim(remote, &code, repeat)) {
1258 if (first_sum || sum < min_signal_length) {
1259 min_signal_length = sum;
1261 if (first_sum || sum > max_signal_length) {
1262 max_signal_length = sum;
1290 }
else if (is_const(remote)) {
1294 logprintf(LIRC_WARNING,
1295 "min_gap_length is 0 for '%s' remote",
1302 logprintf(LIRC_WARNING,
"max_gap_length is 0 for '%s' remote", remote->
name);
1318 while (remotes != NULL) {
1319 next = remotes->next;
1323 if (remotes->
name != NULL)
1324 free((
void*)(remotes->
name));
1325 if (remotes->codes != NULL) {
1326 codes = remotes->codes;
1327 while (codes->
name != NULL) {
1335 next_node = node->next;
1341 free(remotes->codes);
lirc_t min_total_signal_length
lirc_t max_total_signal_length
struct ir_code_node * next
void free_config(struct ir_remote *remotes)
struct ir_code_node * current
const lirc_t * send_buffer_data()
#define LOGPRINTF(level, fmt, args...)
unsigned int min_code_repeat
const struct flaglist all_flags[]
struct ir_remote * read_config(FILE *f, const char *name)
unsigned int bits_in_byte