/** * Gets the value of the specified property key in the internal * property set. If the key is not found in the internal property * set, the application property set is then searched. * * @param key The key to search for * * @return The value associated with <tt>key<tt> if found, otherwise * <tt>NULL<tt> */ const char* getInternalProp(const char* key) { const char* value; value = getProp(&internalPropertySet, key); if (NULL == value) { return getProp(&systemPropertySet, key); } return value; }
int main(int argc, char* argv[]) { char propValue[MAX_PROPVALUE]; int oldStatus, status; printf("DeepSleep for Tolino - version " VERSION "\n"); printf("by Martin Zwicknagl, put to GPL\n\n"); // Wait for boot to complete getProp(PROP_BOOT_COMPLETE, propValue); if (strncmp(propValue, "1", 1) != 0) { printf("Waiting for boot to complete...\n"); do { sleep(1); getProp(PROP_BOOT_COMPLETE, propValue); } while (strncmp(propValue, "1", 1) != 0); } // Set CPU governor printf("Setting CPU governor...\n"); writeToFile(FILE_CPUFREQ_GOVERNOR, "ondemand"); writeToFile(FILE_ONDEMAND_UPTHRESHOLD, "66"); writeToFile(FILE_ONDEMAND_SAMPLING_DOWN_FACTOR, "2"); writeToFile(FILE_ONDEMAND_IGNORE_NICE_LOAD, "0"); // Power save loop printf("Starting power save loop...\n"); status = getStatus(); while (1) { oldStatus = status; status = getStatus(); if (status != oldStatus) { printf("Status change: %u -> %u\n", oldStatus, status); if (status) { // sleep -> awake writeToFile(FILE_SYS_POWER_STATE, "on"); } else { // awake -> sleep writeToFile(FILE_SYS_POWER_STATE, "mem"); } } usleep(POLL_TIME); } return 0; }
/** * Check the "runtime.substitutes" sys property which is used * to specify an alternate Fan runtime to use for specific script * files - this is a bit of a hack so that we can cleanly manage * a "boot build" of the fan runtime with another fan runtime. The * format of the "runtime.substitutes" prop is a list of * <scriptUri> "=" <runtimeUri> pairs separated by whitespace. The * scriptUri identifies a file on the local machine in URI format * of a Fan script file. The runtimeUri identifies the Fan home * directory of a Fan runtime installation. */ int checkSubstitutes() { // we don't check for substitutes except when running the Fan // interpreter and we have at least one argument (which we // assume to be the target script being run) if (strcmp(FAN_TOOL, "Fan") != 0 || fanArgc < 1) return 0; const char* target = fanArgv[0]; // check for system prop const char* prop = getProp(sysProps, "runtime.substitutes"); if (prop == NULL) return 0; if (debug) printf("-- checkSubstitutes\n"); // get the full path of the script as a Fan URI char targetUri[MAX_PATH]; targetUri[0] = '/'; if (GetFullPathName(target, sizeof(targetUri)-1, targetUri+1, NULL) == 0) return 0; for (int i=1; targetUri[i] != '\0'; ++i) if (targetUri[i] == '\\') targetUri[i] = '/'; if (debug) printf("-- targetUri = %s\n", targetUri); // make copy of value on heap char* copy = new char[strlen(prop)+1]; strcpy(copy, prop); // tokenize char* scriptUri = strtok(copy, " "); char* eq = strtok(NULL, " "); char* runtimeUri = strtok(NULL, " "); while (scriptUri != NULL && eq != NULL && runtimeUri != NULL) { if (debug) printf("-- %s = %s\n", scriptUri, runtimeUri); // sanity check if (strcmp(eq, "=") != 0) { err("Invalid format for sys prop \"runtime.substitutes\"\n"); break; } // if we found a match update fan.home and break if (_stricmp(targetUri, scriptUri) == 0) { strcpy(fanHome, runtimeUri); if (debug) printf("-- substitute fan.home = %s\n", fanHome); break; } // move on to next token triple scriptUri = strtok(NULL, " "); eq = strtok(NULL, " "); runtimeUri = strtok(NULL, " "); } delete [] copy; return 0; }
IPropertyTree* RemoteXmlEclRepository::getAttributes(const char *module, const char *attr, int version, unsigned char infoLevel) { IPropertyTree* repositoryTree = 0; StringBuffer xml; try { StringBuffer snapshot; getProp("snapshot",snapshot); bool sandbox4snapshot = getPropInt("sandbox4snapshot", 0) != 0; repository.getAttributes(xml, user, module, attr, version, infoLevel, snapshot.length() ? snapshot.str() : NULL, sandbox4snapshot); if (xml.length()) repositoryTree = createPTreeFromXMLString(xml, ipt_caseInsensitive); } catch(IException *e) { logException(e); if (xml.length()) DBGLOG("Xml: %s", xml.str()); e->Release(); } catch (...) { logException(NULL); } return repositoryTree; }
/** * missing 処理用の口 * TJSインスタンスにメンバが存在しなかった場合は javascriptインスタンスを参照する */ tjs_error TJSInstance::missing(tjs_uint32 flag, const tjs_char * membername, tjs_uint32 *hint, tTJSVariant *result, tjs_int numparams, tTJSVariant **params, iTJSDispatch2 *objthis) { if (numparams < 3) {return TJS_E_BADPARAMCOUNT;}; iTJSNativeInstance *ninstance; if (TJS_SUCCEEDED(objthis->NativeInstanceSupport(TJS_NIS_GETINSTANCE, classId, &ninstance))) { TJSInstance *self = (TJSInstance*)ninstance; HandleScope handle_scope(self->isolate); bool ret = false; if (!(int)*params[0]) { // get tTJSVariant result; if (TJS_SUCCEEDED(getProp(self->isolate, self->getObject(), params[1]->GetString(), &result))) { params[2]->AsObjectClosureNoAddRef().PropSet(0, NULL, NULL, &result, NULL); ret = true; } } else { // set if (TJS_SUCCEEDED(setProp(self->isolate, self->getObject(), params[1]->GetString(), params[2]))) { ret = true; } } if (result) { *result = ret; } } return TJS_E_NATIVECLASSCRASH; }
/** * Find the jvm.dll path to use by querying the registry. */ int findJvmPath() { if (debug) printf("-- findJvmPath\n"); // first see if explicitly specified in config.props const char* prop = getProp(sysProps, "java.jvm"); if (prop != NULL) { if (debug) printf("-- java.jvm = %s\n", prop); sprintf(jvmPath, prop); return 0; } // query registry to get current Java version const char* jreKey = "SOFTWARE\\JavaSoft\\Java Runtime Environment"; char curVer[MAX_PATH]; if (readRegistry(jreKey, "CurrentVersion", curVer, sizeof(curVer))) return -1; if (debug) printf("-- registry query: CurrentVersion = %s\n", curVer); // use curVer to get default jvm.dll to use char jvmKey[MAX_PATH]; sprintf(jvmKey, "%s\\%s", jreKey, curVer); if (readRegistry(jvmKey, "RuntimeLib", jvmPath, sizeof(jvmPath))) return -1; if (debug) printf("-- registry query: RuntimeLib = %s\n", jvmPath); return 0; }
// readName will read the make and model of the image. // // If the name is read, it will return true, and the make/model // will be available in camera_make/camera_model members. boolean X3fDecoder::readName() { if (camera_make.length() != 0 && camera_model.length() != 0) { return ((boolean)TRUE); } // Read from properties if (hasProp("CAMMANUF") && hasProp("CAMMODEL")) { camera_make = getProp("CAMMANUF"); camera_model = getProp("CAMMODEL"); return ((boolean)TRUE); } // See if we can find EXIF info and grab the name from there. // This is needed for Sigma DP2 Quattro and possibly later cameras. vector<X3fImage>::iterator img = mImages.begin(); for (; img != mImages.end(); img++) { X3fImage cimg = *img; if (cimg.type == 2 && cimg.format == 0x12 && cimg.dataSize > 100) { if (!mFile->isValid(cimg.dataOffset + cimg.dataSize - 1)) { return ((boolean)FALSE); } ByteStream i(mFile->getDataWrt(cimg.dataOffset), cimg.dataSize); // Skip jpeg header i.skipBytes(6); if (i.getInt() == 0x66697845) { // Match text 'Exif' TiffParser t(new FileMap(mFile->getDataWrt(cimg.dataOffset+12), i.getRemainSize())); try { t.parseData(); } catch (...) { return ((boolean)FALSE); } TiffIFD *root = t.RootIFD(); try { if (root->hasEntryRecursive(MAKE) && root->hasEntryRecursive(MODEL)) { camera_model = root->getEntryRecursive(MODEL)->getString(); camera_make = root->getEntryRecursive(MAKE)->getString(); mProperties.props["CAMMANUF"] = root->getEntryRecursive(MAKE)->getString(); mProperties.props["CAMMODEL"] = root->getEntryRecursive(MODEL)->getString(); return ((boolean)TRUE); } } catch (...) {} return ((boolean)FALSE); } } } return ((boolean)FALSE); }
int XmlEclRepository::getPropInt(const char* name,int def) { if(properties && properties->hasProp(name)) { StringBuffer temp; getProp(name,temp); return atoi(temp.str()); } return def; }
void PFFracBulkRateMaterial::computeQpProperties() { _gc_prop[_qp] = _gc; /** * This function computes heterogeneous gc * User should override this function if heterogenities needs consideration */ getProp(); }
void X3fDecoder::decodeMetaDataInternal( CameraMetaData *meta ) { if (readName()) { if (checkCameraSupported(meta, camera_make, camera_model, "" )) { int iso = 0; if (hasProp("ISO")) iso = atoi(getProp("ISO").c_str()); setMetaData(meta, camera_make, camera_model, "", iso); return; } } }
static bool loadSO(const char *filename) { void *handle = dlopen(filename, RTLD_LAZY | RTLD_LOCAL); if (handle == NULL) { ALOGV("couldn't dlopen %s, %s", filename, dlerror()); return false; } if (loadSymbols(handle, *dispatch, getProp("ro.build.version.sdk")) == false) { ALOGV("%s init failed!", filename); return false; } ALOGV("Successfully loaded %s", filename); return true; }
void Config::load(string path) { if (m_devInitInfo != NULL) { delete m_devInitInfo; m_devInitInfo = NULL; } if (m_transportInitInfo != NULL) { delete m_transportInitInfo; m_transportInitInfo = NULL; } if (m_pathResolver != NULL) { delete m_pathResolver; m_pathResolver = NULL; } ifstream read(path.c_str()); if (!read.fail()) //no config.properties file available { string line; while (getline(read, line)) { if (!line.empty() && line[0] != '#') { size_t eqlPos = line.find('='); if (eqlPos != string::npos) { m_props[line.substr(0, eqlPos)] = line.substr(eqlPos + 1); } } } } read.close(); string deviceuri = m_props[DEVICEURI]; m_devInitInfo = deviceuri.empty() ? new DeviceInitInfo() : new DeviceInitInfo(deviceuri); string portstr = m_props[PORT]; string username = m_props[USERNAME]; string password = m_props[PASSWORD]; m_transportInitInfo = (portstr.empty() || username.empty() || password.empty()) ? new TransportInitInfo() : new TransportInitInfo(atoi(portstr.c_str()), username, password); m_pathResolver = new PathResolver(getProp(ROOTPATH, ".")); }
WEAK int create_renderscript_context(void *user_context, RsDevice *dev, RsContext *ctx) { uint32_t flags = 0; int targetApi = RS_VERSION; Context::dispatch = new dispatchTable; memset(Context::dispatch, 0, sizeof(dispatchTable)); bool usingNative = false; // attempt to load libRS, load libRSSupport on failure // if property is set, proceed directly to libRSSupport if (getProp("debug.rs.forcecompat") == 0) { usingNative = Context::loadSO("libRS.so"); } if (usingNative == false) { if (Context::loadSO("libRSSupport.so") == false) { ALOGV("Failed to load libRS.so and libRSSupport.so"); return -1; } } *dev = Context::dispatch->DeviceCreate(); if (*dev == 0) { ALOGV("Device creation failed"); return -1; } ALOGV("Created device %p", *dev); if (flags & ~(RS_CONTEXT_SYNCHRONOUS | RS_CONTEXT_LOW_LATENCY | RS_CONTEXT_LOW_POWER)) { ALOGE("Invalid flags passed"); return -1; } *ctx = Context::dispatch->ContextCreate(*dev, 0, targetApi, RS_CONTEXT_TYPE_NORMAL, flags); if (*ctx == 0) { ALOGE("Context creation failed"); return -1; } ALOGV("Created context %p", *ctx); return RS_SUCCESS; }
/** * send an SMS message * * Actually * - sends a datagramm to 11101 port, it can be received by JSR205Tool.jar (used in TCK tests) * - writes a message to the console (it is enough for native tests) * The address to send datagram is one of the following: * - 127.0.0.1 if JSR_205_DATAGRAM_HOST environment variable is not send * - JSR_205_DATAGRAM_HOST environment variable value (if set). * * Refer to javacall_sms.h header for complete description. */ int javacall_sms_send( javacall_sms_encoding msgType, const unsigned char* destAddress, const unsigned char* msgBuffer, int msgBufferLen, unsigned short sourcePort, unsigned short destPort) { javacall_handle datagramHandle; javacall_result ok; int pBytesWritten = 0; void *pContext; unsigned char *pAddress; javacall_int64 timeStamp = 0; const char* recipientPhone = destAddress; char* senderPhone = "+1234567"; int encodedSMSLength; char* encodedSMS; char* IP_text = getProp("JSR_205_DATAGRAM_HOST", "127.0.0.1"); //JSR205Tool listens on 11101 port, but sends to 11100 port int smsRemotePortNumber = getIntProp("JSR_205_SMS_OUT_PORT", 11101); javacall_network_init_start(); pAddress = getIPBytes_nonblock(IP_text); encodedSMS = encodeSmsBuffer(msgType, destPort, timeStamp, recipientPhone, senderPhone, msgBufferLen, msgBuffer, &encodedSMSLength); ok = javacall_datagram_open(0, &datagramHandle); if (ok == JAVACALL_OK) { ok = javacall_datagram_sendto_start(datagramHandle, pAddress, smsRemotePortNumber, encodedSMS, encodedSMSLength, &pBytesWritten, &pContext); if (ok != JAVACALL_OK) { javacall_print("Error: SMS sending - datagram blocked.\n"); } } javacall_print("## javacall: SMS sending...\n"); javanotify_sms_send_completed(JAVACALL_SMS_SENDING_RESULT_SUCCESS, 13); return 1; }
/** * Set the runtime variable with the runtime to use. */ int getRuntime() { const char* rt = getProp(sysProps, "runtime", "java"); if (getenv("fan_runtime") != NULL) rt = getenv("fan_runtime"); if (cmdLineRuntime != NULL) rt = cmdLineRuntime; if (debug) printf("-- getRuntime = %s\n", rt); if (strcmp(rt, "java") == 0) runtime = JavaRuntime; else if (strcmp(rt, "dotnet") == 0) runtime = DotnetRuntime; else return err("Unknown runtime %s", rt); // force stub apps to always use the right runtime if (strcmp(FAN_TOOL, "Jstub") == 0) runtime = JavaRuntime; else if (strcmp(FAN_TOOL, "Nstub") == 0) runtime = DotnetRuntime; return 0; }
SE_BEGIN_CXX ConnmanClient::ConnmanClient(Server &server): DBusRemoteObject(!strcmp(getEnv("DBUS_TEST_CONNMAN", ""), "none") ? NULL : /* simulate missing ConnMan */ GDBusCXX::dbus_get_bus_connection(!strcmp(getEnv("DBUS_TEST_CONNMAN", ""), "session") ? "SESSION" : /* use our own ConnMan stub */ "SYSTEM" /* use real ConnMan */, NULL, true, NULL), "/", "net.connman.Manager", "net.connman", true), m_server(server), m_propertyChanged(*this, "PropertyChanged") { if (getConnection()) { typedef std::map <std::string, boost::variant<std::string> > PropDict; GDBusCXX::DBusClientCall1<PropDict> getProp(*this,"GetProperties"); getProp.start(boost::bind(&ConnmanClient::getPropCb, this, _1, _2)); m_propertyChanged.activate(boost::bind(&ConnmanClient::propertyChanged, this, _1, _2)); }else{ SE_LOG_DEBUG (NULL, NULL, "DBus connection setup for connman failed"); } }
/** * Get the full list of options to pass to the Java VM which * are the required options set by the launcher, plus any additional * options configured in etc/sys/config.props. */ int initOptions() { if (debug) printf("-- initOptions\n"); // predefined classpath, include every jar file // found in lib/java/ext/win and lib/java/ext/win static char optClassPath[MAX_PATH*10]; sprintf(optClassPath, "-Djava.class.path=%s\\lib\\java\\sys.jar", fanHome); options[nOptions++].optionString = optClassPath; // predefined fan.home static char optHome[MAX_PATH]; sprintf(optHome, "-Dfan.home=%s", fanHome); options[nOptions++].optionString = optHome; // user specified options from config.props const char* prop = getProp(sysProps, "java.options", ""); char* copy = new char[strlen(prop)+1]; strcpy(copy, prop); char* tok = strtok(copy, " "); while (tok != NULL) { if (nOptions >= MAX_OPTIONS) break; options[nOptions++].optionString = tok; tok = strtok(NULL, " "); } // debug if (debug) { printf("-- options:\n"); for (int i=0; i<nOptions; ++i) printf("-- %s\n", options[i].optionString); } return 0; }
/** * Gets the value of the specified property key in the application * property set. * * @param key The key to search for * * @return The value associated with <tt>key<tt> if found, otherwise * <tt>NULL<tt> */ const char* getSystemProperty(const char* key) { return getProp(&systemPropertySet, key); }
void moveit_rviz_plugin::PerLinkObjBase::setPropValue(const std::string& name, QVariant value) { getProp(name)->setValue(value); for (std::vector<PerLinkSubObjBase*>::iterator it = sub_objs_.begin() ; it != sub_objs_.end() ; ++it) (*it)->getProp(name)->setValue(value, false); }
moveit_rviz_plugin::PerLinkProperty* moveit_rviz_plugin::PerLinkSubObjBase::getObjProp(const std::string& name) { PerLinkSubProperty* prop = getProp(name); return prop ? prop->getObjProp() : NULL; }
// argv[1] = port name int main(int argc, char** argv) { Semaphore sem_gen_v; Semaphore mutex_boat; Semaphore mutex_sync; Shm shm_boat; Boat boat; mqd_t mqd_trucks; mqd_t mqd_cars_vans; char buffer[MQ_MSGSIZE]; char* port_name = argv[1]; char* msg = malloc(sizeof(msg)); int i = 0; int nb_trucks = 0, nb_cars = 0, nb_vans = 0; int nb_boats = atoi(getProp(PROP_FILE, "nb_boats")); srand(getpid()); // SEM_GEN_V sem_gen_v.oflag = (O_CREAT | O_RDWR); sem_gen_v.mode = 0644; sem_gen_v.value = 0; sprintf(sem_gen_v.semname,"%s%s", SEM_GEN_V, port_name); sem_unlink(sem_gen_v.semname); open_sem(&sem_gen_v); // Preparing mutex for shm_boat access mutex_boat.oflag = O_RDWR; mutex_boat.mode = 0644; mutex_boat.value = 1; strcpy(mutex_boat.semname, MUTEX_BOAT); open_sem(&mutex_boat); // Preparing shm_boat access shm_boat.sizeofShm = sizeof(Boat) * 6; shm_boat.mode = O_RDWR; strcpy(shm_boat.shmName, SHM_BOAT); open_shm(&shm_boat); mapping_shm(&shm_boat, sizeof(Boat) * 6); while(1) { // Waiting signal_sem on sem_gen_v from Docks processes. wait_sem(sem_gen_v); // Waiting for access on shm_boat wait_sem(mutex_boat); boat = get_actual_boat(DOCK, port_name, nb_boats, shm_boat); signal_sem(mutex_boat); sprintf(msg, "Débloqué"); print_boat(port_name, boat.index, msg); // MUTEX_SYNC mutex_sync.oflag = 0; sprintf(mutex_sync.semname,"%s%d", MUTEX_SYNC, boat.index); open_sem(&mutex_sync); // Ouverture MQs mqd_trucks = mq_open(boat.mq1.name, O_WRONLY); mqd_cars_vans = mq_open(boat.mq2.name, O_WRONLY); nb_cars = rand() % MAX_N_CARS + 1; nb_vans = rand() % MAX_N_VANS + 1; nb_trucks = rand()% MAX_N_TRUCKS + 1; memset(buffer, 0, MQ_MSGSIZE); sprintf(msg, "Debut embarquement"); print_boat(port_name, boat.index, msg); sprintf(msg, "Embarquement de %d voitures", nb_cars); print_boat(port_name, boat.index, msg); for(i = 0; i < nb_cars; i++) { sprintf(buffer, "Car %d", i + 1); if(mq_send(mqd_cars_vans, buffer, strlen(buffer), CAR_PRIORITY) == -1) { mq_close(mqd_cars_vans); mq_unlink(boat.mq1.name); perror("Error occured when mq_send (cars & vans)\n"); exit(EXIT_FAILURE); } // Sleep 1/4s -- TODO Paramétrable. nanosleep((struct timespec[]){{0, 250000000}}, NULL); } sprintf(msg, "Embarquement de %d vans", nb_vans); print_boat(port_name, boat.index, msg); for(i = 0; i < nb_vans; i++) { sprintf(buffer, "Van %d", i); if(mq_send(mqd_cars_vans, buffer, strlen(buffer), VAN_PRIORITY) == -1) { mq_close(mqd_cars_vans); mq_unlink(boat.mq1.name); perror("Error occured when mq_send (cars & vans)\n"); exit(EXIT_FAILURE); } // Sleep 1/4s nanosleep((struct timespec[]){{0, 250000000}}, NULL); }