void ApplicationContextImpl::initialise(int argc, char* argv[]) {
	// Give away unnecessary root privileges.
	// Important: must be done before calling gtk_init().
	char *loginname;
	struct passwd *pw;
	seteuid(getuid());

	if (geteuid() == 0 &&
		(loginname = getlogin()) != 0 &&
		(pw = getpwnam(loginname)) != 0)
	{
		setuid(pw->pw_uid);
	}

	initArgs(argc, argv);

    // Initialise the home directory path
    std::string home = os::standardPathWithSlash(g_get_home_dir()) + ".darkradiant/";
    os::makeDirectory(home);
    _homePath = home;

	{
		char real[PATH_MAX];
		_appPath = getexename(real, argv);
		ASSERT_MESSAGE(!_appPath.empty(), "failed to deduce app path");
	}

	// Initialise the relative paths
	initPaths();
}
Esempio n. 2
0
JNIEXPORT jobject JNICALL Java_gnu_rrd_RRDJNI_graph
(JNIEnv *env, jclass cl, jobjectArray argv) {
  char        **argv2;
  char        **calcpr;
  char*       info;
  const char* fn;
  int         asize = 0;
  int         i, j, xsize,  ysize;
  double      ymin, ymax;
  jcharArray  graph;
  jclass      RRDGraphClass;
  jmethodID   RRDGraphMethodInit;
  jmethodID   RRDGraphMethodSetElement;
  jobject     graphObj = NULL;
  jobject     o;

  o  = (*env)->GetObjectArrayElement(env, argv, 0);  
  fn = (*env)->GetStringUTFChars(env, (jstring)o, NULL);
  if (strcmp(fn,"-")==0) {
    throwException(env, "gnu/rrd/RRDException", "output to stdout is not supported.");
    return;
  }
  
  RRDGraphClass      = (*env)->FindClass(env, "gnu/rrd/RRDGraph");
  RRDGraphMethodInit = (*env)->GetMethodID(env, RRDGraphClass, "<init>",
					   "(Ljava/lang/String;Ljava/lang/String;IIDD)V");
    
  calcpr = NULL;
  argv2  = initArgs(env, argv, "graph");
  if (rrd_graph((*env)->GetArrayLength(env, argv)+1, argv2, &calcpr, &xsize, &ysize, NULL, &ymin, &ymax) != -1 ) {
    
    if (calcpr) {
      for(i = 0; calcpr[i]; i++) asize = asize + strlen(calcpr[i]) + 1;
      if((info = (char*)malloc(asize+1))==NULL) {
	throwException(env, "gnu/rrd/RRDException", "unable to allocate memory for graph information.");
	freeArgs(env, argv, argv2);
	free(calcpr);
        return;
      } else {
	for(i = 0; calcpr[i]; i++){
	  if (i>0) info = strcat(strcat(info, "\n"), calcpr[i]);
	  else     info = strcat(info, calcpr[i]);
          free(calcpr[i]);
        } 
      }
      free(calcpr);
    }
    graphObj = (*env)->NewObject(env, RRDGraphClass, RRDGraphMethodInit,
				 (jstring)(*env)->GetObjectArrayElement(env, argv, 0),
				 (jstring)(*env)->NewStringUTF(env, info),
				 (jint)xsize, (jint)ysize, (jdouble)ymin, (jdouble)ymax);
  }
  freeArgs(env, argv, argv2);
  if (rrd_test_error())
    throwException(env, "gnu/rrd/RRDException", rrd_get_error());

  return graphObj;
}
Esempio n. 3
0
JNIEXPORT void JNICALL Java_gnu_rrd_RRDJNI_dump
(JNIEnv *env, jclass cl, jobjectArray argv) {
  char **argv2;
    
  argv2 = initArgs(env, argv, "dump");
  rrd_dump((*env)->GetArrayLength(env, argv)+1, argv2);
  freeArgs(env, argv, argv2);
  if (rrd_test_error())
    throwException(env, "gnu/rrd/RRDException", rrd_get_error());
}
Esempio n. 4
0
UBool ctest_resetICU() {
    UErrorCode   status = U_ZERO_ERROR;
    char         *dataDir = safeGetICUDataDirectory();

    u_cleanup();
    if (!initArgs(gOrigArgc, gOrigArgv, NULL, NULL)) {
        /* Error already displayed. */
        return FALSE;
    }
    u_setDataDirectory(dataDir);
    free(dataDir);
    u_init(&status);
    if (U_FAILURE(status)) {
        log_err_status(status, "u_init failed with %s\n", u_errorName(status));
        return FALSE;
    }
    return TRUE;
}
void ApplicationContextImpl::initialise(int argc, char* argv[])
{
	initArgs(argc, argv);
    
    // Get application data directory from environment
	std::string appData = getenv("APPDATA");
	if (appData.empty())
    {
		throw std::runtime_error(
            "Critical: cannot find APPDATA environment variable."
        );
	}

    // Construct DarkRadiant home directory
	_homePath = appData + "\\DarkRadiant";
	if (!os::makeDirectory(_homePath))
    {
        std::cerr << "ApplicationContextImpl: could not create home directory "
                  << "'" << _homePath << "'" << std::endl;
    }

	{
		// get path to the editor
		wchar_t filename[MAX_PATH+1];
		GetModuleFileName(0, filename, MAX_PATH);
		wchar_t* last_separator = wcsrchr(filename, '\\');
		if (last_separator != 0) {
			*(last_separator+1) = '\0';
		}
		else {
			filename[0] = '\0';
		}

		// convert to std::string
		std::wstring wide(filename); 
		std::string appPathNarrow(wide.begin(), wide.end());

		// Make sure we have forward slashes
		_appPath = os::standardPath(appPathNarrow);
	}
	// Initialise the relative paths
	initPaths();
}
Esempio n. 6
0
File: main.cpp Progetto: bugou/test
int main(int argc, char *argv[])
{
	if (daemon_init() < 0) {
		cerr << "daemon_init error." << endl;
		return 1;
	}

	initArgs(argc, argv);
	
	if (!myicqStart()) {
		LOG(1) ("myicqStart() failed.\n");
		return 1;
	}
		
	handlePacket();
	
	myicqDestroy();	
	return 0;
}
Esempio n. 7
0
int main(int argc, char *argv[])
{
	// serviceMain has been set by its constructor
	ICQ_ASSERT(serviceMain != NULL);

	if (initArgs(argc, argv))
		return 0;

	WSADATA data;
	WSAStartup(MAKEWORD(2, 2), &data);

#ifndef _DEBUG
	NTService service(serviceMain);
	if (!service.start())
#endif
	{
		if (serviceMain->init(argc, argv))
			serviceMain->run();
	}

	WSACleanup();
	return 0;
}
Esempio n. 8
0
int main(int argc, char **argv){
	static ARGS args;
	initArgs(&args);
	parseArgs(argc, argv, &args);
	if(args.conversionModule == -1) {
		printf("Select a conversion module\n");
		return 0;
	}
	if(args.hexValue == 0) getHex(&args);
	if((short)args.hexValue == -1 && args.filename[0] == '\0'){
		printf("Input a hex value or file containing a hex value");
	}
	swapEndian((char*)&(args.hexValue));
	
	if(args.conversionModule == date){
		DATE_STRUCT *dateS = (DATE_STRUCT*)&(args.hexValue);
		printf("Date: %s, %i, %i\n", months[dateS->month], dateS->day, dateS->year + YEAR_OFFSET);
	} else if(args.conversionModule == time){
		TIME_STRUCT *timeS = (TIME_STRUCT*)&(args.hexValue);
		printf("Time: %i:%i:%i %s\n", timeS->hour%12, timeS->minute, timeS->second*2, 
				timeS->hour > 12 ? "PM" : "AM");
	}
	return 1;
}	
Esempio n. 9
0
JNIEXPORT jobject JNICALL Java_gnu_rrd_RRDJNI_last
(JNIEnv *env, jclass cl, jobjectArray argv) {
  char      **argv2;
  time_t    t;
  
  jclass    DateClass;
  jmethodID DateMethodInit;
  jobject   DateObj;
  jlong     timestamp;
  
  argv2 = initArgs(env, argv, "last");
  t = rrd_last((*env)->GetArrayLength(env, argv)+1, argv2);
  timestamp = t;
 
  DateClass      = (*env)->FindClass(env, "java/util/Date");
  DateMethodInit = (*env)->GetMethodID(env, DateClass, "<init>", "(J)V");
  DateObj        = (*env)->NewObject(env, DateClass, DateMethodInit, timestamp*1000);
  
  freeArgs(env, argv, argv2);
  if (rrd_test_error())
    throwException(env, "gnu/rrd/RRDException", rrd_get_error());

  return DateObj;
}
Esempio n. 10
0
   INT32 mainEntry( INT32 argc, CHAR** argv )
   {
      INT32 rc = SDB_OK ;
      CHAR dialogFile[ OSS_MAX_PATHSIZE + 1 ] = {0} ;
      cCMService svc;
      cPmdDaemon daemon( PMDDMN_SVCNAME_DEFAULT ) ;
      BOOLEAN asProc = FALSE ;
      po::variables_map vm ;

      rc = ossGetEWD( dialogFile, OSS_MAX_PATHSIZE ) ;
      if ( rc )
      {
         ossPrintf( "Failed to get working directory, rc: %d"OSS_NEWLINE, rc ) ;
         goto error ;
      }
      rc = engine::utilCatPath( dialogFile, OSS_MAX_PATHSIZE, SDBCM_LOG_PATH ) ;
      if ( rc )
      {
         ossPrintf( "Failed to make dialog path, rc: %d"OSS_NEWLINE, rc ) ;
         goto error ;
      }
      rc = ossMkdir( dialogFile, OSS_CREATE|OSS_READWRITE ) ;
      if ( rc && SDB_FE != rc )
      {
         ossPrintf( "Create dialog dir[%s] failed, rc: %d"OSS_NEWLINE,
                    dialogFile, rc ) ;
         goto error ;
      }
      rc = engine::utilCatPath( dialogFile, OSS_MAX_PATHSIZE,
                                PMDDMN_DIALOG_FILE_NAME ) ;
      if ( rc )
      {
         ossPrintf( "Failed to make dialog path, rc: %d"OSS_NEWLINE, rc ) ;
         goto error ;
      }

      rc = initArgs( argc, argv, vm, asProc ) ;
      if ( rc )
      {
         if ( SDB_PMD_VERSION_ONLY == rc || SDB_PMD_HELP_ONLY == rc )
         {
            rc = SDB_OK ;
         }
         goto error ;
      }

      sdbEnablePD( dialogFile ) ;
      setPDLevel( PDINFO ) ;

      PD_LOG( PDEVENT, "Start cmd[Ver: %d.%d, Release: %d, Build: %s]...",
              SDB_ENGINE_VERISON_CURRENT, SDB_ENGINE_SUBVERSION_CURRENT,
              SDB_ENGINE_RELEASE_CURRENT, SDB_ENGINE_BUILD_TIME ) ;

      svc.setArgInfo( argc, argv ) ;
      rc = svc.init() ;
      PD_RC_CHECK( rc, PDERROR, "Failed to init cm(rc=%d)", rc ) ;
      rc = daemon.addChildrenProcess( &svc ) ;
      PD_RC_CHECK( rc, PDERROR, "Failed to add childrenProcess(rc=%d)", rc ) ;
      rc = daemon.init();
      if ( rc != SDB_OK )
      {
         ossPrintf( "Failed to init daemon process(rc=%d)", rc ) ;
         goto error;
      }

      rc = daemon.run( argc, argv, asProc );
      PD_RC_CHECK( rc, PDERROR, "Execute failed(rc=%d)", rc ) ;

   done:
      daemon.stop() ;
      PD_LOG( PDEVENT, "Stop programme." ) ;
      return SDB_OK == rc ? 0 : 1 ;
   error:
      goto done ;
   }
