int main(int argc, char * argv[]) { printf("Naga Epic Control v%d\n", VERSION); int retry = 0; int count = 0; while ((retry == 1 && count < 3) || count == 0) { count++; if (init() != 0) return 1; // Verbose mode if (scanArgs("-v", argv, argc)) { verbose = 1; } // Brightness control unsigned char brightness = 255; int tmp = scanArgs("-l", argv, argc); if (tmp) { if (tmp < argc - 1) tmp++; // Looking for number after -l brightness = atoi(argv[tmp]); // If number not found, looking for on or off if (strcmp(argv[tmp], "on") == 0) { brightness = 255; } else if (strcmp(argv[tmp], "off") == 0) { brightness = 0; } if (verbose) printf("[Debug] Brightness: %d\n", brightness); // Building command for mouse Lights_Brightness[10] = brightness; Lights_Brightness[11] = brightness ^ 3; sendcmd(Lights_Brightness); // Receiving and checking data if (recvcmd()[0] != 1) { printf("[Error] Command failed!\n"); retry = 1; } else { retry = 0; } } closeHandle(); } return 0; }
int main(int argc, char **argv) { Agraph_t* g; ingraph_state ig; scanArgs(argc,argv); newIngraph (&ig, Files, gread); while ((g = nextGraph(&ig)) != 0) { if (agisdirected(g)) process (g); else fprintf (stderr, "Graph %s in %s is undirected - ignored\n", agnameof(g), fileName(&ig)); agclose (g); } return 0; }
int main(int argc, char **argv) { XGCValues gcv; unsigned long gcm; int exact,left,right,device_index,i; XpmAttributes xpmattr; XpmColorSymbol xpmcsym[4]; elementinfo *e; scanArgs(argc, argv); initXWin(argc, argv); exact=left=right=device_index=-1; init_mixer(); cure=element; e=element; while(e) { if(!strcasecmp(e->info.eid.name,"Master Volume")) e->icon=0; else if(!strcasecmp(e->info.eid.name,"PCM Volume")) e->icon=1; else if(!strcasecmp(e->info.eid.name,"MIC Volume")) e->icon=5; else if(!strcasecmp(e->info.eid.name,"Line Volume")) e->icon=4; else if(!strcasecmp(e->info.eid.name,"CD Volume")) e->icon=3; else if(!strcasecmp(e->info.eid.name,"Synth Volume")) e->icon=2; else if(!strcasecmp(e->info.eid.name,"PC Speaker Volume")) e->icon=6; /* * bass = 7 * treble = 8 */ else e->icon=9; e=e->next; } gcm=GCGraphicsExposures; gcv.graphics_exposures=0; gc_gc=XCreateGC(d_display, w_root, gcm, &gcv); color[0]=mixColor(ledcolor, 0, backcolor, 100); color[1]=mixColor(ledcolor, 100, backcolor, 0); color[2]=mixColor(ledcolor, 60, backcolor, 40); color[3]=mixColor(ledcolor, 25, backcolor, 75); xpmcsym[0].name="back_color"; xpmcsym[0].value=NULL;; xpmcsym[0].pixel=color[0]; xpmcsym[1].name="led_color_high"; xpmcsym[1].value=NULL;; xpmcsym[1].pixel=color[1]; xpmcsym[2].name="led_color_med"; xpmcsym[2].value=NULL;; xpmcsym[2].pixel=color[2]; xpmcsym[3].name="led_color_low"; xpmcsym[3].value=NULL;; xpmcsym[3].pixel=color[3]; xpmattr.numsymbols=4; xpmattr.colorsymbols=xpmcsym; xpmattr.exactColors=0; xpmattr.closeness=40000; xpmattr.valuemask=XpmColorSymbols | XpmExactColors | XpmCloseness; XpmCreatePixmapFromData(d_display, w_root, wmmixer_xpm, &pm_main, &pm_mask, &xpmattr); XpmCreatePixmapFromData(d_display, w_root, tile_xpm, &pm_tile, NULL, &xpmattr); XpmCreatePixmapFromData(d_display, w_root, icons_xpm, &pm_icon, NULL, &xpmattr); pm_disp=XCreatePixmap(d_display, w_root, 64, 64, DefaultDepth(d_display, DefaultScreen(d_display))); if(wmaker || ushape || astep) XShapeCombineMask(d_display, w_activewin, ShapeBounding, winsize/2-32, winsize/2-32, pm_mask, ShapeSet); else XCopyArea(d_display, pm_tile, pm_disp, gc_gc, 0, 0, 64, 64, 0, 0); XSetClipMask(d_display, gc_gc, pm_mask); XCopyArea(d_display, pm_main, pm_disp, gc_gc, 0, 0, 64, 64, 0, 0); XSetClipMask(d_display, gc_gc, None); if(count==0) fprintf(stderr,"%s : Sorry, no supported channels found.\n", NAME); else { int done=0; XEvent xev; checkVol(); XSelectInput(d_display, w_activewin, ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask); XMapWindow(d_display, w_main); while(!done) { while(XPending(d_display)) { XNextEvent(d_display, &xev); switch(xev.type) { case Expose: repaint(); break; case ButtonPress: pressEvent(&xev.xbutton); break; case ButtonRelease: releaseEvent(&xev.xbutton); break; case MotionNotify: motionEvent(&xev.xmotion); break; case ClientMessage: if(xev.xclient.data.l[0]==deleteWin) done=1; break; } } if(btnstate & (BTNPREV | BTNNEXT)) { rpttimer++; if(rpttimer>=RPTINTERVAL) { if(btnstate & BTNNEXT) { cure=cure->next; if(!cure) cure=element; } else { cure=cure->prev; if(!cure) { elementinfo *e; e=element; while(e->next) e=e->next; cure=e; } } checkVol(); rpttimer=0; } } else checkVol(); XFlush(d_display); usleep(50000); } } XFreeGC(d_display, gc_gc); XFreePixmap(d_display, pm_main); XFreePixmap(d_display, pm_tile); XFreePixmap(d_display, pm_disp); XFreePixmap(d_display, pm_mask); XFreePixmap(d_display, pm_icon); freeXWin(); return 0; }
int main(int argc,char **argv) { FILE *fp,*gp; long p; int32_t be64; size_t len; size_t i; unsigned char *dta = NULL; genidl_read_config ("./genidl.conf"); if (scanArgs (--argc, ++argv) < 0) { show_usage (); } #ifdef REDIRECTOR doredirect(use_redirector); #endif for (i = 0; i < file_args_cnt; i++) { char s[1024], *idl_basename,*org_basename; int start, end; gp = fopen (file_args[i], "rb"); if (!gp) { fprintf (stderr, "Failed to open file ,%s'.\n", file_args[i]); continue; } p = genidl_ispe (gp, &be64); if (is_verbose) fprintf (stderr, "Found PE at %ld (%s bits)\n", p, !be64 ? "32" : "64"); end = genidl_pe_typelib_resource_count (gp); if (is_verbose) fprintf (stderr, "Contains %d typelib resource(s)\n", end); org_basename = get_idl_basename (file_args[i]); idl_basename = strdup (org_basename); if (strrchr (idl_basename, '.') != NULL) *strrchr (idl_basename, '.') = 0; for (start = 0; start < end; start++) { genidl_pe_typelib_resource_read (gp, start, &dta, &len); if (generate_header == 0) { if (end != 1) sprintf (s, "%s%s_%d.idl", idl_basename, basedumpname, start); else sprintf (s, "%s%s.idl", idl_basename, basedumpname); fp = fopen (s, "wb"); if (fp) { sTI2TypLib *tl = TI2_typlib_init (dta, (size_t) len); if (tl) { TI2_typlib_idl (fp, tl, org_basename); TI2_typlib_dest (tl); } if (show_dump_too) dumpInfo (fp, dta, len); fclose (fp); } } else if (generate_header == 1) { if (end != 1) sprintf (s, "%s%s_%d.h", idl_basename, basedumpname, start); else sprintf (s, "%s%s.h", idl_basename, basedumpname); fp = fopen (s, "wb"); if (fp) { sTI2TypLib *tl = TI2_typlib_init (dta, (size_t) len); if (tl) { TI2_typlib_hdr (fp, tl, org_basename); TI2_typlib_dest (tl); } fclose (fp); } } } free (idl_basename); free (org_basename); fclose (gp); } /* genidl_save_config_fp (stderr); */ genidl_save_config ("./genidl.conf"); return 0; }