'\" t .TH "BUXTON_SET_VALUE" "3" "buxton 1" "buxton_set_value" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" buxton_set_value, buxton_unset_value \- Modify values for BuxtonKeys .SH "SYNOPSIS" .nf \fB #include \fR .sp \fB int buxton_set_value(BuxtonClient \fIclient\fB, .br BuxtonKey \fIkey\fB, .br void *\fIvalue\fB, .br BuxtonCallback \fIcallback\fB, .br void *\fIdata\fB, .br bool \fIsync\fB) .sp .br int buxton_unset_value(BuxtonClient \fIclient\fB, .br BuxtonKey \fIkey\fB, .br BuxtonCallback \fIcallback\fB, .br void *\fIdata\fB, .br bool \fIsync\fB) \fR .fi .SH "DESCRIPTION" .PP These functions are used to modify values for a BuxtonKey, referenced by \fIkey\fR, on behalf of the \fIclient\fR. To set the value for a \fIkey\fR, clients should call \fBbuxton_set_value\fR(3), passing a pointer the \fIvalue\fR for the third argument\&. To unset the value for a \fIkey\fR, clients should call \fBbuxton_unset_value\fR(3)\&. Both functions accept optional callback functions to register with the daemon, referenced by the \fIcallback\fR argument; the callback function is called upon completion of the operation\&. The \fIdata\fR argument is a pointer to arbitrary userdata that is passed along to the callback function\&. Additonally, the \fIsync\fR argument controls whether the operation should be synchronous or not; if \fIsync\fR is false, the operation is asynchronous\&. .SH "CODE EXAMPLE" .PP An example for set_value: .nf .sp #define _GNU_SOURCE #include #include #include #include #include "buxton.h" void set_cb(BuxtonResponse response, void *data) { BuxtonKey key; char *name; if (buxton_response_status(response) != 0) { printf("Failed to set value\\n"); return; } key = buxton_response_key(response); name = buxton_key_get_name(key); printf("Set value for key %s\\n", name); buxton_key_free(key); free(name); } int main(void) { BuxtonClient client; BuxtonKey key; struct pollfd pfd[1]; int r; int fd; int32_t set; if ((fd = buxton_open(&client)) < 0) { printf("couldn't connect\\n"); return -1; } key = buxton_key_create("hello", "test", "user", INT32); if (!key) { return -1; } set = 10; if (buxton_set_value(client, key, &set, set_cb, NULL, false)) { printf("set call failed to run\\n"); return -1; } pfd[0].fd = fd; pfd[0].events = POLLIN; pfd[0].revents = 0; r = poll(pfd, 1, 5000); if (r <= 0) { printf("poll error\\n"); return -1; } if (!buxton_client_handle_response(client)) { printf("bad response from daemon\\n"); return -1; } buxton_key_free(key); buxton_close(client); return 0; } .fi .PP An example for unset_value: .nf .sp #define _GNU_SOURCE #include #include #include #include #include "buxton.h" void unset_cb(BuxtonResponse response, void *data) { if (buxton_response_status(response) != 0) { printf("Failed to unset value\\n"); } else { printf("Unset value\\n"); } } int main(void) { BuxtonClient client; BuxtonKey key; struct pollfd pfd[1]; int r; int fd; if ((fd = buxton_open(&client)) < 0) { printf("couldn't connect\\n"); return -1; } key = buxton_key_create("hello", "test", "user", INT32); if (!key) { return -1; } if (buxton_unset_value(client, key, unset_cb, NULL, false)) { printf("unset call failed to run\\n"); return -1; } pfd[0].fd = fd; pfd[0].events = POLLIN; pfd[0].revents = 0; r = poll(pfd, 1, 5000); if (r <= 0) { printf("poll error\\n"); return -1; } if (!buxton_client_handle_response(client)) { printf("bad response from daemon\\n"); return -1; } buxton_key_free(key); buxton_close(client); return 0; } .fi .SH "RETURN VALUE" .PP Returns 0 on success, and a non\-zero value on failure\&. .SH "COPYRIGHT" .PP Copyright 2014 Intel Corporation\&. License: Creative Commons Attribution\-ShareAlike 3.0 Unported\s-2\u[1]\d\s+2, with exception for code examples found in the \fBCODE EXAMPLE\fR section, which are licensed under the MIT license provided in the \fIdocs/LICENSE.MIT\fR file from this buxton distribution\&. .SH "SEE ALSO" .PP \fBbuxton\fR(7), \fBbuxtond\fR(8), \fBbuxton\-api\fR(7) .SH "NOTES" .IP " 1." 4 Creative Commons Attribution\-ShareAlike 3.0 Unported .RS 4 \%http://creativecommons.org/licenses/by-sa/3.0/ .RE