示例#1
0
int main(int argc, char *argv[])
{
	unsigned int vol;
	unsigned int but;
	unsigned int lang;

	pspDebugScreenInit();
	printf("Simple Registry Sample (c) 2k6 TyRaNiD\n");
	if(get_registry_value("/CONFIG/SYSTEM/SOUND", "main_volume", &vol))
	{
		printf("Main Volume: %d\n", vol);
	}
	if(get_registry_value("/CONFIG/SYSTEM/XMB", "language", &lang))
	{
		printf("Language : %d\n", lang);
	}
	if(get_registry_value("/CONFIG/SYSTEM/XMB", "button_assign", &but))
	{
		if(but == 0)
		{
			printf("Jap button assignment (Circle is enter)\n");
		}
		else
		{
			printf("NA/EU button assignment (Cross is enter)\n");
		}
	}
	else
	{
		printf("Could not get button_assign (v1.0?). Exiting in 5 seconds\n");
		sceKernelDelayThread(5000000);
		sceKernelExitGame();
	}

	printf("* To swap buttons press Circle *\n");
	printf("* To exit press start *\n");
	while(1)
	{
		SceCtrlData pad;
		sceCtrlPeekBufferPositive(&pad, 1);
		if(pad.Buttons & PSP_CTRL_START)
		{
			sceKernelExitGame();
		}
		if(pad.Buttons & PSP_CTRL_CIRCLE)
		{
			but ^= 1;
			if(set_registry_value("/CONFIG/SYSTEM/XMB", "button_assign", but))
			{
				if(but)
				{
					printf("Set to NA/EU mode\n");
				}
				else
				{
					printf("Set to Jap mode\n");
				}
			}
			else
			{
				printf("Error setting button assignment\n");
			}
			printf("Exiting in 5 seconds\n");
			sceKernelDelayThread(5000000);
			sceKernelExitGame();
		}
		sceDisplayWaitVblankStart();
	}

	return 0;
}
示例#2
0
/**
 * Main entry for program.
 *
 * @param argc Number of command line arguments
 * @param argv Command line arguments
 * @return 0 on success
 */
