コード例 #1
0
ファイル: main.c プロジェクト: deglingo/los
/* main:
 */
gint main ( gint argc,
            gchar **argv )
{
  Parser *parser;
  FILE *infile = NULL;;
  gboolean close_infile;
  AST *ast;
  Dumper *dumper;
  gint a;
  gchar *srcdir = ".";
  gchar *incsubdir = "";
  /* CL_DEBUG("hello!"); */
  /* command line */
  for (a = 1; a < argc; a++)
    {
      if (!strcmp(argv[a], "-s"))
        {
          a++;
          ASSERT(a < argc);
          srcdir = argv[a];
        }
      else if (!strcmp(argv[a], "-u"))
        {
          a++;
          ASSERT(a < argc);
          incsubdir = argv[a];
        }
      else
        {
          ASSERT(!infile);
          if (!(infile = fopen(argv[a], "r")))
            CL_ERROR("could not open '%s' : %s", argv[a], strerror(errno));
          close_infile = TRUE;
        }
    }
  if (!infile)
    {
      infile = stdin;
      close_infile = FALSE;
    }
  /* parse */
  parser = parser_new();
  if (!(ast = parser_parse(parser, infile)))
    CL_ERROR("parse error");
  if (close_infile)
    fclose(infile);
  /* dump */
  dumper = dumper_new(srcdir, incsubdir);
  dumper_dump(dumper, ast);
  dumper_write(dumper);
  return 0;
}
コード例 #2
0
ファイル: friidump.c プロジェクト: MauPlay/friidump
int dologic (disc *d, progstats stats) {
	disc_type type_id;
	char *type, *game_id, *region, *maker_id, *maker, *version, *title, tmp[0x03E0 + 4 + 1];
	bool drive_supported;
	int out;
	dumper *dmp;
	u_int32_t current_sector;
	
	

				if (options.stop_unit) { //stop rotation, if requested
					fprintf (stderr, "Issuing STOP command... %s\n", (disc_stop_unit (d, false)) ? "OK" : "Failed");
					exit (1);
				}
				else disc_stop_unit(d, true); //else start rotation

				drive_supported = disc_get_drive_support_status (d);
				fprintf (stderr,
					"\n"
					"Drive information:\n"
					"----------------------------------------------------------------------\n"
					"Drive model........: %s\n"
					"Supported..........: %s\n", disc_get_drive_model_string (d), drive_supported ? "Yes" : "No"
				);

				init_range(d, options.sec_disc, options.sec_mem);

				if (!(disc_set_read_method (d, options.dump_method)))
					exit (2);

				if (options.command!=-1) fprintf (stderr, 
					"Command............: %d (forced)\n", disc_get_command(d));
				else fprintf (stderr, 
					"Command............: %d\n", disc_get_command(d));
				options.dump_method=disc_get_method(d);
				if (disc_get_def_method(d)!=options.dump_method) fprintf (stderr, 
					"Method.............: %d (forced)\n", options.dump_method);
				else fprintf (stderr, 
					"Method.............: %d\n", options.dump_method);
				if ((options.dump_method==0) 
				|| (options.dump_method==1) || (options.dump_method==2) || (options.dump_method==3)
				|| (options.dump_method==4) || (options.dump_method==5) || (options.dump_method==6)
				){
					fprintf (stderr, 
					"Requested sectors..: %d\n", disc_get_sec_disc(d));
					fprintf (stderr, 
					"Expected sectors...: %d\n", disc_get_sec_mem(d));
				}

				fprintf (stderr, "\nPress Ctrl+C at any time to terminate\n");
				fprintf (stderr, "\nRetrieving disc seeds, this might take a while... ");

				//set speed for 1st time
				if (options.speed != -1) disc_set_speed(d, options.speed * 177);
				if (options.speed != -1) disc_set_streaming_speed(d, options.speed * 177);
//				disc_set_speed(d, 0xffff);

				if (!disc_init (d, options.disctype, options.sectors_no)) {
					fprintf (stderr, "Failed\n");
					out = false;
				} else {
					fprintf (stderr, "OK\n");
					disc_get_type (d, &type_id, &type);
					disc_get_gameid (d, &game_id);
					disc_get_region (d, NULL, &region);
					disc_get_maker (d, &maker_id, &maker);
					disc_get_version (d, NULL, &version);
					disc_get_title (d, &title);
					fprintf (stderr, 
						"\n"
						"Disc information:\n"
						"----------------------------------------------------------------------\n");

					if (options.disctype!=-1) fprintf (stderr, 
						"Disc type..........: %s (forced)\n", type);
					else fprintf (stderr, 
						"Disc type..........: %s\n", type);
					if (options.sectors_no!=-1) fprintf (stderr, 
						"Disc size..........: %d (forced)\n", disc_get_sectors_no(d));
					else fprintf (stderr, 
						"Disc size..........: %d\n", disc_get_sectors_no(d));

					if (disc_get_layerbreak(d)>0 && type_id==DISC_TYPE_DVD) fprintf (stderr, 
						"Layer break........: %d\n", disc_get_layerbreak(d));

					if ((type_id==DISC_TYPE_GAMECUBE) || (type_id==DISC_TYPE_WII) || (type_id==DISC_TYPE_WII_DL)) fprintf (stderr, 
						"Game ID............: %s\n"
						"Region.............: %s\n"
						"Maker..............: %s - %s\n"
						"Version............: %s\n"
						"Game title.........: %s\n", game_id, region, maker_id, maker, version, title
					);

					if (type_id == DISC_TYPE_WII || type_id == DISC_TYPE_WII_DL)
						fprintf (stderr, "Contains update....: %s\n" , disc_get_update (d) ? "Yes" : "No");
					fprintf (stderr, "\n");
					
					disc_set_unscrambling (d, !options.no_unscrambling);

					unscrambler_set_disctype (type_id);

					if (options.autodump) {
						snprintf (tmp, sizeof (tmp), "%s.iso", title);
						my_strdup (options.iso_out, tmp);
					}

					//set speed 2nd time after rotation is started and some sectors read
					if (options.speed != -1) disc_set_streaming_speed(d, options.speed * 177);
					if (options.speed != -1) disc_set_speed(d, options.speed * 177);

					/* If at least an output file was specified, proceed dumping, otherwise stop here */
					if (options.raw_out || options.iso_out) {
						if (options.raw_out)
							fprintf (stderr, "Writing to file \"%s\" in raw format\n", options.raw_out);
						if (options.iso_out)
							fprintf (stderr, "Writing to file \"%s\" in ISO format\n", options.iso_out);
						fprintf (stderr, "\n");

						dmp = dumper_new (d);

						dumper_set_hashing (dmp, !options.no_hashing);
						dumper_set_flushing (dmp, !options.no_flushing);

						if (!dumper_set_raw_output_file (dmp, options.raw_out, options.resume)) {
							fprintf (stderr, "Cannot setup raw output file\n");
						} else if (!dumper_set_iso_output_file (dmp, options.iso_out, options.resume)) {
							fprintf (stderr, "Cannot setup ISO output file\n");
						} else if (!dumper_prepare (dmp)) {
							fprintf (stderr, "Cannot prepare dumper");
						} else {
//	 						fprintf (stderr, "Starting dump process from sector %u...\n", dmp -> start_sector);
//		 					opdd.start_sector = options.start_sector;

							if (options.gui)
								dumper_set_progress_callback (dmp, (progress_func) progress_for_guis, &stats);
							else
								dumper_set_progress_callback (dmp, (progress_func) progress, &stats);

							if (dumper_dump (dmp, &current_sector)) {
								fprintf (stderr, "Dump completed successfully!\n");
								if (!options.no_hashing && options.raw_out)
									fprintf (stderr,
										"Raw image hashes:\n"
										"CRC32...: %s\n"
										//"MD4.....: %s\n"
										"MD5.....: %s\n"
										"SHA-1...: %s\n"
										/*"ED2K....: %s\n"*/,
										dumper_get_raw_crc32 (dmp), /*dumper_get_raw_md4 (dmp),*/ dumper_get_raw_md5 (dmp),
										dumper_get_raw_sha1 (dmp)/*, dumper_get_raw_ed2k (dmp)*/
									);
								if (!options.no_hashing && options.iso_out)
									fprintf (stderr,
										"ISO image hashes:\n"
										"CRC32...: %s\n"
										//"MD4.....: %s\n"
										"MD5.....: %s\n"
										"SHA-1...: %s\n"
										/*"ED2K....: %s\n"*/,
										dumper_get_iso_crc32 (dmp), /*dumper_get_iso_md4 (dmp),*/ dumper_get_iso_md5 (dmp),
										dumper_get_iso_sha1 (dmp)/*, dumper_get_iso_ed2k (dmp)*/
									);

								out = true;
								disc_stop_unit (d, 0);
							} else {
								fprintf (stderr, "\nDump failed at sectors: %u..%u\n", current_sector, current_sector+15);
								out = false;
								//disc_stop_unit (d, 0);
							}
						}

						dmp = dumper_destroy (dmp);
					} else {
						fprintf (stderr, "No output file for dumping specified, please take a look at the -i, -r and -a options\n");
					}
				}				
	return out;
}