/*Open client connection*/ void sbuxton_open(void) { if ((fd= buxton_open(&client)) <0 ){ printf("Couldn't connect.\n"); return; } printf("Connection successful.\n"); }
int main(void) { BuxtonClient client; BuxtonKey key; struct pollfd pfd[1]; int r; int32_t gvalue = -1; int fd; if ((fd = buxton_open(&client)) < 0) { printf("couldn't connect\n"); return -1; } /* * A fully qualified key-name is being created since both group and key-name are not null. * Group: "hello", Key-name: "test", Layer: "user", DataType: INT */ key = buxton_key_create("hello", "test", "user", BUXTON_TYPE_INT32); if (!key) { return -1; } if (buxton_get_value(client, key, get_cb, &gvalue, false)) { printf("get 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; } if (gvalue >= 0) { printf("got value: %d\n", gvalue); } buxton_key_free(key); buxton_close(client); return 0; }
int main(void) { BuxtonClient client; int fd; if ((fd = buxton_open(&client)) < 0) { printf("couldn't connect\n"); return -1; } /* Manipulate data, register for notifications, ... */ buxton_close(client); return 0; }
int main(void){ BuxtonClient client; int fd;/*file descriptor*/ BuxtonKey key; struct response_info gotten; /*open client*/ if (buxton_open(&client)<0){ printf("Failed to open client.\n"); return -1; } printf("Connection successful.\n"); /*create a key*/ key=buxton_key_create("test_group","test_key_name","user",INT32); /*print group name*/ printf("group: %s \n", buxton_key_get_group(key)); /*print the key name*/ printf("key: %s \n", buxton_key_get_name(key)); /*print the layer name*/ printf("layer: %s \n", buxton_key_get_layer(key)); /*unset the value of the key*/ if (buxton_unset_value(client, key, usv_cb, NULL,true)){ printf("Unset call failed to run.\n"); } key=buxton_key_create("test_group","test_key_name","user",UINT32); /*get value*/ if(buxton_get_value(client, key, gv_cb, &gotten,true)){ printf("get_value call failed.\n"); } if(!gotten.status){ printf("No value has been set.\n"); /*create a group and set a key value*/ printf("setting value...\n"); my_set_group(client,key); my_set_key(client,key); }else{ /*print the gotten value*/ my_set_key(client,key); printf("the value is was changed from %i.\n", gotten.value); } /*free the key*/ buxton_key_free(key); /*close the client*/ buxton_close(client); }
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", BUXTON_TYPE_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; }
int main(void) { BuxtonClient client; BuxtonKey key; int32_t gvalue = -1; int fd; if ((fd = buxton_open(&client)) < 0) { printf("couldn't connect\n"); return -1; } /* * A fully qualified key-name is being created since both group and key-name are not null. * Group: "hello", Key-name: "test", Layer: "user", DataType: INT */ key = buxton_key_create("hello", "test", "user", INT32); if (!key) { return -1; } if (buxton_get_value(client, key, get_cb, &gvalue, true)) { printf("get call failed to run\n"); return -1; } if (gvalue >= 0) { printf("got value: %d\n", gvalue); } buxton_key_free(key); buxton_close(client); return 0; }
int main(void) { BuxtonClient client; BuxtonKey key; bool status = true; struct pollfd pfd[1]; int r; int fd; int repoll_count = 10; if ((fd = buxton_open(&client)) < 0) { printf("couldn't connect\n"); return -1; } key = buxton_key_create("hello", "test", NULL, INT32); if (!key) { return -1; } if (buxton_register_notification(client, key, notify_cb, &status, false)) { printf("set call failed to run\n"); return -1; } repoll: 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; } else if (r == 0) { if (repoll_count-- > 0) { goto out; } goto repoll; } if (!buxton_client_handle_response(client)) { printf("bad response from daemon\n"); return -1; } if (!status) { printf("Failed to register for notification\n"); return -1; } goto repoll; out: if (buxton_unregister_notification(client, key, NULL, NULL, true)) { printf("Unregistration of notification failed\n"); return -1; } buxton_key_free(key); buxton_close(client); return 0; }