int main(int argc, char **argv){ FILE *file1, *file2; int i; int ret; int count; char **button; struct opspec op; struct rcspec rc1, rc2; unsigned char code1[RC_SIGCNT], code2[RC_SIGCNT]; char buf[80]; char *command; rc_getopt(argc, argv, &op); sprintf(buf, "%s/analyzer.conf", op.dir); file1 = fopen(buf, "r"); if(file1 == NULL){ fprintf(stderr, "fail to open %s. %s\n", buf, strerror(errno)); return -1; } sprintf(buf, "%s/received.conf", op.dir); file2 = fopen(buf, "r"); if(file2 == NULL){ fprintf(stderr, "fail to open %s. %s\n", buf, strerror(errno)); return -1; } count = rc_getbuttons(file1, &button); rc2.code1 = code1; rc2.code2 = code2; ret = daemon(0, 0); if(ret < 0){ fprintf(stderr, "daemon can't start.\n"); return -1; } while(1){ ret = rc_analyze(op.port, &rc2);//ir catch if(ret < 0)// occur some error during ir catch exit(EXIT_FAILURE); for(i = 0; i < count; i++){ ret = rc_getdata(file1, button[i], &rc1); if(ret < 0)// button not entry in analyzer.conf continue; if(rc_speccmp(&rc1, &rc2) == 0){ command = rc_getcommand(file2, button[i]); system(command);//if not entry, no operation break; } } } }
int main(int argc, char **argv){ char buf[80]; long son[RC_SIGLEN], soff[RC_SIGLEN]; uint8_t code1[RC_SIGCNT], code2[RC_SIGCNT]; allspec all; all.new_data = 0; all.memo_data = 0; all.not_saved = 0; all.serial = 0; all.ir.son = son; all.ir.soff = soff; all.rc.code1 = code1; all.rc.code2 = code2; rc_getopt(argc, argv, &all.op); Fl_Double_Window win(540, 232, "Fl_analyzer"); all.dist_t = new Histogram(10, 10, 160, 64, "T"); all.dist_1 = new Histogram(10, 84, 160, 64, "H"); all.dist_0 = new Histogram(10, 158, 160, 64, "L"); all.wave_l = new Waveform(180, 10, 160, 64, "Leader"); all.wave_1 = new Waveform(180, 84, 160, 64, "Signal High"); all.wave_0 = new Waveform(180, 158, 160, 64, "Signal Low"); all.report = new Fl_Text_Display(350, 10, 180, 138); all.report_buf = new Fl_Text_Buffer(); all.report->buffer(all.report_buf); all.report->textsize(10); all.btn_rec = new Fl_Button(350, 158, 56, 20, "@-5circle"); all.btn_rec->callback(cb_rec, &all); all.btn_rec->deactivate(); all.btn_play = new Fl_Button(412, 158, 56, 20, "@-2>"); all.btn_play->callback(cb_play, &all); all.btn_play->deactivate(); all.btn_memo = new Fl_Button(474, 158, 56, 20, "@-4+"); all.btn_memo->callback(cb_memo, &all); all.btn_memo->deactivate(); all.btn_save = new Fl_Button(350, 202, 56, 20, "Save"); all.btn_save->labelsize(12); all.btn_save->callback(cb_save, &all); all.btn_save->deactivate(); all.btn_exit = new Fl_Button(412, 202, 56, 20, "Exit"); all.btn_exit->labelsize(12); all.btn_exit->callback(cb_exit, &all); win.show(); all.btn_rec->activate(); return(Fl::run()); }
int main(int argc, char **argv){ int i; int fd; int ret; char buf[80]; FILE *file; int count; char **button; char *name; option_t op; irform_t ir; rc_getopt(argc, argv, &op); name = argv[argc - 1]; sprintf(buf, "%s/analyzer.conf", op.d); file = fopen(buf, "r"); if(file == NULL){ perror("fopen"); return -1; } rc_tassign(op.t); fd = rc_topen(op.t); count = rc_getbuttons(file, &button); for(i = 0; i < count; i++){ ret = strcmp(name, button[i]); if(ret == 0){ rc_getdata(file, name, &ir); rc_transmit(fd, &ir); free(ir.code1); if(ir.multi) free(ir.code2); break; } } if(ret != 0) printf("Button %s is not found.\n", name); for(i = 0; i < count; i++) free(button[i]); fclose(file); close(fd); return 0; }
extern int main(int argc, char *argv[], char *envp[]) { char *dashsee[2], *dollarzero, *null[1]; int c; initprint(); dashsee[0] = dashsee[1] = NULL; dollarzero = argv[0]; rc_pid = getpid(); dashell = (*argv[0] == '-'); /* Unix tradition */ while ((c = rc_getopt(argc, argv, "c:deiIlnopsvx")) != -1) switch (c) { case 'c': dashsee[0] = rc_optarg; goto quitopts; case 'd': dashdee = TRUE; break; case 'e': dashee = TRUE; break; case 'I': dashEYE = TRUE; interactive = FALSE; break; case 'i': dasheye = interactive = TRUE; break; case 'l': dashell = TRUE; break; case 'n': dashen = TRUE; break; case 'o': dashoh = TRUE; break; case 'p': dashpee = TRUE; break; case 's': dashess = TRUE; break; case 'v': dashvee = TRUE; break; case 'x': dashex = TRUE; break; case '?': exit(1); } quitopts: argv += rc_optind; /* use isatty() iff neither -i nor -I is set, and iff the input is not from a script or -c flags */ if (!dasheye && !dashEYE && dashsee[0] == NULL && (dashess || *argv == NULL)) interactive = isatty(0); if (!dashoh) { checkfd(0, rFrom); checkfd(1, rCreate); checkfd(2, rCreate); } initsignal(); inithash(); initparse(); assigndefault("ifs", " ", "\t", "\n", (void *)0); #ifdef DEFAULTPATH assigndefault("path", DEFAULTPATH, (void *)0); #endif assigndefault("pid", nprint("%d", rc_pid), (void *)0); assigndefault("prompt", "; ", "", (void *)0); assigndefault("version", VERSION, "$Release: @(#)" PACKAGE " " VERSION " " RELDATE " $", (void *)0); initenv(envp); initinput(); null[0] = NULL; starassign(dollarzero, null, FALSE); /* assign $0 to $* */ inithandler(); if (dashell) { char *rcrc; int fd; rcrc = concat(varlookup("home"), word("/.rcrc", NULL))->w; fd = rc_open(rcrc, rFrom); if (fd == -1) { if (errno != ENOENT) uerror(rcrc); } else { bool push_interactive; pushfd(fd); push_interactive = interactive; interactive = FALSE; doit(TRUE); interactive = push_interactive; close(fd); } } if (dashsee[0] != NULL || dashess) { /* input from -c or -s? */ if (*argv != NULL) starassign(dollarzero, argv, FALSE); if (dashess) pushfd(0); else pushstring(dashsee, TRUE); } else if (*argv != NULL) { /* else from a file? */ b_dot(--argv); rc_exit(getstatus()); } else { /* else stdin */ pushfd(0); } dasheye = FALSE; doit(TRUE); rc_exit(getstatus()); return 0; /* Never really reached. */ }
static void b_whatis(char **av) { bool ess, eff, vee, pee, bee; bool f, found; int i, ac, c; List *s; Node *n; char *e; for (rc_optind = ac = 0; av[ac] != NULL; ac++) ; /* count the arguments for getopt */ ess = eff = vee = pee = bee = FALSE; while ((c = rc_getopt(ac, av, "sfvpb")) != -1) switch (c) { default: set(FALSE); return; case 's': ess = TRUE; break; case 'f': eff = TRUE; break; case 'v': vee = TRUE; break; case 'p': pee = TRUE; break; case 'b': bee = TRUE; break; } av += rc_optind; if (*av == NULL) { if (vee|eff) whatare_all_vars(eff, vee); if (ess) whatare_all_signals(); if (bee) for (i = 0; i < arraysize(builtins); i++) fprint(1, "builtin %s\n", builtins[i].name); if (pee) fprint(2, "whatis -p: must specify argument\n"); if (show(FALSE)) /* no options? */ whatare_all_vars(TRUE, TRUE); set(TRUE); return; } found = TRUE; for (i = 0; av[i] != NULL; i++) { f = FALSE; errno = ENOENT; if (show(vee) && (s = varlookup(av[i])) != NULL) { f = TRUE; prettyprint_var(1, av[i], s); } if (((show(ess)&&issig(av[i])) || show(eff)) && (n = fnlookup(av[i])) != NULL) { f = TRUE; prettyprint_fn(1, av[i], n); } else if (show(bee) && isbuiltin(av[i]) != NULL) { f = TRUE; fprint(1, "builtin %s\n", av[i]); } else if (show(pee) && (e = which(av[i], FALSE)) != NULL) { f = TRUE; fprint(1, "%S\n", e); } if (!f) { found = FALSE; if (errno != ENOENT) uerror(av[i]); else fprint(2, "%s not found\n", av[i]); } } set(found); }