int
main (int argc, char* argv[])
{
  char *option;
  int result;
  char *sparam1=NULL, *sparam2, *sparam3, *sparam4;
  char *sparam5, *sparam6, *sparam7, *sparam8, *sparam9;
#ifdef _WIN32
  char path[MAX_PATH];
#endif
  int iparam1, iparam2;
  long lparam1;

  /****************************************************************************
   * Show program help
  ****************************************************************************/
  if (get_option (argv, argc, "--help", NULL) == 0)
    {
      usage (stdout);
      exit (0);
    }
  /****************************************************************************
   * Read command line options from file
  ****************************************************************************/
  if (get_option (argv, argc, "-file", &option) == 0)
    {
      result = read_file_options (option);
      free (option);
      if (result == -1)
        fail ("Failed to read options file: %s.", option);
    }
  /****************************************************************************
   * Enable logging
  ****************************************************************************/
  if (get_option (argv, argc, "-log", &option) == 0)
    {
      logFile = fopen (option, "a");
      if (logFile == NULL)
        fail ("Failed to write log file: %s", option);
      free (option);
    }
  /****************************************************************************
   * Wait for process to terminate
  ****************************************************************************/
  if (get_option (argv, argc, "-pid", &option) == 0)
    {
      iparam1 = -1;
      lparam1 = atoi (option);
      free (option);
      if (get_option (argv, argc, "-wait", &option) == 0)
        {
          iparam1 = atoi (option);
        }
      if (wait_for_pid (lparam1, iparam1) != 0)
        fail ("Timed out waiting for process to terminate.");
      free (option);
    }
  /****************************************************************************
   * Remove directories
  ****************************************************************************/
  if (get_option (argv, argc, "-removeDir", &option) == 0)
    {
      result = delete_directories (option, 0);
      if (result != 0)
        fail ("Failed to delete directories: %s", option);
      else
        log_message ("-removeDir %s", option);
      free (option);
    }
  /****************************************************************************
   * Remove directories if they are empty
  ****************************************************************************/
  if (get_option (argv, argc, "-removeEmptyDir", &option) == 0)
    {
      result = delete_directories (option, 1);
      if (result != 0)
        fail ("Failed to delete empty directories: %s", option);
      else
        log_message ("-removeEmptyDir %s", option);
      free (option);
    }
  /****************************************************************************
   * Set registry value
  ****************************************************************************/
  if (get_option (argv, argc, "-regSetValue", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);
      sparam3 = get_argument (NULL);
      sparam4 = get_argument (NULL);
      result = set_registry_value (sparam1, sparam2, sparam3, sparam4);
      if (result != 0)
        fail ("Failed to set registry value.");
      else
        log_message ("-regSetValue %s, %s, %s, %s", sparam1, sparam2,
          sparam3, sparam4);
      free (option);
#else
      fail ("-regSetValue is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Get registry value
  ****************************************************************************/
  if (get_option (argv, argc, "-regGetValue", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);
      sparam3 = get_registry_value (sparam1, sparam2);
      if (sparam3)
        puts (sparam3);
      else
        fail ("Failed to get registry value %s, %s.", sparam1, sparam2);
      free (option);
#else
      fail ("-regSetValue is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Delete registry value
  ****************************************************************************/
  if (get_option (argv, argc, "-regDeleteValue", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);
      result = delete_registry_value (sparam1, sparam2);
      if (result != 0)
        fail ("Failed to delete registry value.");
      else
        log_message ("-regDeleteValue %s, %s", sparam1, sparam2);
      free (option);
#else
      fail ("-regDeleteValue is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Delete registry key
  ****************************************************************************/
  if (get_option (argv, argc, "-regDeleteKey", &option) == 0)
    {
#ifdef _WIN32
      result = delete_registry_key (option);
      if (result != 0)
        fail ("Failed to delete registry key.");
      else
        log_message ("-regDeleteKey %s", option);
      free (option);
#else
      fail ("-regDeleteKey is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Run as administrator
  ****************************************************************************/
  if (get_option (argv, argc, "-runAdmin", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);

      result = -1;
      if ((sparam1 != NULL) && (sparam2 != NULL))
      {
        replace_chars (sparam2, '\'', '"');
        result = run_admin (sparam1, sparam2);
      }
      if (result != 0)
        fail ("Failed to run program.");
      else
        log_message ("-runAdmin %s,%s", sparam1, sparam2);
      free (option);
#else
      fail ("-runAdmin is currently only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Create short-cut
  ****************************************************************************/
  if (get_option (argv, argc, "-createShortcut", &option) == 0)
    {
      sparam1 = get_argument (option);
      sparam2 = get_argument (NULL);
      sparam3 = get_argument (NULL);
      sparam4 = get_argument (NULL);
      sparam5 = get_argument (NULL);
      sparam6 = get_argument (NULL);
      sparam7 = get_argument (NULL);
      sparam8 = get_argument (NULL);
      sparam9 = get_argument (NULL);
      if (strlen (sparam6) != 0)
        iparam1 = atoi (sparam6);
      else
        iparam1 = 0;
      if (strlen (sparam9) != 0)
        iparam2 = atoi (sparam9);
      else
        iparam2 = 0;
      result = create_shortcut (sparam1, sparam2, sparam3, sparam4, sparam5,
        iparam1, sparam7, sparam8, iparam2);
      if (result != 0)
        fail ("Failed to create shortcut.");
      else
        log_message ("-createShortcut %s, %s, %s, %s, %s, %s, %s, %s %s",
          sparam1, sparam2, sparam3, sparam4, sparam5, sparam6, sparam7,
          sparam8, sparam9);
      free (option);
    }
  /****************************************************************************
   * Get special folder
  ****************************************************************************/
  if (get_option (argv, argc, "-getSpecialFolder", &option) == 0)
    {
#ifdef _WIN32
      sparam1 = get_argument (option);
      iparam1 = get_clsid (sparam1);
      result = get_special_folder (iparam1, path);
      free (option);
      if (result != 0)
        fail ("Failed to get special folder: %s", sparam1);
      else
        puts(path);
#else
      fail ("-getSpecialFolder is only supported on Windows.");
#endif
    }
  /****************************************************************************
   * Get property
  ****************************************************************************/
  if (get_option (argv, argc, "-getOsProperty", &option) == 0)
    {
      sparam1 = get_argument (option);
      print_os_property (sparam1);
      free (option);
    }

  if (logFile != NULL)
    fclose (logFile);
  if (fargv != NULL)
    free (fargv);

  return EXIT_SUCCESS;
}