2 .TH "BUXTON_GET_VALUE" "3" "buxton 1" "buxton_get_value"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
17 .\" disable justification (adjust text to left margin only)
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
23 buxton_get_value \- Get the value of a key\-name
32 int buxton_get_value(BuxtonClient \fIclient\fB,
36 BuxtonCallback \fIcallback\fB,
46 This function is used to get the value of a key\-name for
47 \fIclient\fR. The key\-name is referenced by \fIkey\fR. If the layer
48 for \fIkey\fR is NULL, buxton will traverse layers in priority order
49 searching for the key-name value, selecting the value for the first
50 key\-name found\&. If the argument is non-NULL, the operation will
51 target only that layer\&. For more information on creating a
52 BuxtonKey to pass for \fIkey\fR, see \fBbuxton_key_create\fR(3)\&.
54 To retrieve the result of the operation, clients should define a
55 callback function, referenced by the \fIcallback\fR argument; the
56 callback function is called upon completion of the operation\&. The
57 \fIdata\fR argument is a pointer to arbitrary userdata that is passed
58 along to the callback function\&. Additonally, the \fIsync\fR
59 argument controls whether the operation should be synchronous or not;
60 if \fIsync\fR is false, the operation is asynchronous\&.
73 void get_cb(BuxtonResponse response, void *data)
75 int32_t* ret = (int32_t*)data;
77 if (buxton_response_status(response) != 0) {
78 printf("Failed to get value\\n");
82 *ret = *(int32_t*)buxton_response_value(response);
94 if ((fd = buxton_open(&client)) < 0) {
95 printf("couldn't connect\\n");
99 key = buxton_key_create("hello", "test", "user", INT32);
104 if (buxton_get_value(client, key, get_cb,
106 printf("get call failed to run\\n");
111 pfd[0].events = POLLIN;
113 r = poll(pfd, 1, 5000);
116 printf("poll error\\n");
120 if (!buxton_client_handle_response(client)) {
121 printf("bad response from daemon\\n");
126 printf("got value: %d\\n", gvalue);
129 buxton_key_free(key);
130 buxton_close(client);
137 Returns 0 on success, and a non\-zero value on failure\&.
141 Copyright 2014 Intel Corporation\&. License: Creative Commons
142 Attribution\-ShareAlike 3.0 Unported\s-2\u[1]\d\s+2, with exception
143 for code examples found in the \fBCODE EXAMPLE\fR section, which are
144 licensed under the MIT license provided in the \fIdocs/LICENSE.MIT\fR
145 file from this buxton distribution\&.
155 Creative Commons Attribution\-ShareAlike 3.0 Unported
157 \%http://creativecommons.org/licenses/by-sa/3.0/