本文整理汇总了C++中read_value函数的典型用法代码示例。如果您正苦于以下问题:C++ read_value函数的具体用法?C++ read_value怎么用?C++ read_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_value函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: read_key_value
/*
* read a key value pair and add it to tree
*/
static void
read_key_value(unsigned int *offset, tvbuff_t *tvb, proto_tree *etch_tree)
{
proto_tree *new_tree;
proto_tree *new_tree_bck;
proto_item *ti, *parent_ti;
gbl_have_symbol = FALSE;
parent_ti =
proto_tree_add_item(etch_tree, hf_etch_keyvalue, tvb, *offset, 1,
ENC_NA);
new_tree_bck = new_tree =
proto_item_add_subtree(parent_ti, ett_etch_keyvalue);
ti = proto_tree_add_item(new_tree, hf_etch_keyname, tvb, *offset, 0,
ENC_NA);
new_tree = proto_item_add_subtree(ti, ett_etch_key);
read_value(offset, tvb, new_tree, hf_etch_value);
/* append the symbol of the key */
if(gbl_have_symbol == TRUE){
proto_item_append_text(parent_ti, " (");
proto_item_append_text(parent_ti, "%s", wmem_strbuf_get_str(gbl_symbol_buffer));
proto_item_append_text(parent_ti, ")");
}
ti = proto_tree_add_item(new_tree_bck, hf_etch_valuename, tvb, *offset,
0, ENC_NA);
new_tree = proto_item_add_subtree(ti, ett_etch_value);
read_value(offset, tvb, new_tree, hf_etch_value);
}
开发者ID:appneta,项目名称:wireshark,代码行数:35,代码来源:packet-etch.c
示例2: read_struct
/*
* read a struct and add it to tree
*/
static void
read_struct(unsigned int *offset, tvbuff_t *tvb, proto_tree *etch_tree,
int add_type_field)
{
proto_item *ti;
proto_tree *new_tree;
int length;
int i;
ti = proto_tree_add_item(etch_tree, hf_etch_struct, tvb, *offset,
tvb_captured_length(tvb) - *offset, ENC_NA);
new_tree = proto_item_add_subtree(ti, ett_etch_struct);
if (add_type_field) {
read_type(offset, tvb, new_tree);
}
/* struct type as hash */
read_value(offset, tvb, new_tree, hf_etch_value);
/* struct length */
length = read_value(offset, tvb, new_tree, hf_etch_length);
for (i = 0; i < length; i++) {
read_key_value(offset, tvb, new_tree);
}
/* termination */
read_type(offset, tvb, new_tree);
}
开发者ID:appneta,项目名称:wireshark,代码行数:32,代码来源:packet-etch.c
示例3: read_value
void Eurotherm2000Series::get_setpoint_limits(double& min, double& max) const {
std::string answer;
read_value("LS",answer);
min=strtod(answer.c_str(),NULL);
read_value("HS",answer);
max=strtod(answer.c_str(),NULL);
}
开发者ID:BackupTheBerlios,项目名称:damaris-svn,代码行数:7,代码来源:Eurotherm-2000Series.cpp
示例4: reset_type
struct menuinfo reset_type(FILE *cfgfile, struct menuinfo stats_menu, int vehicle)
{
// function loads the options for that type of plane
char vehicle_str[15]; // for storing the vehicle heading (in the cfg file)
char vehicle_number_str[3]; // for temporarily storing the vehicle number
// open the config file
cfgfile = fopen("dogfight.cfg", "r");
// generate the vehicle heading required
strcpy(vehicle_str, "vehicle ");
fixed_str(vehicle_number_str, vehicle, 2);
strcat(vehicle_str, vehicle_number_str);
stats_menu.optionval[0] = read_value(cfgfile, '@', vehicle_str, "vehicle");
stats_menu.optionval[1] = read_value(cfgfile, '@', vehicle_str, "turn_speed");
stats_menu.optionval[2] = read_value(cfgfile, '@', vehicle_str, "acceleration");
stats_menu.optionval[3] = read_value(cfgfile, '@', vehicle_str, "min_speed");
stats_menu.optionval[4] = read_value(cfgfile, '@', vehicle_str, "max_speed");
stats_menu.optionval[5] = read_value(cfgfile, '@', vehicle_str, "num_of_shots");
stats_menu.optionval[6] = read_value(cfgfile, '@', vehicle_str, "shot_life");
stats_menu.optionval[7] = read_value(cfgfile, '@', vehicle_str, "shot_lag");
stats_menu.optionval[8] = read_value(cfgfile, '@', vehicle_str, "shot_base_speed");
stats_menu.optionval[9] = read_value(cfgfile, '@', vehicle_str, "laser_length");
fclose(cfgfile);
return(stats_menu);
}
开发者ID:puyo,项目名称:dogfight,代码行数:30,代码来源:menus.c
示例5: array_read
struct array*
array_read(char * filename)
{
int i;
FILE * h;
int num;
value value;
struct array * res;
h = fopen(filename, "r");
i = read_value(h, &num);
assert(i > 0);
res = array_alloc(num);
num = 1;
for (i = 0; i < res->capacity && num > 0; i++)
{
num = read_value(h, &value);
array_put(res, value);
}
fclose(h);
return res;
}
开发者ID:em-mo,项目名称:TDDD56,代码行数:26,代码来源:array.c
示例6: read_object
static mrb_value
read_object(MarshalContext *ctx)
{
mrb_state *mrb = ctx->mrb;
mrb_value class_path = read_value(ctx);
struct RClass *klass =
mrb_class_from_path(mrb, class_path);
mrb_value obj = mrb_obj_value(mrb_obj_alloc(mrb, MRB_TT_OBJECT, klass));
ctx->objects.add(obj);
int iv_count = read_fixnum(ctx);
int i;
for (i = 0; i < iv_count; ++i)
{
mrb_value iv_name = read_value(ctx);
mrb_value iv_value = read_value(ctx);
mrb_obj_iv_set(mrb, mrb_obj_ptr(obj),
mrb_symbol(iv_name), iv_value);
}
return obj;
}
开发者ID:cjv123,项目名称:RPG,代码行数:27,代码来源:marshal.cpp
示例7: read_value
static char *check_device(const char *name)
{
char path[PATH_MAX];
int busnum, devnum, vendor, product;
busnum = read_value(name, "busnum", "%d");
if (busnum < 0)
return NULL;
devnum = read_value(name, "devnum", "%d");
if (devnum < 0)
return NULL;
snprintf(path, sizeof(path), "/dev/bus/usb/%03u/%03u", busnum, devnum);
vendor = read_value(name, "idVendor", "%04x");
if (vendor < 0)
return NULL;
product = read_value(name, "idProduct", "%04x");
if (product < 0)
return NULL;
if (vendor != 0x0a12 || product != 0x0001)
return NULL;
return strdup(path);
}
开发者ID:AndroidXperia,项目名称:android_external_bluetooth_bluez,代码行数:28,代码来源:csr_usb.c
示例8: MouseXYZ
static bool_t MouseXYZ(GMouse* m, GMouseReading* pdr)
{
(void)m;
// No buttons
pdr->buttons = 0;
pdr->z = 0;
if (getpin_pressed(m)) {
pdr->z = 1; // Set to Z_MAX as we are pressed
aquire_bus(m);
read_value(m, CMD_X); // Dummy read - disable PenIRQ
pdr->x = read_value(m, CMD_X); // Read X-Value
read_value(m, CMD_Y); // Dummy read - disable PenIRQ
pdr->y = read_value(m, CMD_Y); // Read Y-Value
read_value(m, CMD_ENABLE_IRQ); // Enable IRQ
release_bus(m);
}
return TRUE;
}
开发者ID:danielchen76,项目名称:CarStation2,代码行数:25,代码来源:gmouse_lld_ADS7843.c
示例9: exec_opc
void exec_opc(t_proc_list **lst, t_proc_list **exec_proc, t_vm *vm)
{
if (vm->cycles != 0 && vm->cycles == (*lst)->proc->wex)
{
if (ft_codage_erase(vm->mem, (*lst)->proc) ||
ft_param_erase(vm->mem, (*lst)->proc))
{
if ((*lst)->proc->opc == 1 || (*lst)->proc->opc == 9 ||
(*lst)->proc->opc == 12 || (*lst)->proc->opc == 15)
(*lst)->proc->codage = read_value(vm->mem,
(*lst)->proc->prevpc + 1, 1);
else
(*lst)->proc->codage = read_value(vm->mem,
(*lst)->proc->prevpc + 2, 1);
reset_param(&((*lst)->proc->par_list));
(*lst)->proc->exec = 1;
(*lst)->proc->pc = (*lst)->proc->prevpc;
get_opc(lst, vm);
}
ft_exec(lst, exec_proc, vm);
(*lst)->proc->exec = 1;
reset_param(&((*lst)->proc->par_list));
(*lst)->proc->opc = 0;
(*lst)->proc->wex = 0;
(*lst)->proc->codage = 0;
}
}
开发者ID:NicolasFlores,项目名称:corewar,代码行数:27,代码来源:exec_opc.c
示例10: main
int main( int argc, char** argv )
{
// Parse args and read values
const Args args = parse(argc,argv);
const int current = read_value("actual_brightness");
const int max = read_value("max_brightness");
int newval = current;
switch (args.mode)
{
case PRINT:
std::cout<<current<<" / "<<max<<std::endl;
break;
case PLUS:
case MINUS: // args.value is negtive in this case.
newval = clamp(current + args.value, 0, max);
write_value("brightness", newval);
break;
case ABSOLUTE:
newval = clamp(args.value, 0, max);
write_value("brightness", newval);
break;
case ERROR:
print_usage();
break;
}
// Return 0 if everything went fine, and 1 if not.
return args.mode == ERROR;
}
开发者ID:louen,项目名称:config-files,代码行数:33,代码来源:brightness.cpp
示例11: sk_write
static void sk_write(const int argc, char *argv[])
{
unsigned char slave_address, reg_address, i;
unsigned short count;
char buf[MAX_BUFF_SIZE] = { 0 };
unsigned char val;
unsigned char instance = atoi(argv[1]);
/* Write command */
if (argc > 5) {
if (read_value(argv[3], &slave_address))
printf("\nSlave Adress 0x%02x\n", slave_address);
if (read_value(argv[4], ®_address))
printf("Reg Adress 0x%02x\n", reg_address);
count = 1;
for (i = 5; i < argc; i++) {
if (read_value(argv[i], &val)) {
buf[count++] = val;
printf("0x%02x ", val);
}
}
buf[0] = reg_address;
/* Register Adress */
i2c_RDWR(instance, slave_address, 0, 0, count, buf);
printf("\n");
} else {
usage();
}
}
开发者ID:Meticulus,项目名称:vendor_st-ericsson_u8500,代码行数:34,代码来源:sk-i2c.c
示例12: get_backlight
int get_backlight (char* buf, char* color) {
char val[200];
char status[4];
char *status_icon;
char *ptr;
char bl_path[45 + 10];
char bl_bright[55 + 17];
sprintf(bl_path, "/sys/class/backlight/%s_backlight", BACKLIGHT_TYPE);
sprintf(bl_bright, "%s/%s", bl_path, "max_brightness");
read_value(bl_bright, val);
int max_level = strtol(val, &ptr, 10);
sprintf(bl_bright, "%s/%s", bl_path, "actual_brightness");
read_value(bl_bright, val);
int lvl = strtol(val, &ptr, 10);
float per = ((float) lvl) / ((float) max_level);
int percent = (int) (per * 100);
status_icon = "";
sprintf(buf, "%%{F%s}%%{B%s}%s%%{F%s}%%{B%s} %s %d", COLOR_BG_BACK, color, SEP_LEFT, COLOR_FG_BACK, COLOR_BG_BACK, status_icon, percent);
return 1;
}
开发者ID:sammy8806,项目名称:statusline,代码行数:26,代码来源:statusline.c
示例13: msg_parser
void msg_parser(char *msg_req_buffer, char *msg_resp_buffer, uint32_t *msg_len)
{
msg_req_t * req;
msg_val_t ret_msg_val;
/* Store req and resp buffers into global context
* to work for current message */
g_msg_parser_ctxt->msg_req_buffer = msg_req_buffer;
g_msg_parser_ctxt->msg_resp_buffer = msg_resp_buffer;
g_msg_parser_ctxt->msg_len = msg_len;
#if 0
{
uint16_t i;
printf("Bytes : ");
for (i=0; i<sizeof(msg_req_t); i++) {
printf("%x ,", (uint8_t)msg_req_buffer[i]);
}
printf("\n");
}
#endif
req = (msg_req_t *) msg_req_buffer;
if (req->req_type==KEEP_ALIVE_REQ) {
msg_parser_resp(req->handle, req->req_type, STATUS_OK);
} else {
ret_msg_val = -1;
switch (req->req_type) {
case BYTE_READ_REQ:
ret_msg_val = read_value(req->addr, 1);
break;
case BYTE_WRITE_REQ:
write_value(req->addr, req->value, 1);
break;
case HALF_WORD_READ_REQ:
ret_msg_val = read_value(req->addr, 2);
break;
case HALF_WORD_WRITE_REQ:
write_value(req->addr, req->value, 2);
break;
case WORD_READ_REQ:
ret_msg_val = read_value(req->addr, 4);
break;
case WORD_WRITE_REQ:
write_value(req->addr, req->value, 4);
break;
default:
assert(0, ASSERT_FATAL);
}
msg_parser_resp(req->handle, req->req_type, STATUS_OK,
req->addr, ret_msg_val);
}
#if 0
{
uint16_t i;
printf("Bytes : ");
for (i=0; i<sizeof(msg_resp_t); i++) {
printf("%x ,", (uint8_t)msg_resp_buffer[i]);
}
printf("\n");
}
#endif
}
开发者ID:vipersnh,项目名称:regbank_reader,代码行数:60,代码来源:msg_parser.cpp
示例14: evaluate_formula
void evaluate_formula (int *queue, int *queue_length, struct pcp_vars *pcp)
{
register int *y = y_address;
register int lastg = pcp->lastg;
register int i;
int nmr_entries;
int *weight;
int total;
int nmr;
total = 6 * lastg + 6;
if (is_space_exhausted (total, pcp))
return;
/* fudge the value of submlg because of possible call to power */
pcp->submlg -= total;
read_value (TRUE, "Input number of components of formula: ",
&nmr_entries, 1);
weight = allocate_vector (nmr_entries, 1, FALSE);
first = allocate_vector (nmr_entries + 1, 0, FALSE);
last = allocate_vector (nmr_entries + 1, 0, FALSE);
list = allocate_vector (nmr_entries + 1, 0, FALSE);
printf ("Input weight of each component of formula: ");
for (i = 1; i < nmr_entries; ++i) {
read_value (FALSE, "", &weight[i], 1);
}
read_value (TRUE, "", &weight[i], 1);
read_value (TRUE, "Input power of individual component: ",
&power_of_entry, 1);
read_value (TRUE, "Input power of word: ", &exponent, 1);
for (i = 1; i <= nmr_entries; ++i) {
first[i] = y[pcp->clend + weight[i] - 1] + 1;
last[i] = y[pcp->clend + weight[i]];
}
/* generate the list of words; evaluate each, echelonise it
and build up the queue of redundant generators */
nmr = 0;
loop (queue, queue_length, nmr_entries, list, &nmr,
first[nmr_entries], last[nmr_entries], pcp);
/* reset value of submlg */
pcp->submlg += total;
free_vector (weight, 1);
free_vector (first, 0);
free_vector (last, 0);
free_vector (list, 0);
}
开发者ID:fingolfin,项目名称:gap-osx-binary,代码行数:56,代码来源:formula.c
示例15: get_battery
int get_battery(char* buf) {
char val[200];
char status[4];
char *status_icon;
char *ptr;
char bat_path_full[40];
char bat_path_now[40];
char bat_path_status[40];
char *bat_path_base = "/sys/class/power_supply/BAT0";
char bat_type_name[7];
char bat_path_buf[50];
sprintf(bat_path_buf, "%s/status", bat_path_base);
if(file_exists("/sys/class/power_supply/BAT0/energy_full") == 1) {
strcpy(bat_type_name, "energy");
} else {
strcpy(bat_type_name, "charge");
}
sprintf(bat_path_full, "%s/%s_full", bat_path_base, bat_type_name);
sprintf(bat_path_now, "%s/%s_now", bat_path_base, bat_type_name);
sprintf(bat_path_status, "%s/status", bat_path_base);
read_value(bat_path_full, val);
if(DEBUG) fprintf(stderr, "%s = %s\n", bat_path_full, val);
int max_level = strtol(val, &ptr, 10) / 10000;
read_value(bat_path_now, val);
if(DEBUG) fprintf(stderr, "%s = %s\n", bat_path_now, val);
int lvl = strtol(val, &ptr, 10) / 10000;
float per = ((float) lvl) / ((float) max_level);
int percent = (int) (per * 100);
read_value(bat_path_status, val);
for (int i=0; i < 3; i++) {
status[i] = val[i];
}
status[3] = '\0';
if (status[0] == 'C') {
status_icon = "";
} else {
status_icon = "";
if (percent < 80) {
status_icon = "";
} else if (percent < 50) {
status_icon = "";
} else if (percent < 30) {
status_icon = "";
}
}
sprintf(buf, "%%{F%s}%%{B%s}%s%%{F%s}%%{B%s} %s %d%%", COLOR_BG_BAT, COLOR_BG_BACK, SEP_LEFT, COLOR_FG_BAT, COLOR_BG_BAT,status_icon, percent);
return 1;
}
开发者ID:sammy8806,项目名称:statusline,代码行数:55,代码来源:statusline.c
示例16: unpack_block
void unpack_block(FILE *f, scan_desc_t *scan_desc, uint32_t index,
int32_t T[_BSIZE])
{
printdecod("Start unpack_block #%u (index = %u)\n",calls_count,index);
assert(feof(f) == 0);
huff_table_t *DC = scan_desc->table[0][index];
huff_table_t *AC = scan_desc->table[1][index];
if (DC == NULL || AC == NULL) {
printf("\n** ERREUR: Table de Huffman absente **\n");
}
assert(DC != NULL);
assert(AC != NULL);
/* decodage du coefficient DC */
uint8_t magnitude = read_symbol(f,scan_desc,DC);
int32_t offset = read_value(f,scan_desc,magnitude);
T[0] = scan_desc->pred[index] + offset;
scan_desc->pred[index] = T[0];
/* decodage des coefficients AC */
uint8_t symbol;
uint8_t nb_zero;
uint32_t i = 1;
while (i < 64) {
symbol = read_symbol(f,scan_desc,AC);
if (symbol == 0xf0) { /* ZRL */
for (uint32_t j = 0; j < 16; j++) {
T[i] = 0;
i++;
}
} else if (symbol == 0x00) { /* EOB */
while (i < 64) {
T[i] = 0;
i++;
}
} else { /* symbole normal */
magnitude = symbol % 16;
nb_zero = symbol >> 4;
printdecod("=> sym: %u mag: %u nb_zero: %u\n",symbol,
magnitude,nb_zero);
for (uint32_t j = 0; j < nb_zero; j++) {
T[i] = 0;
i++;
}
T[i] = read_value(f,scan_desc,magnitude);
i++;
}
}
printdecod("\n");
printblock(T);
calls_count++;
}
开发者ID:joffrey-bion,项目名称:jpeg-codec,代码行数:50,代码来源:unpack_block.c
示例17: get_meminfo
void get_meminfo(meminfo_t *meminfo)
{
char buffer[BUFSIZ];
if (read_file("/proc/meminfo", buffer, sizeof (buffer)) != -1) {
meminfo->total = read_value(buffer, "MemTotal:");
meminfo->free = read_value(buffer, "MemFree:");
meminfo->shared = read_value(buffer, "MemShared:");
meminfo->buffers = read_value(buffer, "Buffers:");
meminfo->cached = read_value(buffer, "Cached:");
} else {
memset(meminfo, 0, sizeof (meminfo_t));
}
}
开发者ID:bluemutedwisdom,项目名称:mini-snmpd,代码行数:14,代码来源:linux.c
示例18: process_ce_data
void process_ce_data(int col, char *input, char *output)
{
int i;
struct istruct data;
double d =
read_value("device.inp", 0, 12) + read_value("device.inp", 0, 39);
double area =
read_value("device.inp", 0, 21) * read_value("device.inp", 0, 23);
double cap = read_value("blom_bulk.inp", 0, 84) * epsilon0 * area / d;
double capq = 0.0;
double dt = 0.0;
int x = 0;
FILE *out = fopen(output, "w");
for (x = 0; x < col; x++) {
printf("loading.... %d\n", x);
inter_load_by_col(&data, input, x);
double tot = 0.0;
for (i = 1; i < data.len - 1; i++) {
//if ((data.x[i]>1e-6)&&(data.x[i]<1e-5))
{
dt = (data.x[i + 1] - data.x[i - 1]) / 2.0;
tot += data.data[i] * dt;
}
}
capq = (data.x[0] * cap) / Q; //charge on capasitor
capq /= area;
capq /= d;
tot /= area;
tot /= d;
tot /= Q;
fprintf(out, "%e %e\n", data.data[0], tot - capq);
inter_free(&data);
}
//getchar();
fclose(out);
}
开发者ID:roderickmackenzie,项目名称:opvdm,代码行数:49,代码来源:anal.c
示例19: read_line
static int read_line(Vector v){
char op[4];
char s[10];
struct Inst inst;
int res = scanf("%s %s", op, s);
if(res == EOF) return 0;
inst.op_code = read_opcode(op);
inst.x = read_value(s);
if(inst.op_code == cpy || inst.op_code == jnz){
scanf("%s", s);
inst.y = read_value(s);
}
Vector_push(v, &inst);
return 1;
}
开发者ID:Jassob,项目名称:advent_of_code_2016,代码行数:15,代码来源:day12.c
示例20: read_list
Value *
read_list(Globals *g)
{
Value *list;
Value **tail;
Value *v;
tail = &list;
while (g->buflen > 0) {
if (NULL == (v = read_value(g))) {
switch (PEEK_CHAR(g)) {
case ')':
if (tail != NULL) { /* if no last cdr yet, use nil */
*tail = NULL;
}
NEXT_CHAR(g);
return list;
break;
case '.': /* set last cdr explicitly */
NEXT_CHAR(g);
*tail = read_value(g);
if (*tail == NULL) {
/* badly formed input ??? */
ABORT(g, 13);
}
tail = NULL;
break;
default:
/* badly formed input ??? */
ABORT(g, 13);
break;
}
}
else { /* read a value, add it to the list */
if (NULL == tail) {
/* two values after a . in a list. very bad! ??? */
ABORT(g, 13);
}
*tail = ALLOC_VALUE();
(*tail)->tag = cons;
(*tail)->value.cons.car = v;
tail = &(*tail)->value.cons.cdr;
}
}
}
开发者ID:emacsmirror,项目名称:ohio-archive,代码行数:48,代码来源:lread.c
注:本文中的read_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论