/* Initialization of group */ void sbuxton_set_group(char *group, char *layer) { if (!_client_connection()) { errno = ENOTCONN; return; } saved_errno = errno; int status = 0; /* strcpy the name of the layer and group*/ strncpy(_layer, layer, MAX_LG_LEN-1); strncpy(_group, group, MAX_LG_LEN-1); /* In case a string is longer than MAX_LG_LEN, set the last byte to null */ _layer[MAX_LG_LEN -1] = '\0'; _group[MAX_LG_LEN -1] = '\0'; BuxtonKey g = buxton_key_create(_group, NULL, _layer, BUXTON_TYPE_STRING); buxton_debug("buxton key group = %s\n", buxton_key_get_group(g)); if (buxton_create_group(client, g, _cg_cb, &status, true) || !status) { buxton_debug("Create group call failed.\n"); errno = EBADMSG; } else { buxton_debug("Switched to group: %s, layer: %s.\n", buxton_key_get_group(g), buxton_key_get_layer(g)); errno = saved_errno; } _client_disconnect(); }
/*Initialization of group*/ void buxtond_set_group(char *group, char *layer) { client_connection(); save_errno(); if(_layer){ free(_layer); } if(_group){ free(_group); } _layer = strdup(layer); if(!_layer){ printf("Layer assignment failed. Aborting operation.\n"); return; } _group = strdup(group); if(!_group){ printf("Group assignment failed. Aborting operation.\n"); return; } BuxtonKey g = buxton_key_create(_group, NULL, _layer, STRING); int status; if (buxton_create_group(client, g, cg_cb, &status, true)){ printf("Create group call failed.\n"); } else { printf("Switched to group: %s, layer: %s.\n", buxton_key_get_group(g), buxton_key_get_layer(g)); errno = saved_errno; } buxton_key_free(g); }
/*create a buxtond side group*/ void buxtond_create_group(BuxtonKey group) { client_connection(); if (buxton_create_group(client, group, NULL, NULL, true)){ printf("Create group call failed.\n"); buxton_key_free(group); return; } /*TODO*/ //buxton_key_free(group); }
BuxtonKey buxtond_create_group2(char *group_name, char *layer) { client_connection(); BuxtonKey group = buxton_key_create(group_name, NULL, layer, STRING); if (buxton_create_group(client, group, NULL, NULL, true)){ printf("Create group call failed.\n"); buxton_key_free(group); return; } return group; /*Buxton free key? TODO*/ }
void my_set_group(BuxtonClient client, BuxtonKey key) { BuxtonKey group; /*create a group*/ group=buxton_key_create("test_group",NULL,"user",STRING); if(buxton_create_group(client,group,NULL,NULL,true)){ printf("create group call failed.\n"); buxton_key_free(group); return; } buxton_key_free(group); }