void sysexit(int status) { // Print Process Termination Message // File Name char* name = thread_current()->name; char* token, *save_ptr; token = strtok_r(name, " ", &save_ptr); putbuf (token, strlen(token)); char* str1 = ": exit("; putbuf (str1, strlen(str1)); // ExitStatus char strstatus[32]; snprintf(strstatus, 32, "%d", status); putbuf (strstatus, strlen(strstatus)); char* str2 = ")\n"; putbuf (str2, strlen(str2)); // EXIT Child Processes if(thread_current()->numchild > 0) { struct list_elem * e; while (!list_empty(&thread_current()->child_list)) { e = list_pop_front(&thread_current()->child_list); struct childproc * childitem = list_entry (e, struct childproc, elem); if(!exit_remove(childitem->childid)) { list_push_back(&ignore_list, &childitem->elem); } else { free(childitem); } } } // Save exit status struct exitstatus * es = (struct exitstatus *) malloc(sizeof(struct exitstatus)); if(es != NULL && !ignore_remove(thread_current()->tid)) { es->avail = true; es->status = status; es->childid = thread_current()->tid; list_push_back(&exit_list, &es->elem); struct list_elem * e; for (e = list_begin (&waitproc_list); e != list_end (&waitproc_list); e = list_next (e)) { struct waitproc * item = list_entry (e, struct waitproc, elem); sema_up(&item->sema); } }
static void parse_arguments(int argn, char** argv) { int i, produced = 0, skip_symbols = 0; int dump_tags = 0, dontsave = 0; int showrenames = 0; char* dump_tag_prefix = ""; for (i=1; i<argn; i++) { if (argv[i][0] == '-') { if (!strcmp(argv[i], "--help")) { show_help(); exit(0); } else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-V")) { printf("sob version 0.2 beta Copyright (C) 2008 Kostas Michalopoulos\n"); printf("Visit http://www.badsectoracula.com/projects/sob/ for the latest version\n"); exit(0); } else if (!strcmp(argv[i], "--skip-symbols-file")) { skip_symbols = 1; if (!quiet) printf("sob: warning: skipping default symbols file\n"); } else if (!strcmp(argv[i], "--ignore-file") || !strcmp(argv[i], "-I")) { ignore_load_file(argv[++i]); } else if (!strcmp(argv[i], "--ignore") || !strcmp(argv[i], "-i")) { ignore_add(argv[++i]); } else if (!strcmp(argv[i], "--deignore") || !strcmp(argv[i], "-d")) { ignore_remove(argv[++i]); } else if (!strcmp(argv[i], "--quiet") || !strcmp(argv[i], "-q")) { quiet = 1; } else if (!strcmp(argv[i], "--output") || !strcmp(argv[i], "-o")) { outfile = argv[++i]; } else if (!strcmp(argv[i], "--dont-save")) { dontsave = 1; } else if (!strcmp(argv[i], "--show-renames")) { showrenames = 1; } else if (!strcmp(argv[i], "--obfuscate-mask")) { opt_parse_obfuscate_mask_string(argv[++i]); } else if (!strcmp(argv[i], "--dump-tags")) { dump_tags = 1; dump_tag_prefix = argv[++i]; } else { fprintf(stderr, "sob: unknown argument '%s'\n", argv[i]); } } else { char* swffile = outfile; swf_t* swf; if (!produced && !skip_symbols) { load_default_symbols(argv[0]); } produced = 1; swf = swf_read(argv[i]); if (!swf) { fprintf(stderr, "sob: failed to read swf file '%s'\n", argv[i]); exit(1); } if (!quiet) { printf("sob: processing %s swf '%s', version %i, body length %i\n", swf->compressed?"compressed":"uncompressed", swf->filename, swf->version, (int)swf->body_length); printf("sob: movie area=%i,%i -> %i,%i ", (int)(swf->rect.xmin/20), (int)(swf->rect.ymin/20), (int)(swf->rect.xmax/20), (int)(swf->rect.ymax/20)); printf("rate=%i.%i frames=%i tags=%i\n", (int)(swf->rate>>8), (int)(swf->rate&0xFF), (int)swf->frame_count, (int)swf->tag_count); } if (dump_tags) { dump_swf_tags(swf, dump_tag_prefix); swf_free(swf); exit(0); } begin_obfuscation(swf); if (showrenames) { int i; for (i=0; i<swf->renames; i++) { printf("sob: rename: '%s' => '%s'\n", swf->rename[i].old_name, swf->rename[i].new_name); } printf("sob: %i renames total\n", swf->renames); } if (!swffile) { swffile = malloc(strlen(argv[i]) + 15); sprintf(swffile, "obfuscated_%s", argv[i]); } if (!dontsave) { if (!swf_write(swf, swffile)) { fprintf(stderr, "sob: failed to write swf file '%s'\n", swffile); } else { if (!quiet) printf("sob: wrote swf file '%s' with body length %i\n", swffile, (int)swf->body_length); } } else { if (!quiet) printf("sob: pretending i wrote swf file '%s' with body length %i\n", swffile, (int)swf->body_length); } if (!outfile) free(swffile); outfile = NULL; swf_free(swf); } }