harmonize coding style and messages

This commit is contained in:
marschap
2006-04-08 17:36:05 +00:00
parent a92603f96e
commit 57a5944a88
+30 -28
View File
@@ -70,13 +70,13 @@ lircin_init (Driver *drvthis)
PrivateData *p; PrivateData *p;
/* Alocate and store private data */ /* Alocate and store private data */
p = (PrivateData *) malloc( sizeof( PrivateData) ); p = (PrivateData *) malloc(sizeof(PrivateData));
if( ! p ) { if (p == NULL) {
report( RPT_ERR, "%s: Could not allocate private data.", drvthis->name ); report(RPT_ERR, "%s: Could not allocate private data.", drvthis->name);
return -1; return -1;
} }
if( drvthis->store_private_ptr( drvthis, p ) ) { if (drvthis->store_private_ptr(drvthis, p)) {
report( RPT_ERR, "%s: Could not store private data.", drvthis->name ); report(RPT_ERR, "%s: Could not store private data.", drvthis->name);
return -1; return -1;
} }
@@ -89,48 +89,49 @@ lircin_init (Driver *drvthis)
/* READ CONFIG FILE:*/ /* READ CONFIG FILE:*/
/* Get location of lircrc to be used */ /* Get location of lircrc to be used */
if (drvthis->config_get_string ( drvthis->name , "lircrc" , 0 , NULL) != NULL) if (drvthis->config_get_string(drvthis->name, "lircrc", 0 , NULL) != NULL) {
strncpy(s, drvthis->config_get_string ( drvthis->name , "lircrc" , 0 , ""), sizeof(s)); strncpy(s, drvthis->config_get_string(drvthis->name, "lircrc", 0, ""), sizeof(s));
s[sizeof(s)-1] = '\0';
}
if (*s != '\0') { if (*s != '\0') {
s[sizeof(s)-1] = '\0';
p->lircrc = malloc(strlen(s) + 1); p->lircrc = malloc(strlen(s) + 1);
if( p->lircrc == NULL ) { if (p->lircrc == NULL) {
report( RPT_ERR, "%s: Could not allocate new memory.", drvthis->name ); report(RPT_ERR, "%s: Could not allocate new memory.", drvthis->name);
return -1; return -1;
} }
strcpy(p->lircrc, s); strcpy(p->lircrc, s);
report (RPT_INFO,"%s: Using lircrc: %s", drvthis->name, p->lircrc); report(RPT_INFO,"%s: Using lircrc: %s", drvthis->name, p->lircrc);
} }
else { else {
report (RPT_INFO,"%s: Using default lircrc: ~/.lircrc", drvthis->name); report(RPT_INFO,"%s: Using default lircrc: ~/.lircrc", drvthis->name);
} }
/* Get program identifier "prog=..." to be used */ /* Get program identifier "prog=..." to be used */
strncpy(s, drvthis->config_get_string ( drvthis->name , "Prog" , 0 , LIRCIN_DEF_PROG), sizeof(s)); strncpy(s, drvthis->config_get_string(drvthis->name, "Prog", 0, LIRCIN_DEF_PROG), sizeof(s));
p->prog = malloc(strlen(s) + 1); p->prog = malloc(strlen(s) + 1);
if( p->prog == NULL ) { if (p->prog == NULL) {
report( RPT_ERR, "%s: Could not allocate new memory.", drvthis->name ); report(RPT_ERR, "%s: Could not allocate new memory.", drvthis->name);
return -1; return -1;
} }
strcpy(p->prog, s); strcpy(p->prog, s);
report (RPT_INFO, "%s: Using prog: %s", drvthis->name, p->prog); report(RPT_INFO, "%s: Using prog: %s", drvthis->name, p->prog);
/* End of config file parsing */ /* End of config file parsing */
/* open socket to lirc */ /* open socket to lirc */
if (-1 == (p->lircin_fd = lirc_init (p->prog, LIRCIN_VERBOSELY))) { if (-1 == (p->lircin_fd = lirc_init(p->prog, LIRCIN_VERBOSELY))) {
report( RPT_ERR, "%s: Could not connect to lircd.", drvthis->name ); report(RPT_ERR, "%s: Could not connect to lircd.", drvthis->name);
lircin_close( drvthis); lircin_close(drvthis);
return -1; return -1;
} }
if (0 != lirc_readconfig (p->lircrc, &p->lircin_irconfig, NULL)) { if (0 != lirc_readconfig(p->lircrc, &p->lircin_irconfig, NULL)) {
report( RPT_ERR, "%s: lirc_readconfig() failed.", drvthis->name ); report(RPT_ERR, "%s: lirc_readconfig() failed.", drvthis->name);
lircin_close( drvthis); lircin_close(drvthis);
return -1; return -1;
} }
@@ -139,12 +140,13 @@ lircin_init (Driver *drvthis)
report(RPT_ERR, "%s: Unable to change lircin_fd(%d) to O_NONBLOCK: %s", report(RPT_ERR, "%s: Unable to change lircin_fd(%d) to O_NONBLOCK: %s",
drvthis->name, p->lircin_fd, strerror(errno)); drvthis->name, p->lircin_fd, strerror(errno));
lircin_close( drvthis); lircin_close(drvthis);
return -1; return -1;
} }
fcntl (p->lircin_fd, F_SETFD, FD_CLOEXEC); fcntl (p->lircin_fd, F_SETFD, FD_CLOEXEC);
report(RPT_DEBUG, "%s: init() done", drvthis->name);
return 0; return 0;
} }
@@ -192,11 +194,11 @@ lircin_get_key (Driver *drvthis)
char *code = NULL, *cmd = NULL; char *code = NULL, *cmd = NULL;
if ( (lirc_nextcode(&code) == 0) && (code != NULL) ) { if ((lirc_nextcode(&code) == 0) && (code != NULL)) {
if ( (lirc_code2char(p->lircin_irconfig,code,&cmd)==0) && (cmd!=NULL) ) { if ((lirc_code2char(p->lircin_irconfig,code,&cmd)==0) && (cmd!=NULL)) {
report (RPT_DEBUG, "%s: \"%s\"", drvthis->name, cmd); report(RPT_DEBUG, "%s: \"%s\"", drvthis->name, cmd);
} }
free (code); free(code);
} }
return cmd; return cmd;