예제 #1
0
파일: dlc5.c 프로젝트: dihmuzikien/ECE473
static int
dlc5_init( cable_t *cable )
{
	if (parport_open( cable->link.port ))
		return -1;

	PARAM_SIGNALS(cable) = CS_TRST;

	return 0;
}
예제 #2
0
파일: triton.c 프로젝트: DerGenaue/usbprog
static int
triton_init( cable_t *cable )
{
	if (parport_open( cable->port ))
		return -1;

	PARAM_TRST(cable) = 1;
	PARAM_SRESET(cable) = 1;

	return 0;
}
예제 #3
0
int
ucon64_execute_options (void)
/*
  Execute all options for a single file.
  Please, if you experience problems then try your luck with the flags
  in ucon64_misc.c/ucon64_wf[] before changing things here or in
  ucon64_rom_handling()
*/
{
  int c = 0, result = 0, x = 0, opts = 0;
  static int first_call = 1;                    // first call to this function

  ucon64.dat = NULL;
#ifdef  USE_DISCMAGE
  ucon64.image = NULL;
#endif
  ucon64.rominfo = NULL;

  ucon64.battery =
  ucon64.bs_dump =
  ucon64.buheader_len =
  ucon64.console =
  ucon64.controller =
  ucon64.controller2 =
  ucon64.do_not_calc_crc =
  ucon64.id =
  ucon64.interleaved =
  ucon64.mirror =
  ucon64.part_size =
  ucon64.region =
  ucon64.snes_header_base =
  ucon64.snes_hirom =
  ucon64.split =
  ucon64.tv_standard =
  ucon64.use_dump_info =
  ucon64.vram = UCON64_UNKNOWN;

  ucon64.file_size =
  ucon64.crc32 =
  ucon64.fcrc32 =
  ucon64.io_mode = 0;

  // switches
  for (x = 0; arg[x].val; x++)
    {
      if (arg[x].console != UCON64_UNKNOWN)
        ucon64.console = arg[x].console;
      if (arg[x].flags)
        ucon64.flags = arg[x].flags;
      if (arg[x].val)
        ucon64.option = arg[x].val;
      ucon64.optarg = arg[x].optarg;

//      if (ucon64.flags & WF_SWITCH)
        ucon64_switches (&ucon64);
    }
#ifdef  USE_ANSI_COLOR
  if (ucon64.ansi_color && first_call)
    ucon64.ansi_color = ansi_init ();
#endif

#ifdef  USE_PARALLEL
  /*
    The copier options need root privileges for parport_open()
    We can't use ucon64.flags & WF_PAR to detect whether a (parallel port)
    copier option has been specified, because another switch might've been
    specified after -port.
  */
  if (ucon64.parport_needed == 1)
    ucon64.parport = parport_open (ucon64.parport);
#endif // USE_PARALLEL
#if     defined __unix__ && !defined __MSDOS__
  /*
    We can drop privileges after we have set up parallel port access. We cannot
    drop privileges if the user wants to communicate with the USB version of the
    F2A.
    SECURITY WARNING: We stay in root mode if the user specified an F2A option!
    We could of course drop privileges which requires the user to run uCON64 as
    root (not setuid root), but we want to be user friendly. Besides, doing
    things as root is bad anyway (from a security viewpoint).
  */
  if (first_call && ucon64.parport_needed != 2
#ifdef  USE_USB
      && !ucon64.usbport
#endif
     )
    drop_privileges ();
#endif // __unix__ && !__MSDOS__
  first_call = 0;

  for (x = 0; arg[x].val; x++)
    if (!(arg[x].flags & WF_SWITCH))
      {
        if (ucon64.console == UCON64_UNKNOWN)
          ucon64.console = arg[x].console;
        ucon64.flags = arg[x].flags;
        ucon64.option = arg[x].val;
        ucon64.optarg = arg[x].optarg;

        opts++;

        // WF_NO_SPLIT, WF_INIT, WF_PROBE, CRC32, DATabase and WF_NFO
        result = ucon64_rom_handling ();

        if (result == -1) // no rom, but WF_NO_ROM
          return -1;

        if (ucon64_options (&ucon64) == -1)
          {
            const st_getopt2_t *p = getopt2_get_index_by_val (options, c);
            const char *opt = p ? p->name : NULL;

            fprintf (stderr, "ERROR: %s%s encountered a problem\n",
                             opt ? (!opt[1] ? OPTION_S : OPTION_LONG_S) : "",
                             opt ? opt : "uCON64");

//            if (p)
//              getopt2_usage (p);

            fputs ("       Is the option you used available for the current console system?\n"
                   "       Please report bugs to [email protected] or [email protected]\n\n",
                   stderr);

            return -1;
          }

#if 0
        // WF_NFO_AFTER?!
        if (!result && (ucon64.flags & WF_NFO_AFTER) && ucon64.quiet < 1)
          ucon64_rom_handling ();
#endif

        /*
          "stop" options:
          - -multi (and -xfalmulti) takes more than one file as argument, but
            should be executed only once.
          - stop after sending one ROM to a copier ("multizip")
          - stop after applying a patch so that the patch file won't be
            interpreted as ROM
        */
        if (ucon64.flags & WF_STOP)
          break;
      }

  if (!opts) // no options => just display ROM info
    {
      ucon64.flags = WF_DEFAULT;
      // WF_NO_SPLIT WF_INIT, WF_PROBE, CRC32, DATabase and WF_NFO
      if (ucon64_rom_handling () == -1)
        return -1; // no rom, but WF_NO_ROM
    }

  fflush (stdout);

  return 0;
}