Esempio n. 11
0
U_CDECL_END

int main(int argc, char* argv[])
{
    int32_t nerrors = 0;
    TestNode *root = NULL;
    UErrorCode errorCode = U_ZERO_ERROR;
    UDate startTime, endTime;
    int32_t diffTime;

    startTime = uprv_getRawUTCtime();

    /* Check whether ICU will initialize without forcing the build data directory into
    *  the ICU_DATA path.  Success here means either the data dll contains data, or that
    *  this test program was run with ICU_DATA set externally.  Failure of this check
    *  is normal when ICU data is not packaged into a shared library.
    *
    *  Whether or not this test succeeds, we want to cleanup and reinitialize
    *  with a data path so that data loading from individual files can be tested.
    */
    u_init(&errorCode);
    if (U_FAILURE(errorCode)) {
        fprintf(stderr,
            "#### Note:  ICU Init without build-specific setDataDirectory() failed.\n");
    }
    u_cleanup();
    errorCode = U_ZERO_ERROR;
    if (!initArgs(argc, argv, argHandler, (void *) &STANDARD_TEST_FILE)) {
        /* Error already displayed. */
        return -1;
    }

    /* Initialize ICU */
    ctest_setICU_DATA();    /* u_setDataDirectory() must happen Before u_init() */
    u_init(&errorCode);
    if (U_FAILURE(errorCode)) {
        fprintf(stderr,
            "#### ERROR! %s: u_init() failed with status = \"%s\".\n"
            "*** Check the ICU_DATA environment variable and \n"
            "*** check that the data files are present.\n", argv[0], u_errorName(errorCode));
        return 1;
    }

    fprintf(stdout, "Default charset for this run is %s\n", ucnv_getDefaultName());

    addAllTests(&root);
    nerrors = runTestRequest(root, argc, argv);

#if 1
    {
        FILE* fileToRemove = fopen(STANDARD_TEST_FILE, "r");
        /* This should delete any temporary files. */
        if (fileToRemove) {
            fclose(fileToRemove);
            log_verbose("Deleting: %s\n", STANDARD_TEST_FILE);
            if (remove(STANDARD_TEST_FILE) != 0) {
                /* Maybe someone didn't close the file correctly. */
                fprintf(stderr, "FAIL: Could not delete %s\n", STANDARD_TEST_FILE);
                nerrors += 1;
            }
        }
    }
#endif

    cleanUpTestTree(root);
    DataDrivenLogger::cleanUp();
    u_cleanup();

    endTime = uprv_getRawUTCtime();
    diffTime = (int32_t)(endTime - startTime);
    printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
        (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
        (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
        (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
        (int)(diffTime%U_MILLIS_PER_SECOND));

    return nerrors;
}
Esempio n. 12
0
// Ensure the CLR is loaded, create a new AppDomain, get the manager loader running,
// and do the ExportInfo hook-up.
bool XlLibraryInitialize(XlAddInExportInfo* pExportInfo)
{
	HRESULT hr;
	ICorRuntimeHostPtr pHost;
	std::wstring clrVersion;
	bool shadowCopyFiles;
	bool createSandboxedAppDomain;
	
	hr = GetClrOptions(clrVersion, shadowCopyFiles, createSandboxedAppDomain);
	if (FAILED(hr))
	{
		// SelectClrVersion shows diagnostic MessageBoxes if needed.
		// Perhaps remember that we are not loaded?
		return 0;
	}
#ifdef _M_X64
	bool allowedVersion = CompareNoCase(clrVersion, L"v4.0") >= 0;
	if (!allowedVersion)
	{
		ShowMessage(IDS_MSG_HEADER_64NET4, 
					IDS_MSG_BODY_64NET4,
					IDS_MSG_FOOTER_ENSUREVERSION,
					hr);
		return 0;
	}
#endif
	hr = LoadClr(clrVersion, &pHost);
	if (FAILED(hr) || pHost == NULL)
	{
		// LoadClr shows diagnostic MessageBoxes if needed.
		// Perhaps remember that we are not loaded?
		return 0;
	}

	// If all is fine now, also start the CLR (always safe to do again).
	hr = pHost->Start();
	if (FAILED(hr))
	{
		ShowMessage(IDS_MSG_HEADER_NEEDCLR20, 
					IDS_MSG_BODY_HOSTSTART,
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}

	// Load (or find) the AppDomain that will contain the add-in
	std::wstring addInFullPath = GetAddInFullPath();
	_AppDomainPtr pAppDomain;
	_AssemblyPtr pLoaderAssembly;
	bool unloadAppDomain;

	hr = LoadAppDomain(pHost, addInFullPath, createSandboxedAppDomain, shadowCopyFiles, pLoaderAssembly, pAppDomain, unloadAppDomain);
	if (FAILED(hr))
	{
		// Message already shown by LoadAppDomain
		return 0;
	}

	_TypePtr pXlAddInType;
	hr = pLoaderAssembly->GetType_2(_bstr_t(L"ExcelDna.Loader.XlAddIn"), &pXlAddInType);
	if (FAILED(hr) || pXlAddInType == NULL)
	{
		ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
					IDS_MSG_BODY_XLADDIN, 
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}

	SafeVariantArray initArgs(3);
	initArgs.lock();
#ifndef _M_X64
	initArgs.setElement(0, (INT32)pExportInfo);
	initArgs.setElement(1, (INT32)hModuleCurrent);
#else
	initArgs.setElement(0, (INT64)pExportInfo);
	initArgs.setElement(1, (INT64)hModuleCurrent);
#endif
	initArgs.setElement(2, SysAllocStringLen(addInFullPath.c_str(), static_cast<UINT>(addInFullPath.length())));
	initArgs.unlock();
	_variant_t initRetVal;
	_variant_t target;
#ifndef _M_X64
	hr = pXlAddInType->InvokeMember_3(_bstr_t("Initialize32"), (BindingFlags)(BindingFlags_Static | BindingFlags_Public | BindingFlags_InvokeMethod), NULL, target, initArgs, &initRetVal);
#else
	hr = pXlAddInType->InvokeMember_3(_bstr_t("Initialize64"), (BindingFlags)(BindingFlags_Static | BindingFlags_Public | BindingFlags_InvokeMethod), NULL, target, initArgs, &initRetVal);
#endif
	if (FAILED(hr) || initRetVal.boolVal == 0)
	{
		ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
					IDS_MSG_BODY_XLADDININIT, 
					IDS_MSG_FOOTER_CHECKINTEGRATION,
					hr);
		return 0;
	}

	// Keep references needed for later host reference unload.
	if (unloadAppDomain)
	{
		pAppDomain_ForUnload = (IUnknown*)pAppDomain.Detach();
	}
	pHost_ForUnload = pHost.Detach();

	return initRetVal.boolVal == 0 ? false : true;
}
Esempio n. 13
0
int main(int argc, const char* const argv[])
{
    int nerrors = 0;
    UBool   defaultDataFound;
    TestNode *root;
    const char *warnOrErr = "Failure"; 
    UDate startTime, endTime;
    int32_t diffTime;

    /* initial check for the default converter */
    UErrorCode errorCode = U_ZERO_ERROR;
    UResourceBundle *rb;
    UConverter *cnv;

    U_MAIN_INIT_ARGS(argc, argv);

    startTime = uprv_getRawUTCtime();

    gOrigArgc = argc;
    gOrigArgv = argv;
    if (!initArgs(argc, argv, NULL, NULL)) {
        /* Error already displayed. */
        return -1;
    }
    
    /* Check whether ICU will initialize without forcing the build data directory into
     *  the ICU_DATA path.  Success here means either the data dll contains data, or that
     *  this test program was run with ICU_DATA set externally.  Failure of this check
     *  is normal when ICU data is not packaged into a shared library.
     *
     *  Whether or not this test succeeds, we want to cleanup and reinitialize
     *  with a data path so that data loading from individual files can be tested.
     */
    defaultDataFound = TRUE;
    u_init(&errorCode);
    if (U_FAILURE(errorCode)) {
        fprintf(stderr,
            "#### Note:  ICU Init without build-specific setDataDirectory() failed. %s\n", u_errorName(errorCode));
        defaultDataFound = FALSE;
    }
    u_cleanup();
#ifdef URES_DEBUG
    fprintf(stderr, "After initial u_cleanup: RB cache %s empty.\n", ures_dumpCacheContents()?"WAS NOT":"was");
#endif

    while (getTestOption(REPEAT_TESTS_OPTION) > 0) {   /* Loop runs once per complete execution of the tests
                                  *   used for -r  (repeat) test option.                */
        if (!initArgs(argc, argv, NULL, NULL)) {
            /* Error already displayed. */
            return -1;
        }
        errorCode = U_ZERO_ERROR;

        /* Initialize ICU */
        if (!defaultDataFound) {
            ctest_setICU_DATA();    /* u_setDataDirectory() must happen Before u_init() */
        }
        u_init(&errorCode);
        if (U_FAILURE(errorCode)) {
            fprintf(stderr,
                "#### ERROR! %s: u_init() failed with status = \"%s\".\n" 
                "*** Check the ICU_DATA environment variable and \n"
                "*** check that the data files are present.\n", argv[0], u_errorName(errorCode));
                if(!getTestOption(WARN_ON_MISSING_DATA_OPTION)) {
                    fprintf(stderr, "*** Exiting.  Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
                    u_cleanup();
                    return 1;
                }
        }
        


        /* try more data */
        cnv = ucnv_open(TRY_CNV_2, &errorCode);
        if(cnv != 0) {
            /* ok */
            ucnv_close(cnv);
        } else {
            fprintf(stderr,
                    "*** %s! The converter for " TRY_CNV_2 " cannot be opened.\n"
                    "*** Check the ICU_DATA environment variable and \n"
                    "*** check that the data files are present.\n", warnOrErr);
            if(!getTestOption(WARN_ON_MISSING_DATA_OPTION)) {
                fprintf(stderr, "*** Exitting.  Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
                u_cleanup();
                return 1;
            }
        }

        rb = ures_open(NULL, "en", &errorCode);
        if(U_SUCCESS(errorCode)) {
            /* ok */
            ures_close(rb);
        } else {
            fprintf(stderr,
                    "*** %s! The \"en\" locale resource bundle cannot be opened.\n"
                    "*** Check the ICU_DATA environment variable and \n"
                    "*** check that the data files are present.\n", warnOrErr);
            if(!getTestOption(WARN_ON_MISSING_DATA_OPTION)) {
                fprintf(stderr, "*** Exitting.  Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
                u_cleanup();
                return 1;
            }
        }

        errorCode = U_ZERO_ERROR;
        rb = ures_open(NULL, NULL, &errorCode);
        if(U_SUCCESS(errorCode)) {
            /* ok */
            if (errorCode == U_USING_DEFAULT_WARNING || errorCode == U_USING_FALLBACK_WARNING) {
                fprintf(stderr,
                        "#### Note: The default locale %s is not available\n", uloc_getDefault());
            }
            ures_close(rb);
        } else {
            fprintf(stderr,
                    "*** %s! Can not open a resource bundle for the default locale %s\n", warnOrErr, uloc_getDefault());
            if(!getTestOption(WARN_ON_MISSING_DATA_OPTION)) {
                fprintf(stderr, "*** Exitting.  Use the '-w' option if data files were\n"
                    "*** purposely removed, to continue test anyway.\n");
                u_cleanup();
                return 1;
            }
        }
        fprintf(stdout, "Default locale for this run is %s\n", uloc_getDefault());

        /* Build a tree of all tests.   
         *   Subsequently will be used to find / iterate the tests to run */
        root = NULL;
        addAllTests(&root);

        /*  Tests acutally run HERE.   TODO:  separate command line option parsing & setting from test execution!! */
        nerrors = runTestRequest(root, argc, argv);

        setTestOption(REPEAT_TESTS_OPTION, DECREMENT_OPTION_VALUE);
        if (getTestOption(REPEAT_TESTS_OPTION) > 0) {
            printf("Repeating tests %d more time(s)\n", getTestOption(REPEAT_TESTS_OPTION));
        }
        cleanUpTestTree(root);

#ifdef CTST_LEAK_CHECK
        ctst_freeAll();
        /* To check for leaks */
        u_cleanup(); /* nuke the hashtable.. so that any still-open cnvs are leaked */
        
        if(getTestOption(VERBOSITY_OPTION) && ctst_allocated_total>0) {
          fprintf(stderr,"ctst_freeAll():  cleaned up after %d allocations (queue of %d)\n", ctst_allocated_total, CTST_MAX_ALLOC);
        }
#ifdef URES_DEBUG
        if(ures_dumpCacheContents()) {
          fprintf(stderr, "Error: After final u_cleanup, RB cache was not empty.\n");
          nerrors++;
        } else {
          fprintf(stderr,"OK: After final u_cleanup, RB cache was empty.\n");
        }
#endif
#endif

    }  /* End of loop that repeats the entire test, if requested.  (Normally doesn't loop)  */

#ifdef UNISTR_COUNT_FINAL_STRING_LENGTHS
    unistr_printLengths();
#endif

    endTime = uprv_getRawUTCtime();
    diffTime = (int32_t)(endTime - startTime);
    printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
        (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
        (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
        (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
        (int)(diffTime%U_MILLIS_PER_SECOND));

    return nerrors ? 1 : 0;
}
Esempio n. 14
0
   INT32 pmdThreadMainEntry( INT32 argc, CHAR** argv )
   {
      INT32 rc = SDB_OK ;
      pmdKRCB *krcb = pmdGetKRCB() ;
      CHAR currentPath[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ;
      CHAR dialogPath[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ;
      CHAR dialogFile[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ;
      INT32 delSig[] = { 17, 0 } ; // del SIGCHLD
      CHAR verText[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ;
      po::variables_map vm ;

      rc = initArgs( argc, argv, vm ) ;
      if ( rc )
      {
         if ( SDB_PMD_HELP_ONLY == rc || SDB_PMD_VERSION_ONLY == rc )
         {
            rc = SDB_OK ;
         }
         goto done ;
      }

      rc = ossGetEWD( currentPath, OSS_MAX_PATHSIZE ) ;
      if ( rc )
      {
         std::cout << "Get current path failed: " << rc << std::endl ;
         goto error ;
      }
      ossChDir( currentPath ) ;

      rc = utilBuildFullPath( currentPath, SDBCM_LOG_PATH,
                              OSS_MAX_PATHSIZE, dialogPath ) ;
      if ( rc )
      {
         std::cout << "Build dialog path failed: " << rc << std::endl ;
         goto error ;
      }
      rc = ossMkdir( dialogPath ) ;
      if ( rc && SDB_FE != rc )
      {
         std::cout << "Create dialog dir: " << dialogPath << " failed: "
                   << rc << std::endl ;
         goto error ;
      }
      rc = utilBuildFullPath( dialogPath, SDBCM_DIALOG_FILE_NAME,
                              OSS_MAX_PATHSIZE, dialogFile ) ;
      if ( rc )
      {
         std::cout << "Build dialog path failed: " << rc << std::endl ;
         goto error ;
      }
      sdbEnablePD( dialogFile ) ;

      ossSprintVersion( "Version", verText, OSS_MAX_PATHSIZE, FALSE ) ;
      PD_LOG( PDEVENT, "Start cm[%s]...", verText) ;

      rc = sdbGetOMAgentOptions()->init( currentPath ) ;
      if ( rc )
      {
         PD_LOG( PDERROR, "Failed to init config, rc: %d", rc ) ;
         goto error ;
      }
      if ( vm.count( PMD_OPTION_CURUSER ) )
      {
         sdbGetOMAgentOptions()->setCurUser() ;
      }
      if ( vm.count( PMD_OPTION_STANDALONE ) )
      {
         sdbGetOMAgentOptions()->setStandAlone() ;
         if ( vm.count( PMD_OPTION_ALIVE_TIME ) )
         {
            UINT32 timeout = vm[ PMD_OPTION_ALIVE_TIME ].as<INT32>() ;
            sdbGetOMAgentOptions()->setAliveTimeout( timeout ) ;
         }
      }
      if ( vm.count( PMD_OPTION_PORT ) )
      {
         string svcname = vm[ PMD_OPTION_PORT ].as<string>() ;
         sdbGetOMAgentOptions()->setCMServiceName( svcname.c_str() ) ;
         pmdSetLocalPort( (UINT16)ossAtoi( svcname.c_str() ) ) ;
      }
      setPDLevel( sdbGetOMAgentOptions()->getDiagLevel() ) ;

      {
         string configs ;
         sdbGetOMAgentOptions()->toString( configs ) ;
         PD_LOG( PDEVENT, "All configs:\n%s", configs.c_str() ) ;
      }

      pmdSetDBRole( SDB_ROLE_OMA ) ;

      rc = pmdEnableSignalEvent( dialogPath, (PMD_ON_QUIT_FUNC)pmdOnQuit,
                                 delSig ) ;
      PD_RC_CHECK ( rc, PDERROR, "Failed to enable trap, rc: %d", rc ) ;

#if defined( _LINUX )
      signal( SIGCHLD, SIG_IGN ) ;
#endif // _LINUX

      PMD_REGISTER_CB( sdbGetOMAgentMgr() ) ;

      rc = krcb->init() ;
      PD_RC_CHECK( rc, PDERROR, "Failed to init krcb, rc: %d", rc ) ;

      {
         EDUID agentEDU = PMD_INVALID_EDUID ;
         pmdEDUMgr *eduMgr = krcb->getEDUMgr() ;
         rc = eduMgr->startEDU ( EDU_TYPE_PIPESLISTENER,
                                 (void*)sdbGetOMAgentOptions()->getCMServiceName(),
                                 &agentEDU ) ;
         PD_RC_CHECK( rc, PDERROR, "Start PIPELISTENER failed, rc: %d",
                      rc ) ;

         rc = eduMgr->waitUntil( agentEDU, PMD_EDU_RUNNING ) ;
         PD_RC_CHECK( rc, PDERROR, "Wait pipe listener to running "
                      "failed, rc: %d", rc ) ;
      }

#if defined (_LINUX)
      {
         CHAR pmdProcessName [ OSS_RENAME_PROCESS_BUFFER_LEN + 1 ] = {0} ;
         ossSnprintf ( pmdProcessName, OSS_RENAME_PROCESS_BUFFER_LEN,
                       "%s(%s)", utilDBTypeStr( pmdGetDBType() ),
                       sdbGetOMAgentOptions()->getCMServiceName() ) ;
         ossEnableNameChanges ( argc, argv ) ;
         ossRenameProcess ( pmdProcessName ) ;
      }
#endif // _LINUX

      while ( PMD_IS_DB_UP() )
      {
         ossSleepsecs ( 1 ) ;
      }
      rc = krcb->getShutdownCode() ;

   done:
      PMD_SHUTDOWN_DB( rc ) ;
      pmdSetQuit() ;
      krcb->destroy () ;
      PD_LOG ( PDEVENT, "Stop programme, exit code: %d",
               krcb->getShutdownCode() ) ;
      return rc == SDB_OK ? 0 : 1 ;
   error:
      goto done ;
   }
Esempio n. 15
0
static ActionRetCodeEnum createFrameRenderResultsForView(const ViewerNodePtr& viewer,
                                                         const TreeRenderQueueProviderPtr& provider,
                                                         const ViewerRenderFrameResultsContainerPtr& results,
                                                         ViewIdx view,
                                                         const RenderStatsPtr& stats,
                                                         bool isPlayback,
                                                         const RectD* partialUpdateRoIParam,
                                                         unsigned int mipMapLevel,
                                                         ViewerCompositingOperatorEnum viewerBlend,
                                                         bool byPassCache,
                                                         bool draftModeEnabled,
                                                         bool fullFrameProcessing,
                                                         bool viewerBEqualsViewerA,
                                                         const RotoStrokeItemPtr& activeDrawingStroke)
{

    // Initialize for each view a sub-result.
    // Each view has 2 renders: the A and B viewerprocess
    ViewerRenderFrameSubResultPtr subResult(new ViewerRenderFrameSubResult);
    results->frames.push_back(subResult);
    subResult->view = view;
    subResult->stats = stats;

    if (partialUpdateRoIParam) {
        subResult->textureTransferType = OpenGLViewerI::TextureTransferArgs::eTextureTransferTypeOverlay;
    } else if (activeDrawingStroke && activeDrawingStroke->getRenderCloneCurrentStrokeStartPointIndex() > 0) {
        // Upon painting ticks, we just have to update the viewer for the area that was painted
        subResult->textureTransferType = OpenGLViewerI::TextureTransferArgs::eTextureTransferTypeModify;
    } else {
        subResult->textureTransferType = OpenGLViewerI::TextureTransferArgs::eTextureTransferTypeReplace;
    }

    for (int viewerInputIndex = 0; viewerInputIndex < 2; ++viewerInputIndex) {
        subResult->perInputsData[viewerInputIndex].retCode = eActionStatusFailed;
        if (viewerInputIndex == 1 && (viewerBEqualsViewerA || viewerBlend == eViewerCompositingOperatorNone)) {
            if (viewerBEqualsViewerA && viewerBlend != eViewerCompositingOperatorNone) {
                subResult->copyInputBFromA = true;
            }
            continue;
        }
        if (viewer->isViewerPaused(viewerInputIndex)) {
            subResult->perInputsData[viewerInputIndex].retCode = eActionStatusAborted;
            continue;
        }
        ViewerInstancePtr viewerProcess = viewer->getViewerProcessNode(viewerInputIndex);
        subResult->perInputsData[viewerInputIndex].viewerProcessNode = viewerProcess->getNode();



        TreeRender::CtorArgsPtr initArgs(new TreeRender::CtorArgs);
        initArgs->treeRootEffect = viewerProcess;
        initArgs->provider = provider;
        initArgs->time = results->time;
        initArgs->view = subResult->view;

        // Render by default on disk is always using a mipmap level of 0 but using the proxy scale of the project
        initArgs->mipMapLevel = mipMapLevel;


#pragma message WARN("Todo: set proxy scale here")
        initArgs->proxyScale = RenderScale(1.);

        // Render the RoD if fullframe processing
        if (partialUpdateRoIParam) {
            initArgs->canonicalRoI = *partialUpdateRoIParam;
        } else {
            RectD roi;
            if (!fullFrameProcessing) {
                roi = viewerProcess->getViewerRoI();
            }
            initArgs->canonicalRoI = roi;

        }
        
        initArgs->stats = stats;
        initArgs->activeRotoDrawableItem = activeDrawingStroke;
        initArgs->draftMode = draftModeEnabled;
        initArgs->playback = isPlayback;
        initArgs->byPassCache = byPassCache;
        initArgs->preventConcurrentTreeRenders = (activeDrawingStroke || partialUpdateRoIParam);
        if (!isPlayback && subResult->textureTransferType == OpenGLViewerI::TextureTransferArgs::eTextureTransferTypeReplace && !activeDrawingStroke) {
            subResult->perInputsData[viewerInputIndex].colorPickerNode = viewerInputIndex == 0 ? viewer->getCurrentAInput() : viewer->getCurrentBInput();
            if (subResult->perInputsData[viewerInputIndex].colorPickerNode) {
                // Also sample the "main" input of the color picker node, this is useful for keyers.
                int mainInput = subResult->perInputsData[viewerInputIndex].colorPickerNode->getPreferredInput();
                subResult->perInputsData[viewerInputIndex].colorPickerInputNode = subResult->perInputsData[viewerInputIndex].colorPickerNode->getInput(mainInput);
            }
        }
        if (subResult->perInputsData[viewerInputIndex].colorPickerNode) {
            initArgs->extraNodesToSample.push_back(subResult->perInputsData[viewerInputIndex].colorPickerNode);
        }
        if (subResult->perInputsData[viewerInputIndex].colorPickerInputImage) {
            initArgs->extraNodesToSample.push_back(subResult->perInputsData[viewerInputIndex].colorPickerInputNode);
        }

        subResult->perInputsData[viewerInputIndex].render = TreeRender::create(initArgs);
        if (!subResult->perInputsData[viewerInputIndex].render) {
            return eActionStatusFailed;
        }

    } // for each viewer input
    return eActionStatusOK;
} // createFrameRenderResultsForView
Esempio n. 16
0
JNIEXPORT jobject JNICALL Java_gnu_rrd_RRDJNI_info
(JNIEnv *env, jclass cl, jobjectArray argv) {
  char      **argv2;
  rrd_info_t    *info, *save;

  jclass        HashtableClass;
  jmethodID     HashtableMethodInit;
  jmethodID     HashtableMethodPut;
  jclass        RRDInfoClass;
  jmethodID     RRDInfoMethodVal;
  jmethodID     RRDInfoMethodCnt;
  jmethodID     RRDInfoMethodStr;
  jmethodID     RRDInfoMethodDate;
  jclass        DateClass;
  jmethodID     DateMethodInit;
  jobject       DateObj;

  jobject       rtnObj;
  jstring       key;
  jdouble       value;
  jlong         counter;
  jstring       strval;
  
  HashtableClass      = (*env)->FindClass(env, "java/util/Hashtable");
  HashtableMethodInit = (*env)->GetMethodID(env, HashtableClass, "<init>", "()V");
  HashtableMethodPut  = (*env)->GetMethodID(env, HashtableClass, "put",
					    "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
  RRDInfoClass        = (*env)->FindClass(env, "gnu/rrd/RRDInfo");
  RRDInfoMethodVal    = (*env)->GetMethodID(env, RRDInfoClass, "<init>", "(D)V");
  RRDInfoMethodCnt    = (*env)->GetMethodID(env, RRDInfoClass, "<init>", "(J)V");
  RRDInfoMethodStr    = (*env)->GetMethodID(env, RRDInfoClass, "<init>", "(Ljava/lang/String;)V");
  RRDInfoMethodDate   = (*env)->GetMethodID(env, RRDInfoClass, "<init>", "(Ljava/util/Date;)V");
  DateClass           = (*env)->FindClass(env, "java/util/Date");
  DateMethodInit      = (*env)->GetMethodID(env, DateClass, "<init>", "(J)V");
  rtnObj              = (*env)->NewObject(env, HashtableClass, HashtableMethodInit, NULL);

  argv2 = initArgs(env, argv, "last");
  info = rrd_info((*env)->GetArrayLength(env, argv)+1, argv2);

  while (info) {
    save=info;
    key = (jstring)(*env)->NewStringUTF(env, info->key);
    switch (info->type) {
      case RD_I_VAL:
        value = info->value.u_val;
        (*env)->CallVoidMethod(env, rtnObj, HashtableMethodPut, key,
          (*env)->NewObject(env, RRDInfoClass, RRDInfoMethodVal, value), NULL);
        break;
      case RD_I_CNT:
	counter = info->value.u_cnt;
	if (strcmp(info->key, "last_update")==0) {
          (*env)->CallVoidMethod(env, rtnObj, HashtableMethodPut, key,
            (*env)->NewObject(env, RRDInfoClass, RRDInfoMethodDate,
	      (*env)->NewObject(env, DateClass, DateMethodInit, counter*1000)), NULL);
	} else {
          (*env)->CallVoidMethod(env, rtnObj, HashtableMethodPut, key,
            (*env)->NewObject(env, RRDInfoClass, RRDInfoMethodCnt, counter), NULL);
	}
        break;
      case RD_I_STR:
        strval = (jstring)(*env)->NewStringUTF(env, info->value.u_str);
        (*env)->CallVoidMethod(env, rtnObj, HashtableMethodPut, key,
          (*env)->NewObject(env, RRDInfoClass, RRDInfoMethodStr, strval), NULL);
        break;
    }
    info = info->next;
    free(save);
  }
  free(info);
  freeArgs(env, argv, argv2);
  if (rrd_test_error())
    throwException(env, "gnu/rrd/RRDException", rrd_get_error());

  return rtnObj;
}
Esempio n. 17
0
JNIEXPORT jobject JNICALL Java_gnu_rrd_RRDJNI_fetch
(JNIEnv *env, jclass cl, jobjectArray argv) {
  time_t        start, end;
  unsigned long step, ds_cnt, i, ii;
  rrd_value_t   *data, *datai;
  char          **ds_namv;
  char          s[30];
  char          **argv2;
  
  jclass        VectorClass;
  jmethodID     VectorMethodInit;
  jmethodID     VectorMethodAdd;
  jclass        DateClass;
  jmethodID     DateMethodInit;
  jclass        DoubleClass;
  jmethodID     DoubleMethodInit;
  jclass        RRDRecClass;
  jmethodID     RRDRecMethodInit;
  
  jobject       dateObj;
  jdouble       dataObj;
  jobject       dsObj;
  jobject       rtnObj;
  jlong         timestamp;
    
  VectorClass      = (*env)->FindClass(env, "java/util/Vector");
  VectorMethodInit = (*env)->GetMethodID(env, VectorClass, "<init>", "()V");
  VectorMethodAdd  = (*env)->GetMethodID(env, VectorClass, "addElement", "(Ljava/lang/Object;)V");
  DateClass        = (*env)->FindClass(env, "java/util/Date");
  DateMethodInit   = (*env)->GetMethodID(env, DateClass, "<init>", "(J)V");
  DoubleClass      = (*env)->FindClass(env, "java/lang/Double");
  DoubleMethodInit = (*env)->GetMethodID(env, DoubleClass, "<init>", "(D)V");
  RRDRecClass      = (*env)->FindClass(env, "gnu/rrd/RRDRec");
  RRDRecMethodInit = (*env)->GetMethodID(env, RRDRecClass, "<init>", "(Ljava/util/Date;Ljava/util/Vector;)V");
  rtnObj           = (*env)->NewObject(env, VectorClass, VectorMethodInit, NULL);

  argv2 = initArgs(env, argv, "fetch");
  if (rrd_fetch((*env)->GetArrayLength(env, argv)+1, argv2, &start, &end, &step,
      &ds_cnt, &ds_namv, &data) != -1) {
    datai = data;
    for (i = start; i <= end; i += step) {
      timestamp = i;
      dateObj = (*env)->NewObject(env, DateClass, DateMethodInit, timestamp*1000);
      dsObj   = (*env)->NewObject(env, VectorClass, VectorMethodInit, NULL);
      for (ii = 0; ii < ds_cnt; ii++) {
	dataObj = *(datai++);
        (*env)->CallVoidMethod(env, dsObj, VectorMethodAdd,
          (*env)->NewObject(env, DoubleClass, DoubleMethodInit, dataObj));
      }
      (*env)->CallVoidMethod(env, rtnObj, VectorMethodAdd,
        (*env)->NewObject(env, RRDRecClass, RRDRecMethodInit, dateObj, dsObj));
    }
    for (i=0; i<ds_cnt; i++) free(ds_namv[i]);
    free(ds_namv);
    free(data);
  }
  freeArgs(env, argv, argv2);
  if (rrd_test_error())
    throwException(env, "gnu/rrd/RRDException", rrd_get_error());

  return rtnObj;
}