void end_lesson(int min,int sec,int eff,int err, int speed) { int change=0,y,x; show_summary(min, sec, eff, err, speed); draw_3dbox(260,220,320,240,15); settextstyle(0,0,1); color_text(280,227,"Ok",3); showMouse(); while(1) { while(1) { x=getMouseX(); /* get the mouse position*/ y=getMouseY(); if(x>=260&&x<=320&&y>=220&&y<=240 && !change) { change = 1; settextstyle(0,0,1); hideMouse(); draw_3dbox(260,220,320,240,6); /* change the color of the box*/ /* change the text color*/ color_text(280,227,"Ok",15); /*cursor on yes*/ showMouse(); } if((x<=260||x>=320||y<=220||y>=240)&& change) { change = 0; hideMouse(); draw_3dbox(260,220,320,240,15); /* when mouse moves away change the color to normal one*/ color_text(280,227,"Ok",3); showMouse(); /*cursor on yes/no*/ } if(mouseClicked()) { x=getMouseX(); /*get the position where mouse is clicked*/ y=getMouseY(); while(1) if(mouseReleased()) /* get the position*/ break; /* where mouse is clicked*/ break; /* and released */ } }/*end of while 2 which changes color of button*/ /*check the position of mouse clicked*/ if(x>=260&&x<=320&&y>=220&&y<=240) // back { hideMouse(); up_down_button(260,220,320,240,280,227,19,15,15,6); break; } }/*end of while 1*/ }
static void normal_exit(void) { if (options.summary) show_summary(); if (options.output) { fclose(options.output); options.output = NULL; } }
static void cb_complete_run (CutRunContext *run_context, gboolean success, CutPDFReport *report) { #ifdef HAVE_GOFFICE cairo_save(report->context); draw_chart(report, run_context); cairo_restore(report->context); cairo_show_page(report->context); #endif init_page(report->context); show_summary(report, run_context); }
static void normal_exit(void) { output_line(0, 0); if (options.summary) { show_summary(); } if (options.output) { fclose(options.output); options.output = NULL; } #ifdef HAVE_PYTHON Py_Finalize(); #endif }
int main (int argc, char *argv[]) { int c = -1, option_index = 0, action = 0, i = 0, rval = 0; slapt_list_t *names = slapt_init_list (); slapt_src_config *config = NULL; slapt_src_slackbuild_list *sbs = NULL; slapt_src_slackbuild_list *remote_sbs = NULL; slapt_pkg_list_t *installed = NULL; SLAPT_BOOL_T prompt = SLAPT_TRUE, do_dep = SLAPT_TRUE, simulate = SLAPT_FALSE; char *config_file = NULL, *postcmd = NULL; static struct option long_options[] = { {"version", no_argument, 0, VERSION_OPT}, {"help", no_argument, 0, HELP_OPT}, {"update", no_argument, 0, UPDATE_OPT}, {"list", no_argument, 0, LIST_OPT}, {"clean", no_argument, 0, CLEAN_OPT}, {"e", no_argument, 0, CLEAN_OPT}, {"search", required_argument, 0, SEARCH_OPT}, {"s", required_argument, 0, SEARCH_OPT}, {"show", required_argument, 0, SHOW_OPT}, {"w", required_argument, 0, SHOW_OPT}, {"fetch", required_argument, 0, FETCH_OPT}, {"build", required_argument, 0, BUILD_OPT}, {"install", required_argument, 0, INSTALL_OPT}, {"yes", no_argument, 0, YES_OPT}, {"simulate", no_argument, 0, SIMULATE_OPT}, {"t", no_argument, 0, SIMULATE_OPT}, {"no-dep", no_argument, 0, NODEP_OPT}, {"config", required_argument, 0, CONFIG_OPT}, {"c", required_argument, 0, CONFIG_OPT}, {"postprocess", required_argument, 0, POSTCMD_OPT}, {0, 0, 0, 0} }; /* initialization */ setbuf (stdout, NULL); #ifdef ENABLE_NLS setlocale (LC_ALL,""); textdomain (GETTEXT_PACKAGE); #endif #ifdef SLAPT_HAS_GPGME gpgme_check_version (NULL); #ifdef ENABLE_NLS gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); #endif #endif curl_global_init (CURL_GLOBAL_ALL); uname (&uname_v); /* stop early */ if (argc < 2) { help (); exit (EXIT_SUCCESS); } while ( (c = getopt_long_only (argc, argv, "", long_options, &option_index)) != -1) { switch (c) { case HELP_OPT: help (); break; case VERSION_OPT: version (); break; case UPDATE_OPT: action = UPDATE_OPT; break; case LIST_OPT: action = LIST_OPT; break; case CLEAN_OPT: action = CLEAN_OPT; break; case FETCH_OPT: action = FETCH_OPT; slapt_add_list_item (names, optarg); break; case SEARCH_OPT: action = SEARCH_OPT; slapt_add_list_item (names, optarg); break; case SHOW_OPT: action = SHOW_OPT; slapt_add_list_item (names, optarg); break; case BUILD_OPT: action = BUILD_OPT; slapt_add_list_item (names, optarg); break; case INSTALL_OPT: action = INSTALL_OPT; slapt_add_list_item (names, optarg); break; case YES_OPT: prompt = SLAPT_FALSE; break; case SIMULATE_OPT: simulate = SLAPT_TRUE; break; case NODEP_OPT: do_dep = SLAPT_FALSE; break; case CONFIG_OPT: config_file = strdup (optarg); break; case POSTCMD_OPT: postcmd = strdup (optarg); break; default: help (); exit (EXIT_FAILURE); } } /* add extra arguments */ while (optind < argc) { slapt_add_list_item (names, argv[optind]); ++optind; } if (config_file != NULL) config = slapt_src_read_config (config_file); else config = slapt_src_read_config (SLAPT_SRC_RC); if (config == NULL) { fprintf (stderr, gettext ("Failed to read %s\n"), SLAPT_SRC_RC); exit (EXIT_FAILURE); } /* honor command line option */ config->do_dep = do_dep; config->postcmd = postcmd; /* to be freed in slapt_src_config_free */ init_builddir (config); if ( (chdir (config->builddir)) != 0) { perror (gettext ("Failed to chdir to build directory")); exit (EXIT_FAILURE); } /* setup, fetch, and other preperation steps */ switch (action) { case LIST_OPT: case SEARCH_OPT: case SHOW_OPT: remote_sbs = slapt_src_get_available_slackbuilds (); break; case FETCH_OPT: case BUILD_OPT: case INSTALL_OPT: remote_sbs = slapt_src_get_available_slackbuilds (); installed = slapt_get_installed_pkgs (); /* convert all names to slackbuilds */ if (names->count > 0) { sbs = slapt_src_names_to_slackbuilds (config, remote_sbs, names, installed); if (sbs == NULL || sbs->count == 0) { printf (gettext ("Unable to find all specified slackbuilds.\n")); exit (EXIT_FAILURE); } } /* provide summary */ if (!simulate) action = show_summary (sbs, names, action, prompt); break; } /* now, actually do what was requested */ switch (action) { case UPDATE_OPT: rval = slapt_src_update_slackbuild_cache (config); break; case FETCH_OPT: for (i = 0; i < sbs->count; i++) { if (simulate) { printf (gettext ("FETCH: %s\n"), sbs->slackbuilds[i]->name); continue; } else slapt_src_fetch_slackbuild (config, sbs->slackbuilds[i]); } break; case BUILD_OPT: for (i = 0; i < sbs->count; i++) { slapt_src_slackbuild *sb = sbs->slackbuilds[i]; int r = 0, nv_len = strlen (sb->name) + strlen (sb->version) + 2; char *namever = slapt_malloc (sizeof *namever * nv_len); r = snprintf (namever, nv_len, "%s:%s", sb->name, sb->version); if (r+1 != nv_len) exit (EXIT_FAILURE); if (simulate) { printf (gettext ("BUILD: %s\n"), sb->name); free (namever); continue; } slapt_src_fetch_slackbuild (config, sb); slapt_src_build_slackbuild (config, sb); /* XXX we assume if we didn't request the slackbuild, then it is a dependency, and needs to be installed */ if (slapt_search_list (names, sb->name) == NULL && slapt_search_list (names, namever) == NULL) slapt_src_install_slackbuild (config, sbs->slackbuilds[i]); free (namever); } break; case INSTALL_OPT: for (i = 0; i < sbs->count; i++) { slapt_src_slackbuild *sb = sbs->slackbuilds[i]; if (simulate) { printf (gettext ("INSTALL: %s\n"), sb->name); continue; } slapt_src_fetch_slackbuild (config, sb); slapt_src_build_slackbuild (config, sb); slapt_src_install_slackbuild (config, sb); } break; case SEARCH_OPT: { slapt_src_slackbuild_list *search = slapt_src_search_slackbuild_cache (remote_sbs, names); for (i = 0; i < search->count; i++) { slapt_src_slackbuild *sb = search->slackbuilds[i]; printf ("%s:%s - %s\n", sb->name, sb->version, sb->short_desc != NULL ? sb->short_desc : "" ); } slapt_src_slackbuild_list_free (search); } break; case LIST_OPT: for (i = 0; i < remote_sbs->count; i++) { slapt_src_slackbuild *sb = remote_sbs->slackbuilds[i]; printf ("%s:%s - %s\n", sb->name, sb->version, sb->short_desc != NULL ? sb->short_desc : "" ); } break; case SHOW_OPT: { int c; for (i = 0; i < names->count; i++) { slapt_src_slackbuild *sb = NULL; slapt_list_t *parts = slapt_parse_delimited_list (names->items[i], ':'); const char *name = parts->items[0]; const char *ver = NULL; if (parts->count > 1) ver = parts->items[1]; sb = slapt_src_get_slackbuild (remote_sbs, name, ver); if (sb != NULL) { printf (gettext ("SlackBuild Name: %s\n"), sb->name); printf (gettext ("SlackBuild Version: %s\n"), sb->version); printf (gettext ("SlackBuild Category: %s\n"), sb->location); printf (gettext ("SlackBuild Description: %s\n"), sb->short_desc != NULL ? sb->short_desc : ""); printf (gettext ("SlackBuild Files:\n")); for (c = 0; c < sb->files->count; c++) { printf (" %s\n", sb->files->items[c]); } if (sb->requires != NULL) printf (gettext ("SlackBuild Requires: %s\n"), sb->requires); if (i+1 != names->count) printf ("\n"); /* slapt_src_slackbuild_free (sb); NO FREE */ } slapt_free_list (parts); } } break; case CLEAN_OPT: clean (config); break; } if (names != NULL) slapt_free_list (names); if (sbs != NULL) slapt_src_slackbuild_list_free (sbs); if (remote_sbs != NULL) slapt_src_slackbuild_list_free (remote_sbs); if (installed != NULL) slapt_free_pkg_list (installed); if (config_file != NULL) free (config_file); slapt_src_config_free (config); return rval; }
int continue_close(int min, int sec, int eff, int err, int speed) { unsigned int sum; void* summary; int x,y,j=-2,pr=-1,i; // sum=imagesize(200,90,380,250); sum=imagesize(170,90,410,250); summary= malloc(sum); getimage(170,90,410,250,summary); show_summary(min,sec,eff,err,speed); draw_3dbox(210,220,280,240,15); draw_3dbox(305,220,370,240,15); settextstyle(0,0,1); color_text(214,227,"Continue",3); color_text(317,227,"Close",3); showMouse(); while(1) { while(1) { x=getMouseX(); /* get the mouse position*/ y=getMouseY(); for(i=0;i<2;i++) { if(x>=210+(i*95)&&x<=280+(i*90)&&y>=220&&y<=240 ) { j=i; /* check the position*/ break; } } settextstyle(0,0,1); if(j>=0&&j<2&& j!=pr) { hideMouse(); draw_3dbox(210+(j*95),220,280+(j*90),240,6); /* change the color of the box*/ /* change the text color*/ if(j) color_text(317,227,"Close",15); /*cursor on no*/ else if(!j) color_text(214,227,"Continue",15); /*cursor on yes*/ showMouse(); } if(j!=pr && pr>=0 && pr<2) { hideMouse(); draw_3dbox(210+(pr*95),220,280+(pr*90),240,15); /* when mouse moves away change the color to normal one*/ if(pr) color_text(317,227,"Close",3); else if(!pr) color_text(214,227,"Continue",3); showMouse(); /*cursor on yes/no*/ } pr = j; /* keeps the current postion to use next time as previous*/ j = -1; if(mouseClicked()) { x=getMouseX(); /*get the position where mouse is clicked*/ y=getMouseY(); break; } }/*end of while 2 which changes color of button*/ /*check the position of mouse clicked*/ if(x>=210&&x<=280&&y>=220&&y<=240) // continue { hideMouse(); up_down_button(210,220,280,240,214,227,18,15,15,6); putimage(170,90,summary,COPY_PUT); //showMouse(); /*if clicked on back return to previous stage*/ free(summary); return 0; } else if(x>=305&&x<=370&&y>=220&&y<=240) { hideMouse(); up_down_button(305,220,370,240,317,227,23,15,15,6); free(summary); //if clicked on close exit from the lesson time_interval=0, min=0, sec=0, minute=0,second=0,eff=0, err=0, speed=0; pressed=0, correct= 0, wrong= 0, cpm=0, correction=0; showMouse(); return 1; } }/*end of while 1*/ }
int main(int argc, char *argv[]) { struct timeval start_time, end_time; struct sigaction handler; double seconds,total_time; // for timers bool lrzcat = false; int c, i; int hours,minutes; extern int optind; char *eptr; /* for environment */ control = &base_control; initialise_control(control); if (strstr(argv[0], "lrunzip")) control->flags |= FLAG_DECOMPRESS; else if (strstr(argv[0], "lrzcat")) { control->flags |= FLAG_DECOMPRESS | FLAG_STDOUT; lrzcat = true; } /* generate crc table */ CrcGenerateTable(); /* Get Preloaded Defaults from lrzip.conf * Look in ., $HOME/.lrzip/, /etc/lrzip. * If LRZIP=NOCONFIG is set, then ignore config */ eptr = getenv("LRZIP"); if (eptr == NULL) read_config(control); else if (!strstr(eptr,"NOCONFIG")) read_config(control); while ((c = getopt_long(argc, argv, "bcdDefghHiklL:nN:o:O:p:qS:tTUm:vVw:z?", long_options, &i)) != -1) { switch (c) { case 'b': if (control->flags & FLAG_NOT_LZMA) failure("Can only use one of -l, -b, -g, -z or -n\n"); control->flags |= FLAG_BZIP2_COMPRESS; break; case 'c': control->flags |= FLAG_CHECK; control->flags |= FLAG_HASH; break; case 'd': control->flags |= FLAG_DECOMPRESS; break; case 'D': control->flags &= ~FLAG_KEEP_FILES; break; case 'e': control->flags |= FLAG_ENCRYPT; break; case 'f': control->flags |= FLAG_FORCE_REPLACE; break; case 'g': if (control->flags & FLAG_NOT_LZMA) failure("Can only use one of -l, -b, -g, -z or -n\n"); control->flags |= FLAG_ZLIB_COMPRESS; break; case 'h': case '?': usage(); return -1; case 'H': control->flags |= FLAG_HASH; break; case 'i': control->flags |= FLAG_INFO; break; case 'k': control->flags |= FLAG_KEEP_BROKEN; break; case 'l': if (control->flags & FLAG_NOT_LZMA) failure("Can only use one of -l, -b, -g, -z or -n\n"); control->flags |= FLAG_LZO_COMPRESS; break; case 'L': control->compression_level = atoi(optarg); if (control->compression_level < 1 || control->compression_level > 9) failure("Invalid compression level (must be 1-9)\n"); break; case 'm': control->ramsize = atol(optarg) * 1024 * 1024 * 100; break; case 'n': if (control->flags & FLAG_NOT_LZMA) failure("Can only use one of -l, -b, -g, -z or -n\n"); control->flags |= FLAG_NO_COMPRESS; break; case 'N': control->nice_val = atoi(optarg); if (control->nice_val < -20 || control->nice_val > 19) failure("Invalid nice value (must be -20..19)\n"); break; case 'o': if (control->outdir) failure("Cannot have -o and -O together\n"); if (unlikely(STDOUT)) failure("Cannot specify an output filename when outputting to stdout\n"); control->outname = optarg; control->suffix = ""; break; case 'O': if (control->outname) /* can't mix -o and -O */ failure("Cannot have options -o and -O together\n"); if (unlikely(STDOUT)) failure("Cannot specify an output directory when outputting to stdout\n"); control->outdir = malloc(strlen(optarg) + 2); if (control->outdir == NULL) fatal("Failed to allocate for outdir\n"); strcpy(control->outdir,optarg); if (strcmp(optarg+strlen(optarg) - 1, "/")) /* need a trailing slash */ strcat(control->outdir, "/"); break; case 'p': control->threads = atoi(optarg); if (control->threads < 1) failure("Must have at least one thread\n"); break; case 'q': control->flags &= ~FLAG_SHOW_PROGRESS; break; case 'S': if (control->outname) failure("Specified output filename already, can't specify an extension.\n"); if (unlikely(STDOUT)) failure("Cannot specify a filename suffix when outputting to stdout\n"); control->suffix = optarg; break; case 't': if (control->outname) failure("Cannot specify an output file name when just testing.\n"); if (!KEEP_FILES) failure("Doubt that you want to delete a file when just testing.\n"); control->flags |= FLAG_TEST_ONLY; break; case 'T': control->flags &= ~FLAG_THRESHOLD; break; case 'U': control->flags |= FLAG_UNLIMITED; break; case 'v': /* set verbosity flag */ if (!(control->flags & FLAG_VERBOSITY) && !(control->flags & FLAG_VERBOSITY_MAX)) control->flags |= FLAG_VERBOSITY; else if ((control->flags & FLAG_VERBOSITY)) { control->flags &= ~FLAG_VERBOSITY; control->flags |= FLAG_VERBOSITY_MAX; } break; case 'V': print_output("lrzip version %s\n", PACKAGE_VERSION); exit(0); break; case 'w': control->window = atol(optarg); break; case 'z': if (control->flags & FLAG_NOT_LZMA) failure("Can only use one of -l, -b, -g, -z or -n\n"); control->flags |= FLAG_ZPAQ_COMPRESS; break; } } argc -= optind; argv += optind; if (control->outname && argc > 1) failure("Cannot specify output filename with more than 1 file\n"); if (VERBOSE && !SHOW_PROGRESS) { print_err("Cannot have -v and -q options. -v wins.\n"); control->flags |= FLAG_SHOW_PROGRESS; } if (UNLIMITED && control->window) { print_err("If -U used, cannot specify a window size with -w.\n"); control->window = 0; } if (argc < 1) control->flags |= FLAG_STDIN; if (UNLIMITED && STDIN) { print_err("Cannot have -U and stdin, unlimited mode disabled.\n"); control->flags &= ~FLAG_UNLIMITED; } setup_overhead(control); /* Set the main nice value to half that of the backend threads since * the rzip stage is usually the rate limiting step */ if (control->nice_val > 0 && !NO_COMPRESS) { if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val / 2) == -1)) print_err("Warning, unable to set nice value\n"); } else { if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val) == -1)) print_err("Warning, unable to set nice value\n"); } /* One extra iteration for the case of no parameters means we will default to stdin/out */ for (i = 0; i <= argc; i++) { if (i < argc) control->infile = argv[i]; else if (!(i == 0 && STDIN)) break; if (control->infile) { if ((strcmp(control->infile, "-") == 0)) control->flags |= FLAG_STDIN; else { struct stat infile_stat; stat(control->infile, &infile_stat); if (unlikely(S_ISDIR(infile_stat.st_mode))) failure("lrzip only works directly on FILES.\n" "Use lrztar or pipe through tar for compressing directories.\n"); } } if (INFO && STDIN) failure("Will not get file info from STDIN\n"); if ((control->outname && (strcmp(control->outname, "-") == 0)) || /* If no output filename is specified, and we're using * stdin, use stdout */ (!control->outname && STDIN) || lrzcat ) { control->flags |= FLAG_STDOUT; control->outFILE = stdout; control->msgout = stderr; register_outputfile(control, control->msgout); } if (lrzcat) { control->msgout = stderr; control->outFILE = stdout; register_outputfile(control, control->msgout); } if (!STDOUT) { control->msgout = stdout; register_outputfile(control, control->msgout); } if (STDIN) control->inFILE = stdin; /* Implement signal handler only once flags are set */ sigemptyset(&handler.sa_mask); handler.sa_flags = 0; handler.sa_handler = &sighandler; sigaction(SIGTERM, &handler, 0); sigaction(SIGINT, &handler, 0); if (!FORCE_REPLACE) { if (STDIN && isatty(fileno((FILE *)stdin))) { print_err("Will not read stdin from a terminal. Use -f to override.\n"); usage(); exit (1); } if (!TEST_ONLY && STDOUT && isatty(fileno((FILE *)stdout))) { print_err("Will not write stdout to a terminal. Use -f to override.\n"); usage(); exit (1); } } if (CHECK_FILE) { if (!DECOMPRESS) { print_err("Can only check file written on decompression.\n"); control->flags &= ~FLAG_CHECK; } else if (STDOUT) { print_err("Can't check file written when writing to stdout. Checking disabled.\n"); control->flags &= ~FLAG_CHECK; } } setup_ram(control); show_summary(); gettimeofday(&start_time, NULL); if (unlikely(STDIN && ENCRYPT)) failure("Unable to work from STDIN while reading password\n"); memcpy(&local_control, &base_control, sizeof(rzip_control)); if (DECOMPRESS || TEST_ONLY) decompress_file(&local_control); else if (INFO) get_fileinfo(&local_control); else compress_file(&local_control); /* compute total time */ gettimeofday(&end_time, NULL); total_time = (end_time.tv_sec + (double)end_time.tv_usec / 1000000) - (start_time.tv_sec + (double)start_time.tv_usec / 1000000); hours = (int)total_time / 3600; minutes = (int)(total_time / 60) % 60; seconds = total_time - hours * 3600 - minutes * 60; if (!INFO) print_progress("Total time: %02d:%02d:%05.2f\n", hours, minutes, seconds); } return 0; }