int is_unit_present(char *label, char *unit){ if(strlen(label)!=strlen(unit)||STRCMP(label,unit)!=0)return 0; return 1; }
/* * External interface */ static void DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) { #ifndef PY_CAN_RECURSE static int recursive = 0; #endif #if defined(MACOS) && !defined(MACOS_X_UNIX) GrafPtr oldPort; #endif #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) char *saved_locale; #endif #ifdef PY_CAN_RECURSE PyGILState_STATE pygilstate; #endif #ifndef PY_CAN_RECURSE if (recursive) { EMSG(_("E659: Cannot invoke Python recursively")); return; } ++recursive; #endif #if defined(MACOS) && !defined(MACOS_X_UNIX) GetPort(&oldPort); /* Check if the Python library is available */ if ((Ptr)PyMac_Initialize == (Ptr)kUnresolvedCFragSymbolAddress) goto theend; #endif if (Python_Init()) goto theend; init_range(arg); Python_Release_Vim(); /* leave vim */ #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) /* Python only works properly when the LC_NUMERIC locale is "C". */ saved_locale = setlocale(LC_NUMERIC, NULL); if (saved_locale == NULL || STRCMP(saved_locale, "C") == 0) saved_locale = NULL; else { /* Need to make a copy, value may change when setting new locale. */ saved_locale = (char *) PY_STRSAVE(saved_locale); (void)setlocale(LC_NUMERIC, "C"); } #endif #ifdef PY_CAN_RECURSE pygilstate = PyGILState_Ensure(); #else Python_RestoreThread(); /* enter python */ #endif run((char *) cmd, arg #ifdef PY_CAN_RECURSE , &pygilstate #endif ); #ifdef PY_CAN_RECURSE PyGILState_Release(pygilstate); #else Python_SaveThread(); /* leave python */ #endif #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) if (saved_locale != NULL) { (void)setlocale(LC_NUMERIC, saved_locale); PyMem_Free(saved_locale); } #endif Python_Lock_Vim(); /* enter vim */ PythonIO_Flush(); #if defined(MACOS) && !defined(MACOS_X_UNIX) SetPort(oldPort); #endif theend: #ifndef PY_CAN_RECURSE --recursive; #endif return; }
/* * Routers * */ void parse_routers() { xmlXPathObjectPtr xmlobject; xmlNode *router; char *text, *request="/config_ndpmon/routers"; xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt); if (xmlobject->nodesetval==NULL) { xmlXPathFreeObject (xmlobject); return; } router = xmlobject->nodesetval->nodeTab[0]->children; while(router != NULL) { if (router->type == XML_ELEMENT_NODE && STRCMP(router->name,"router")==0) { struct ether_addr mac; struct in6_addr lla; uint8_t param_curhoplimit=0; uint8_t param_flags_reserved=0; uint16_t param_router_lifetime=0; uint32_t param_reachable_timer=0; uint32_t param_retrans_timer=0; uint32_t param_mtu=0; int params_volatile=1; prefix_t* tmp_prefix = NULL; address_t* tmp_address = NULL; xmlNode *param = router->children; int vlan_id = 4095; while(param != NULL) { if (param->type != XML_ELEMENT_NODE) { param = param->next; continue; } /* We have an XML Element: */ if( !STRCMP(param->name,"mac") ) { memcpy(&mac,ether_aton((char *)XML_GET_CONTENT(param->children)),sizeof(struct ether_addr)); } else if( !STRCMP(param->name,"vlan_id") ) { text = (char*)XML_GET_CONTENT(param->children); vlan_id = atoi(text!=NULL?text:"4095"); } else if( !STRCMP(param->name,"lla") ) { inet_pton(AF_INET6,(char *)XML_GET_CONTENT(param->children), &lla); } else if( !STRCMP(param->name,"param_curhoplimit") ) { text = (char*)XML_GET_CONTENT(param->children); param_curhoplimit = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_flags_reserved") ) { text = (char*)XML_GET_CONTENT(param->children); param_flags_reserved = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_router_lifetime") ) { text = (char*)XML_GET_CONTENT(param->children); param_router_lifetime = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_reachable_timer") ) { text = (char*)XML_GET_CONTENT(param->children); param_reachable_timer = strtoul(text!=NULL?text:"0", NULL, 10); } else if( !STRCMP(param->name,"param_retrans_timer") ) { text = (char*)XML_GET_CONTENT(param->children); param_retrans_timer = strtoul(text!=NULL?text:"0", NULL, 10); } else if( !STRCMP(param->name,"param_mtu") ) { text = (char*)XML_GET_CONTENT(param->children); param_mtu = strtoul(text!=NULL?text:"0", NULL, 10); } else if( !STRCMP(param->name,"params_volatile") ) { text = (char*)XML_GET_CONTENT(param->children); params_volatile = atoi(text!=NULL?text:"1"); } else if( !STRCMP(param->name,"addresses") ) { xmlNode *address = param->children; while(address != NULL) { if (address->type == XML_ELEMENT_NODE && STRCMP(address->name,"address")==0 ) { /* Read address: */ address_t* new_address = malloc(sizeof(address_t)); if (new_address==NULL) { fprintf(stderr, "malloc failed."); } inet_pton(AF_INET6,(char *)XML_GET_CONTENT(address->children), &new_address->address); /* Add address to tmp address list: */ new_address->next = tmp_address; tmp_address = new_address; } /* Fetch next address node: */ address = address->next; } } /* end addresses */ else if( !STRCMP(param->name,"prefixes") ) { xmlNode *prefix = param->children; while(prefix != NULL) { if (prefix->type == XML_ELEMENT_NODE && STRCMP(prefix->name,"prefix")==0) { /* Read prefix params: */ xmlNode *prefix_param = prefix->children; prefix_t* new_prefix = malloc(sizeof(prefix_t)); char buffer[INET6_ADDRSTRLEN]; if (new_prefix==NULL) { fprintf(stderr, "malloc failed."); } memset(&new_prefix->prefix, 0, sizeof(struct in6_addr)); new_prefix->mask = 0; new_prefix->param_valid_time = 0; new_prefix->param_preferred_time = 0; while(prefix_param != NULL) { if (prefix_param->type != XML_ELEMENT_NODE) { prefix_param = prefix_param->next; continue; } /* We have an XML Element: */ if (STRCMP(prefix_param->name,"address")==0) { text=(char *)XML_GET_CONTENT(prefix_param->children); strncpy(buffer,text, INET6_ADDRSTRLEN); inet_pton(AF_INET6,buffer, &new_prefix->prefix); } else if (STRCMP(prefix_param->name,"mask")==0) { text=(char *)XML_GET_CONTENT(prefix_param->children); new_prefix->mask = atoi(text!=NULL?text:0); } else if (STRCMP(prefix_param->name,"param_flags_reserved")==0) { text=(char *)XML_GET_CONTENT(prefix_param->children); new_prefix->param_flags_reserved = atoi(text!=NULL?text:0); } else if (STRCMP(prefix_param->name,"param_valid_time")==0) { text=(char *)XML_GET_CONTENT(prefix_param->children); new_prefix->param_valid_time = strtoul(text!=NULL?text:"0", NULL, 10); } else if (STRCMP(prefix_param->name,"param_preferred_time")==0) { text=(char *)XML_GET_CONTENT(prefix_param->children); new_prefix->param_preferred_time = strtoul(text!=NULL?text:"0", NULL, 10); } prefix_param = prefix_param->next; } /* Add prefix to tmp list:*/ new_prefix->next = tmp_prefix; tmp_prefix = new_prefix; } /* Fetch next prefix node: */ prefix = prefix->next; } } /* end prefixes */ /* Fetch next router param: */ param = param->next; } /* end router params */ /* Add router to the router list: */ router_add( &routers, vlan_id, &mac, &lla, param_curhoplimit, param_flags_reserved, param_router_lifetime, param_reachable_timer, param_retrans_timer, param_mtu, params_volatile ); while (tmp_prefix!=NULL) { prefix_t* current=tmp_prefix; router_add_prefix( routers, vlan_id, lla, mac, current->prefix, current->mask, current->param_flags_reserved, current->param_valid_time, current->param_preferred_time ); tmp_prefix = current->next; free(current); } while (tmp_address!=NULL) { address_t* current=tmp_address; router_add_address(routers, vlan_id, mac, current->address); tmp_address = current->next; free(current); } } /* end is XML element and router */ /* Fetch next router node: */ router = router->next; } xmlXPathFreeObject (xmlobject); }
int oph_server_conf_load(short unsigned int instance, HASHTBL **hashtbl) { if(!hashtbl){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Null input parameter\n"); return OPH_SERVER_CONF_NULL_PARAM; } if( !(*hashtbl = hashtbl_create(OPH_SERVER_CONF_LOAD_SIZE, NULL)) ){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to create hash table\n"); return OPH_SERVER_CONF_ERROR; } FILE *file = fopen(OPH_SERVER_CONF_FILE_PATH, "r"); if(file == NULL) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Configuration file not found\n"); hashtbl_destroy(*hashtbl); *hashtbl = NULL; return OPH_SERVER_CONF_ERROR; } else { char buffer[OPH_SERVER_CONF_LINE_LEN] = {0}; char tmp_buffer[OPH_SERVER_CONF_LINE_LEN] = {0}; char *value = NULL; char *position = NULL, *position2 = NULL; const char *param_iter = NULL; int i = 0, j = 0; short int instance_flag = 0; char *instance_string = 0; short unsigned int instance_number = 0; while(!feof(file)) { //Retrieve instance header memset(tmp_buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer)); if (!fgets (buffer, sizeof(buffer), file)) { if(feof(file)){ fclose (file); return OPH_SERVER_CONF_SUCCESS; } else{ fclose (file); pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while reading configuration file\n"); hashtbl_destroy(*hashtbl); return OPH_SERVER_CONF_ERROR; } } //Check if row is a comment j = 0; while(buffer[j] == ' ') j++; //Row is a comment if(buffer[j] == OPH_SERVER_CONF_COMMENT) continue; //Check if row is newline j = 0; while(buffer[j] == ' ') j++; //Row is a newline if(buffer[j] == '\n') continue; sscanf (buffer, "[%[^]]", tmp_buffer); if(instance_flag == 0){ //If row does not contain an instance ref then step to next row if (!(instance_string = strstr (tmp_buffer, OPH_SERVER_CONF_INSTANCE))){ continue; } else{ //Check instance number if(instance != 0){ instance_string += strlen(OPH_SERVER_CONF_INSTANCE); instance_number = (short unsigned int)strtol(instance_string, NULL, 10); if(instance_number == 0) continue; if(instance_number != instance) continue; } //If instance header is found read all lines until next one instance_flag = 1; } } else{ if (!strstr (tmp_buffer, OPH_SERVER_CONF_INSTANCE)){ //Parse row //Get param-value separator value = NULL; position = position2 = NULL; position = strchr(buffer, '='); if(position != NULL){ //Set = symbol to NULL position[0] = 0; position++; //If new line char is read, then remove it if((position2 = strchr(position, '\n')) != NULL){ position2[0] = 0; } //Check if param is allowed i = 0; param_iter = oph_server_conf_params[i++]; while(param_iter){ if(STRCMP(buffer, param_iter) == 0) break; param_iter = oph_server_conf_params[i++]; } if( param_iter == NULL ) { pmesg(LOG_DEBUG, __FILE__, __LINE__, "Configuration param not allowed %s\n", buffer); continue; } //Alloc value to be added to hash table value = strndup(position, OPH_SERVER_CONF_LINE_LEN); if(value == NULL){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while copying param %s\n", buffer); fclose(file); hashtbl_destroy(*hashtbl); *hashtbl = NULL; return OPH_SERVER_CONF_ERROR; } if(hashtbl_insert(*hashtbl, buffer, value)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while loading param %s\n", buffer); fclose(file); free(value); hashtbl_destroy(*hashtbl); *hashtbl = NULL; return OPH_SERVER_CONF_ERROR; } pmesg(LOG_DEBUG, __FILE__, __LINE__, "LOADED PARAM: %s = %s \n", buffer, position); } else{ pmesg(LOG_DEBUG, __FILE__, __LINE__, "Configuration param corrupted %s\n", buffer); } } else{ //Found second instance ref, end cycle break; } } } fclose(file); } return OPH_SERVER_CONF_SUCCESS; }
int gtmrecv_get_opt(void) { boolean_t autorollback, cmplvl_status, filter, log, log_interval_specified, plaintext_fallback; char statslog_val[4]; /* "ON" or "OFF" */ gtm_int64_t buffsize; int status; uint4 n_readers, n_helpers; unsigned short filter_cmd_len, instfilename_len, instname_len, log_file_len, statslog_val_len, tlsid_len; gtmrecv_options.start = (CLI_PRESENT == cli_present("START")); gtmrecv_options.shut_down = (CLI_PRESENT == cli_present("SHUTDOWN")); gtmrecv_options.checkhealth = (CLI_PRESENT == cli_present("CHECKHEALTH")); gtmrecv_options.statslog = (CLI_PRESENT == cli_present("STATSLOG")); gtmrecv_options.showbacklog = (CLI_PRESENT == cli_present("SHOWBACKLOG")); gtmrecv_options.changelog = (CLI_PRESENT == cli_present("CHANGELOG")); gtmrecv_options.updateonly = (CLI_PRESENT == cli_present("UPDATEONLY")); gtmrecv_options.updateresync = (CLI_PRESENT == cli_present("UPDATERESYNC")); gtmrecv_options.reuse_specified = (CLI_PRESENT == cli_present("REUSE")); gtmrecv_options.resume_specified = (CLI_PRESENT == cli_present("RESUME")); gtmrecv_options.initialize_specified = (CLI_PRESENT == cli_present("INITIALIZE")); if (gtmrecv_options.updateresync) { instfilename_len = SIZEOF(gtmrecv_options.updresync_instfilename) - 1; /* keep 1 byte for trailing NULL */ /* Treat -UPDATERESYNC (with no value) as if -UPDATERESYNC="" was specified */ if (!cli_get_str("UPDATERESYNC", gtmrecv_options.updresync_instfilename, &instfilename_len)) { instfilename_len = 0; if (gtmrecv_options.reuse_specified) { util_out_print("Error: REUSE qualifier not allowed if UPDATERESYNC qualifier has no value", TRUE); return (-1); } } else if (gtmrecv_options.reuse_specified) { instname_len = SIZEOF(gtmrecv_options.reuse_instname) - 1; /* keep 1 byte for trailing NULL */ if (!cli_get_str("REUSE", gtmrecv_options.reuse_instname, &instname_len)) { util_out_print("Error parsing REUSE qualifier", TRUE); return (-1); } else { assert(SIZEOF(gtmrecv_options.reuse_instname) > instname_len); gtmrecv_options.reuse_instname[instname_len] = '\0'; } } assert(SIZEOF(gtmrecv_options.updresync_instfilename) > instfilename_len); gtmrecv_options.updresync_instfilename[instfilename_len] = '\0'; if (gtmrecv_options.resume_specified) { if (!cli_get_int("RESUME", >mrecv_options.resume_strm_num)) { util_out_print("Error parsing RESUME qualifier", TRUE); return (-1); } if ((0 >= gtmrecv_options.resume_strm_num) || (MAX_SUPPL_STRMS <= gtmrecv_options.resume_strm_num)) { util_out_print("RESUME qualifier should specify a stream number between 1 and 15 (both inclusive)", TRUE); return (-1); } } } gtmrecv_options.noresync = (CLI_PRESENT == cli_present("NORESYNC")); gtmrecv_options.helpers = (CLI_PRESENT == cli_present("HELPERS")); gtmrecv_options.listen_port = 0; /* invalid port; indicates listenport not specified */ if (gtmrecv_options.start && CLI_PRESENT == cli_present("LISTENPORT")) { if (!cli_get_int("LISTENPORT", >mrecv_options.listen_port)) { util_out_print("Error parsing LISTENPORT qualifier", TRUE); return (-1); } if (CLI_PRESENT == cli_present("BUFFSIZE")) { /* use a big conversion so we have a signed number for comparison */ if (!cli_get_int64("BUFFSIZE", &buffsize)) { util_out_print("Error parsing BUFFSIZE qualifier", TRUE); return(-1); } if (MIN_RECVPOOL_SIZE > buffsize) gtmrecv_options.buffsize = MIN_RECVPOOL_SIZE; else if ((gtm_int64_t)MAX_RECVPOOL_SIZE < buffsize) gtmrecv_options.buffsize = (uint4)MAX_RECVPOOL_SIZE; else gtmrecv_options.buffsize = (uint4)buffsize; } else gtmrecv_options.buffsize = DEFAULT_RECVPOOL_SIZE; /* Check if -autorollback is specified (default is -noautorollback) */ autorollback = cli_present("AUTOROLLBACK"); gtmrecv_options.autorollback = autorollback ? (CLI_NEGATED != autorollback) : FALSE; if (gtmrecv_options.autorollback) gtmrecv_options.autorollback_verbose = cli_present("AUTOROLLBACK.VERBOSE"); /* Check if compression level is specified */ if (cmplvl_status = (CLI_PRESENT == cli_present("CMPLVL"))) { if (!cli_get_int("CMPLVL", >mrecv_options.cmplvl)) { util_out_print("Error parsing CMPLVL qualifier", TRUE); return(-1); } if (GTM_CMPLVL_OUT_OF_RANGE(gtmrecv_options.cmplvl)) gtmrecv_options.cmplvl = ZLIB_CMPLVL_MIN; /* no compression in this case */ /* CMPLVL qualifier should override any value specified in the environment variable gtm_zlib_cmp_level */ gtm_zlib_cmp_level = gtmrecv_options.cmplvl; } else gtmrecv_options.cmplvl = ZLIB_CMPLVL_MIN; /* no compression in this case */ if (filter = (CLI_PRESENT == cli_present("FILTER"))) { filter_cmd_len = MAX_FILTER_CMD_LEN; if (!cli_get_str("FILTER", gtmrecv_options.filter_cmd, &filter_cmd_len)) { util_out_print("Error parsing FILTER qualifier", TRUE); return (-1); } } else gtmrecv_options.filter_cmd[0] = '\0'; gtmrecv_options.stopsourcefilter = (CLI_PRESENT == cli_present("STOPSOURCEFILTER")); /* Check if SSL/TLS secure communication is requested. */ # ifdef GTM_TLS if (CLI_PRESENT == cli_present("TLSID")) { tlsid_len = MAX_TLSID_LEN; if (!cli_get_str("TLSID", repl_tls.id, &tlsid_len)) { util_out_print("Error parsing TLSID qualifier", TRUE); return -1; } assert(0 < tlsid_len); /* Check if plaintext-fallback mode is specified. Default option is NOPLAINTEXTFALLBACK. */ if (CLI_PRESENT == (plaintext_fallback = cli_present("PLAINTEXTFALLBACK"))) repl_tls.plaintext_fallback = (plaintext_fallback != CLI_NEGATED); else repl_tls.plaintext_fallback = FALSE; } # endif } if ((gtmrecv_options.start && 0 != gtmrecv_options.listen_port) || gtmrecv_options.statslog || gtmrecv_options.changelog) { log = (CLI_PRESENT == cli_present("LOG")); log_interval_specified = (CLI_PRESENT == cli_present("LOG_INTERVAL")); if (log) { log_file_len = MAX_FN_LEN + 1; if (!cli_get_str("LOG", gtmrecv_options.log_file, &log_file_len)) { util_out_print("Error parsing LOG qualifier", TRUE); return (-1); } } else gtmrecv_options.log_file[0] = '\0'; gtmrecv_options.rcvr_log_interval = gtmrecv_options.upd_log_interval = 0; if (log_interval_specified && 0 == cli_parse_two_numbers("LOG_INTERVAL", GTMRECV_LOGINTERVAL_DELIM, >mrecv_options.rcvr_log_interval, >mrecv_options.upd_log_interval)) return (-1); if (gtmrecv_options.start) { if (0 == gtmrecv_options.rcvr_log_interval) gtmrecv_options.rcvr_log_interval = LOGTRNUM_INTERVAL; if (0 == gtmrecv_options.upd_log_interval) gtmrecv_options.upd_log_interval = LOGTRNUM_INTERVAL; } /* For changelog, interval == 0 implies don't change log interval already established */ /* We ignore interval specification for statslog, Vinaya 2005/02/07 */ } if (gtmrecv_options.shut_down) { if (CLI_PRESENT == (status = cli_present("TIMEOUT"))) { if (!cli_get_int("TIMEOUT", >mrecv_options.shutdown_time)) { util_out_print("Error parsing TIMEOUT qualifier", TRUE); return (-1); } if (DEFAULT_SHUTDOWN_TIMEOUT < gtmrecv_options.shutdown_time || 0 > gtmrecv_options.shutdown_time) { gtmrecv_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; util_out_print("shutdown TIMEOUT changed to !UL", TRUE, gtmrecv_options.shutdown_time); } } else if (CLI_NEGATED == status) gtmrecv_options.shutdown_time = -1; else /* TIMEOUT not specified */ gtmrecv_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; } if (gtmrecv_options.statslog) { statslog_val_len = 4; /* max(strlen("ON"), strlen("OFF")) + 1 */ if (!cli_get_str("STATSLOG", statslog_val, &statslog_val_len)) { util_out_print("Error parsing STATSLOG qualifier", TRUE); return (-1); } cli_strupper(statslog_val); if (0 == STRCMP(statslog_val, "ON")) gtmrecv_options.statslog = TRUE; else if (0 == STRCMP(statslog_val, "OFF")) gtmrecv_options.statslog = FALSE; else { util_out_print("Invalid value for STATSLOG qualifier, should be either ON or OFF", TRUE); return (-1); } } gtmrecv_options.n_readers = gtmrecv_options.n_writers = 0; if (gtmrecv_options.helpers && gtmrecv_options.start) { /* parse the helpers qualifier to find out how many readers and writes have to be started */ if (0 == (status = cli_parse_two_numbers("HELPERS", UPD_HELPERS_DELIM, &n_helpers, &n_readers))) return (-1); if (!(status & CLI_2NUM_FIRST_SPECIFIED)) n_helpers = DEFAULT_UPD_HELPERS; if (MIN_UPD_HELPERS > n_helpers || MAX_UPD_HELPERS < n_helpers) { util_out_print("Invalid number of helpers; must be in the range [!UL,!UL]", TRUE, MIN_UPD_HELPERS, MAX_UPD_HELPERS); return (-1); } if (!(status & CLI_2NUM_SECOND_SPECIFIED)) n_readers = (int)(n_helpers * ((float)DEFAULT_UPD_HELP_READERS)/DEFAULT_UPD_HELPERS); /* may round down */ if (n_readers > n_helpers) { n_readers = n_helpers; util_out_print("Number of readers exceeds number of helpers, reducing number of readers to number of " "helpers", TRUE); } gtmrecv_options.n_readers = n_readers; gtmrecv_options.n_writers = n_helpers - n_readers; } return (0); }
fsal_status_t FUSEFSAL_load_FS_specific_parameter_from_conf(config_file_t in_config, fsal_parameter_t * out_parameter) { int err; int var_max, var_index; char *key_name; char *key_value; config_item_t block; block = config_FindItemByName(in_config, CONF_LABEL_FS_SPECIFIC); /* cannot read item */ if(block == NULL) { LogCrit(COMPONENT_CONFIG, "FSAL LOAD PARAMETER: Cannot read item \"%s\" from configuration file", CONF_LABEL_FS_SPECIFIC); ReturnCode(ERR_FSAL_NOENT, 0); } else if(config_ItemType(block) != CONFIG_ITEM_BLOCK) { LogCrit(COMPONENT_CONFIG, "FSAL LOAD PARAMETER: Item \"%s\" is expected to be a block", CONF_LABEL_FS_SPECIFIC); ReturnCode(ERR_FSAL_INVAL, 0); } /* makes an iteration on the (key, value) couplets */ var_max = config_GetNbItems(block); for(var_index = 0; var_index < var_max; var_index++) { config_item_t item; item = config_GetItemByIndex(block, var_index); err = config_GetKeyValue(item, &key_name, &key_value); if(err) { LogCrit(COMPONENT_CONFIG, "FSAL LOAD PARAMETER: ERROR reading key[%d] from section \"%s\" of configuration file.", var_index, CONF_LABEL_FS_SPECIFIC); ReturnCode(ERR_FSAL_SERVERFAULT, err); } /* what parameter is it ? */ if(!STRCMP(key_name, "my_parameter_name1")) { /* >> interpret the parameter string and fill the fs_specific_info structure << */ } else if(!STRCMP(key_name, "my_parameter_name2")) { /* >> interpret the parameter string and fill the fs_specific_info structure << */ } /* etc... */ else { LogCrit(COMPONENT_CONFIG, "FSAL LOAD PARAMETER: ERROR: Unknown or unsettable key: %s (item %s)", key_name, CONF_LABEL_FS_SPECIFIC); ReturnCode(ERR_FSAL_INVAL, 0); } } ReturnCode(ERR_FSAL_NO_ERROR, 0); } /* FSAL_load_FS_specific_parameter_from_conf */
bool same_device_check (mstr tname, char *buf) { int fstat_res, gsn_stat; struct stat outbuf1, outbuf2; GTM_SOCKLEN_TYPE socknamelen1; GTM_SOCKLEN_TYPE socknamelen2; GTM_SOCKLEN_TYPE psocknamelen1; GTM_SOCKLEN_TYPE psocknamelen2; struct sockaddr_storage sockname1; struct sockaddr_storage sockname2; struct sockaddr_storage psockname1; struct sockaddr_storage psockname2; char port_buffer1[NI_MAXSERV]; char port_buffer2[NI_MAXSERV]; char pport_buffer1[NI_MAXSERV]; char pport_buffer2[NI_MAXSERV]; char host_buffer1[NI_MAXHOST]; char host_buffer2[NI_MAXHOST]; char phost_buffer1[NI_MAXHOST]; char phost_buffer2[NI_MAXHOST]; int errcode, tmplen, save_errno; const char *errptr; FSTAT_FILE(0, &outbuf1, fstat_res); if (-1 == fstat_res) { save_errno = errno; rts_error_csa(CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5, RTS_ERROR_LITERAL("fstat"), CALLFROM, save_errno); } FSTAT_FILE(1, &outbuf2, fstat_res); if (-1 == fstat_res) { save_errno = errno; rts_error_csa(CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5, RTS_ERROR_LITERAL("fstat"), CALLFROM, save_errno); } if ((S_IFMT & outbuf1.st_mode) != (S_IFMT & outbuf2.st_mode)) return FALSE; if (S_ISSOCK(outbuf1.st_mode)) { /* if here then both 0,1 are sockets */ socknamelen1 = SIZEOF(sockname1); if (-1 == (gsn_stat = getsockname(0, (struct sockaddr *)&sockname1, (GTM_SOCKLEN_TYPE *)&socknamelen1))) { save_errno = errno; if (IS_SOCKNAME_UNIXERROR(save_errno)) { /* problem with getsockname for AF_UNIX socket so just assign family for the switch below */ (((sockaddr_ptr)&sockname1)->sa_family) = AF_UNIX; } else { /* process error */ errptr = (char *)STRERROR(save_errno); tmplen = STRLEN(errptr); rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr); } } socknamelen2 = SIZEOF(sockname2); if (-1 == (gsn_stat = getsockname(1, (struct sockaddr *)&sockname2, (GTM_SOCKLEN_TYPE *)&socknamelen2))) { save_errno = errno; if (IS_SOCKNAME_UNIXERROR(save_errno)) { /* problem with getsockname for AF_UNIX socket so just assign family for the switch below */ (((sockaddr_ptr)&sockname2)->sa_family) = AF_UNIX; } else { /* process error */ errptr = (char *)STRERROR(save_errno); tmplen = STRLEN(errptr); rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr); } } /* if both sockets not the same family then not the same device */ if ((((sockaddr_ptr)&sockname1)->sa_family) != (((sockaddr_ptr)&sockname2)->sa_family)) return FALSE; switch(((sockaddr_ptr)&sockname1)->sa_family) { case AF_INET: case AF_INET6: GETNAMEINFO((struct sockaddr *)&sockname1, socknamelen1, host_buffer1, NI_MAXHOST, port_buffer1, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode); if (0 != errcode) { RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode); return FALSE; } GETNAMEINFO((struct sockaddr *)&sockname2, socknamelen2, host_buffer2, NI_MAXHOST, port_buffer2, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode); if (0 != errcode) { RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode); return FALSE; } /* hosts and ports must be the same */ if (STRCMP(host_buffer1, host_buffer2) || STRCMP(port_buffer1, port_buffer2)) return FALSE; psocknamelen1 = SIZEOF(psockname1); if (-1 == (gsn_stat = getpeername(0, (struct sockaddr *)&psockname1, (GTM_SOCKLEN_TYPE *)&psocknamelen1))) { save_errno = errno; errptr = (char *)STRERROR(save_errno); tmplen = STRLEN(errptr); rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr); } psocknamelen2 = SIZEOF(psockname2); if (-1 == (gsn_stat = getpeername(1, (struct sockaddr *)&psockname2, (GTM_SOCKLEN_TYPE *)&psocknamelen2))) { save_errno = errno; errptr = (char *)STRERROR(save_errno); tmplen = STRLEN(errptr); rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr); } GETNAMEINFO((struct sockaddr *)&psockname1, psocknamelen1, phost_buffer1, NI_MAXHOST, pport_buffer1, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode); if (0 != errcode) { RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode); return FALSE; } GETNAMEINFO((struct sockaddr *)&psockname2, psocknamelen2, phost_buffer2, NI_MAXHOST, pport_buffer2, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode); if (0 != errcode) { RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode); return FALSE; } /* hosts and ports for the peer sockets must also be the same */ if (STRCMP(phost_buffer1, phost_buffer2) || STRCMP(pport_buffer1, pport_buffer2)) return FALSE; break; case AF_UNIX: default: /* if inodes are different or st_dev different then not the same device */ if ((outbuf1.st_ino != outbuf2.st_ino) || (outbuf1.st_dev != outbuf2.st_dev)) return FALSE; break; } return TRUE; } else if (S_ISCHR(outbuf1.st_mode)) { /* if here then both 0,1 are character devices */ /* if inodes are different or st_dev different then not the same device */ if ((outbuf1.st_ino != outbuf2.st_ino) || (outbuf1.st_dev != outbuf2.st_dev)) return FALSE; else return TRUE; } else { /* unexpected type so assert */ assert(FALSE); return FALSE; } }
/* * Sync the memory file *mfp to disk. * Flags: * MFS_ALL If not given, blocks with negative numbers are not synced, * even when they are dirty! * MFS_STOP Stop syncing when a character becomes available, but sync at * least one block. * MFS_FLUSH Make sure buffers are flushed to disk, so they will survive a * system crash. * MFS_ZERO Only write block 0. * * Return FAIL for failure, OK otherwise */ int mf_sync(memfile_T *mfp, int flags) { int status; bhdr_T *hp; #if defined(SYNC_DUP_CLOSE) int fd; #endif int got_int_save = got_int; if (mfp->mf_fd < 0) /* there is no file, nothing to do */ { mfp->mf_dirty = FALSE; return FAIL; } /* Only a CTRL-C while writing will break us here, not one typed * previously. */ got_int = FALSE; /* * sync from last to first (may reduce the probability of an inconsistent * file) If a write fails, it is very likely caused by a full filesystem. * Then we only try to write blocks within the existing file. If that also * fails then we give up. */ status = OK; for (hp = mfp->mf_used_last; hp != NULL; hp = hp->bh_prev) if (((flags & MFS_ALL) || hp->bh_bnum >= 0) && (hp->bh_flags & BH_DIRTY) && (status == OK || (hp->bh_bnum >= 0 && hp->bh_bnum < mfp->mf_infile_count))) { if ((flags & MFS_ZERO) && hp->bh_bnum != 0) continue; if (mf_write(mfp, hp) == FAIL) { if (status == FAIL) /* double error: quit syncing */ break; status = FAIL; } if (flags & MFS_STOP) { /* Stop when char available now. */ if (ui_char_avail()) break; } else ui_breakcheck(); if (got_int) break; } /* * If the whole list is flushed, the memfile is not dirty anymore. * In case of an error this flag is also set, to avoid trying all the time. */ if (hp == NULL || status == FAIL) mfp->mf_dirty = FALSE; if ((flags & MFS_FLUSH) && *p_sws != NUL) { #if defined(UNIX) # ifdef HAVE_FSYNC /* * most Unixes have the very useful fsync() function, just what we need. * However, with OS/2 and EMX it is also available, but there are * reports of bad problems with it (a bug in HPFS.IFS). * So we disable use of it here in case someone tries to be smart * and changes os_os2_cfg.h... (even though there is no __EMX__ test * in the #if, as __EMX__ does not have sync(); we hope for a timely * sync from the system itself). */ # if defined(__EMX__) error "Don't use fsync with EMX! Read emxdoc.doc or emxfix01.doc for info." # endif if (STRCMP(p_sws, "fsync") == 0) { if (fsync(mfp->mf_fd)) status = FAIL; } else # endif /* OpenNT is strictly POSIX (Benzinger) */ /* Tandem/Himalaya NSK-OSS doesn't have sync() */ /* No sync() on Stratus VOS */ # if defined(__OPENNT) || defined(__TANDEM) || defined(__VOS__) fflush(NULL); # else sync(); # endif #endif #ifdef VMS if (STRCMP(p_sws, "fsync") == 0) { if (fsync(mfp->mf_fd)) status = FAIL; } #endif #ifdef SYNC_DUP_CLOSE /* * Win32 is a bit more work: Duplicate the file handle and close it. * This should flush the file to disk. */ if ((fd = dup(mfp->mf_fd)) >= 0) close(fd); #endif #ifdef AMIGA # if defined(__AROS__) || defined(__amigaos4__) if (fsync(mfp->mf_fd) != 0) status = FAIL; # else /* * Flush() only exists for AmigaDos 2.0. * For 1.3 it should be done with close() + open(), but then the risk * is that the open() may fail and lose the file.... */ # ifdef FEAT_ARP if (dos2) # endif # ifdef SASC { struct UFB *fp = chkufb(mfp->mf_fd); if (fp != NULL) Flush(fp->ufbfh); } # else # if defined(_DCC) || defined(__GNUC__) || defined(__MORPHOS__) { # if defined(__GNUC__) && !defined(__MORPHOS__) && defined(__libnix__) /* Have function (in libnix at least), * but ain't got no prototype anywhere. */ extern unsigned long fdtofh(int filedescriptor); # endif # if !defined(__libnix__) fflush(NULL); # else BPTR fh = (BPTR)fdtofh(mfp->mf_fd); if (fh != 0) Flush(fh); # endif } # else /* assume Manx */ Flush(_devtab[mfp->mf_fd].fd); # endif # endif # endif #endif /* AMIGA */ }
ACPI_STATUS acpi_ns_root_initialize (void) { ACPI_STATUS status = AE_OK; PREDEFINED_NAMES *init_val = NULL; ACPI_NAMESPACE_NODE *new_node; ACPI_OPERAND_OBJECT *obj_desc; acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); /* * The global root ptr is initially NULL, so a non-NULL value indicates * that Acpi_ns_root_initialize() has already been called; just return. */ if (acpi_gbl_root_node) { status = AE_OK; goto unlock_and_exit; } /* * Tell the rest of the subsystem that the root is initialized * (This is OK because the namespace is locked) */ acpi_gbl_root_node = &acpi_gbl_root_node_struct; /* Enter the pre-defined names in the name table */ for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) { status = acpi_ns_lookup (NULL, init_val->name, (OBJECT_TYPE_INTERNAL) init_val->type, IMODE_LOAD_PASS2, NS_NO_UPSEARCH, NULL, &new_node); /* * Name entered successfully. * If entry in Pre_defined_names[] specifies an * initial value, create the initial value. */ if (init_val->val) { /* * Entry requests an initial value, allocate a * descriptor for it. */ obj_desc = acpi_cm_create_internal_object ( (OBJECT_TYPE_INTERNAL) init_val->type); if (!obj_desc) { status = AE_NO_MEMORY; goto unlock_and_exit; } /* * Convert value string from table entry to * internal representation. Only types actually * used for initial values are implemented here. */ switch (init_val->type) { case ACPI_TYPE_NUMBER: obj_desc->number.value = (ACPI_INTEGER) STRTOUL (init_val->val, NULL, 10); break; case ACPI_TYPE_STRING: obj_desc->string.length = (u16) STRLEN (init_val->val); /* * Allocate a buffer for the string. All * String.Pointers must be allocated buffers! * (makes deletion simpler) */ obj_desc->string.pointer = acpi_cm_allocate ( (obj_desc->string.length + 1)); if (!obj_desc->string.pointer) { acpi_cm_remove_reference (obj_desc); status = AE_NO_MEMORY; goto unlock_and_exit; } STRCPY (obj_desc->string.pointer, init_val->val); break; case ACPI_TYPE_MUTEX: obj_desc->mutex.sync_level = (u16) STRTOUL (init_val->val, NULL, 10); if (STRCMP (init_val->name, "_GL_") == 0) { /* * Create a counting semaphore for the * global lock */ status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 1, &obj_desc->mutex.semaphore); if (ACPI_FAILURE (status)) { goto unlock_and_exit; } /* * We just created the mutex for the * global lock, save it */ acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore; } else { /* Create a mutex */ status = acpi_os_create_semaphore (1, 1, &obj_desc->mutex.semaphore); if (ACPI_FAILURE (status)) { goto unlock_and_exit; } } break; default: REPORT_ERROR (("Unsupported initial type value %X\n", init_val->type)); acpi_cm_remove_reference (obj_desc); obj_desc = NULL; continue; } /* Store pointer to value descriptor in the Node */ acpi_ns_attach_object (new_node, obj_desc, obj_desc->common.type); } } unlock_and_exit: acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); return (status); }
CFileMatcher::CFileMatcher(LPTSTR pszMask) { m_pszDirBuffer = NULL; if (pszMask == NULL) { ASSERT(FALSE); // I am not sure if this is possible - but I better check for it just in case! m_fMatchAll = TRUE; m_fMatchAllDir = TRUE; // There is no point in initialising m_pszMask and m_pszMultiple - as they will not be used! return; } m_pszMask = pszMask; m_pszMaskDir = NULL; m_pszMultiple = NULL; m_pszMultipleDir = NULL; // Parse the mask to see if it contains multiple/dual masks (ie, look for ",;!") TCHAR ch; int nDir = 0; int nChars = 0; LPTSTR pszDir = NULL; LPTSTR psz = pszMask; while (ch = *psz++) { if ((ch == ',') || (ch == ';')) { if (pszDir) { if (m_pszMultipleDir == NULL) m_pszMultipleDir = pszDir; // We need to re-point this to the mask buffer when we create it later on } else { if (m_pszMultiple == NULL) { // We will be modifying the multiple mask string - so copy it into m_szMultiple m_pszMultiple = m_szMultiple; STRNCPY(m_pszMultiple, pszMask, MAX_PATH); } } } else if ((ch == '|') && !pszDir) { pszDir = psz; nDir = nChars; } nChars++; } BOOL fNoDirs = FALSE; if (pszDir) { // We have a second mask - we will need to assign m_pszDirBuffer so it can hold it // We also need to copy the original mask into its own buffer (we will use m_szMultiple) as we will need to replace the | with a nul! if (nDir) { if (m_pszMultiple == NULL) STRNCPY(m_szMultiple, pszMask, MAX_PATH); m_pszMask = m_szMultiple; ASSERT(m_szMultiple[nDir] == '|'); m_szMultiple[nDir] = 0; } else { // We have an *empty* mask - we will display *no* files! m_pszMask = NULL; ASSERT(m_pszMultiple == NULL); } // If the directory mask contains anything - create a buffer for it - otherwise we will use the same buffers as the "file" int nLen = STRLEN(pszDir); if (nLen) { m_pszDirBuffer = new TCHAR[nLen+2]; // We may need to add 2 nuls to the end - this will be done when we parse the buffer later on STRCPY(m_pszDirBuffer, pszDir); m_pszMaskDir = m_pszDirBuffer; if (m_pszMultipleDir) m_pszMultipleDir = m_pszMaskDir; } else { // The dir mask is empty - display *no* dirs! fNoDirs = TRUE; } } if (m_pszMask) m_fMatchAll = (!STRCMP(m_pszMask, _T("*.*")) ||! STRCMP(m_pszMask, _T("*"))) ? TRUE : FALSE; else m_fMatchAll = FALSE; if (m_pszMaskDir) m_fMatchAllDir = (!STRCMP(m_pszMaskDir, _T("*.*")) ||! STRCMP(m_pszMaskDir, _T("*"))) ? TRUE : FALSE; else m_fMatchAllDir = !fNoDirs; if (m_pszMultiple) ParseMultiple(m_pszMultiple); if (m_pszMultipleDir && (m_pszMultipleDir != m_pszMultiple)) ParseMultiple(m_pszMultipleDir); }
//Do not change these these are stored in the database CLIPFORMAT GetFormatID(LPCTSTR cbName) { if(STRCMP(cbName, _T("CF_TEXT")) == 0) return CF_TEXT; else if(STRCMP(cbName, _T("CF_METAFILEPICT")) == 0) return CF_METAFILEPICT; else if(STRCMP(cbName, _T("CF_SYLK")) == 0) return CF_SYLK; else if(STRCMP(cbName, _T("CF_DIF")) == 0) return CF_DIF; else if(STRCMP(cbName, _T("CF_TIFF")) == 0) return CF_TIFF; else if(STRCMP(cbName, _T("CF_OEMTEXT")) == 0) return CF_OEMTEXT; else if(STRCMP(cbName, _T("CF_DIB")) == 0) return CF_DIB; else if(STRCMP(cbName, _T("CF_PALETTE")) == 0) return CF_PALETTE; else if(STRCMP(cbName, _T("CF_PENDATA")) == 0) return CF_PENDATA; else if(STRCMP(cbName, _T("CF_RIFF")) == 0) return CF_RIFF; else if(STRCMP(cbName, _T("CF_WAVE")) == 0) return CF_WAVE; else if(STRCMP(cbName, _T("CF_UNICODETEXT")) == 0) return CF_UNICODETEXT; else if(STRCMP(cbName, _T("CF_ENHMETAFILE")) == 0) return CF_ENHMETAFILE; else if(STRCMP(cbName, _T("CF_HDROP")) == 0) return CF_HDROP; else if(STRCMP(cbName, _T("CF_LOCALE")) == 0) return CF_LOCALE; else if(STRCMP(cbName, _T("CF_OWNERDISPLAY")) == 0) return CF_OWNERDISPLAY; else if(STRCMP(cbName, _T("CF_DSPTEXT")) == 0) return CF_DSPTEXT; else if(STRCMP(cbName, _T("CF_DSPBITMAP")) == 0) return CF_DSPBITMAP; else if(STRCMP(cbName, _T("CF_DSPMETAFILEPICT")) == 0) return CF_DSPMETAFILEPICT; else if(STRCMP(cbName, _T("CF_DSPENHMETAFILE")) == 0) return CF_DSPENHMETAFILE; return ::RegisterClipboardFormat(cbName); }
static void hddfmt_start() { UINT8 back_saved; win_popup_choice_t choice; UINT8 mode; struct dvr_HDD_info hdd_info; char volume_name[48]; char osd_name[48]; char hint[64]; BOOL ret; disk_format_mode_num = get_fsystem_installed(disk_mode, 8); //sprintf(temp, "%s", disk_mode[input]); storage_index_to_osd_string((UINT8)hddfmt_cur_volume,osd_name); sprintf(hint, "Are you sure to format the %s?", osd_name); if(disk_format_mode_num == 1) { win_compopup_init(WIN_POPUP_TYPE_OKNO); win_compopup_set_btnstr_ext(0, disk_mode[0]); win_compopup_set_default_choice(WIN_POP_CHOICE_NO); } else if(disk_format_mode_num == 2) { win_compopup_init(WIN_POPUP_TYPE_OKNOCANCLE); win_compopup_set_btnstr_ext(0, disk_mode[0]); win_compopup_set_btnstr_ext(1, disk_mode[1]); win_compopup_set_default_choice(WIN_POP_CHOICE_CANCEL); } win_compopup_set_msg(hint, NULL, 0); choice = win_compopup_open_ext(&back_saved); if(((disk_format_mode_num == 1) && (choice == WIN_POP_CHOICE_YES)) || ((disk_format_mode_num == 2) && ((choice == WIN_POP_CHOICE_YES) || (choice == WIN_POP_CHOICE_NO)))) { if(choice == WIN_POP_CHOICE_YES) mode = 1; else mode = 2; storage_index2volume((UINT8)hddfmt_cur_volume,volume_name); storage_add_parent_dir(volume_name); win_compopup_init(WIN_POPUP_TYPE_SMSG); win_compopup_set_frame(GET_MID_L(286), GET_MID_T(130), 286, 130); win_compopup_set_msg_ext("formating wait!",NULL,0); win_compopup_open_ext(&back_saved); ret = pvr_format_multi_hdd(mode, volume_name); win_compopup_smsg_restoreback(); if(!ret) { win_compopup_init(WIN_POPUP_TYPE_OK); sprintf(hint, "Format %s error?", osd_name); win_compopup_set_msg(hint, NULL, 0); win_compopup_set_default_choice(WIN_POP_CHOICE_CANCEL); win_compopup_open_ext(&back_saved); return; } if(STRCMP((char *)pvr_get_mout_prefix(), volume_name)==0) { if(pvr_get_HDD_info(&hdd_info)) { api_pvr_check_level(&hdd_info); ap_clear_all_message();//or usb reflash msg maybe send fail pvr_evnt_callback(0, PVR_HDD_FORMATTED); } } win_hddfmt_draw_disk_infor(); } }
// // Return 1 if path can be mounted. // the share name is the folder after the NETWORK_SHARE sub folder. // Then the nmt settings are inspected to get the full mount definition. // // First try to ping the host. // // If that doesnt work and using SMB/cifs then try to use nbtscan to // resolve wins names. // // The current_mount_status is passed in case the share is alread present // in /etc/mtab. If it is not - try to mount it, if it is, then check for timeouts. static int nmt_mount_share(char *path,char *current_mount_status) { int result = 0; char *link_prefix=NULL; char *share_name = util_basename(path); HTML_LOG(0,"mount path=[%s] share_name [%s] current status [%s]",path,share_name,current_mount_status); // eg "abc" char index = get_link_index("servname",share_name); if (index) { link_prefix="servlink"; } else { index = get_link_index("netfs_name",share_name); if (index) { link_prefix="netfs_url"; } } if (index) { char *key; ovs_asprintf(&key,"%s%c",link_prefix,index); char *serv_link = setting_val(key); // Look for corresponding variable servlinkN HTML_LOG(0,"DEMOTE mount %s [%s]",link_prefix,serv_link); FREE(key); char *link = get_pingable_link(serv_link); if (!link) { set_mount_status(path,MOUNT_STATUS_BAD); } else if (STRCMP(current_mount_status,MOUNT_STATUS_NOT_IN_MTAB) == 0) { char *user = get_link_user(serv_link); char *passwd = get_link_passwd(serv_link); NETFSProtocol proto = get_link_protocol(serv_link); char *cmd = get_mount_command(proto,link,path,user,passwd); FREE(user); FREE(passwd); if (cmd ) { long t = time(NULL); int mount_result = util_system(cmd); // Mount prints detailed error to stdout but just returns exit codes // 0(OK) , 1(Bad args?) OR 0xFF00 (Something else). // So we cant tell exactly why it failed without scraping // stdout. // Eg if mount display 'Device or resource Busy' it doesnt return EBUSY(16) // // Also trying to use native mount() function is hard work // (it does kernel space work but not other stuff - update /etc/mtab etc?) // // So I've taken a big liberty here and assumed that if the mount returns // immediately that it worked. // This obviously is risky of the mount failed due to bad parameters. switch(mount_result) { case 0: result = 1; break; case 0xFF00: // some mount error occured. If it occured in less than 1 second // just assume its a device busy and continue happily assuming it // is already mounted. if (time(NULL) - t <= 5) { HTML_LOG(0,"mount [%s] failed quickly - assume all is ok",cmd); result = 1; } else { HTML_LOG(0,"mount [%s] failed slowly - assume the worst ",cmd); result = 0; } break; default: HTML_LOG(0,"mount [%s] unknown error - assume the worst ",cmd); //even though mount failed - add it to the list to avoid repeat attempts. result = 0; } set_mount_status(path,(result ? MOUNT_STATUS_OK : MOUNT_STATUS_BAD)); FREE(cmd); } } else if (STRCMP(current_mount_status,MOUNT_STATUS_IN_MTAB) == 0) { // Its pingable but now we check it is accessible. TRACE; result = check_accessible(path,5); } else { // shouldnt get here assert(0); } FREE(link); } FREE(share_name); return result; }
static void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startcol, Integer endcol, Integer clearcol, Integer clearattr, Boolean wrap, const schar_T *chunk, const sattr_T *attrs) { UIData *data = ui->data; if (ui->ui_ext[kUILinegrid]) { Array args = ARRAY_DICT_INIT; ADD(args, INTEGER_OBJ(grid)); ADD(args, INTEGER_OBJ(row)); ADD(args, INTEGER_OBJ(startcol)); Array cells = ARRAY_DICT_INIT; int repeat = 0; size_t ncells = (size_t)(endcol-startcol); int last_hl = -1; for (size_t i = 0; i < ncells; i++) { repeat++; if (i == ncells-1 || attrs[i] != attrs[i+1] || STRCMP(chunk[i], chunk[i+1])) { Array cell = ARRAY_DICT_INIT; ADD(cell, STRING_OBJ(cstr_to_string((const char *)chunk[i]))); if (attrs[i] != last_hl || repeat > 1) { ADD(cell, INTEGER_OBJ(attrs[i])); last_hl = attrs[i]; } if (repeat > 1) { ADD(cell, INTEGER_OBJ(repeat)); } ADD(cells, ARRAY_OBJ(cell)); repeat = 0; } } if (endcol < clearcol) { Array cell = ARRAY_DICT_INIT; ADD(cell, STRING_OBJ(cstr_to_string(" "))); ADD(cell, INTEGER_OBJ(clearattr)); ADD(cell, INTEGER_OBJ(clearcol-endcol)); ADD(cells, ARRAY_OBJ(cell)); } ADD(args, ARRAY_OBJ(cells)); push_call(ui, "grid_line", args); } else { for (int i = 0; i < endcol-startcol; i++) { remote_ui_cursor_goto(ui, row, startcol+i); remote_ui_highlight_set(ui, attrs[i]); remote_ui_put(ui, (const char *)chunk[i]); if (utf_ambiguous_width(utf_ptr2char(chunk[i]))) { data->client_col = -1; // force cursor update } } if (endcol < clearcol) { remote_ui_cursor_goto(ui, row, endcol); remote_ui_highlight_set(ui, (int)clearattr); // legacy eol_clear was only ever used with cleared attributes // so be on the safe side if (clearattr == 0 && clearcol == Columns) { Array args = ARRAY_DICT_INIT; push_call(ui, "eol_clear", args); } else { for (Integer c = endcol; c < clearcol; c++) { remote_ui_put(ui, " "); } } } } }
/* * External interface */ static void DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) { #if defined(MACOS) && !defined(MACOS_X_UNIX) GrafPtr oldPort; #endif #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) char *saved_locale; #endif PyObject *cmdstr; PyObject *cmdbytes; PyGILState_STATE pygilstate; #if defined(MACOS) && !defined(MACOS_X_UNIX) GetPort(&oldPort); /* Check if the Python library is available */ if ((Ptr)PyMac_Initialize == (Ptr)kUnresolvedCFragSymbolAddress) goto theend; #endif if (Python3_Init()) goto theend; init_range(arg); Python_Release_Vim(); /* leave vim */ #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) /* Python only works properly when the LC_NUMERIC locale is "C". */ saved_locale = setlocale(LC_NUMERIC, NULL); if (saved_locale == NULL || STRCMP(saved_locale, "C") == 0) saved_locale = NULL; else { /* Need to make a copy, value may change when setting new locale. */ saved_locale = (char *)vim_strsave((char_u *)saved_locale); (void)setlocale(LC_NUMERIC, "C"); } #endif pygilstate = PyGILState_Ensure(); /* PyRun_SimpleString expects a UTF-8 string. Wrong encoding may cause * SyntaxError (unicode error). */ cmdstr = PyUnicode_Decode(cmd, strlen(cmd), (char *)ENC_OPT, CODEC_ERROR_HANDLER); cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER); Py_XDECREF(cmdstr); run(PyBytes_AsString(cmdbytes), arg, &pygilstate); Py_XDECREF(cmdbytes); PyGILState_Release(pygilstate); #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) if (saved_locale != NULL) { (void)setlocale(LC_NUMERIC, saved_locale); vim_free(saved_locale); } #endif Python_Lock_Vim(); /* enter vim */ PythonIO_Flush(); #if defined(MACOS) && !defined(MACOS_X_UNIX) SetPort(oldPort); #endif theend: return; /* keeps lint happy */ }
/* EXTPROTO */ int rxvt_scale_pixmap(rxvt_t *r, int page, const char *geom) { int flags, changed = 0; int x = 0, y = 0; unsigned int w = 0, h = 0; unsigned int n; char *p, *str; bgPixmap_t *bgpixmap = &(PVTS(r, page)->bg); #define MAXLEN_GEOM sizeof("[1000x1000+1000+1000]") if (geom == NULL) return 0; str = rxvt_malloc(MAXLEN_GEOM + 1); if (!STRCMP(geom, "?")) { sprintf(str, "[%dx%d+%d+%d]", /* can't presume snprintf() ! */ min(bgpixmap->w, 9999), min(bgpixmap->h, 9999), min(bgpixmap->x, 9999), min(bgpixmap->y, 9999)); rxvt_xterm_seq(r, page, XTerm_title, str, CHAR_ST); rxvt_free(str); return 0; } if ((p = STRCHR(geom, ';')) == NULL) p = STRCHR(geom, '\0'); n = (p - geom); if (n <= MAXLEN_GEOM) { STRNCPY(str, geom, n); str[n] = '\0'; flags = XParseGeometry(str, &x, &y, &w, &h); if (!flags) { flags |= WidthValue; w = 0; } /* default is tile */ if (flags & WidthValue) { if (!(flags & XValue)) x = 50; if (!(flags & HeightValue)) h = w; if (w && !h) { w = (bgpixmap->w * w) / 100; h = bgpixmap->h; } else if (h && !w) { w = bgpixmap->w; h = (bgpixmap->h * h) / 100; } if (w > 1000) w = 1000; if (h > 1000) h = 1000; if (bgpixmap->w != (short)w) { bgpixmap->w = (short)w; changed++; } if (bgpixmap->h != (short)h) { bgpixmap->h = (short)h; changed++; } } if (!(flags & YValue)) { if (flags & XNegative) flags |= YNegative; y = x; } if (!(flags & WidthValue) && geom[0] != '=') { x += bgpixmap->x; y += bgpixmap->y; } else { if (flags & XNegative) x += 100; if (flags & YNegative) y += 100; } MIN_IT(x, 100); MIN_IT(y, 100); MAX_IT(x, 0); MAX_IT(y, 0); if (bgpixmap->x != x) { bgpixmap->x = x; changed++; } if (bgpixmap->y != y) { bgpixmap->y = y; changed++; } } rxvt_free(str); return changed; }
int main() { int argc; wchar_t **argv = CommandLineToArgvW(GetCommandLineW(), &argc); #else int main(int argc, char *argv[]) { #endif // _WIN32 is_fast = false; is_verbose = false; iterations = 15; depth = 1; max_depth = INT_MAX; #ifdef _WIN32 is_pause = !getenv("PROMPT"); #endif // _WIN32 int i; for (i = 1; i < argc && argv[i][0] == L'-'; i++) { #ifdef _WIN32 // do not pause if any options are given is_pause = false; #endif // _WIN32 int num_optargs = 0; for (int j = 1; argv[i][j]; j++) { switch (argv[i][j]) { case 'f': is_fast = true; break; case 'i': if (i < argc - 1) { iterations = STRTOL(argv[i + ++num_optargs], nullptr, 10); // strtol will return 0 on fail if (iterations == 0) { std::cerr << "There should be a positive number after -i option." << std::endl; PrintInfo(); return 1; } } break; case 'd': if (i < argc - 1) { max_depth = STRTOL(argv[i + ++num_optargs], nullptr, 10); // strtol will return 0 on fail if (max_depth == 0) { std::cerr << "There should be a positive number after -d option." << std::endl; PrintInfo(); return 1; } } break; case 'q': std::cout.setstate(std::ios::failbit); is_verbose = false; break; case 'v': std::cout.clear(); is_verbose = true; break; case '-': if (STRCMP(argv[i] + j + 1, "fastmode") == 0) { j += 7; argv[i][j + 1] = 'f'; } else if (STRCMP(argv[i] + j + 1, "iteration") == 0) { j += 8; argv[i][j + 1] = 'i'; } else if (STRCMP(argv[i] + j + 1, "max_depth") == 0) { j += 8; argv[i][j + 1] = 'd'; } else if (STRCMP(argv[i] + j + 1, "quiet") == 0) { j += 4; argv[i][j + 1] = 'q'; } else if (STRCMP(argv[i] + j + 1, "verbose") == 0) { j += 6; argv[i][j + 1] = 'v'; } else if (STRCMP(argv[i] + j + 1, "keep-exif") == 0) { j += 9; Jpeg::keep_exif = true; } else { #ifdef _WIN32 char mbs[64] = { 0 }; WideCharToMultiByte(CP_ACP, 0, argv[i] + j + 1, -1, mbs, sizeof(mbs) - 1, nullptr, nullptr); std::cerr << "Unknown option: " << mbs << std::endl; #else std::cerr << "Unknown option: " << argv[i] + j + 1 << std::endl; #endif // _WIN32 PrintInfo(); return 1; } break; default: std::cerr << "Unknown option: " << (char)argv[i][j] << std::endl; PrintInfo(); return 1; } } i += num_optargs; } if (i == argc) { std::cerr << "No file path provided." << std::endl; PrintInfo(); return 1; } std::cout << std::fixed; std::cout.precision(2); // support multiple input file do { if (IsDirectory(argv[i])) { // directory TraverseDirectory(argv[i], ProcessFile); } else { // file ProcessFile(argv[i]); } } while (++i < argc); PauseIfNotTerminal(); return 0; }
/* * Test trunc_string(). */ static void test_trunc_string(void) { char_u *buf; /*allocated every time to find uninit errors */ char_u *s; /* in place */ buf = alloc(40); STRCPY(buf, "text"); trunc_string(buf, buf, 20, 40); assert(STRCMP(buf, "text") == 0); vim_free(buf); buf = alloc(40); STRCPY(buf, "a short text"); trunc_string(buf, buf, 20, 40); assert(STRCMP(buf, "a short text") == 0); vim_free(buf); buf = alloc(40); STRCPY(buf, "a text tha just fits"); trunc_string(buf, buf, 20, 40); assert(STRCMP(buf, "a text tha just fits") == 0); vim_free(buf); buf = alloc(40); STRCPY(buf, "a text that nott fits"); trunc_string(buf, buf, 20, 40); assert(STRCMP(buf, "a text t...nott fits") == 0); vim_free(buf); /* copy from string to buf */ buf = alloc(40); s = vim_strsave((char_u *)"text"); trunc_string(s, buf, 20, 40); assert(STRCMP(buf, "text") == 0); vim_free(buf); vim_free(s); buf = alloc(40); s = vim_strsave((char_u *)"a text that fits"); trunc_string(s, buf, 34, 40); assert(STRCMP(buf, "a text that fits") == 0); vim_free(buf); vim_free(s); buf = alloc(40); s = vim_strsave((char_u *)"a short text"); trunc_string(s, buf, 20, 40); assert(STRCMP(buf, "a short text") == 0); vim_free(buf); vim_free(s); buf = alloc(40); s = vim_strsave((char_u *)"a text tha just fits"); trunc_string(s, buf, 20, 40); assert(STRCMP(buf, "a text tha just fits") == 0); vim_free(buf); vim_free(s); buf = alloc(40); s = vim_strsave((char_u *)"a text that nott fits"); trunc_string(s, buf, 20, 40); assert(STRCMP(buf, "a text t...nott fits") == 0); vim_free(buf); vim_free(s); }
int main(int argc, char **argv) { #ifndef NO_CDE _DtEnvControl(DT_ENV_SET); #endif // run as user's UID #ifdef hpux setresuid(getuid(), getuid(), (uid_t)0); #else seteuid(getuid()); #endif setlocale(LC_ALL, ""); char *lang = getenv("LANG"); if (lang && strcmp(lang, "C")) { errno = 0; #ifdef NL_CAT_LOCALE dtprintinfo_cat = catopen("dtprintinfo", NL_CAT_LOCALE); #else dtprintinfo_cat = catopen("dtprintinfo", 0); #endif if ((nl_catd) errno) dtprintinfo_cat = (nl_catd) -1; #ifdef hpux else msg_strings = (char **)calloc(LAST_MSG_NO, sizeof(char *)); #endif } if (dtprintinfo_cat == NULL) { dtprintinfo_cat = (nl_catd) -1; } if (!STRCMP(argv[1], "-help")) { char *output; char *cmd = new char [strlen(LIST_QUEUES) + 30]; sprintf(cmd, "%s | awk '{print \"\\t\", $1}'", LIST_QUEUES); Invoke *_thread = new Invoke(cmd, &output); printf(MESSAGE(CommandLineHelpL), output); printf("\n"); delete output; delete [] cmd; delete _thread; return 0; } char *progname = strrchr(argv[0], '/'); if (progname) progname++; else progname = argv[0]; if (!STRCMP(argv[1], "-populate")) { if (getuid() != 0) { fprintf(stderr, MESSAGE(RootUserL), progname, "-populate"); fprintf(stderr, "\n"); return 1; } PrintSubSystem *prt = new PrintSubSystem(NULL); int n_queues = prt->NumChildren(); // Get Print Subsystem children, (these are queues) Queue **queues = (Queue **)prt->Children(); int i; for (i = 0; i < n_queues; i++) { DtPrinterIcon *icon = new DtPrinterIcon(NULL, NULL, queues[i], INITIALIZE_PRINTERS); icon->CreateActionFile(); delete icon; } return 0; } DtApp *app = new DtApp(progname, &argc, argv); app->Visible(true); app->Run(); return 0; }
WORD DosGetMessageW( IN LPTSTR * InsertionStrings, IN WORD NumberofStrings, OUT LPTSTR Buffer, IN WORD BufferLength, IN WORD MessageId, IN LPTSTR FileName, OUT PWORD pMessageLength ) /*++ Routine Description: This maps the OS/2 DosGetMessage API to the NT FormatMessage API. Arguments: InsertionStrings - Pointer to an array of strings that will be used to replace the %n's in the message. NumberofStrings - The number of insertion strings. Buffer - The buffer to put the message into. BufferLength - The length of the supplied buffer. MessageId - The message number to retrieve. FileName - The name of the message file to get the message from. pMessageLength - A pointer to return the length of the returned message. Return Value: NERR_Success ERROR_MR_MSG_TOO_LONG ERROR_MR_INV_IVCOUNT ERROR_MR_UN_ACC_MSGF ERROR_MR_MID_NOT_FOUND ERROR_INVALID_PARAMETER --*/ { DWORD dwFlags = FORMAT_MESSAGE_ARGUMENT_ARRAY; DWORD Status ; TCHAR NumberString [18]; static HANDLE lpSource = NULL ; static TCHAR CurrentMsgFile[MAX_PATH] = {0,} ; // // init clear the output string // Status = NERR_Success; if (BufferLength) Buffer[0] = NULLC ; // // make sure we are not over loaded & allocate // memory for the Unicode buffer // if (NumberofStrings > MAX_INSERT_STRINGS) return ERROR_INVALID_PARAMETER ; // // See if they want to get the message from the system message file. // if (! STRCMP(FileName, OS2MSG_FILENAME)) { dwFlags |= FORMAT_MESSAGE_FROM_SYSTEM; } else { // // They want it from a separate message file. Get a handle to DLL // If its for the same file as before, dont reload. // if (!(lpSource && !STRCMP(CurrentMsgFile,FileName))) { if (lpSource) { FreeLibrary(lpSource) ; } STRCPY(CurrentMsgFile, FileName) ; lpSource = LoadLibrary(FileName); if (!lpSource) { Status = ERROR_MR_UN_ACC_MSGF; goto ExitPoint ; } } dwFlags |= FORMAT_MESSAGE_FROM_HMODULE; } // // If they just want to get the message back for later formatting, // ignore the insert strings. // if (NumberofStrings == 0) { dwFlags |= FORMAT_MESSAGE_IGNORE_INSERTS; } // // call the Unicode version // *pMessageLength = (WORD) FormatMessageW(dwFlags, (LPVOID) lpSource, (DWORD) MessageId, 0, // LanguageId defaulted Buffer, (DWORD)BufferLength * sizeof(WCHAR), (va_list *)InsertionStrings); // // If it failed get the return code and map it to an OS/2 equivalent // if (*pMessageLength == 0) { Buffer[0] = 0 ; Status = GetLastError(); if (Status == ERROR_MR_MID_NOT_FOUND) { // // get the message number in Unicode // ultow(MessageId, NumberString, 16); // // re-setup to get it from the system. use the not found message // dwFlags = FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_SYSTEM; MessageId = ERROR_MR_MID_NOT_FOUND ; // // setup insert strings // InsertionStrings[0] = NumberString ; InsertionStrings[1] = FileName ; // // recall the API // *pMessageLength = (WORD) FormatMessageW(dwFlags, (LPVOID) lpSource, (DWORD) MessageId, 0, // LanguageId defaulted Buffer, (DWORD)BufferLength * sizeof(WCHAR), (va_list *)InsertionStrings); InsertionStrings[1] = NULL ; // // revert to original error // Status = ERROR_MR_MID_NOT_FOUND ; } } ExitPoint: // // note: NumberString dont need to be freed // since if used, they would be in the InsertionStrings which is whacked // return LOWORD(Status); }
void WriteData (int crc) { def_t *def; ddef_t *dd; dprograms_t progs; char tname[1024]; int h; unsigned int i; int size; for (def = pr.def_head.next ; def ; def = def->next) { if ((def->type->type == ev_field) && def->constant) { dd = &fields[numfielddefs]; numfielddefs++; dd->type = def->type->aux_type->type == ev_int ? ev_float : def->type->aux_type->type; if (def->save == 0) { strcpy(tname, def->name); strcat(tname, "__"); dd->s_name = CopyString(tname, 0); } else dd->s_name = CopyString (def->name, 0); dd->ofs = G_INT(def->ofs); } else if (pr_optimize_constant_names && def->constant && (def->type->type != ev_function)) { num_constant_names += strlen(def->name) + 1; num_constant_names += sizeof(ddef_t); continue; } else if (pr_optimize_unreferenced && pr_global_refs[def->ofs] <= 0) { if (!(def->type->type != ev_function)) { num_unreferenced += 1; continue; } } else if (pr_optimize_unreferenced && def->type->type == ev_vector) { if (pr_global_refs[def->ofs] + pr_global_refs[def->ofs + 1] + pr_global_refs[def->ofs +1] == 3) { num_unreferenced += 3; def = def->next; // def_x def = def->next; // def_y def = def->next; // def_z continue; } } dd = &globals[numglobaldefs]; dd->type = def->type->type == ev_int ? ev_float : def->type->type; if (def->save && ( dd->type != ev_field || def->constant != 1)) dd->type |= DEF_SAVEGLOBAL; if (def->name) { if (pr_optimize_locals && (def->scope || !(STRCMP(def->name, "IMMEDIATE")))) { num_locals_saved += strlen(def->name); dd->s_name = 0; } else dd->s_name = CopyString (def->name, 0); } dd->ofs = def->ofs; numglobaldefs++; } strofs = (strofs+3)&~3; if (strofs > INT_MAX) PR_ParseWarning(122, "strofs exceeds INT_MAX by %i", strofs - INT_MAX); if (numstatements > INT_MAX) PR_ParseWarning(123, "numstatements exceeds INT_MAX by %i", numstatements - INT_MAX); if (numfunctions > SHRT_MAX) PR_ParseWarning(124, "numfunctions exceeds SHRT_MAX by %i", numfunctions - SHRT_MAX); if (numglobaldefs > SHRT_MAX) PR_ParseWarning(125, "numglobaldefs exceeds SHRT_MAX by %i", numglobaldefs - SHRT_MAX); if (numfielddefs > SHRT_MAX) PR_ParseWarning(126, "numfielddefs exceeds SHRT_MAX by %i", numfielddefs - SHRT_MAX); if (numpr_globals > SHRT_MAX) PR_ParseWarning(127, "numpr_globals exceeds SHRT_MAX by %i", numpr_globals - SHRT_MAX); if (crc != NQ_PROGHEADER_CRC && crc != QW_PROGHEADER_CRC) PR_ParseWarning(208, "System defs do match internal crcs."); if (summary) { summary_print("----------- Summary -----------\n"); i = I_FloatTime() - StartTime; summary_print (" %02i:%02i elapsed time\n", (i / 60) % 59, i % 59); summary_print ("%6i strofs (MAX: %6i)\n", strofs, MAX_STRINGS ); summary_print ("%6i numstatements (MAX: %6i)\n", numstatements, MAX_STATEMENTS); summary_print ("%6i numfunctions (MAX: %6i)\n", numfunctions, SHRT_MAX); summary_print ("%6i numglobaldefs (MAX: %6i)\n", numglobaldefs, SHRT_MAX); summary_print ("%6i numfielddefs (MAX: %6i)\n", numfielddefs, SHRT_MAX); summary_print ("%6i numpr_globals (MAX: %6i)\n", numpr_globals, SHRT_MAX); } h = SafeOpenWrite (destfile); SafeWrite (h, &progs, sizeof(progs)); progs.ofs_strings = lseek (h, 0, SEEK_CUR); progs.numstrings = strofs; SafeWrite (h, strings, strofs); progs.ofs_statements = lseek (h, 0, SEEK_CUR); progs.numstatements = numstatements; for (i=0 ; i<numstatements ; i++) { statements[i].op = LittleShort(statements[i].op); statements[i].a = LittleShort(statements[i].a); statements[i].b = LittleShort(statements[i].b); statements[i].c = LittleShort(statements[i].c); } SafeWrite (h, statements, numstatements*sizeof(dstatement_t)); progs.ofs_functions = lseek (h, 0, SEEK_CUR); progs.numfunctions = numfunctions; for (i=0 ; i<numfunctions ; i++) { functions[i].first_statement = LittleLong (functions[i].first_statement); functions[i].parm_start = LittleLong (functions[i].parm_start); functions[i].s_name = LittleLong (functions[i].s_name < 0 || functions[i].s_name > strofs ? 0 : functions[i].s_name); functions[i].s_file = LittleLong (functions[i].s_file < 0 || functions[i].s_file > strofs ? 0 : functions[i].s_file); functions[i].numparms = LittleLong (functions[i].numparms > MAX_PARMS ? MAX_PARMS : functions[i].numparms); functions[i].locals = LittleLong (functions[i].locals); } SafeWrite (h, functions, numfunctions*sizeof(dfunction_t)); progs.ofs_globaldefs = lseek (h, 0, SEEK_CUR); progs.numglobaldefs = numglobaldefs; for (i=0 ; i<numglobaldefs ; i++) { globals[i].type = LittleShort (globals[i].type); globals[i].ofs = LittleShort (globals[i].ofs); globals[i].s_name = LittleLong (globals[i].s_name); } SafeWrite (h, globals, numglobaldefs*sizeof(ddef_t)); progs.ofs_fielddefs = lseek (h, 0, SEEK_CUR); progs.numfielddefs = numfielddefs; for (i=0 ; i<numfielddefs ; i++) { fields[i].type = LittleShort (fields[i].type); fields[i].ofs = LittleShort (fields[i].ofs); fields[i].s_name = LittleLong (fields[i].s_name < 0 || fields[i].s_name > strofs ? 0: fields[i].s_name); } SafeWrite (h, fields, numfielddefs*sizeof(ddef_t)); progs.ofs_globals = lseek (h, 0, SEEK_CUR); progs.numglobals = numpr_globals; for (i=0 ; i<numpr_globals ; i++) ((int *)pr_globals)[i] = LittleLong (((int *)pr_globals)[i]); SafeWrite (h, pr_globals, numpr_globals*4); i = (int)lseek(h, 0, SEEK_CUR); if (summary) summary_print ("%6i TOTAL SIZE\n", i); size = (i+16)&(~15); progs.entityfields = pr.size_fields; progs.version = PROG_VERSION; progs.crc = crc; if (summary) { summary_print("%6i Progheader CRC ", crc); if (crc == NQ_PROGHEADER_CRC) summary_print("( Quake )\n"); else if (crc == QW_PROGHEADER_CRC) summary_print("(Quake World)\n"); else summary_print("( UNKNOWN )\n"); } // byte swap the header and write it out for (i=0 ; i<sizeof(progs)/4 ; i++) ((int *)&progs)[i] = LittleLong ( ((int *)&progs)[i] ); lseek (h, 0, SEEK_SET); SafeWrite (h, &progs, sizeof(progs)); // look for progs if ((def = PR_GetDef(&type_entity, "progs", NULL, false, 0, 0))) { lseek(h, progs.ofs_globals + 4 * def->ofs, SEEK_SET); i = - (size + 112); SafeWrite (h, &i, 4); } for (def = pr.def_head.next ; def ; def = def->next) { if (def->type->arraysize) { lseek(h, progs.ofs_globals + 4 * def->ofs, SEEK_SET); i = (-(size + 112)) + progs.ofs_globals + 4 * (def->arraystart); //printf("filled in %s with %i\n", def->name, def->arraystart); SafeWrite (h, &i, 4); } } if (summary) { summary_print ("%6i precache_sounds(MAX: %6i)\n", numsounds, MAX_SOUNDS); summary_print ("%6i precache_models(MAX: %6i)\n", nummodels, MAX_MODELS); } close (h); if (summary) { if (pr_optimize_eliminate_temps || pr_optimize_shorten_ifs || pr_optimize_nonvec_parms || pr_optimize_constant_names || pr_optimize_defs || pr_optimize_hash_strings || pr_optimize_locals || pr_optimize_function_names || pr_optimize_filenames || pr_optimize_unreferenced || pr_optimize_logicops || pr_optimize_recycle || pr_optimize_constant_arithmetic) { summary_print("----------- Optimization Summary -----------\n"); if (pr_optimize_eliminate_temps) summary_print("%d stores shortened\n", num_stores_shortened); if (pr_optimize_shorten_ifs) summary_print("%d ifs shortened\n", num_ifs_shortened); if (pr_optimize_nonvec_parms) summary_print("%d non-vector parms\n", num_nonvec_parms); if (pr_optimize_constant_names) summary_print("%d bytes of constant defs/names eliminated\n", num_constant_names); if (pr_optimize_defs) summary_print("%d duplicate defs eliminated\n", num_defs); if (pr_optimize_hash_strings) summary_print("%d bytes of duplicate strings eliminated\n", num_strings); if (pr_optimize_locals) summary_print("%d bytes of immediate and local names eliminated\n", num_locals_saved); if (pr_optimize_function_names) summary_print("%d bytes of function names eliminated\n", num_funcs_saved); if (pr_optimize_filenames) summary_print("%d bytes of filenames eliminated\n", num_files_saved); if (pr_optimize_unreferenced) summary_print("%d unreferenced global defs eliminated\n", num_unreferenced); if (pr_optimize_logicops) summary_print("%d logic jumps added\n", num_logic_jumps); if (pr_optimize_recycle) summary_print("%d temporary globals recycled\n", num_recycled); if (pr_optimize_constant_arithmetic) summary_print("%d constant arithmetic statements eliminated\n", num_constant_ops_saved); } } }
int STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, locale_t l) { struct __locale_data *current = l->__locales[LC_COLLATE]; uint_fast32_t nrules = current->values[_NL_ITEM_INDEX (_NL_COLLATE_NRULES)].word; /* We don't assign the following values right away since it might be unnecessary in case there are no rules. */ const unsigned char *rulesets; const int32_t *table; const USTRING_TYPE *weights; const USTRING_TYPE *extra; const int32_t *indirect; if (nrules == 0) return STRCMP (s1, s2); /* Catch empty strings. */ if (__glibc_unlikely (*s1 == '\0') || __glibc_unlikely (*s2 == '\0')) return (*s1 != '\0') - (*s2 != '\0'); rulesets = (const unsigned char *) current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULESETS)].string; table = (const int32_t *) current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_TABLE,SUFFIX))].string; weights = (const USTRING_TYPE *) current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_WEIGHT,SUFFIX))].string; extra = (const USTRING_TYPE *) current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_EXTRA,SUFFIX))].string; indirect = (const int32_t *) current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_INDIRECT,SUFFIX))].string; assert (((uintptr_t) table) % __alignof__ (table[0]) == 0); assert (((uintptr_t) weights) % __alignof__ (weights[0]) == 0); assert (((uintptr_t) extra) % __alignof__ (extra[0]) == 0); assert (((uintptr_t) indirect) % __alignof__ (indirect[0]) == 0); int result = 0, rule = 0; coll_seq seq1, seq2; seq1.len = 0; seq1.idxmax = 0; seq1.rule = 0; seq2.len = 0; seq2.idxmax = 0; for (int pass = 0; pass < nrules; ++pass) { seq1.idxcnt = 0; seq1.idx = 0; seq2.idx = 0; seq1.backw_stop = ~0ul; seq1.backw = ~0ul; seq2.idxcnt = 0; seq2.backw_stop = ~0ul; seq2.backw = ~0ul; /* We need the elements of the strings as unsigned values since they are used as indices. */ seq1.us = (const USTRING_TYPE *) s1; seq2.us = (const USTRING_TYPE *) s2; /* We assume that if a rule has defined `position' in one section this is true for all of them. Please note that the localedef programs makes sure that `position' is not used at the first level. */ int position = rulesets[rule * nrules + pass] & sort_position; while (1) { get_next_seq (&seq1, nrules, rulesets, weights, table, extra, indirect, pass); get_next_seq (&seq2, nrules, rulesets, weights, table, extra, indirect, pass); /* See whether any or both strings are empty. */ if (seq1.len == 0 || seq2.len == 0) { if (seq1.len == seq2.len) { /* Both strings ended and are equal at this level. Do a byte-level comparison to ensure that we don't waste time going through multiple passes for totally equal strings before proceeding to subsequent passes. */ if (pass == 0 && STRCMP (s1, s2) == 0) return result; else break; } /* This means one string is shorter than the other. Find out which one and return an appropriate value. */ return seq1.len == 0 ? -1 : 1; } result = do_compare (&seq1, &seq2, position, weights); if (result != 0) return result; } rule = seq1.rule; } return result; }
/* ==================================================================== Get/delete names of all themes found in themes directory. ==================================================================== */ void theme_get_list() { int i; int default_theme_count = 4; char *default_theme_names[] = { "AbsoluteB", "Oz", "Moiree", "Classic" }; char name[64]; char dir[256]; DIR *hdir = 0; struct dirent *entry = 0; struct stat estat; List *list = 0; /* auxilary list */ list = list_create( LIST_NO_AUTO_DELETE, LIST_NO_CALLBACK ); /* install theme directory */ snprintf( dir, sizeof(dir) - 1, "%s/gfx", SRC_DIR ); if ( ( hdir = opendir( dir ) ) != 0 ) { while ( ( entry = readdir( hdir ) ) ) { if ( entry->d_name[0] == '.' ) continue; /* full path */ sprintf( theme_path, "%s/%s", dir, entry->d_name ); stat( theme_path, &estat ); if ( S_ISDIR( estat.st_mode ) ) { /* ignore entry if it is a default theme */ for ( i = 0; i < default_theme_count; i++ ) if ( STRCMP( default_theme_names[i], entry->d_name ) ) { i = -1; break; } if ( i == -1 ) continue; /* store it otherwise */ sprintf( name, "%s", entry->d_name ); list_add( list, strdup( name ) ); } } closedir( hdir ); } /* home theme directory */ snprintf( dir, sizeof(dir)-1, "%s/%s/lbreakout2-themes", (getenv( "HOME" )?getenv( "HOME" ):"."), CONFIG_DIR_NAME ); if ( ( hdir = opendir( dir ) ) != 0 ) { while ( ( entry = readdir( hdir ) ) ) { if ( entry->d_name[0] == '.' ) continue; /* full path */ sprintf( theme_path, "%s/%s", dir, entry->d_name ); stat( theme_path, &estat ); if ( S_ISDIR( estat.st_mode ) ) { sprintf( name, "~%s", entry->d_name ); list_add( list, strdup( name ) ); } } closedir( hdir ); } /* create static list. the default themes are the first four entries in the order at the beginning of this function. */ theme_count = list->count + default_theme_count; theme_names = calloc( theme_count, sizeof( char* ) ); for ( i = 0; i < default_theme_count; i++ ) theme_names[i] = strdup( default_theme_names[i] ); for ( i = 0; i < list->count; i++ ) { theme_names[i + default_theme_count] = list_get( list, i ); } list_delete( list ); /* if config's theme count is not equal reset the theme_id to 0 */ if ( theme_count != config.theme_count ) { config.theme_count = theme_count; config.theme_id = 0; } }
/*---------------------------------------------------------- * * func name: check_upgrade_configfile() * function : 分析版本配置文件.检查是否需要更新. * calllist : * * * calledlist: * input : * output : * parameter: line sver * sfile model * return : NULL 失败 * 成功 版本信息的sw_version的地址 * * * * notice : 使用前get_system_version_info()必需先调用成功. *--------------------------------------------------------*/ static int check_config_version(char *line, char **sver, char **sfile, const char *model,const char* swversion) { int i; char *sitems[] = {NULL, NULL, NULL, NULL,NULL}; /* model,softversion, version, file */ i = 0; char *token = get_new_line(&line, ";"); while(token) { sitems[i++] = token; if(i == 3) break; token = get_new_line(&line, ";"); } if(i != 3) { //not enough field, return 0 return 0; } //split the STB model version //1=35001-01001 char *s = sitems[0]; token = get_new_line(&s, "="); if(token == 0) { //not follow the format return 0; } //check with the ver in bootloader /* CHUNK_HEADER blk_header; unsigned long id = 0; sto_chunk_goto(&id, 0, 1); sto_get_chunk_header(id, &blk_header); */ //libc_printf("STB module = %s\n",s); //libc_printf("updata System softversion = %s\n",sitems[1]); //libc_printf("updataversion = %s, %d\n", sitems[2], calcheck_version(sitems[2])); //libc_printf("file = %s\n", sitems[3]); //libc_printf("System bootload version = %s\n", model); //libc_printf("System soft version = %s\n", swversion); if(STRCMP(s, (char *)model) != 0) { //not for the model return 0; } if(STRCMP(get_svn_version(sitems[1]),get_svn_version((char *)swversion)) <= 0) { //have no new version. return 0; } if(sver) *sver = sitems[1]; if(sfile) *sfile = sitems[2]; return 1; }
/* * opts_set -- * Change the values of one or more options. * * PUBLIC: int opts_set __P((SCR *, ARGS *[], char *)); */ int opts_set(SCR *sp, ARGS **argv, const char *usage) { enum optdisp disp; enum nresult nret; OPTLIST const *op; OPTION *spo; u_long isset, turnoff, value; int ch, equals, nf, nf2, offset, qmark, rval; CHAR_T *endp, *name, *p, *sep; char *p2, *t2; const char *np; size_t nlen; disp = NO_DISPLAY; for (rval = 0; argv[0]->len != 0; ++argv) { /* * The historic vi dumped the options for each occurrence of * "all" in the set list. Puhleeze. */ if (!STRCMP(argv[0]->bp, L("all"))) { disp = ALL_DISPLAY; continue; } /* Find equals sign or question mark. */ for (sep = NULL, equals = qmark = 0, p = name = argv[0]->bp; (ch = *p) != '\0'; ++p) if (ch == '=' || ch == '?') { if (p == name) { if (usage != NULL) msgq(sp, M_ERR, "032|Usage: %s", usage); return (1); } sep = p; if (ch == '=') equals = 1; else qmark = 1; break; } turnoff = 0; op = NULL; if (sep != NULL) *sep++ = '\0'; /* Search for the name, then name without any leading "no". */ if ((op = opts_search(name)) == NULL && name[0] == L('n') && name[1] == L('o')) { turnoff = 1; name += 2; op = opts_search(name); } if (op == NULL) { opts_nomatch(sp, name); rval = 1; continue; } /* Find current option values. */ offset = op - optlist; spo = sp->opts + offset; /* * !!! * Historically, the question mark could be a separate * argument. */ if (!equals && !qmark && argv[1]->len == 1 && argv[1]->bp[0] == '?') { ++argv; qmark = 1; } /* Set name, value. */ switch (op->type) { case OPT_0BOOL: case OPT_1BOOL: /* Some options may not be reset. */ if (F_ISSET(op, OPT_NOUNSET) && turnoff) { msgq_wstr(sp, M_ERR, name, "291|set: the %s option may not be turned off"); rval = 1; break; } /* Some options may not be set. */ if (F_ISSET(op, OPT_NOSET) && !turnoff) { msgq_wstr(sp, M_ERR, name, "313|set: the %s option may never be turned on"); rval = 1; break; } if (equals) { msgq_wstr(sp, M_ERR, name, "034|set: [no]%s option doesn't take a value"); rval = 1; break; } if (qmark) { if (!disp) disp = SELECT_DISPLAY; F_SET(spo, OPT_SELECTED); break; } /* * Do nothing if the value is unchanged, the underlying * functions can be expensive. */ isset = !turnoff; if (!F_ISSET(op, OPT_ALWAYS)) { if (isset) { if (O_ISSET(sp, offset)) break; } else if (!O_ISSET(sp, offset)) break; } /* Report to subsystems. */ if ((op->func != NULL && op->func(sp, spo, NULL, &isset)) || ex_optchange(sp, offset, NULL, &isset) || v_optchange(sp, offset, NULL, &isset) || sp->gp->scr_optchange(sp, offset, NULL, &isset)) { rval = 1; break; } /* Set the value. */ if (isset) O_SET(sp, offset); else O_CLR(sp, offset); break; case OPT_NUM: if (turnoff) { msgq_wstr(sp, M_ERR, name, "035|set: %s option isn't a boolean"); rval = 1; break; } if (qmark || !equals) { if (!disp) disp = SELECT_DISPLAY; F_SET(spo, OPT_SELECTED); break; } if (!ISDIGIT((UCHAR_T)sep[0])) goto badnum; if ((nret = nget_uslong(sp, &value, sep, &endp, 10)) != NUM_OK) { INT2CHAR(sp, name, STRLEN(name) + 1, np, nlen); p2 = msg_print(sp, np, &nf); INT2CHAR(sp, sep, STRLEN(sep) + 1, np, nlen); t2 = msg_print(sp, np, &nf2); switch (nret) { case NUM_ERR: msgq(sp, M_SYSERR, "036|set: %s option: %s", p2, t2); break; case NUM_OVER: msgq(sp, M_ERR, "037|set: %s option: %s: value overflow", p2, t2); break; case NUM_OK: case NUM_UNDER: abort(); } if (nf) FREE_SPACE(sp, p2, 0); if (nf2) FREE_SPACE(sp, t2, 0); rval = 1; break; } if (*endp && !ISBLANK(*endp)) { badnum: INT2CHAR(sp, name, STRLEN(name) + 1, np, nlen); p2 = msg_print(sp, np, &nf); INT2CHAR(sp, sep, STRLEN(sep) + 1, np, nlen); t2 = msg_print(sp, np, &nf2); msgq(sp, M_ERR, "038|set: %s option: %s is an illegal number", p2, t2); if (nf) FREE_SPACE(sp, p2, 0); if (nf2) FREE_SPACE(sp, t2, 0); rval = 1; break; } /* Some options may never be set to zero. */ if (F_ISSET(op, OPT_NOZERO) && value == 0) { msgq_wstr(sp, M_ERR, name, "314|set: the %s option may never be set to 0"); rval = 1; break; } /* * Do nothing if the value is unchanged, the underlying * functions can be expensive. */ if (!F_ISSET(op, OPT_ALWAYS) && O_VAL(sp, offset) == value) break; /* Report to subsystems. */ INT2CHAR(sp, sep, STRLEN(sep) + 1, np, nlen); if ((op->func != NULL && op->func(sp, spo, np, &value)) || ex_optchange(sp, offset, np, &value) || v_optchange(sp, offset, np, &value) || sp->gp->scr_optchange(sp, offset, np, &value)) { rval = 1; break; } /* Set the value. */ if (o_set(sp, offset, 0, NULL, value)) rval = 1; break; case OPT_STR: if (turnoff) { msgq_wstr(sp, M_ERR, name, "039|set: %s option isn't a boolean"); rval = 1; break; } if (qmark || !equals) { if (!disp) disp = SELECT_DISPLAY; F_SET(spo, OPT_SELECTED); break; } /* Check for strings that must have even length */ if (F_ISSET(op, OPT_PAIRS) && STRLEN(sep) & 1) { msgq_wstr(sp, M_ERR, name, "047|set: the %s option must be in two character groups"); rval = 1; break; } /* * Do nothing if the value is unchanged, the underlying * functions can be expensive. */ INT2CHAR(sp, sep, STRLEN(sep) + 1, np, nlen); if (!F_ISSET(op, OPT_ALWAYS) && O_STR(sp, offset) != NULL && !strcmp(O_STR(sp, offset), np)) break; /* Report to subsystems. */ if ((op->func != NULL && op->func(sp, spo, np, NULL)) || ex_optchange(sp, offset, np, NULL) || v_optchange(sp, offset, np, NULL) || sp->gp->scr_optchange(sp, offset, np, NULL)) { rval = 1; break; } /* Set the value. */ if (o_set(sp, offset, OS_STRDUP, np, 0)) rval = 1; break; default: abort(); } } if (disp != NO_DISPLAY) opts_dump(sp, disp); return (rval); }
fsal_status_t LUSTREFSAL_load_FSAL_parameter_from_conf(config_file_t in_config, fsal_parameter_t * out_parameter) { int err; int var_max, var_index; char *key_name; char *key_value; config_item_t block; int DebugLevel = -1; char *LogFile = NULL; block = config_FindItemByName(in_config, CONF_LABEL_FSAL); /* cannot read item */ if(block == NULL) { LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Cannot read item \"%s\" from configuration file", CONF_LABEL_FSAL); ReturnCode(ERR_FSAL_NOENT, 0); } else if(config_ItemType(block) != CONFIG_ITEM_BLOCK) { LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Item \"%s\" is expected to be a block", CONF_LABEL_FSAL); ReturnCode(ERR_FSAL_INVAL, 0); } /* read variable for fsal init */ var_max = config_GetNbItems(block); for(var_index = 0; var_index < var_max; var_index++) { config_item_t item; item = config_GetItemByIndex(block, var_index); err = config_GetKeyValue(item, &key_name, &key_value); if(err) { LogCrit(COMPONENT_FSAL, "FSAL LOAD PARAMETER: ERROR reading key[%d] from section \"%s\" of configuration file.", var_index, CONF_LABEL_FSAL); ReturnCode(ERR_FSAL_SERVERFAULT, err); } if(!STRCMP(key_name, "DebugLevel")) { DebugLevel = ReturnLevelAscii(key_value); if(DebugLevel == -1) { LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: ERROR: Invalid debug level name: \"%s\".", key_value); ReturnCode(ERR_FSAL_INVAL, -1); } } else if(!STRCMP(key_name, "LogFile")) { LogFile = key_value; } else if(!STRCMP(key_name, "Max_FS_calls")) { int maxcalls = s_read_int(key_value); if(maxcalls < 0) { LogCrit(COMPONENT_FSAL, "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: null or positive integer expected.", key_name); ReturnCode(ERR_FSAL_INVAL, 0); } out_parameter->fsal_info.max_fs_calls = (unsigned int)maxcalls; } else { LogCrit(COMPONENT_FSAL, "FSAL LOAD PARAMETER: ERROR: Unknown or unsettable key: %s (item %s)", key_name, CONF_LABEL_FSAL); ReturnCode(ERR_FSAL_INVAL, 0); } } /* init logging */ if(LogFile) SetComponentLogFile(COMPONENT_FSAL, LogFile); if(DebugLevel != -1) SetComponentLogLevel(COMPONENT_FSAL, DebugLevel); ReturnCode(ERR_FSAL_NO_ERROR, 0); } /* FSAL_load_FSAL_parameter_from_conf */
/* Initialize the syslogging */ void init_syslog() { char *request ="/config_ndpmon/syslog_facility/text()"; char *value; int facility = -1; xmlXPathObjectPtr xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt); value = (char *)xmlobject->nodesetval->nodeTab[0]->content; strncpy(syslog_facility,(char *)xmlobject->nodesetval->nodeTab[0]->content, SYSLOG_FACILITY_SIZE); if( !STRCMP(value,"LOG_LOCAL0") ) { facility = LOG_LOCAL0; } else if( !STRCMP(value,"LOG_LOCAL0") ) { facility = LOG_LOCAL0; } else if( !STRCMP(value,"LOG_LOCAL1") ) { facility = LOG_LOCAL1; } else if( !STRCMP(value,"LOG_LOCAL2") ) { facility = LOG_LOCAL2; } else if( !STRCMP(value,"LOG_LOCAL3") ) { facility = LOG_LOCAL3; } else if( !STRCMP(value,"LOG_LOCAL4") ) { facility = LOG_LOCAL4; } else if( !STRCMP(value,"LOG_LOCAL5") ) { facility = LOG_LOCAL5; } else if( !STRCMP(value,"LOG_LOCAL6") ) { facility = LOG_LOCAL6; } else if( !STRCMP(value,"LOG_LOCAL7") ) { facility = LOG_LOCAL7; } else if( !STRCMP(value,"LOG_USER") ) { facility = LOG_USER; } else if( !STRCMP(value,"LOG_MAIL") ) { facility = LOG_MAIL; } else if( !STRCMP(value,"LOG_DAEMON") ) { facility = LOG_DAEMON; } else if( !STRCMP(value,"LOG_AUTH") ) { facility = LOG_AUTH; } else if( !STRCMP(value,"LOG_SYSLOG") ) { facility = LOG_SYSLOG; } else if( !STRCMP(value,"LOG_LPR") ) { facility = LOG_LPR; } else if( !STRCMP(value,"LOG_NEWS") ) { facility = LOG_NEWS; } else if( !STRCMP(value,"LOG_UUCP") ) { facility = LOG_UUCP; } else if( !STRCMP(value,"LOG_CRON") ) { facility = LOG_CRON; } else if( !STRCMP(value,"LOG_AUTHPRIV") ) { facility = LOG_AUTHPRIV; } else if( !STRCMP(value,"LOG_FTP") ) { facility = LOG_FTP; } if (facility == -1) return; openlog ("NDPMon", LOG_NDELAY|LOG_CONS|LOG_PID, facility); syslog (LOG_NOTICE, "Program started by User %d", getuid ()); xmlXPathFreeObject (xmlobject); return; }
fsal_status_t LUSTREFSAL_load_FS_common_parameter_from_conf(config_file_t in_config, fsal_parameter_t * out_parameter) { int err; int var_max, var_index; char *key_name; char *key_value; config_item_t block; block = config_FindItemByName(in_config, CONF_LABEL_FS_COMMON); /* cannot read item */ if(block == NULL) { LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Cannot read item \"%s\" from configuration file", CONF_LABEL_FS_COMMON); ReturnCode(ERR_FSAL_NOENT, 0); } else if(config_ItemType(block) != CONFIG_ITEM_BLOCK) { LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Item \"%s\" is expected to be a block", CONF_LABEL_FS_COMMON); ReturnCode(ERR_FSAL_INVAL, 0); } /* configurable common info for filesystem are: link_support # hardlink support symlink_support # symlinks support cansettime # Is it possible to change file times maxread # Max read size from FS maxwrite # Max write size to FS umask auth_exportpath_xdev xattr_access_rights */ var_max = config_GetNbItems(block); for(var_index = 0; var_index < var_max; var_index++) { config_item_t item; item = config_GetItemByIndex(block, var_index); err = config_GetKeyValue(item, &key_name, &key_value); if(err) { LogCrit(COMPONENT_FSAL, "FSAL LOAD PARAMETER: ERROR reading key[%d] from section \"%s\" of configuration file.", var_index, CONF_LABEL_FS_COMMON); ReturnCode(ERR_FSAL_SERVERFAULT, err); } /* does the variable exists ? */ if(!STRCMP(key_name, "link_support")) { int bool = StrToBoolean(key_value); if(bool == -1) { LogCrit(COMPONENT_FSAL, "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: 0 or 1 expected.", key_name); ReturnCode(ERR_FSAL_INVAL, 0); } /* if set to false, force value to false. * else keep fs default. */ FSAL_SET_INIT_INFO(out_parameter->fs_common_info, link_support, FSAL_INIT_MAX_LIMIT, bool); } else if(!STRCMP(key_name, "symlink_support"))
void parse_routers() { xmlDoc *doc = NULL; xmlNode *root_element = NULL; xmlNode *current = NULL; char* c; /*parse the file and get the DOM */ doc = xmlReadFile(config_path, NULL, 0); /*Get the root element node */ root_element = xmlDocGetRootElement(doc); current = root_element->children; request ="/config_ndpmon/actions_low_pri/sendmail/text()"; xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt); if ((xmlobject->nodesetval!=NULL) || (strcmp("1", (char*)xmlobject->nodesetval->nodeTab[0]->content)!=0)) action_low_pri.sendmail=0; else action_low_pri.sendmail=1; xmlXPathFreeObject (xmlobject); while(current != NULL) { if (current->type == XML_ELEMENT_NODE) { if( !STRCMP(current->name,"routers") ) { xmlNode *router = current->children; while(router != NULL) { if (router->type == XML_ELEMENT_NODE) { if( !STRCMP(router->name,"router") ) { struct ether_addr mac; struct in6_addr lla; uint8_t param_curhoplimit=0; uint8_t param_flags_reserved=0; uint16_t param_router_lifetime=0; uint32_t param_reachable_timer=0; uint32_t param_retrans_timer=0; xmlNode *param = router->children; while(param != NULL) { if (param->type == XML_ELEMENT_NODE) { if( !STRCMP(param->name,"mac") ) { memcpy(&mac,ether_aton((char *)XML_GET_CONTENT(param->children)),sizeof(struct ether_addr)); } else if( !STRCMP(param->name,"lla") ) { inet_pton(AF_INET6,(char *)XML_GET_CONTENT(param->children), &lla); } else if( !STRCMP(param->name,"param_curhoplimit") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_curhoplimit = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_flags_reserved") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_flags_reserved = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_router_lifetime") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_router_lifetime = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_reachable_timer") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_reachable_timer = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_retrans_timer") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_retrans_timer = atoi(text!=NULL?text:"0"); add_router(&routers, &mac, &lla, param_curhoplimit, param_flags_reserved, param_router_lifetime, param_reachable_timer, param_retrans_timer); } else if( !STRCMP(param->name,"addresses") ) { xmlNode *address = param->children; while(address != NULL) { if (address->type == XML_ELEMENT_NODE) { if( !STRCMP(address->name,"address") ) { struct in6_addr addr; inet_pton(AF_INET6,(char *)XML_GET_CONTENT(address->children), &addr); add_router_address(&routers, mac, addr); } } address = address->next; } } else if( !STRCMP(param->name,"prefixes") ) { xmlNode *prefix = param->children; while(prefix != NULL) { if (prefix->type == XML_ELEMENT_NODE) { if( !STRCMP(prefix->name,"prefix") ) { struct in6_addr addr; int mask=0; char buffer[INET6_ADDRSTRLEN]; struct _xmlAttr *attr = prefix->properties; while(attr != NULL) { if (attr->type == XML_ATTRIBUTE_NODE) { if( !STRCMP(attr->name,"mask") ) { c=(char *)XML_GET_CONTENT(attr->children); mask = atoi(c); /* mask = atoi((char *)XML_GET_CONTENT(attr->children)); */ } } attr = attr->next; } c=(char *)XML_GET_CONTENT(prefix->children); strncpy(buffer,c, INET6_ADDRSTRLEN); /* strcpy(buffer,(char *)XML_GET_CONTENT(prefix->children)); */ inet_pton(AF_INET6,buffer, &addr); add_prefix(&routers, lla, mac, addr,mask); } } prefix = prefix->next; } } } param = param->next; } } } router = router->next; } } } current = current->next; } xmlFreeDoc(doc); return; }
static void win_miscset_save_setting(void) { MULTISEL *msel; SYSTEM_DATA* sys_data; UINT32 val; sys_data = sys_data_get(); #ifndef NEW_DEMO_FRAME struct nim_lnb_info lnb_info; for(i=0;i<2;i++) { lib_nimg_get_lnb_info(i+1,&lnb_info); if(LNB_POWER_OFF == sys_data->bLNB_power) lnb_info.lnb_power_off = 1; else lnb_info.lnb_power_off = 0; lib_nimg_set_lnb_info(i+1,&lnb_info); } #else struct nim_config lnb_info; struct nim_device *nim; UINT16 i; for(i=0;i<2;i++) { nim = (struct nim_device *)dev_get_by_id(HLD_DEV_TYPE_NIM, i); dev_get_nim_config(nim,FRONTEND_TYPE,&lnb_info); if(LNB_POWER_OFF == sys_data->bLNB_power) lnb_info.antenna.antenna_enable = /*0*/1; //Seiya fix BUG37540: else lnb_info.antenna.antenna_enable = 1; dev_set_nim_config(nim, FRONTEND_TYPE, &lnb_info); } #endif msel =&miscset_sel1; val = OSD_GetMultiselSel(msel); sys_data->chan_sw = val; msel =&miscset_sel2; val = OSD_GetMultiselSel(msel); sys_data->chchgvideo_type = val; #ifdef CHANCHG_VIDEOTYPE_SUPPORT #ifndef NEW_DEMO_FRAME UIChChgSetVideoType(sys_data->chchgvideo_type); #endif #endif msel =&miscset_sel3; val = OSD_GetMultiselSel(msel); sys_data->install_beep = val; msel =&miscset_sel4; val = OSD_GetMultiselSel(msel); sys_data->auto_standby_en= val; #ifdef ORDER_GZ1207009 msel =&miscset_sel6; val = OSD_GetMultiselSel(msel); sys_data->standbymode= val; #endif #ifdef RAM_TMS_TEST msel =&miscset_sel5; val = OSD_GetMultiselSel(msel); char rec_part[16]; char tms_part[16]; if (sys_data->ram_tms_en != val) // detach tms part { rec_part[0] = tms_part[0] = 0; pvr_get_cur_mode(rec_part, tms_part); if (tms_part[0] != 0) { if (STRCMP(rec_part, tms_part) == 0) pvr_set_disk_use(PVR_REC_ONLY_DISK, rec_part); else pvr_detach_part(tms_part, PVR_TMS_ONLY_DISK); api_pvr_adjust_tms_space(); } } if (sys_data->ram_tms_en == 0 && val == 1) // enable RAM disk timeshift { UINT32 ram_len = RAM_DISK_SIZE; UINT32 ram_addr = (void *)(RAM_DISK_ADDR & 0x0fffffff | 0x80000000); ramdisk_create((UINT32)ram_addr, ram_len); struct pvr_register_info pvr_reg_info; MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, "/mnt/rda1"); pvr_reg_info.disk_usage = PVR_TMS_ONLY_DISK; pvr_reg_info.sync = 1; pvr_reg_info.init_list = 0; pvr_reg_info.check_speed = 0; pvr_register((UINT32)&pvr_reg_info, 0); } else if (sys_data->ram_tms_en == 1 && val == 0) // disable RAM disk timeshift { ramdisk_delete(); } if (sys_data->ram_tms_en != val) { if (val == 0) // disable RAM disk timeshift, select PVR partition again { UINT8 back_saved; rec_part[0] = tms_part[0] = 0; pvr_select_part(rec_part, tms_part); if (rec_part[0] != 0 || tms_part[0] != 0) { win_compopup_init(WIN_POPUP_TYPE_SMSG); win_compopup_set_msg_ext("Init PVR partitions, please wait...", NULL, 0); win_compopup_open_ext(&back_saved); if (STRCMP(rec_part, tms_part) == 0) { pvr_change_part(rec_part, PVR_REC_AND_TMS_DISK); } else { pvr_change_part(rec_part, PVR_REC_ONLY_DISK); pvr_change_part(tms_part, PVR_TMS_ONLY_DISK); } win_compopup_smsg_restoreback(); } } struct dvr_HDD_info hdd_info; pvr_get_HDD_info(&hdd_info); api_pvr_check_level(&hdd_info); if (pvr_get_cur_mode(NULL, NULL) == PVR_DISK_INVALID) { api_pvr_clear_up_all(); } } sys_data->ram_tms_en = val; #endif sys_data_save(1); }