本文整理汇总了C++中read_value函数的典型用法代码示例。如果您正苦于以下问题:C++ read_value函数的具体用法?C++ read_value怎么用?C++ read_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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
}
示例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);
}
示例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;
}