示例#1
0
// TODO!!!!!
// create the install_libname.bat installation batch file:
void gen_vc_install_bat(const Project &project, const Workspace &workspace)
{
	std::string bat_file = "Sources\\install_";
	bat_file += project.libname;
	bat_file += ".bat";

	std::ofstream bat(bat_file.c_str());

	std::string instdir = workspace.output_include_dir;
	instdir += "\\ClanLib";
	install_mkdir(bat, "API\\", instdir, &project);
	install_copydir(bat, "API\\", instdir, &project);
}
void CBTControllerServerSession::GetBatteryStatusComplete(TInt aBatteryStatus, TInt aError)
    {
	if(iMessage.Function() == EBatteryStatus)
		{
        TPckg<TInt> pck(aBatteryStatus);
        if(!iMessage.IsNull())
            {
            TInt err(KErrNone);
            TInt bat(aBatteryStatus);
            TPtr8 ptr( reinterpret_cast<TUint8*>( &bat ), sizeof( bat ), sizeof( bat ) );
            err = iMessage.Write(0,ptr,0);
            iMessage.Complete(aError);
            }			
		}	
    }
int Valid(int X, int Y) {
  if (X != Y) return 1;
  if (X == Y + 0) return 1;
  if (P.x == P.y) return 1;
  if (P.a[P.x] < P.a[P.y]) return 1;
  if (P.a[0] < P.a[1]) return 1;

  if (P.a[0] < P.a[0ULL]) return 1;
  if (0 < 0ULL) return 1;
  if ((int)0 < (int)0ULL) return 1;

  if (++X != ++X) return 1;
  if (P.a[X]++ != P.a[X]++) return 1;
  if (P.a[X++] != P.a[X++]) return 1;

  if ("abc" == "ABC") return 1;
  if (foo(bar(0)) < (foo(bat(0, 1)))) return 1;
  return 0;
}
bool ZeroTierOneService::doStartUpgrade(const std::string &msiPath)
{
	std::string msiLog(ZeroTier::ZT_DEFAULTS.defaultHomePath + "\\LastUpdateLog.txt");
	ZeroTier::Utils::rm(msiLog);

	std::string bat(ZeroTier::ZT_DEFAULTS.defaultHomePath + "\\InstallAndRestartService.bat");
	FILE *batf = fopen(bat.c_str(),"wb");
	if (!batf)
		return false;
	fprintf(batf,"TIMEOUT.EXE /T 1 /NOBREAK\r\n");
	fprintf(batf,"NET.EXE STOP \"ZeroTier One\"\r\n");
	fprintf(batf,"MSIEXEC.EXE /i \"%s\" /l* \"%s\" /qn\r\n",msiPath.c_str(),msiLog.c_str());
	fprintf(batf,"NET.EXE START \"ZeroTier One\"\r\n");
	fclose(batf);

	STARTUPINFOA si;
	PROCESS_INFORMATION pi;
	memset(&si,0,sizeof(si));
	memset(&pi,0,sizeof(pi));
	if (!CreateProcessA(NULL,const_cast <LPSTR>((std::string("CMD.EXE /c \"") + bat + "\"").c_str()),NULL,NULL,FALSE,CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP,NULL,NULL,&si,&pi))
		return false;

	return true;
}
void WorkspaceGenerator_MSVC8::write_install_batch_file(const Workspace &workspace, const Project &project)
{
	// create the install_libname.bat installation batch file:
	{
		std::string bat_file = "Projects\\install_clan";
		bat_file += project.name.c_str();
		bat_file += ".bat";

		std::ofstream bat(bat_file.c_str());
		bat << "mode con cp select=" << GetACP() << " > nul" << std::endl;

		install_mkdir(bat, workspace.output_lib_dir);

		std::string instdir = workspace.output_include_dir.c_str();
		instdir += "\\ClanLib";
		install_mkdir(bat, "API\\", std::string(instdir), &project);
		install_copydir(bat, "API\\", std::string(instdir), &project);

		bat << "copy %1 \"" << workspace.output_lib_dir.c_str() << "\\%4\" > nul" << std::endl;
		if (target_android)	//TODO: Fixme
			bat << "rem ";
		bat << "copy %2 \"" << workspace.output_lib_dir.c_str() << "\\%4\\%3\" > nul" << std::endl;
	}
}
示例#6
0
//
// main routine
//
int main(void) {
#ifdef DEBUG
	CSerial ser;		// declare a UART object
	ser.enable();
	CDebug dbg(ser);	// Debug stream use the UART object
	dbg.start();
#endif
	//
	// Declare SoftDevice Object
	//
	bleDevice ble;
	ble.enable();						// enable BLE stack

	// GAP
	ble.m_gap.settings(DEVICE_NAME);	// set Device Name on GAP
	ble.m_gap.tx_power(BLE_TX_0dBm);	// set output radio Power

	//
	// Declare a HRM service object
	//
	bleServiceHRM hrm(ble);

	//
	// Declare a HTM service object
	//
	bleServiceHTM htm(ble);

	//
	// Declare a BAT service object
	//
	bleServiceBattery bat(ble);

	//
	// Add "connection parameters update" negotiation. (optional)
	//
	bleConnParams conn(ble);

	//
	// update advertisement contents
	//
	ble.m_advertising.commpany_identifier(APP_COMPANY_IDENTIFIER);	// add company identifier
	ble.m_advertising.add_uuid_to_complete_list(hrm);				// add hrm object to the uuid list of advertisement
	ble.m_advertising.add_uuid_to_complete_list(htm);				// add htm object to the uuid_list of advertisement
	ble.m_advertising.add_uuid_to_complete_list(bat);				// add bat object to the uuid_list of advertisement
	ble.m_advertising.appearance(BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR);
	ble.m_advertising.update();										// update advertisement data

	// Start advertising
	ble.m_advertising.interval(APP_ADV_INTERVAL);					// set advertising interval
//	ble.m_advertising.timeout(30); // set timeout, will cause the system to enter to the power off mode.
	ble.m_advertising.start();

	//
	// Tickless Low Power Feature
	//
#ifndef DEBUG
	CPowerSave::tickless(true);
#endif

	//
	// Analog input (for VDD detected)
	//
	CAdc::init();			// AREF internal VBG
	CAdc::source(VDD_1_3);	// source from internal: VDD x 1/3
	CAdc::enable();

	//
	// LED Task
	//
	CThread t(tskLED);
	t.start("LED", 45);	// stack size=45 DWORD

	//
	uint16_t value;
	float 	 temp, percentage;

	//
    // Enter main loop.
	//
    while(1) {

    	//
    	// wait for BLE connected, the task will be blocked until connected.
    	//
    	ble.wait();

    	//
    	// Heart Rate Measurement Service
    	//
    	if ( hrm.isAvailable() ) {	// is service available (when remote app connected to the service)
    		hrm.send(70);			// send Heart Rate Measurement
    	}

    	//
    	// Health Thermometer Measurement Service
    	//
    	if ( htm.isAvailable() ) {		// is service available (when remote app connected to the service)
			if ( bleServiceHTM::get_temperature(temp) ) {
				htm.send(temp);	// send temp
			}
    	}

    	//
    	// Battery Service
    	//
    	if ( bat.isAvailable() ) {		// is service available (when remote app connected to the service)
			if ( CAdc::read(value) ) {
				percentage = (value / 1024.0f) * 100.0;
				bat.send(percentage);
			}
    	}

    	// Negotiate the "connection parameters update"
    	conn.negotiate();

    	// sleep to make more idle time for tickless.
    	sleep(200);
    }
}
示例#7
0
//
// Main Routine
//
int main(void) {
#ifdef DEBUG
	CSerial ser;		// declare a UART object
	ser.enable();
	CDebug dbg(ser);	// Debug stream use the UART object
	dbg.start();
#endif
	//
	// SoftDevice
	//
	bleDevice ble;
	ble.enable("Shutter", "1234");	// enable BLE SoftDevice task

	// Pin to clear all center list
	CPin btn(17);
	btn.input();

	// Device Manager for bond device.
	bleDeviceManager man(ble, (btn==LOW ? true : false));
	man.connect_directed_mode();	// enable "connect directed" mode to fast connected. (BT 4.1 spec.)

	// GAP
	ble.m_gap.settings( DEVICE_NAME,
			 	 	 	20,		// min. connection interval in millisecond
						100,	// max. connection interval in millisecond
						12);	// slave latency (save power)

	ble.m_gap.tx_power(BLE_TX_0dBm);

	//
	// HID Keyboard Service
	//
	bleServiceKB kbs(ble);

	//
	// Battery Level Service
	//
	bleServiceBattery bat(ble);

	//
	// Optional: Add "Connection Parameters Update" negotiation.
	//
	bleConnParams conn(ble);

	//
	// BLE Advertising
	//
	ble.m_advertising.add_uuid_to_complete_list(bat);				// add bat object to the uuid list of advertising
	ble.m_advertising.add_uuid_to_complete_list(kbs);				// add kbs object to the uuid list of advertising

	// Optional: add appearance to indicate who you are in advertisement.
	ble.m_advertising.appearance(BLE_APPEARANCE_HID_KEYBOARD);
	ble.m_advertising.update();										// update advertisement data

	// Start advertising
	ble.m_advertising.interval(APP_ADV_INTERVAL);					// set advertising interval
	ble.m_advertising.timeout(30);									// Enter system power off mode when adv. timeout. (disable system off if timeout=0)
	ble.m_advertising.start();

	//
	// Optional: Enable tickless technology
	//
#ifndef DEBUG
	CPowerSave::tickless(true);
#endif

	//
	// Key Test Task
	//
	CThread t(keyTask);
	t.start("kb", 76);		// start the keyTask

	//
	// Analog
	//
	CAdc::init();
	CAdc::source(VDD_1_3);	// to detect the VDD voltage
	CAdc::enable();

	//
	// LED
	//
	CPin led(LED_PIN_0);
	led.output();

	CTimeout tmBAT, tmLED;
	uint16_t value;
	float 	 percentage;

	//
    // Enter main loop.
	//
    while(1) {

    	//
    	// BLE Battery Service
    	//
    	if ( bat.isAvailable() ) {
    		if ( tmBAT.isExpired(1000) ) {
    			tmBAT.reset();
    			if ( CAdc::read(value) ) {
    				percentage = (value / 1024.0f) * 100;
    				bat.send(percentage);
    			}
    		}
    	}

    	//
    	// blink led
    	//
    	led = LED_ON;
    	sleep(10);
    	led = LED_OFF;
    	if ( ble.isConnected() ) {
    		sleep(290);
    	} else {
    		sleep(1990);
    	}

    	// Negotiate the "connection parameters update" in main-loop
    	conn.negotiate();
    }
}
示例#8
0
void VpeMain::executeEditor( const WString& cmd )
{
    if( _config->debug() && !confirm( "executeEditor: '%s'", cmd ) ) {
        return;
    }
    setStatus( "Executing editor..." );
    WStringList x( cmd );
    if( _editorIsDll ) {
        if( _editorDll.isInitialized() ) {      //internal-use DLL
            if( x.stringAt(0) == "EditSaveAll" ) {
                // don't start a new editor up if one is not already there
                _editorDll.EDITSaveAll();
            } else if( _editorDll.EDITConnect() ) {
                if( x.stringAt(0) == "EditFile" ) {
                    char* file = (char*)(const char*)x.stringAt( 1 );
                    char* help = (char*)(const char*)x.stringAt( 2 );
                    if( _editorDll.EDITFile( file, help ) ) {
                        _editorDll.EDITShowWindow( EDIT_SHOWNORMAL );
                    } else {
                        WMessageDialog::messagef( this, MsgError, MsgOk,
                                    _viperInfo, "Unable to start editor" );
                    }
                } else if( x.stringAt( 0 ) == "EditLocate" ) {
                    long lRow = atol( x.stringAt( 1 ) );
                    int nCol = atoi( x.stringAt( 2 ) );
                    int len = atoi( x.stringAt( 3 ) );
                    _editorDll.EDITLocate( lRow, nCol, len );
                    _editorDll.EDITShowWindow( EDIT_SHOWNORMAL );
                } else if( x.stringAt( 0 ) == "EditLocateError" ) {
                    long lRow = atol( x.stringAt( 1 ) );
                    int nCol = atoi( x.stringAt( 2 ) );
                    int len = atoi( x.stringAt( 3 ) );
                    int resId = atoi( x.stringAt( 4 ) );
                    char* msg = (char*)(const char*)x.stringAt( 5 );
                    _editorDll.EDITLocateError( lRow, nCol, len, resId, msg );
                    _editorDll.EDITShowWindow( EDIT_SHOWNORMAL );
                } else if( x.stringAt(0) == "EditFileAtPos" ) {
                    char* file = (char*)(const char*)x.stringAt( 1 );
                    file += 2; // for "-f" before filename
                    long lRow = atol( x.stringAt( 2 ) );
                    int nCol = atoi( x.stringAt( 3 ) );
                    int len = atoi( x.stringAt( 4 ) );
                    int resId = atoi( x.stringAt( 5 ) );
                    char* msg = (char*)(const char*)x.stringAt( 6 );
                    char* help = (char*)(const char*)x.stringAt( 7 );
                    if( _editorDll.EDITFile( file, help ) ) {
                        _editorDll.EDITShowWindow( EDIT_SHOWNORMAL );
                        _editorDll.EDITLocateError( lRow, nCol, len, resId, msg );
                        _editorDll.EDITShowWindow( EDIT_SHOWNORMAL );
                    } else {
                        WMessageDialog::messagef( this, MsgError, MsgOk,
                                    _viperInfo, "Unable to start editor" );
                    }
                } else if( x.stringAt(0) == "TakeFocus" ) {
                    _editorDll.EDITShowWindow( EDIT_SHOWNORMAL );
                }
            } else {
                WMessageDialog::messagef( this, MsgError, MsgOk, _viperInfo,
                                          "Unable to connect to editor" );
            }
        } else {
            WMessageDialog::messagef( this, MsgError, MsgOk, _viperInfo,
                                        "Editor not available" );
        }
    } else if( x.stringAt(0) == "EditFile" ) {
        WString bat( _editor );
        bat.concat( ' ' );
        bat.concat( x.cStringAt(1) );
        execute( bat );
    } else if( x.stringAt(0) == "EditFileAtPos" ) {
        WString bat( _editor );
        bat.concat( ' ' ); // space after editor name before parms
        size_t parmsize = _editorParms.size();
        for( size_t i = 0; i < parmsize; i++ ) {
            switch( _editorParms[i] ) {
            case '%':
                switch( _editorParms[i+1] ) {
                case 'f': // file name
                    // string contains "-f<filename>" so strip the -f
                    bat.concat( (char*)(const char*)x.stringAt( 1 )+2 );
                    break;
                case 'r': // row to go to
                    bat.concat( x.stringAt( 2 ) );
                    break;
                case 'c': // column to go to
                    bat.concat( x.stringAt( 3 ) );
                    break;
                case 'l': // length of hilight
                    bat.concat( x.stringAt( 4 ) );
                    break;
                case 'h': // helpid
                    bat.concat( x.stringAt( 5 ) );
                    break;
                case 'e': // error message
                    bat.concat( x.stringAt( 6 ) );
                    break;
                case '%': // a real '%'
                    bat.concat( x.stringAt( '%' ) );
                    break;
                default:
                    // ignore the '%' and the character
                    break;
                }
                i+=2; // skip % and following char
            default:
                bat.concat( _editorParms[i] );
                break;
            }
        }
        execute( bat );
    }
}
示例#9
0
void UObjectTest::testIDs()
{
    ids_count = 0;
    UErrorCode status = U_ZERO_ERROR;
    static const UChar SMALL_STR[] = {0x51, 0x51, 0x51, 0}; // "QQQ"

#if !UCONFIG_NO_TRANSLITERATION || !UCONFIG_NO_FORMATTING
    UParseError parseError;
#endif
   

#if !UCONFIG_NO_NORMALIZATION
    UnicodeString emptyString;
    TESTCLASSID_CTOR(Normalizer, (emptyString, UNORM_NONE));
    const Normalizer2 *noNormalizer2 = NULL;
    UnicodeSet emptySet;
    TESTCLASSID_NONE_CTOR(FilteredNormalizer2, (*noNormalizer2, emptySet));
    TESTCLASSID_FACTORY(CanonicalIterator, new CanonicalIterator(UnicodeString("abc"), status));
#endif
#if !UCONFIG_NO_IDNA
    TESTCLASSID_NONE_FACTORY(IDNA, IDNA::createUTS46Instance(0, status));
#endif
    //TESTCLASSID_DEFAULT(CollationElementIterator);
#if !UCONFIG_NO_COLLATION
    TESTCLASSID_DEFAULT(CollationKey);
    TESTCLASSID_FACTORY(UStringEnumeration, Collator::getKeywords(status));
    //TESTCLASSID_FACTORY_HIDDEN(CollationLocaleListEnumeration, Collator::getAvailableLocales());
#endif
    //TESTCLASSID_FACTORY(CompoundTransliterator, Transliterator::createInstance(UnicodeString("Any-Jex;Hangul-Jamo"), UTRANS_FORWARD, parseError, status));
    
#if !UCONFIG_NO_FORMATTING
    /* TESTCLASSID_FACTORY(NFSubstitution,  NFSubstitution::makeSubstitution(8, */
    /* TESTCLASSID_DEFAULT(DigitList);  UMemory but not UObject*/
    TESTCLASSID_ABSTRACT(NumberFormat);
    TESTCLASSID_CTOR(RuleBasedNumberFormat, (UnicodeString("%default: -x: minus >>;"), parseError, status));
    TESTCLASSID_CTOR(ChoiceFormat, (UNICODE_STRING_SIMPLE("0#are no files|1#is one file|1<are many files"), status));
    TESTCLASSID_CTOR(MessageFormat, (UnicodeString(), status));
    TESTCLASSID_CTOR(DateFormatSymbols, (status));
    TESTCLASSID_CTOR(PluralFormat, (status));
    TESTCLASSID_CTOR(PluralRules, (status));
    TESTCLASSID_CTOR(SelectFormat, (UnicodeString("feminine {feminineVerbValue} other{otherVerbValue}"), status) );
    TESTCLASSID_FACTORY(DateTimePatternGenerator, DateTimePatternGenerator::createInstance(status));
    TESTCLASSID_FACTORY(RelativeDateFormat, DateFormat::createDateInstance(DateFormat::kFullRelative, Locale::getUS()));
    TESTCLASSID_CTOR(DecimalFormatSymbols, (status));
    TESTCLASSID_DEFAULT(FieldPosition);
    TESTCLASSID_DEFAULT(Formattable);
    TESTCLASSID_CTOR(CurrencyAmount, (1.0, SMALL_STR, status));
    TESTCLASSID_CTOR(CurrencyUnit, (SMALL_STR, status));
    TESTCLASSID_NONE_FACTORY(LocaleDisplayNames, LocaleDisplayNames::createInstance("de"));
    TESTCLASSID_FACTORY_HIDDEN(CurrencyFormat, MeasureFormat::createCurrencyFormat(Locale::getUS(), status));
    TESTCLASSID_FACTORY(GregorianCalendar, Calendar::createInstance(Locale("@calendar=gregorian"), status));
    TESTCLASSID_FACTORY(BuddhistCalendar, Calendar::createInstance(Locale("@calendar=buddhist"), status));
    TESTCLASSID_FACTORY(IslamicCalendar, Calendar::createInstance(Locale("@calendar=islamic"), status));
    TESTCLASSID_FACTORY(JapaneseCalendar, Calendar::createInstance(Locale("@calendar=japanese"), status));
    TESTCLASSID_FACTORY(HebrewCalendar, Calendar::createInstance(Locale("@calendar=hebrew"), status));
    TESTCLASSID_FACTORY(PersianCalendar, Calendar::createInstance(Locale("@calendar=persian"), status));
    TESTCLASSID_FACTORY(IndianCalendar, Calendar::createInstance(Locale("@calendar=indian"), status));
    TESTCLASSID_FACTORY(ChineseCalendar, Calendar::createInstance(Locale("@calendar=chinese"), status));
    TESTCLASSID_FACTORY(TaiwanCalendar, Calendar::createInstance(Locale("@calendar=roc"), status));
#ifdef U_WINDOWS
    TESTCLASSID_FACTORY(Win32DateFormat, DateFormat::createDateInstance(DateFormat::kFull, Locale("@compat=host")));
    TESTCLASSID_FACTORY(Win32NumberFormat, NumberFormat::createInstance(Locale("@compat=host"), status));
#endif
#endif

#if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO
    /* TESTCLASSID_ABSTRACT(BreakIterator); No staticID!  */
    TESTCLASSID_FACTORY(RuleBasedBreakIterator, BreakIterator::createLineInstance("mt",status));
    //TESTCLASSID_FACTORY(DictionaryBasedBreakIterator, BreakIterator::createLineInstance("th",status));

#if !UCONFIG_NO_SERVICE
    TESTCLASSID_FACTORY_HIDDEN(ICULocaleService, BreakIterator::getAvailableLocales());
#endif
#endif
    
    //TESTCLASSID_DEFAULT(GregorianCalendar);
    
#if !UCONFIG_NO_TRANSLITERATION
    TESTCLASSID_TRANSLIT(AnyTransliterator, "Any-Latin");
    TESTCLASSID_TRANSLIT(CompoundTransliterator, "Latin-Greek");
    TESTCLASSID_TRANSLIT(EscapeTransliterator, "Any-Hex");
    TESTCLASSID_TRANSLIT(LowercaseTransliterator, "Lower");
    TESTCLASSID_TRANSLIT(NameUnicodeTransliterator, "Name-Any");
    TESTCLASSID_TRANSLIT(NormalizationTransliterator, "NFD");
    TESTCLASSID_TRANSLIT(NullTransliterator, "Null");
    TESTCLASSID_TRANSLIT(RemoveTransliterator, "Remove");
    TESTCLASSID_FACTORY(RuleBasedTransliterator, Transliterator::createFromRules(UnicodeString("abcd"),UnicodeString("a>b;"),UTRANS_FORWARD,parseError,status));
    TESTCLASSID_TRANSLIT(TitlecaseTransliterator, "Title");
    TESTCLASSID_TRANSLIT(UnescapeTransliterator, "Hex-Any");
    TESTCLASSID_TRANSLIT(UnicodeNameTransliterator, "Any-Name");
    TESTCLASSID_TRANSLIT(UppercaseTransliterator, "Upper");
    TESTCLASSID_ABSTRACT(CaseMapTransliterator);
    TESTCLASSID_ABSTRACT(Transliterator);
    TESTCLASSID_FACTORY_HIDDEN(TransliteratorRegistry::Enumeration, Transliterator::getAvailableIDs(status));

#if UOBJTEST_TEST_INTERNALS
    TESTCLASSID_CTOR(Quantifier, (NULL, 0, 0));
    TESTCLASSID_CTOR(FunctionReplacer, (NULL,NULL));
    TESTCLASSID_CTOR(StringMatcher, (UnicodeString("x"), 0,0,0,TransliterationRuleData(status)));
    TESTCLASSID_CTOR(StringReplacer,(UnicodeString(),new TransliterationRuleData(status)));
#endif
#endif
        
    TESTCLASSID_FACTORY(Locale, new Locale("123"));
    TESTCLASSID_FACTORY_HIDDEN(KeywordEnumeration, Locale("@a=b").createKeywords(status));

    //TESTCLASSID_DEFAULT(NumeratorSubstitution);
    
#if !UCONFIG_NO_TRANSLITERATION
    TESTCLASSID_DEFAULT(ParsePosition);
#endif
    

// NO_REG_EX
    //TESTCLASSID_DEFAULT(RegexCompile);
    //TESTCLASSID_DEFAULT(RegexMatcher);
    //TESTCLASSID_DEFAULT(RegexPattern);

    //TESTCLASSID_DEFAULT(ReplaceableGlue);
    TESTCLASSID_FACTORY(ResourceBundle, new ResourceBundle(UnicodeString(), status) );
    //TESTCLASSID_DEFAULT(RuleBasedTransliterator);
    
    //TESTCLASSID_DEFAULT(SimpleFwdCharIterator);
    //TESTCLASSID_DEFAULT(StringReplacer);
    //TESTCLASSID_DEFAULT(StringSearch);
    
    //TESTCLASSID_DEFAULT(TestMultipleKeyStringFactory);
    //TESTCLASSID_DEFAULT(TestReplaceable);

#if !UCONFIG_NO_FORMATTING
    TESTCLASSID_ABSTRACT(TimeZone);
    TESTCLASSID_FACTORY(OlsonTimeZone, TimeZone::createTimeZone(UnicodeString("America/Los_Angeles")));
    TESTCLASSID_FACTORY_HIDDEN(KeywordEnumeration, TimeZone::createEnumeration());
#endif
    
    TESTCLASSID_DEFAULT(UnicodeString);
    TESTCLASSID_CTOR(UnicodeSet, (0, 1));
    TESTCLASSID_ABSTRACT(UnicodeFilter);
    TESTCLASSID_ABSTRACT(UnicodeFunctor);
    TESTCLASSID_CTOR(UnicodeSetIterator,(UnicodeSet(0,1)));
    TESTCLASSID_CTOR(UStack, (status));
    TESTCLASSID_CTOR(UVector, (status));
    TESTCLASSID_CTOR(UVector32, (status));

#if !UCONFIG_NO_SERVICE
    TESTCLASSID_CTOR(SimpleFactory, (NULL, UnicodeString("foo")));
    TESTCLASSID_DEFAULT(EventListener);
    TESTCLASSID_DEFAULT(ICUResourceBundleFactory);
    //TESTCLASSID_DEFAULT(Key); // does not exist?
    UnicodeString baz("baz");
    UnicodeString bat("bat");
    TESTCLASSID_FACTORY(LocaleKey, LocaleKey::createWithCanonicalFallback(&baz, &bat, LocaleKey::KIND_ANY, status));
    TESTCLASSID_CTOR(SimpleLocaleKeyFactory, (NULL, UnicodeString("bar"), 8, 12) );
    TESTCLASSID_CTOR(TestLocaleKeyFactory, (42));   // Test replacement for LocaleKeyFactory
//#if UOBJTEST_TEST_INTERNALS
//    TESTCLASSID_CTOR(LocaleKeyFactory, (42));
//#endif
#endif

#if UOBJTEST_DUMP_IDS
    int i;
    for(i=0;i<ids_count;i++) {
        char junk[800];
        sprintf(junk, " %4d:\t%p\t%s\t%s\n", 
            i, ids[i], ids_class[i], ids_factory[i]);
        logln(UnicodeString(junk));
    }
#endif
}
示例#10
0
文件: iopen.c 项目: szfn/teddy
static gpointer iopen_buffer_thread(gpointer data) {
	char *request = NULL;
	uint32_t *urequest = NULL;
	int ureqlen = 0;
	int bufidx = -1;
	int count;

	for (;;) {
		char *new_request;

		if (bufidx < 0) {
			//printf("Waiting\n");
			new_request = g_async_queue_pop(buffers_requests);
		} else {
			new_request = g_async_queue_try_pop(buffers_requests);
		}

		if (new_request != NULL) {
			if (request != NULL) {
				free(request);
				free(urequest);
			}
			if (strlen(new_request) >= 3) {
				request = new_request;
			} else {
				request = strdup("");
			}

			char *first_colon = strchr(request, ':');
			if (first_colon != NULL) *first_colon = '\0';

			bufidx = (strcmp(request, "") == 0) ? -1 : 0;
			count = 0;

			urequest = utf8_to_utf32_string(request, &ureqlen);
		}

		if (bufidx < 0) continue;

		buffer_t *buf = NULL;

		for (; bufidx < buffers_allocated; ++bufidx) {
			if ((buffers[bufidx] != NULL) && (buffers[bufidx]->path[0] != '+') && (buffers[bufidx]->path[strlen(buffers[bufidx]->path)-1] != '/')) {
				buf = buffers[bufidx];
				break;
			}
		}

		if (buf == NULL) {
			bufidx = -1;
			count = 0;
			continue;
		}

		for (int p = 0; p+ureqlen < MIN(100000, BSIZE(buf)); ++p) {
			int i;
			for (i = 0; i < ureqlen; ++i) {
				my_glyph_info_t *g = bat(buf, p+i);
				if (urequest[i] != g->code) break;
			}
			if (i == ureqlen) {
				// match found
				int s = p, e = p;
				buffer_move_point_glyph(buf, &s, MT_ABS, 1);
				buffer_move_point_glyph(buf, &e, MT_END, 0);

				char *line = buffer_lines_to_text(buf, s, e);

				int indentation_depth = too_much_indent(line);
				if (indentation_depth >= 0) {
					int lineno = buffer_line_of(buf, p, false);
					struct iopen_result *r = malloc(sizeof(struct iopen_result));

					int c = strncmp(buf->path, top_working_directory(), strlen(top_working_directory()));
					if (c == 0) {
						r->path = strdup(buf->path + strlen(top_working_directory()) + 1);
					} else {
						r->path = strdup(buf->path);
					}
					alloc_assert(r->path);

					r->show = g_markup_printf_escaped("<big><b>%s</b></big>\n%s:%d", line, r->path, lineno);
					free(line);

					asprintf(&(r->search), ":%d", lineno);
					alloc_assert(r->search);
					r->rank = 10000 + indentation_depth * 100 + (p - s);
					g_idle_add((GSourceFunc)iopen_add_result, r);

					//printf("\t<%s>\n", tag_entries[idx].tag);

					if (count++ > IOPEN_MAX_SENT_RESULTS) {
						bufidx = -1;
						count = 0;
						break;
					}
				} else {
					free(line);
				}

				p = e+1;
			}
		}

		if (count++ > IOPEN_MAX_SENT_RESULTS) {
			bufidx = -1;
			count = 0;
			continue;
		}

		++bufidx;
	}

	return NULL;
}
示例#11
0
//
// main task
//
int main(void) {

#ifdef DEBUG
	#if __USE_USB
		usbCDC ser;
		ser.connect();
	#else
		CSerial ser;
		ser.settings(115200);
	#endif
	CDebug dbg(ser);
	dbg.start();
#endif

	/*************************************************************************
	 *
	 *                         your setup code here
	 *
	**************************************************************************/
	//
	// BLE engine (serial stream)
	//
	bleSerial	ble("myHRM");
	ble.enable(96);

	//
	// Heart Beat Rate Service
	//
	bleHeartRate hrm(ble);
	hrm.supportContact(true);
	hrm.contactStatus(true);
	hrm.setSensorLocation(HRSL_FINGER);

	//
	// Battery Level & Health Thermometer Service (Use internal sensors)
	//
	bleBatteryLevel		 bat(ble);
	bleHealthThermometer ht(ble);

	//
	// Pulse Sensor
	//
	myPulseSensor pulse(AD0);	// signal on AD0
	pulse.start();

	//
	// Fade LED task
	//
	ledTask led(pulse);
	led.start("LED", 50);	// reduce stack size to 58 to increase the heap memory

	//
	//
	//
	CTimeout t1, t2, t3;
	float value;
	uint8_t level;

	while(1) {
		/**********************************************************************
		 *
		 *                         your loop code here
		 *
		 **********************************************************************/
		//
		// Heart Rate Measurement
		//
		if ( hrm.isAvailable() ) {
			if ( t1.isExpired(1000) ) {	// interval 1 second
				t1.reset();
				hrm.sendMeasure((uint8_t)pulse.BPM);
			}
		}

		//
		// Battery Level
		//
		if ( t2.isExpired(10000) ) {	// interval 10 seconds
			t2.reset();
			if ( bat.readSystemVoltage(value) ) {
				level = map(value, 2.0, 3.3, 0, 100);	// 0%~100%
				bat.sendBatteryLevel(level);
			}
		}

		//
		// Health Thermometer Service
		//
		if ( t3.isExpired(5000) ) {	// interval 5 seconds
			t3.reset();
			if ( ht.readTemperature(value) ) {
				ht.sendMeasure(value);
			}
		}

	}
    return 0 ;
}