static int read_next_record(QSP_ARG_DECL void * raw_pdp, int station ) { char data_string[6][32]; int i; int c, expect_c; fprintf(stderr,"read_next_record 0x%lx\n",(long)raw_pdp); /* read any leading spaces */ do { c=good_polh_char(); } while( isspace(c) ); while( c != '0' ){ sprintf(ERROR_STRING, "read 0x%x, expected '0' in first header position",c); warn(ERROR_STRING); c=good_polh_char(); } c=good_polh_char(); expect_c = '1' + curr_station_idx; while( c != expect_c ){ sprintf(ERROR_STRING, "read '%c' (0x%x), expected '%c' in second header position", c,c,expect_c); warn(ERROR_STRING); c=good_polh_char(); } c=good_polh_char(); if( c != 'D' && c != 'Y' ){ sprintf(ERROR_STRING, "read '%c' (0x%x), expected 'D' or 'Y' in third header position",c,c); //warn(ERROR_STRING); advise(ERROR_STRING); c=good_polh_char(); sprintf(ERROR_STRING, "read '%c' (0x%x) after unexpected character",c,c); //warn(ERROR_STRING); advise(ERROR_STRING); } /* BUG don't assume 6 data - use format? */ for(i=0;i<6;i++){ read_data_string(data_string[i]); // advise(data_string[i]); /* raw_pdp doesn't indicate the format? */ } // BUG how do we know that these are the data that were requested??? assign_var("polh_x_pos",data_string[0]); assign_var("polh_y_pos",data_string[1]); assign_var("polh_z_pos",data_string[2]); assign_var("polh_x_rot",data_string[3]); assign_var("polh_y_rot",data_string[4]); assign_var("polh_z_rot",data_string[5]); return(0); }
static int conf_add_connection(const char *rel, const char *full) { char buf[PATH_MAX]; Connection *c; c = connections + nconnections; connection_init(c); c->name = xstrdup(rel); make_path(buf, full, "command"); c->command = read_data_string(buf); if(!c->command) { parse_error(buf,"cannot read command data",xsyserr()); return -1; } make_path(buf, full, "update"); if(read_data_list(buf, conf_add_update, c) < 0) { if (errno != ENOENT) { parse_error(buf,"unable to read update data",xsyserr()); return -1; } conf_add_update(c, "image"); conf_add_update(c, "beep"); } make_path(buf, full, "reset"); if(read_data_list(buf, conf_add_reset, c) < 0) { if (errno != ENOENT) { parse_error(buf,"unable to read reset data",xsyserr()); return -1; } conf_add_reset(c, "image-reset"); } make_path(buf, full, "folders"); if(read_data_list(buf, conf_add_folder, c) < 0) { if (errno != ENOENT) { parse_error(buf,"unable to read folder data",xsyserr()); return -1; } conf_add_folder(c, "INBOX"); } make_path(buf, full, "secret"); if(!dir_is_protected(buf)) { parse_error(buf,"\"secret\" directory has loose permissions",0); return -1; } nconnections++; return 0; }
int conf_read_options(void) { char buf[PATH_MAX]; char *data; make_path(buf, conf_base, "frequency"); data = read_data_string(buf); if(data) { poll_frequency = atoi(data); free(data); } return 0; }
char *conf_read_data(const char *tag, const char *item) { char buf[PATH_MAX]; char *d; make_path(buf, conf_base, "connections"); make_path(buf, buf, tag); make_path(buf, buf, item); d = read_data_string(buf); if(d) strip_newlines(d); return d; }
static int conf_add_action(const char *rel, const char *full) { char *cmd; cmd = read_data_string(full); if(!cmd) { parse_error(full,"unable to read data",xsyserr()); return -1; } action_add(ActionShell, rel, cmd); free(cmd); return 0; }