31 #include <sys/socket.h> 
   34 #include <sys/types.h> 
   38 #include "media/lirc.h" 
   40 #include "lirc/lirc_log.h" 
   41 #include "lirc/lirc_options.h" 
   42 #include "lirc/ir_remote.h" 
   43 #include "lirc/config_file.h" 
   44 #include "lirc/transmit.h" 
   45 #include "lirc/config_flags.h" 
   50 enum directive { ID_none, ID_remote, ID_codes, ID_raw_codes, ID_raw_name };
 
   67 typedef void* (*array_guest_func)(
void* item, 
void* arg);
 
   71 #define MAX_INCLUDES 10 
   73 const char* whitespace = 
" \t";
 
   76 static int parse_error;
 
   78 static struct ir_remote* read_config_recursive(FILE* f, 
const char* 
name, 
int depth);
 
   79 static void calculate_signal_lengths(
struct ir_remote* remote);
 
   81 void** init_void_array(
struct void_array* ar, 
size_t chunk_size, 
size_t item_size)
 
   83         ar->chunk_size = chunk_size;
 
   84         ar->item_size = item_size;
 
   86         ar->ptr = calloc(chunk_size, ar->item_size);
 
  108         { 
"REVERSE",       REVERSE       },
 
  123         if ((ar->nr_items % ar->chunk_size) == (ar->chunk_size) - 1) {
 
  126                 ptr = realloc(ar->ptr,
 
  128                               (ar->nr_items + ar->chunk_size + 1));
 
  136         memcpy((ar->ptr) + (ar->item_size * ar->nr_items), dataptr, ar->item_size);
 
  137         ar->nr_items = (ar->nr_items) + 1;
 
  138         memset((ar->ptr) + (ar->item_size * ar->nr_items), 0, ar->item_size);
 
  160         for (i = 0; i < ar->nr_items; i += 1) {
 
  161                 r =  func(ar->ptr + (i * ar->item_size), arg);
 
  172         if (node1 == NULL || node2 == NULL)
 
  173                 return node1 == node2;
 
  174         return node1->code == node2->code;
 
  182 static void* array_guest_code_equals(
void* arg1, 
void* arg2)
 
  190         if (code1 == NULL || code2 == NULL)
 
  196         while  (next1 != NULL) {
 
  197                 if (!ir_code_node_equals(next1, next2))
 
  202         return next2 == NULL ? arg1 : NULL;
 
  210 static void* array_guest_ncode_cmp(
void* item, 
void* arg)
 
  216         if (strcmp(code1->
name, code2->
name) == 0)
 
  222 void* s_malloc(
size_t size)
 
  232         memset(ptr, 0, size);
 
  236 char* s_strdup(
char* 
string)
 
  240         ptr = strdup(
string);
 
  249 ir_code s_strtocode(
const char* val)
 
  255         code = strtoull(val, &endptr, 0);
 
  256         if ((
code == (uint64_t) -1 && errno == ERANGE) || strlen(endptr) != 0 || strlen(val) == 0) {
 
  257                 log_error(
"error in configfile line %d:", line);
 
  258                 log_error(
"\"%s\": must be a valid (uint64_t) number", val);
 
  265 uint32_t s_strtou32(
char* val)
 
  270         n = strtoul(val, &endptr, 0);
 
  271         if (!*val || *endptr) {
 
  272                 log_error(
"error in configfile line %d:", line);
 
  273                 log_error(
"\"%s\": must be a valid (uint32_t) number", val);
 
  280 int s_strtoi(
char* val)
 
  286         n = strtol(val, &endptr, 0);
 
  288         if (!*val || *endptr || n != ((
long)h)) {
 
  289                 log_error(
"error in configfile line %d:", line);
 
  290                 log_error(
"\"%s\": must be a valid (int) number", val);
 
  297 unsigned int s_strtoui(
char* val)
 
  303         n = strtoul(val, &endptr, 0);
 
  305         if (!*val || *endptr || n != ((uint32_t)h)) {
 
  306                 log_error(
"error in configfile line %d:", line);
 
  307                 log_error(
"\"%s\": must be a valid (unsigned int) number", val);
 
  314 lirc_t s_strtolirc_t(
char* val)
 
  320         n = strtoul(val, &endptr, 0);
 
  322         if (!*val || *endptr || n != ((uint32_t)h)) {
 
  323                 log_error(
"error in configfile line %d:", line);
 
  324                 log_error(
"\"%s\": must be a valid (lirc_t) number", val);
 
  329                 log_warn(
"error in configfile line %d:", line);
 
  330                 log_warn(
"\"%s\" is out of range", val);
 
  335 int checkMode(
int is_mode, 
int c_mode, 
char* error)
 
  337         if (is_mode != c_mode) {
 
  338                 log_error(
"fatal error in configfile line %d:", line);
 
  339                 log_error(
"\"%s\" isn't valid at this position", error);
 
  346 int addSignal(
struct void_array* 
signals, 
char* val)
 
  362         code->name = s_strdup(key);
 
  363         code->code = s_strtocode(val);
 
  372         node = s_malloc(
sizeof(*node));
 
  376         node->code = s_strtocode(val);
 
  381         if (code->current == NULL) {
 
  383                 code->current = node;
 
  385                 code->current->next = node;
 
  386                 code->current = node;
 
  391 int parseFlags(
char* val)
 
  399         while (
flag != NULL) {
 
  400                 while (*help != 
'|' && *help != 0)
 
  410                 while (flaglptr->
name != NULL) {
 
  411                         if (strcasecmp(flaglptr->
name, 
flag) == 0) {
 
  412                                 if (flaglptr->
flag & IR_PROTOCOL_MASK && flags & IR_PROTOCOL_MASK) {
 
  413                                         log_error(
"error in configfile line %d:", line);
 
  414                                         log_error(
"multiple protocols given in flags: \"%s\"", 
flag);
 
  418                                 flags = flags | flaglptr->
flag;
 
  424                 if (flaglptr->
name == NULL) {
 
  425                         log_error(
"error in configfile line %d:", line);
 
  437 int defineRemote(
char* key, 
char* val, 
char* val2, 
struct ir_remote* rem)
 
  439         if ((strcasecmp(
"name", key)) == 0) {
 
  440                 if (rem->
name != NULL)
 
  441                         free((
void*)(rem->
name));
 
  442                 rem->
name = s_strdup(val);
 
  446         if (options_getboolean(
"lircd:dynamic-codes")) {
 
  447                 if ((strcasecmp(
"dyncodes_name", key)) == 0) {
 
  453         } 
else if (strcasecmp(
"driver", key) == 0) {
 
  455                         free((
void*)(rem->
driver));
 
  456                 rem->
driver = s_strdup(val);
 
  458         } 
else if ((strcasecmp(
"bits", key)) == 0) {
 
  459                 rem->
bits = s_strtoi(val);
 
  461         } 
else if (strcasecmp(
"flags", key) == 0) {
 
  462                 rem->
flags |= parseFlags(val);
 
  464         } 
else if (strcasecmp(
"eps", key) == 0) {
 
  465                 rem->
eps = s_strtoi(val);
 
  467         } 
else if (strcasecmp(
"aeps", key) == 0) {
 
  468                 rem->
aeps = s_strtoi(val);
 
  470         } 
else if (strcasecmp(
"plead", key) == 0) {
 
  471                 rem->
plead = s_strtolirc_t(val);
 
  473         } 
else if (strcasecmp(
"ptrail", key) == 0) {
 
  474                 rem->
ptrail = s_strtolirc_t(val);
 
  476         } 
else if (strcasecmp(
"pre_data_bits", key) == 0) {
 
  479         } 
else if (strcasecmp(
"pre_data", key) == 0) {
 
  482         } 
else if (strcasecmp(
"post_data_bits", key) == 0) {
 
  485         } 
else if (strcasecmp(
"post_data", key) == 0) {
 
  488         } 
else if (strcasecmp(
"gap", key) == 0) {
 
  490                         rem->
gap2 = s_strtou32(val2);
 
  491                 rem->
gap = s_strtou32(val);
 
  492                 return val2 != NULL ? 2 : 1;
 
  493         } 
else if (strcasecmp(
"repeat_gap", key) == 0) {
 
  496         } 
else if (strcasecmp(
"repeat_mask", key) == 0) {
 
  501         else if (strcasecmp(
"toggle_bit", key) == 0) {
 
  504         } 
else if (strcasecmp(
"toggle_bit_mask", key) == 0) {
 
  507         } 
else if (strcasecmp(
"toggle_mask", key) == 0) {
 
  510         } 
else if (strcasecmp(
"rc6_mask", key) == 0) {
 
  513         } 
else if (strcasecmp(
"ignore_mask", key) == 0) {
 
  516         } 
else if (strcasecmp(
"manual_sort", key) == 0) {
 
  521         else if (strcasecmp(
"repeat_bit", key) == 0) {
 
  524         } 
else if (strcasecmp(
"suppress_repeat", key) == 0) {
 
  527         } 
else if (strcasecmp(
"min_repeat", key) == 0) {
 
  530         } 
else if (strcasecmp(
"min_code_repeat", key) == 0) {
 
  533         } 
else if (strcasecmp(
"frequency", key) == 0) {
 
  534                 rem->
freq = s_strtoui(val);
 
  536         } 
else if (strcasecmp(
"duty_cycle", key) == 0) {
 
  539         } 
else if (strcasecmp(
"baud", key) == 0) {
 
  540                 rem->
baud = s_strtoui(val);
 
  542         } 
else if (strcasecmp(
"serial_mode", key) == 0) {
 
  543                 if (val[0] < 
'5' || val[0] > 
'9') {
 
  544                         log_error(
"error in configfile line %d:", line);
 
  550                 switch (toupper(val[1])) {
 
  552                         rem->
parity = IR_PARITY_NONE;
 
  555                         rem->
parity = IR_PARITY_EVEN;
 
  558                         rem->
parity = IR_PARITY_ODD;
 
  561                         log_error(
"error in configfile line %d:", line);
 
  566                 if (strcmp(val + 2, 
"1.5") == 0)
 
  571         } 
else if (val2 != NULL) {
 
  572                 if (strcasecmp(
"header", key) == 0) {
 
  573                         rem->phead = s_strtolirc_t(val);
 
  574                         rem->
shead = s_strtolirc_t(val2);
 
  576                 } 
else if (strcasecmp(
"three", key) == 0) {
 
  577                         rem->pthree = s_strtolirc_t(val);
 
  578                         rem->
sthree = s_strtolirc_t(val2);
 
  580                 } 
else if (strcasecmp(
"two", key) == 0) {
 
  581                         rem->ptwo = s_strtolirc_t(val);
 
  582                         rem->
stwo = s_strtolirc_t(val2);
 
  584                 } 
else if (strcasecmp(
"one", key) == 0) {
 
  585                         rem->pone = s_strtolirc_t(val);
 
  586                         rem->
sone = s_strtolirc_t(val2);
 
  588                 } 
else if (strcasecmp(
"zero", key) == 0) {
 
  589                         rem->pzero = s_strtolirc_t(val);
 
  590                         rem->
szero = s_strtolirc_t(val2);
 
  592                 } 
else if (strcasecmp(
"foot", key) == 0) {
 
  593                         rem->pfoot = s_strtolirc_t(val);
 
  594                         rem->
sfoot = s_strtolirc_t(val2);
 
  596                 } 
else if (strcasecmp(
"repeat", key) == 0) {
 
  597                         rem->prepeat = s_strtolirc_t(val);
 
  598                         rem->
srepeat = s_strtolirc_t(val2);
 
  600                 } 
else if (strcasecmp(
"pre", key) == 0) {
 
  601                         rem->pre_p = s_strtolirc_t(val);
 
  602                         rem->
pre_s = s_strtolirc_t(val2);
 
  604                 } 
else if (strcasecmp(
"post", key) == 0) {
 
  605                         rem->post_p = s_strtolirc_t(val);
 
  606                         rem->
post_s = s_strtolirc_t(val2);
 
  611                 log_error(
"error in configfile line %d:", line);
 
  612                 log_error(
"unknown definiton: \"%s %s %s\"", key, val, val2);
 
  614                 log_error(
"error in configfile line %d:", line);
 
  615                 log_error(
"unknown definiton or too few arguments: \"%s %s\"", key, val);
 
  621 static int sanityChecks(
struct ir_remote* rem, 
const char* path)
 
  626         path = path != NULL ? path : 
"unknown file";
 
  629                 log_error(
"%s: Missing remote name", path);
 
  633                 log_warn(
"%s: %s: Gap value missing or invalid",
 
  636         if (has_repeat_gap(rem) && is_const(rem)) {
 
  637                 log_warn(
"%s: %s: Repeat_gap ignored (CONST_LENGTH is set)",
 
  646                           "%s: %s: Invalid pre_data", path, rem->
name);
 
  650                 log_warn(
"%s: %s: Invalid post_data",
 
  658         for (codes = rem->codes; codes->
name != NULL; codes++) {
 
  659                 if ((codes->
code & gen_mask(rem->
bits)) != codes->
code) {
 
  660                         log_warn(
"%s: %s: Invalid code : %s",
 
  664                 for (node = codes->
next; node != NULL; node = node->next) {
 
  665                         if ((node->code & gen_mask(rem->
bits)) != node->code) {
 
  666                                 log_warn(
"%s: %s: Invalid code %s: %s",
 
  668                                 node->code &= gen_mask(rem->
bits);
 
  687         int r1_is_raw = is_raw(r1);
 
  688         int r2_is_raw = is_raw(r2);
 
  690         if (!r1_is_raw && r2_is_raw)
 
  692         if (r1_is_raw && !r2_is_raw)
 
  695         if (r1_is_raw && r2_is_raw) {
 
  696                 for (c = r1->codes, r1_size = 0; c->
name != NULL; c++)
 
  698                 for (c = r2->codes, r2_size = 0; c->
name != NULL; c++)
 
  701                 r1_size = bit_count(r1);
 
  702                 r2_size = bit_count(r2);
 
  704         if (r1_size == r2_size)
 
  706         return r1_size < r2_size ? -1 : 1;
 
  723         for (r = remotes; r != NULL && r != (
void*)-1; r = r->next)
 
  728         while (rem != NULL && rem != (
void*)-1) {
 
  733                 while (scan && remote_bits_cmp(scan, rem) <= 0) {
 
  752 static const char* lirc_parse_include(
char* s)
 
  761         while (last > s && strchr(whitespace, *last) != NULL)
 
  765         if (*s != 
'"' && *s != 
'<')
 
  767         if (*s == 
'"' && *last != 
'"')
 
  769         else if (*s == 
'<' && *last != 
'>')
 
  772         memmove(s, s + 1, len - 2 + 1); 
 
  779 static const char* lirc_parse_relative(
char*            dst,
 
  792                 snprintf(dst, dst_size, 
"%s", child);
 
  795         if (strlen(current) >= dst_size)
 
  797         strcpy(dst, current);
 
  799         dirlen = strlen(dir);
 
  801                 memmove(dst, dir, dirlen + 1);
 
  803         if (dirlen + 1 + strlen(child) + 1 > dst_size)
 
  822         if (root == NULL && what != NULL)
 
  826         for (r = root; r->next != NULL; r = r->next)
 
  837         head = read_config_recursive(f, 
name, 0);
 
  838         head = sort_by_bit_count(head);
 
  854 read_included(
const char* 
name, 
int depth, 
char* val, 
struct ir_remote* top_rem)
 
  857         const char* childName;
 
  860         if (depth > MAX_INCLUDES) {
 
  861                 log_error(
"error opening child file defined at %s:%d", 
name, line);
 
  865         childName = lirc_parse_include(val);
 
  867                 log_error(
"error parsing child file value defined at line %d:", line);
 
  871         childFile = fopen(childName, 
"r");
 
  872         if (childFile == NULL) {
 
  873                 log_error(
"error opening child file '%s' defined at line %d:",
 
  875                 log_error(
"ignoring this child file for now.");
 
  878         rem = read_config_recursive(childFile, childName, depth + 1);
 
  879         top_rem = ir_remotes_append(top_rem, rem);
 
  902         char buff[256] = { 
'\0' };
 
  904         memset(&globbuf, 0, 
sizeof(globbuf));
 
  906         val[strlen(val) - 1] = 
'\0';
 
  907         lirc_parse_relative(buff, 
sizeof(buff), val, 
name);
 
  908         glob(buff, 0, NULL, &globbuf);
 
  909         for (i = 0; i < globbuf.gl_pathc; i += 1) {
 
  910                 snprintf(buff, 
sizeof(buff), 
"\"%s\"", globbuf.gl_pathv[i]);
 
  911                 top_rem = read_included(
name, depth, buff, top_rem);
 
  918 static void check_ncode_dups(
const char* path,
 
  920                              struct void_array* ar,
 
  923         if (foreach_void_array(ar, array_guest_ncode_cmp, code) != NULL) {
 
  924                 log_notice(
"%s: %s: Multiple definitions of: %s",
 
  925                            path, 
name, code->name);
 
  927         if (foreach_void_array(ar, array_guest_code_equals, code) != NULL) {
 
  928                 log_notice(
"%s: %s: Multiple values for same code: %s",
 
  929                            path, 
name, code->name);
 
  935 read_config_recursive(FILE* f, 
const char* 
name, 
int depth)
 
  937         char buf[LINE_LEN + 1];
 
  944         struct void_array codes_list, raw_codes, signals;
 
  945         struct ir_ncode raw_code = { NULL, 0, 0, NULL };
 
  946         struct ir_ncode name_code = { NULL, 0, 0, NULL };
 
  954         while (fgets(buf, LINE_LEN, f) != NULL) {
 
  957                 if (len == LINE_LEN && buf[len - 1] != 
'\n') {
 
  958                         log_error(
"line %d too long in config file", line);
 
  965                         if (buf[len] == 
'\n')
 
  970                         if (buf[len] == 
'\r')
 
  976                 key = strtok(buf, whitespace);
 
  980                 val = strtok(NULL, whitespace);
 
  982                         val2 = strtok(NULL, whitespace);
 
  983                         log_trace2(
"Tokens: \"%s\" \"%s\" \"%s\"", key, val, (val2 == NULL ? 
"(null)" : val));
 
  984                         if (strcasecmp(
"include", key) == 0) {
 
  985                                 int save_line = line;
 
  987                                 top_rem = read_all_included(
name,
 
  992                         } 
else if (strcasecmp(
"begin", key) == 0) {
 
  993                                 if (strcasecmp(
"codes", val) == 0) {
 
  996                                         if (!checkMode(mode, ID_remote, 
"begin codes"))
 
  999                                                 log_error(
"error in configfile line %d:", line);
 
 1005                                         init_void_array(&codes_list, 30, 
sizeof(
struct ir_ncode));
 
 1007                                 } 
else if (strcasecmp(
"raw_codes", val) == 0) {
 
 1010                                         if (!checkMode(mode, ID_remote, 
"begin raw_codes"))
 
 1013                                                 log_error(
"error in configfile line %d:", line);
 
 1020                                         init_void_array(&raw_codes, 30, 
sizeof(
struct ir_ncode));
 
 1021                                         mode = ID_raw_codes;
 
 1022                                 } 
else if (strcasecmp(
"remote", val) == 0) {
 
 1025                                         if (!checkMode(mode, ID_none, 
"begin remote"))
 
 1031                                                 rem = top_rem = s_malloc(
sizeof(
struct ir_remote));
 
 1032                                                 rem->
freq = DEFAULT_FREQ;
 
 1036                                                 rem = s_malloc(
sizeof(
struct ir_remote));
 
 1037                                                 rem->
freq = DEFAULT_FREQ;
 
 1038                                                 ir_remotes_append(top_rem, rem);
 
 1040                                 } 
else if (mode == ID_codes) {
 
 1041                                         code = defineCode(key, val, &name_code);
 
 1042                                         while (!parse_error && val2 != NULL) {
 
 1045                                                 defineNode(
code, val2);
 
 1046                                                 val2 = strtok(NULL, whitespace);
 
 1048                                         code->current = NULL;
 
 1052                                         log_error(
"error in configfile line %d:", line);
 
 1053                                         log_error(
"unknown section \"%s\"", val);
 
 1056                                 if (!parse_error && val2 != NULL) {
 
 1057                                         log_warn(
"%s: garbage after '%s' token " 
 1058                                                   "in line %d ignored",
 
 1059                                                   rem->
name, val, line);
 
 1061                         } 
else if (strcasecmp(
"end", key) == 0) {
 
 1062                                 if (strcasecmp(
"codes", val) == 0) {
 
 1065                                         if (!checkMode(mode, ID_codes, 
"end codes"))
 
 1069                                 } 
else if (strcasecmp(
"raw_codes", val) == 0) {
 
 1073                                         if (mode == ID_raw_name) {
 
 1076                                                 if (raw_code.
length % 2 == 0) {
 
 1077                                                         log_error(
"error in configfile line %d:", line);
 
 1083                                                 mode = ID_raw_codes;
 
 1085                                         if (!checkMode(mode, ID_raw_codes, 
"end raw_codes"))
 
 1089                                 } 
else if (strcasecmp(
"remote", val) == 0) {
 
 1093                                         if (!checkMode(mode, ID_remote, 
"end remote"))
 
 1095                                         if (!sanityChecks(rem, 
name)) {
 
 1099                                         if (options_getboolean(
"lircd:dynamic-codes")) {
 
 1110                                 } 
else if (mode == ID_codes) {
 
 1111                                         code = defineCode(key, val, &name_code);
 
 1112                                         while (!parse_error && val2 != NULL) {
 
 1115                                                 defineNode(
code, val2);
 
 1116                                                 val2 = strtok(NULL, whitespace);
 
 1118                                         code->current = NULL;
 
 1121                                         log_error(
"error in configfile line %d:", line);
 
 1125                                 if (!parse_error && val2 != NULL) {
 
 1127                                                   "%s: garbage after '%s'" 
 1128                                                   " token in line %d ignored",
 
 1129                                                   rem->
name, val, line);
 
 1134                                         argc = defineRemote(key, val, val2, rem);
 
 1136                                             && ((argc == 1 && val2 != NULL)
 
 1137                                                 || (argc == 2 && val2 != NULL && strtok(NULL, whitespace) != NULL))) {
 
 1139                                                           " token in line %d ignored",
 
 1140                                                           rem->
name, key, line);
 
 1144                                         code = defineCode(key, val, &name_code);
 
 1145                                         while (!parse_error && val2 != NULL) {
 
 1148                                                 defineNode(
code, val2);
 
 1149                                                 val2 = strtok(NULL, whitespace);
 
 1151                                         code->current = NULL;
 
 1152                                         check_ncode_dups(
name,
 
 1160                                         if (strcasecmp(
"name", key) == 0) {
 
 1162                                                 if (mode == ID_raw_name) {
 
 1165                                                         if (raw_code.
length % 2 == 0) {
 
 1166                                                                 log_error(
"error in configfile line %d:",
 
 1174                                                 raw_code.
name = s_strdup(val);
 
 1178                                                 init_void_array(&
signals, 50, 
sizeof(lirc_t));
 
 1180                                                 if (!parse_error && val2 != NULL) {
 
 1182                                                                  " token in line %d ignored",
 
 1183                                                                  rem->
name, key, line);
 
 1186                                                 if (mode == ID_raw_codes) {
 
 1187                                                         log_error(
"no name for signal defined at line %d",
 
 1192                                                 if (!addSignal(&
signals, key))
 
 1194                                                 if (!addSignal(&
signals, val))
 
 1197                                                         if (!addSignal(&
signals, val2))
 
 1199                                                 while ((val = strtok(NULL, whitespace)))
 
 1200                                                         if (!addSignal(&
signals, val))
 
 1206                 } 
else if (mode == ID_raw_name) {
 
 1207                         if (!addSignal(&
signals, key))
 
 1210                         log_error(
"error in configfile line %d", line);
 
 1217         if (mode != ID_none) {
 
 1220                         if (raw_code.
name != NULL) {
 
 1221                                 free(raw_code.
name);
 
 1238                 static int print_error = 1;
 
 1253         while (rem != NULL) {
 
 1254                 if ((!is_raw(rem)) && rem->
flags & REVERSE) {
 
 1262                         while (codes->
name != NULL) {
 
 1273                         int all_bits = bit_count(rem);
 
 1278                         int all_bits = bit_count(rem);
 
 1280                         if (has_toggle_bit_mask(rem)) {
 
 1281                                 log_warn(
"%s uses both toggle_bit and toggle_bit_mask", rem->
name);
 
 1287                 if (has_toggle_bit_mask(rem)) {
 
 1288                         if (!is_raw(rem) && rem->codes) {
 
 1290                                 if (rem->toggle_bit_mask_state)
 
 1295                 if (is_serial(rem)) {
 
 1298                         if (rem->
baud > 0) {
 
 1299                                 base = 1000000 / rem->
baud;
 
 1300                                 if (rem->pzero == 0 && rem->
szero == 0)
 
 1302                                 if (rem->pone == 0 && rem->
sone == 0)
 
 1310                                 log_warn(
"invalid min_code_repeat value");
 
 1314                 calculate_signal_lengths(rem);
 
 1321 void calculate_signal_lengths(
struct ir_remote* remote)
 
 1323         if (is_const(remote)) {
 
 1331         lirc_t min_signal_length = 0, max_signal_length = 0;
 
 1332         lirc_t max_pulse = 0, max_space = 0;
 
 1334         struct ir_ncode* c = remote->codes;
 
 1347                                 code.code = next->code;
 
 1350                         for (repeat = 0; repeat < 2; repeat++) {
 
 1351                                 if (init_sim(remote, &code, repeat)) {
 
 1355                                                 if (first_sum || sum < min_signal_length)
 
 1356                                                         min_signal_length = sum;
 
 1357                                                 if (first_sum || sum > max_signal_length)
 
 1358                                                         max_signal_length = sum;
 
 1382         } 
else if (is_const(remote)) {
 
 1386                         log_warn(
"min_gap_length is 0 for '%s' remote",
 
 1393                         log_warn(
"max_gap_length is 0 for '%s' remote", remote->
name);
 
 1409         while (remotes != NULL) {
 
 1410                 next = remotes->next;
 
 1414                 if (remotes->
name != NULL)
 
 1415                         free((
void*)(remotes->
name));
 
 1416                 if (remotes->codes != NULL) {
 
 1417                         codes = remotes->codes;
 
 1418                         while (codes->
name != NULL) {
 
 1427                                         next_node = node->next;
 
 1433                         free(remotes->codes);
 
void *(* array_guest_func)(void *item, void *arg)
foreach_void_array argument.
void * get_void_array(struct void_array *ar)
Return the array dataptr, an array[nr_items] of item_size elements.
int add_void_array(struct void_array *ar, void *dataptr)
Add *dataptr to end of ar, re-allocating as necessary.
const struct flaglist all_flags[]
All flags i config file: Their name and mask.
const lirc_t * send_buffer_data(void)
lirc_t send_buffer_sum(void)
int send_buffer_length(void)
Do not document this function.
void free_config(struct ir_remote *remotes)
Free() an ir_remote instance obtained using read_config().
struct ir_remote * read_config(FILE *f, const char *name)
Parse a lircd.conf config file.
#define SHIFT_ENC
IR data is shift encoded (name obsolete)
#define RAW_CODES
for internal use only
#define RC6
IR data follows RC6 protocol.
#define REPEAT_HEADER
header is also sent before repeat code
#define GRUNDIG
encoding found on Grundig remote
#define BO
encoding found on Bang & Olufsen remote
uint64_t ir_code
Denotes an internal coded representation for an IR transmission.
#define COMPAT_REVERSE
compatibility mode for REVERSE flag
#define SPACE_FIRST
bits are encoded as space+pulse
#define SPACE_ENC
IR data is space encoded.
#define RC5
IR data follows RC5 protocol.
#define NO_FOOT_REP
no foot for key repeats
#define SERIAL
serial protocol
#define NO_HEAD_REP
no header for key repeats
#define CONST_LENGTH
signal length+gap is always constant
#define RCMM
IR data follows RC-MM protocol.
#define log_trace(fmt,...)
Log a trace message.
#define log_notice(fmt,...)
Log a notice message.
#define log_info(fmt,...)
Log an info message.
#define log_trace2(fmt,...)
Log a trace2 message.
#define log_error(fmt,...)
Log an error message.
#define log_trace1(fmt,...)
Log a trace1 message.
logchannel_t
Log channels used to filter messages.
#define log_warn(fmt,...)
Log a warning message.
Description of flag to print.
An ir_code for entering into (singly) linked lists, i.e.
IR Command, corresponding to one (command defining) line of the configuration file.
struct ir_code_node * next
Linked list of the subsequent ir_code's, after the first one.
ir_code code
The first code of the command.
lirc_t * signals
(private)
char * name
Name of command.
One remote as represented in the configuration file.
const char * driver
Name of driver for LIRCCODE cases.
uint32_t repeat_gap
time between two repeat codes if different from gap
lirc_t stwo
2 (only used for RC-MM)
unsigned int freq
modulation frequency
int suppress_repeat
suppress unwanted repeats
unsigned int aeps
detecting very short pulses is difficult with relative tolerance for some remotes,...
uint32_t gap2
time between signals in usecs
lirc_t min_total_signal_length
how long is the shortest signal including gap
unsigned int stop_bits
mapping: 1->2 1.5->3 2->4
unsigned int bits_in_byte
default: 8
struct ir_ncode dyncodes[2]
helper structs for unknown buttons
ir_code rc6_mask
RC-6 doubles signal length of some bits.
lirc_t ptrail
trailing pulse
unsigned int duty_cycle
0<duty cycle<=100 default: 50
lirc_t min_gap_length
how long is the shortest gap
ir_code repeat_mask
mask defines which bits are inverted for repeats
lirc_t srepeat
indicate repeating
ir_code pre_data
data which the remote sends before actual keycode
int bits
bits (length of code)
int post_data_bits
length of post_data
ir_code ignore_mask
mask defines which bits can be ignored when matching a code
lirc_t plead
leading pulse
lirc_t sthree
3 (only used for RC-MM)
ir_code post_data
data which the remote sends after actual keycode
ir_code toggle_mask
Sharp (?) error detection scheme.
unsigned int baud
can be overridden by [p|s]zero, [p|s]one
int min_repeat
code is repeated at least x times code sent once -> min_repeat=0
int manual_sort
If set in any remote, disables automatic sorting.
lirc_t post_s
signal between keycode and post_code
lirc_t pre_s
signal between pre_data and keycode
uint32_t gap
time between signals in usecs
int eps
eps (relative tolerance)
char * dyncodes_name
name for unknown buttons
struct ir_ncode * last_code
code received or sent last
unsigned int min_code_repeat
meaningful only if remote sends a repeat code: in this case this value indicates how often the real c...
const char * name
name of remote control
ir_code toggle_bit_mask
previously only one bit called toggle_bit
unsigned int parity
currently unsupported
int pre_data_bits
length of pre_data
lirc_t max_gap_length
how long is the longest gap
lirc_t max_total_signal_length
how long is the longest signal including gap