Пример #1
0
/** Console write (java long). */
EXTERNAL void sysConsoleWriteLong(long long value, int hexToo)
{
  if (hexToo==0 /*false*/)
    CONSOLE_PRINTF("%lld", value);
  else if (hexToo==1 /*true - also print in hex*/) {
    int value1 = (value >> 32) & 0xFFFFFFFF;
    int value2 = value & 0xFFFFFFFF;
    CONSOLE_PRINTF("%lld (0x%08x%08x)", value, value1, value2);
  } else { /* hexToo==2 for only in hex */
Пример #2
0
/** Console write (java integer). */
EXTERNAL void sysConsoleWriteInteger(int value, int hexToo)
{
  if (hexToo==0 /*false*/)
    CONSOLE_PRINTF("%d", value);
  else if (hexToo==1 /*true - also print in hex*/)
    CONSOLE_PRINTF("%d (0x%08x)", value, value);
  else    /* hexToo==2 for only in hex */
    CONSOLE_PRINTF("0x%08x", value);
}
Пример #3
0
/*
 * What nonstandard command line arguments are supported?
 */
static void
nonstandard_usage()
{
  const char * const *msgp = nonStandardUsage;
  CONSOLE_PRINTF("Usage: %s [options] class [args...]\n",Me);
  CONSOLE_PRINTF("          (to execute a class)\n");
  CONSOLE_PRINTF("where options include\n");
  for (; *msgp; ++msgp) {
    CONSOLE_PRINTF( "%s\n", *msgp);
  }
}
Пример #4
0
static void
fullVersion()
{
  shortVersion();
  CONSOLE_PRINTF( "\thost config: %s\n\ttarget config: %s\n",
                  rvm_host_configuration, rvm_target_configuration);
  CONSOLE_PRINTF( "\theap default initial size: %u MiBytes\n",
                  heap_default_initial_size/(1024*1024));
  CONSOLE_PRINTF( "\theap default maximum size: %u MiBytes\n",
                  heap_default_maximum_size/(1024*1024));
}
Пример #5
0
static void
vqec_rtcp_stats_show (const rtcp_session_stats_t *stats) 
{
    if (!stats) {
        return;
    }
    CONSOLE_PRINTF(" RTCP compound packet stats\n");
    vqec_rtcp_item_stats_show(&stats->pkts);
    CONSOLE_PRINTF("  avg_pkt_size:             %lf\n",
                   stats->avg_pkt_size);
    CONSOLE_PRINTF("  avg_pkt_size_sent         %lf\n",
                   stats->avg_pkt_size_sent);
}
Пример #6
0
/**
 *	Console command handler:	dmm cmds
 */
static void cmd_dmm_cmds(const idCmdArgs& args) {
	int i = 0;
	
	CONSOLE_PRINTF(CINFO "Command syntax: dmm <command> [parameters]\n");
	CONSOLE_PRINTF(CINFO "The following subcommands are available:\n");
		
	while (dmm_scmds[i].cmd) {
		CONSOLE_PRINTF(CINFO "  %-10s - %s\n", dmm_scmds[i].cmd, dmm_scmds[i].desc);
		++i;
	}

	CONSOLE_PRINTF(CINFO "End command listing.\n");
}
Пример #7
0
/** Console write (java character). */
EXTERNAL void sysConsoleWriteChar(unsigned value)
{
  SYS_START();
  char c = (value > 127) ? '?' : (char)value;
  // use high level stdio to ensure buffering policy is observed
  CONSOLE_PRINTF("%c", c);
}
Пример #8
0
/**
 *	Console command handler:	dmm help
 */
static void cmd_dmm_help(const idCmdArgs& args) {
	char* scmd = "help";
	int i = 0;
	
	if (args.argc > 2)
		scmd = args.argv[2];
	
	while (dmm_scmds[i].cmd) {
		if (!cstrcmp(scmd, dmm_scmds[i].cmd)) {
			CONSOLE_PRINTF(CINFO "Help: dmm %s\n", dmm_scmds[i].cmd);
			CONSOLE_PRINTF(CINFO "  Syntax: dmm %s %s\n", dmm_scmds[i].cmd, dmm_scmds[i].syntax);
			CONSOLE_PRINTF(CINFO "  Description: %s\n", dmm_scmds[i].desc);
			return;
		}
		++i;
	}
}
Пример #9
0
/**
 *	Console command handler:	dmm unpause
 */
static void cmd_dmm_unpause(const idCmdArgs& args) {
	int unid = 0;
	if (sscanf(args.argv[2], "%i", &unid) < 1) {
		/* invalid conversion - bad parameter */
		CONSOLE_PRINTF(CINFO INVALID_PARAMS("unpause"));
		return;
	}
	
	int op = unpause_plugin_by_unid(unid);

	if (op == 0)
		CONSOLE_PRINTF(CINFO "Invalid plugin unid %i.\n", unid);
	else if (op == 1)
		CONSOLE_PRINTF(CINFO "Successfully unpaused plugin unid %i.\n", unid);
	else if (op == -1)
		CONSOLE_PRINTF(CINFO "Unpausing a zombie plugin is not permitted.\n", unid);
	else
		CONSOLE_PRINTF(CINFO "Plugin unid %i already paused.\n", unid);
}
Пример #10
0
/**
 *	Console command handler:	dmm info
 */
static void cmd_dmm_info(const idCmdArgs& args) {
	int unid = 0;
	if (sscanf(args.argv[2], "%i", &unid) < 1) {
		/* invalid conversion - bad parameter */
		CONSOLE_PRINTF(CINFO INVALID_PARAMS("info"));
		return;
	}
	
	plugin_info(unid);
}
Пример #11
0
/**
 *	Register DMM console commands with
 *	the Doom3 engine.
 */
void register_console_commands() {
	#ifdef DMM_DETAIL
		CONSOLE_PRINTF(CINFO "Registering console commands ...\n");
	#endif

	int i = 0;
	while (dmm_cmds[i].cmdName) {
		#ifdef DMM_DETAIL
			CONSOLE_PRINTF(CINFO "  Registering command: \"%s\"\n", dmm_cmds[i].cmdName);
		#endif
		
		REGISTER_COMMAND(dmm_cmds[i].cmdName, dmm_cmds[i].function, dmm_cmds[i].flags,
			dmm_cmds[i].description, dmm_cmds[i].argCompletion);
		
		++i;
	}

	#ifdef DMM_DETAIL
		CONSOLE_PRINTF(CINFO "Attempted to register %i command%s.\n", i, GRAMMAR_PLURAL(i));
	#endif
}
Пример #12
0
/**
 *	Console command handler:	dmm pause
 */
static void cmd_dmm_pause(const idCmdArgs& args) {
	int unid = 0;
	int force = 0;
	
	if (sscanf(args.argv[2], "%i", &unid) < 1) {
		/* invalid conversion - bad parameter */
		CONSOLE_PRINTF(CINFO INVALID_PARAMS("pause"));
		return;
	}
	
	if (args.argc >= 4)
		/* force specified? */
		if (!cstrcmp(args.argv[3], "force"))
			force = 1;
	
	int op = pause_plugin_by_unid(unid, force);

	if (op == 0)
		CONSOLE_PRINTF(CINFO "Invalid plugin unid %i.\n", unid);
	else if (op == 1)
		CONSOLE_PRINTF(CINFO "Successfully paused plugin unid %i.\n", unid);
	else if (op == 2)
		CONSOLE_PRINTF(CINFO "Plugin unid %i already paused.\n", unid);
	else if (op == -1)
		CONSOLE_PRINTF(CINFO "Pausing a zombie plugin is not permitted.\n", unid);
	else
		CONSOLE_PRINTF(CINFO "Plugin unid %i can not be paused.\n", unid);
}
Пример #13
0
/**
 *	Console command handler:	dmm
 */
void cmd_dmm(const idCmdArgs& args) {
	int i = 0;
	
	if (args.argc < 2) {
		/*
		 *	Called with no parameters.
		 */
		CONSOLE_PRINTF(CINFO "Doom 3 Metamod (DMM) v" DMM_VERSION " (" DMM_BUILD ") [" OS_ID_STR "] by Para\n");
		CONSOLE_PRINTF(CINFO "Build: " __DATE__ " at " __TIME__ "\n");
		CONSOLE_PRINTF(CINFO "URL: http://doommod.net/ " DMM_URL "\n");
		CONSOLE_PRINTF(CINFO "For available commands, use: dmm cmds\n");
		return;
	}

	/*
	 *	Find the subcommand and execute the callback handler.
	 */
	while (dmm_scmds[i].cmd) {
		if (!strcmp(args.argv[1], dmm_scmds[i].cmd)) {
			if (dmm_scmds[i].cb) {
				if (args.argc >= (dmm_scmds[i].params + 2))
					(*dmm_scmds[i].cb)(args);
				else
					CONSOLE_PRINTF(CINFO "Command syntax: dmm %s %s\n", dmm_scmds[i].cmd, dmm_scmds[i].syntax);
			} else
				CONSOLE_PRINTF(CWARNING "Command: \"dmm %s\" has no callback function.\n", dmm_scmds[i].cmd);
			break;
		}
		++i;
	}
}
Пример #14
0
/**
 *	Console command handler:	dmm list
 */
static void cmd_dmm_list(const idCmdArgs& args) {
	int zombies = 0;
	
	if (args.argc > 2) {
		if (!cstrcmp(args.argv[2], "zombies")) {
			CONSOLE_PRINTF(CINFO INVALID_PARAMS("list"));
			return;
		} else
			zombies = 1;
	}
	
	plugin_list(zombies);
}
Пример #15
0
/**
 *	Console command handler:	dmm unload
 */
static void cmd_dmm_unload(const idCmdArgs& args) {
	int unid = 0;
	int force = 0;

	if (sscanf(args.argv[2], "%i", &unid) < 1) {
		/* invalid conversion - bad parameter */
		CONSOLE_PRINTF(CINFO INVALID_PARAMS("unload"));
		return;
	}
	
	if (args.argc >= 4)
		/* force specified? */
		if (!cstrcmp(args.argv[3], "force"))
			force = 1;

	int op = unload_plugin_by_unid(unid, force);
		
	if (op == 0)
		CONSOLE_PRINTF(CINFO "Invalid plugin unid %i.\n", unid);
	else if ((op == 1) || (op == 2))
		CONSOLE_PRINTF(CINFO "Successfully unloaded plugin unid %i (%scleanly).\n", unid, (op == 1 ? "" : "not "));
	else 
		CONSOLE_PRINTF(CINFO "Plugin unid %i can not be unloaded.\n", unid);
}
Пример #16
0
void 
rtp_show_drop_stats (rtp_session_t *p_sess)
{
    if (!p_sess) {
        return;
    }

    rtp_hdr_session_t *p_stats = &p_sess->rtp_stats;
    CONSOLE_PRINTF(" runts:                     %d\n"
                   " badver:                    %d\n"
                   " badlen:                    %d\n"
                   " badcreate:                 %d\n"
                   " seqjumps:                  %d\n"
                   " initseq_count:             %d\n",
                   p_stats->runts,
                   p_stats->badver,
                   p_stats->badlen,
                   p_sess->badcreate,
                   p_stats->seqjumps,
                   p_stats->initseq_count);
}
Пример #17
0
static void
vqec_rtcp_item_stats_show (const rtcp_item_stats_t *item_stats) 
{
    if (!item_stats) {
        return;
    }
    CONSOLE_PRINTF("  sent:                     %d\n",
                   (int)(item_stats->sent));
    CONSOLE_PRINTF("  send_errors:              %d\n",
                   (int)(item_stats->send_errors));
    CONSOLE_PRINTF("  rcvd:                     %d\n",
                   (int)(item_stats->rcvd));
    CONSOLE_PRINTF("  rcvd_errors:              %d\n",
                   (int)(item_stats->rcvd_errors));
    CONSOLE_PRINTF("  badver:                   %d\n",
                   (int)(item_stats->badver));
    CONSOLE_PRINTF("  runts:                    %d\n",
                   (int)(item_stats->runts));
    CONSOLE_PRINTF("  badlen:                   %d\n",
                   (int)(item_stats->badlen));
    CONSOLE_PRINTF("  unexp:                    %d\n",
                   (int)(item_stats->unexp));
}
Пример #18
0
/**
 * Parse command line arguments to find those arguments that
 *   1) affect the starting of the VM,
 *   2) can be handled without starting the VM, or
 *   3) contain quotes
 * then call createVM().
 */
int main(int argc, const char **argv)
{
  int j, ret;
  JavaVMInitArgs initArgs;
  JavaVM *mainJavaVM;
  JNIEnv *mainJNIEnv;
  SYS_START();
#ifndef RVM_FOR_HARMONY
  SysErrorFile = stderr;
  SysTraceFile = stdout;
  setbuf (SysErrorFile, NULL);
  setbuf (SysTraceFile, NULL);
  setvbuf(stdout,NULL,_IONBF,0);
  setvbuf(stderr,NULL,_IONBF,0);
#endif
#ifndef RVM_FOR_WINDOWS
  Me = strrchr(*argv, '/');
#else
  Me = strrchr(*argv, '\\');
#endif
  if (Me == NULL) {
    Me = "RVM";
  } else {
    Me++;
  }
  ++argv, --argc;
  initialHeapSize = heap_default_initial_size;
  maximumHeapSize = heap_default_maximum_size;

  /* Initialize system call routines and side data structures */
  sysInitialize();

  /*
   * Debugging: print out command line arguments.
   */
  if (TRACE) {
    TRACE_PRINTF("RunBootImage.main(): process %d command line arguments\n",argc);
    for (j=0; j<argc; j++) {
      TRACE_PRINTF("\targv[%d] is \"%s\"\n",j, argv[j]);
    }
  }

  /* Initialize JavaArgc, JavaArgs and initArg */
  initArgs.version = JNI_VERSION_1_4;
  initArgs.ignoreUnrecognized = JNI_TRUE;
  JavaArgs = (char **)processCommandLineArguments(&initArgs, argv, argc);

  if (TRACE) {
    TRACE_PRINTF("RunBootImage.main(): after processCommandLineArguments: %d command line arguments\n", JavaArgc);
    for (j = 0; j < JavaArgc; j++) {
      TRACE_PRINTF("\tJavaArgs[%d] is \"%s\"\n", j, JavaArgs[j]);
    }
  }


  /* Verify heap sizes for sanity. */
  if (initialHeapSize == heap_default_initial_size &&
      maximumHeapSize != heap_default_maximum_size &&
      initialHeapSize > maximumHeapSize) {
    initialHeapSize = maximumHeapSize;
  }

  if (maximumHeapSize == heap_default_maximum_size &&
      initialHeapSize != heap_default_initial_size &&
      initialHeapSize > maximumHeapSize) {
    maximumHeapSize = initialHeapSize;
  }

  if (maximumHeapSize < initialHeapSize) {
    CONSOLE_PRINTF( "%s: maximum heap size %lu MiB is less than initial heap size %lu MiB\n",
                    Me, (unsigned long) maximumHeapSize/(1024*1024),
                    (unsigned long) initialHeapSize/(1024*1024));
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }


  TRACE_PRINTF("\nRunBootImage.main(): VM variable settings\n");
  TRACE_PRINTF("initialHeapSize %lu\nmaxHeapSize %lu\n"
               "bootCodeFileName \"%s\"\nbootDataFileName \"%s\"\n"
               "bootRmapFileName \"%s\"\n"
               "verbose %d\n",
               (unsigned long) initialHeapSize,
               (unsigned long) maximumHeapSize,
               bootCodeFilename, bootDataFilename, bootRMapFilename,
               verbose);

  if (!bootCodeFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image code file using \"-X:ic=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  if (!bootDataFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image data file using \"-X:id=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  if (!bootRMapFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image ref map file using \"-X:ir=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  ret = JNI_CreateJavaVM(&mainJavaVM, &mainJNIEnv, &initArgs);

  if (ret < 0) {
    ERROR_PRINTF("%s: Could not create the virtual machine; goodbye\n", Me);
    sysExit(EXIT_STATUS_MISC_TROUBLE);
  }
  return 0;
}
Пример #19
0
/**
 * Parse command line arguments to find those arguments that
 *   1) affect the starting of the VM,
 *   2) can be handled without starting the VM, or
 *   3) contain quotes
 * then call createVM().
 */
int main(int argc, const char **argv)
{
  int vbufret, j, ret;
  JavaVMInitArgs initArgs;
  JavaVM *mainJavaVM;
  JNIEnv *mainJNIEnv;

  /* Make standard streams unbuffered so that we can use them
     for low level-debugging */
  vbufret = setvbuf(stdout, NULL, _IONBF, 0);
  if (vbufret != 0) {
    printf("Error making stdout unbuffered: %d\n", vbufret);
  }
  vbufret = setvbuf(stderr, NULL, _IONBF, 0);
  if (vbufret != 0) {
    printf("Error making stderr unbuffered: %d\n", vbufret);
  }
  SysErrorFile = stderr;
  SysTraceFile = stdout;
  Me = strrchr(*argv, '/');
  if (Me == NULL) {
    Me = "RVM";
  } else {
    Me++;
  }

  ++argv, --argc;
  initialHeapSize = heap_default_initial_size;
  maximumHeapSize = heap_default_maximum_size;

  // Determine page size information early because
  // it's needed to parse command line options
  pageSize = (Extent) determinePageSize();
  if (pageSize <= 0) {
    ERROR_PRINTF("RunBootImage.main(): invalid page size %u", pageSize);
    exit(EXIT_STATUS_IMPOSSIBLE_LIBRARY_FUNCTION_ERROR);
  }

  /*
   * Debugging: print out command line arguments.
   */
  if (TRACE) {
    TRACE_PRINTF("RunBootImage.main(): process %d command line arguments\n",argc);
    for (j = 0; j < argc; j++) {
      TRACE_PRINTF("\targv[%d] is \"%s\"\n",j, argv[j]);
     }
  }

  /* Initialize JavaArgc, JavaArgs and initArg */
  initArgs.version = JNI_VERSION_1_4;
  initArgs.ignoreUnrecognized = JNI_TRUE;
  JavaArgs = (char **)processCommandLineArguments(&initArgs, argv, argc);

  if (TRACE) {
    TRACE_PRINTF("RunBootImage.main(): after processCommandLineArguments: %d command line arguments\n", JavaArgc);
    for (j = 0; j < JavaArgc; j++) {
      TRACE_PRINTF("\tJavaArgs[%d] is \"%s\"\n", j, JavaArgs[j]);
    }
  }

  /* Verify heap sizes for sanity. */
  if (initialHeapSize == heap_default_initial_size &&
      maximumHeapSize != heap_default_maximum_size &&
      initialHeapSize > maximumHeapSize) {
    initialHeapSize = maximumHeapSize;
  }

  if (maximumHeapSize == heap_default_maximum_size &&
      initialHeapSize != heap_default_initial_size &&
      initialHeapSize > maximumHeapSize) {
    maximumHeapSize = initialHeapSize;
  }

  if (maximumHeapSize < initialHeapSize) {
    CONSOLE_PRINTF( "%s: maximum heap size %lu MiB is less than initial heap size %lu MiB\n",
                    Me, (unsigned long) maximumHeapSize/(1024*1024),
                    (unsigned long) initialHeapSize/(1024*1024));
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  TRACE_PRINTF("\nRunBootImage.main(): VM variable settings\n");
  TRACE_PRINTF("initialHeapSize %lu\nmaxHeapSize %lu\n"
           "bootCodeFileName \"%s\"\nbootDataFileName \"%s\"\n"
           "bootRmapFileName \"%s\"\n"
           "verbose %d\n",
           (unsigned long) initialHeapSize,
           (unsigned long) maximumHeapSize,
           bootCodeFilename, bootDataFilename, bootRMapFilename,
           verbose);

  if (!bootCodeFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image code file using \"-X:ic=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  if (!bootDataFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image data file using \"-X:id=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  if (!bootRMapFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image ref map file using \"-X:ir=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  ret = JNI_CreateJavaVM(&mainJavaVM, &mainJNIEnv, &initArgs);
  if (ret < 0) {
    ERROR_PRINTF("%s: Could not create the virtual machine; goodbye\n", Me);
    exit(EXIT_STATUS_MISC_TROUBLE);
  }
  return 0;
}
Пример #20
0
static void
shortVersion()
{
  CONSOLE_PRINTF( "%s %s\n",rvm_configuration, rvm_version);
}
Пример #21
0
/*
 * What standard command line arguments are supported?
 */
static void
usage(void)
{
  CONSOLE_PRINTF("Usage: %s [-options] class [args...]\n", Me);
  CONSOLE_PRINTF("          (to execute a class)\n");
  CONSOLE_PRINTF("   or  %s [-options] -jar jarfile [args...]\n",Me);
  CONSOLE_PRINTF("          (to execute a jar file)\n");
  CONSOLE_PRINTF("\nwhere options include:\n");
  CONSOLE_PRINTF("    -cp -classpath <directories and zip/jar files separated by :>\n");
  CONSOLE_PRINTF("              set search path for application classes and resources\n");
  CONSOLE_PRINTF("    -D<name>=<value>\n");
  CONSOLE_PRINTF("              set a system property\n");
  CONSOLE_PRINTF("    -verbose[:class|:gc|:jni]\n");
  CONSOLE_PRINTF("              enable verbose output\n");
  CONSOLE_PRINTF("    -version  print version\n");
  CONSOLE_PRINTF("    -showversion\n");
  CONSOLE_PRINTF("              print version and continue\n");
  CONSOLE_PRINTF("    -fullversion\n");
  CONSOLE_PRINTF("              like version but with more information\n");
  CONSOLE_PRINTF("    -? -help  print this message\n");
  CONSOLE_PRINTF("    -X        print help on non-standard options\n");
  CONSOLE_PRINTF("    -javaagent:<jarpath>[=<options>]\n");
  CONSOLE_PRINTF("              load Java programming language agent, see java.lang.instrument\n");

  CONSOLE_PRINTF("\n For more information see http://jikesrvm.sourceforge.net\n");

  CONSOLE_PRINTF("\n");
}
Пример #22
0
/**
 *	This function uses a pointer to itself in attempt to
 *	find it's absolute path on the filesystem.
 *
 *	For this to parse correctly, DMM must be in a subfolder of
 *	Doom3.
 *	Example:
 *		If you are on Linux using the home-path Doom directory,
 *		your Doom3 files would be in:
 *			/home/your_name/.doom3/
 *		Therefore, DMM should be in:
 *			/home/your_name/.doom3/.dmm/
 *		Check definitions.h macro DMM_PATH for the real
 *		relative path used.
 *
 *	If running on Linux:
 *		If DMM is in the installation directory (ie: /opt/doom3),
 *		Doom3 will copy DMM into your home directory.
 *		For this reason, DMM will always assume DMM files are
 *		in your home directory, so put them there, not the
 *		installation path.
 *
 *		It is a good idea to not run DMM as a "mod" (ie +set fs_game),
 *		instead, make a symlink in the game directory to DMM,
 *		and change the permission of DMM to 444.
 *		This will prevent Doom from being able to copy the real
 *		mod into place and allow Doom to run in pure mode while using DMM.
 *
 *	This method required GLIBC, dladdr() is not defined in POSIX.
 *
 *	@return 1 on success, 0 on failure.
 */
int determine_paths() {
	/*
	 *	Initialize the paths.
	 */
	g_paths.mod_file = NULL;
	g_paths.base = NULL;
	g_paths.game = NULL;
	g_paths.dmm = _dmm_path;
	
	/*
	 *	Request information on this module
	 *	from the operating system.
	 */	
	Dl_info self_info;
	if (!dladdr((void*)&determine_paths, &self_info)) {
		CONSOLE_PRINTF(CERROR "Failed to find absolute path to DMM; expect a segfault.\n");
		return 0;
	}

	#ifdef WIN32
		char filename[MAX_PATH_SIZE];
		if (!GetModuleFileName((HMODULE)self_info.AllocationBase, filename, MAX_PATH_SIZE)) {
			CONSOLE_PRINTF(CERROR "Failed to find absolute path to DMM; expect a segfault.\n");
			return 0;
		}
		filename[MAX_PATH_SIZE - 1] = '\0';
	#endif

	char* s = NULL;
	
	#ifdef WIN32
		s = (filename + strlen(filename) - 1);
	#else
		s = (char*)(self_info.dli_fname + strlen(self_info.dli_fname) - 1);
	#endif

	/*
	 *	Parse the returned path.
	 */
	int level = 0;
	for (; s > 0; --s) {
		if (*s == OS_DIR_DIV) {
			++level;
			if (level == 1) {
				/* found game path */
				*(s + 1) = 0;
			} else if (level == 2) {
				/* found base path */
				g_paths.game = strdup(s + 1);				/* copy game path */
				*(s + 1) = 0;
				#ifdef WIN32
					g_paths.base = strdup(filename);			/* copy base path */
				#else
					g_paths.base = strdup(self_info.dli_fname);	/* copy base path */
				#endif
				break;
			}
		}
	}

	if (g_paths.base) {
		CONSOLE_PRINTF(CINFO "Found path to Doom 3: \"%s\".\n", g_paths.base);
		CONSOLE_PRINTF(CINFO "Found relative path to game: \"%s\".\n", g_paths.game);
		CONSOLE_PRINTF(CINFO "Using relative path to DMM: \"%s\".\n", g_paths.dmm);
	} else
		CONSOLE_PRINTF(CERROR "Unable to find path to Doom3; expect a segfault\n");

	return (g_paths.base ? 1 : 0);
}
Пример #23
0
void
vqec_rtp_session_show (vqec_dp_streamid_t id,
                       rtp_session_t *sess,
                       const char *namestr,
                       boolean first_pak_rx)
{
    rtcp_session_info_t rtcp_info;
    rtcp_session_stats_t rtcp_stats;
    rtcp_sender_info_t rtcp_sender_info[MAX_SENDERS];
    rtp_hdr_source_t rtp_hdr_src[MAX_SENDERS];
    int num_senders;
    int i;
    vqec_dp_rtp_src_table_t table;
    char str[INET_ADDRSTRLEN];

    if (!sess || !namestr) {
        return;
    }

    CONSOLE_PRINTF("%7s data received:     %s", namestr, 
                   first_pak_rx ? "TRUE": "FALSE");
    CONSOLE_PRINTF("RTP %s session\n", namestr);

    /* Call low level function to get rtcp_session_info_t */
    rtcp_get_session_info(sess, &rtcp_info);
    CONSOLE_PRINTF("  ssrc:                     %x\n",
                   rtcp_info.ssrc);
    CONSOLE_PRINTF("  cname:                    %s\n",
                   rtcp_info.cname);
    CONSOLE_PRINTF("  nmembers:                 %u\n",
                   rtcp_info.rtcp_nmembers);
    CONSOLE_PRINTF("  nsenders:                 %u\n",
                   rtcp_info.rtcp_nsenders);
    rtcp_get_session_stats (sess, &rtcp_stats, NULL);
    vqec_rtcp_stats_show(&rtcp_stats);

    rtcp_get_sender_info(sess, MAX_SENDERS, &num_senders,
                         rtcp_sender_info);

    rtcp_get_sender_stats(sess, MAX_SENDERS, &num_senders,
                          rtp_hdr_src);
    /* Only display upto MAX_SENDER */
    if (num_senders > MAX_SENDERS) {
        num_senders = MAX_SENDERS;
    }
    for (i = 0; i < num_senders; i++) {
        CONSOLE_PRINTF(" Sender info for sender %d\n",
                       i+1);
        CONSOLE_PRINTF("  ssrc:                     %x\n",
                       rtcp_sender_info[i].ssrc);
        CONSOLE_PRINTF("  cname:                    %s\n",
                       rtcp_sender_info[i].cname);
        CONSOLE_PRINTF("  received:                 %u\n",
                       rtcp_sender_info[i].received);
        CONSOLE_PRINTF("  cum_loss:                 %d\n",
                       rtcp_sender_info[i].cum_loss);
        CONSOLE_PRINTF("  ehsr:                     %u\n",
                       rtcp_sender_info[i].ehsr);
        CONSOLE_PRINTF("  jitter (us):              %u\n",
                       TIME_GET_R(usec, 
                          TIME_MK_R(pcr, rtcp_sender_info[i].jitter)));
        CONSOLE_PRINTF(" Sender stats for sender %d\n",
                       i+1);
        CONSOLE_PRINTF("  max_seq:                  %u\n",
                       rtp_hdr_src[i].max_seq);
        CONSOLE_PRINTF("  cycles:                   %u\n",
                       rtp_hdr_src[i].cycles);
        CONSOLE_PRINTF("  bad_seq:                  %u\n",
                       rtp_hdr_src[i].bad_seq);
        CONSOLE_PRINTF("  base_seq:                 %u\n",
                       rtp_hdr_src[i].base_seq);
        CONSOLE_PRINTF("  transit:                  %u\n",
                       rtp_hdr_src[i].transit);
        /*
         * Don't display sender stats.jitter as it is
         * a scaled up version of sender_info jiter,
         * i.e. redundant.
         */
        CONSOLE_PRINTF("  received:                 %u\n",
                       rtp_hdr_src[i].received);
        CONSOLE_PRINTF("  last_arr_ts_media:        %u\n",
                       rtp_hdr_src[i].last_arr_ts_media);
        CONSOLE_PRINTF("  seqjumps:                 %u\n",
                       rtp_hdr_src[i].seqjumps);
        CONSOLE_PRINTF("  initseq_count:            %u\n",
                       rtp_hdr_src[i].initseq_count);
        CONSOLE_PRINTF("  out_of_order:             %u\n",
                       rtp_hdr_src[i].out_of_order);

        /* RTCP XR Stats */
        if (rtcp_sender_info[i].xr_info_avail) {
            CONSOLE_PRINTF(" RTCP XR info\n");
            CONSOLE_PRINTF("  begin seq:                %u\n",
                           (uint16_t)rtcp_sender_info[i].begin_seq);
            CONSOLE_PRINTF("  end seq:                  %u\n",
                           (uint16_t)rtcp_sender_info[i].end_seq);
            CONSOLE_PRINTF("  lost pkts:                %u\n",
                           rtcp_sender_info[i].lost_packets);
            CONSOLE_PRINTF("  duplicated pkts:          %u\n",
                           rtcp_sender_info[i].dup_packets);
            CONSOLE_PRINTF("  late arrival pkts:        %u\n",
                           rtcp_sender_info[i].late_arrivals);
            CONSOLE_PRINTF("  min jitter (us):          %u\n",
                           TIME_GET_R(usec, 
                             TIME_MK_R(pcr, rtcp_sender_info[i].min_jitter)));
            CONSOLE_PRINTF("  max jitter (us):          %u\n",
                           TIME_GET_R(usec, 
                             TIME_MK_R(pcr, rtcp_sender_info[i].max_jitter)));
            CONSOLE_PRINTF("  mean jitter (us):         %u\n",
                           TIME_GET_R(usec, 
                             TIME_MK_R(pcr, rtcp_sender_info[i].mean_jitter)));
            CONSOLE_PRINTF("  std dev jitter (us):      %u\n",
                           TIME_GET_R(usec, 
                             TIME_MK_R(pcr, rtcp_sender_info[i].dev_jitter)));
            CONSOLE_PRINTF("  before interval:          %u\n",
                           rtcp_sender_info[i].before_intvl);
            CONSOLE_PRINTF("  not reported:             %u\n",
                           rtcp_sender_info[i].not_reported);
            CONSOLE_PRINTF("  reinit:                   %u\n",
                           rtcp_sender_info[i].re_init);
        }
    }

    CONSOLE_PRINTF("%7s RTCP RRs sent:      %d\n", 
                   namestr, (int)(rtcp_stats.pkts.sent));

    memset(&table, 0, sizeof(table));
    if (vqec_rtp_session_dp_get_src_table(sess,
                                          id,
                                          &table)) {
        CONSOLE_PRINTF(" DP sources:                %u\n",
                       table.num_entries);
        for (i = 0; i < table.num_entries; i++) {
#define RTP_DP_TABLE_DISPLAY_ENTRIES_PER_LINE 4
            CONSOLE_PRINTF("  ssrc=%8x, src ip:%s port:%d\n"
                           "     source status:               (%s%s%s)\n"
                           "     source PCM seq num offset:   %d\n",
                           table.sources[i].key.ssrc,
                           inaddr_ntoa_r(
                               table.sources[i].key.ipv4.src_addr,
                               str, sizeof(str)),
                           ntohs(table.sources[i].key.ipv4.src_port),
                           (table.sources[i].info.state == 
                            VQEC_DP_RTP_SRC_ACTIVE ? "active" : "inactive"),
                           (table.sources[i].info.pktflow_permitted ? 
                            ", pktflow" : ""),
                           (table.sources[i].info.buffer_for_failover ?
                            ", failover" : ""),
                           table.sources[i].info.session_rtp_seq_num_offset);
            if (i &&
                !(i % RTP_DP_TABLE_DISPLAY_ENTRIES_PER_LINE)) {
                CONSOLE_PRINTF("\n");
            }
        }
    }    
}