| 158 | static struct cpg_name group_name; |
| 159 | |
| 160 | int main (int argc, char *argv[]) { |
| 161 | cpg_handle_t handle; |
| 162 | fd_set read_fds; |
| 163 | int select_fd; |
| 164 | int result; |
| 165 | const char *options = "i"; |
| 166 | int opt; |
| 167 | unsigned int nodeid; |
| 168 | char *fgets_res; |
| 169 | void *buffer; |
| 170 | |
| 171 | while ( (opt = getopt(argc, argv, options)) != -1 ) { |
| 172 | switch (opt) { |
| 173 | case 'i': |
| 174 | show_ip = 1; |
| 175 | break; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | if (argc > optind) { |
| 180 | if (strlen(argv[optind]) >= CPG_MAX_NAME_LENGTH) { |
| 181 | fprintf(stderr, "Invalid name for cpg group\n"); |
| 182 | return (1); |
| 183 | } |
| 184 | |
| 185 | strcpy(group_name.value, argv[optind]); |
| 186 | group_name.length = strlen(argv[optind])+1; |
| 187 | } |
| 188 | else { |
| 189 | strcpy(group_name.value, DEFAULT_GROUP_NAME); |
| 190 | group_name.length = strlen(DEFAULT_GROUP_NAME) + 1; |
| 191 | } |
| 192 | |
| 193 | result = cpg_initialize (&handle, &callbacks); |
| 194 | if (result != CS_OK) { |
| 195 | printf ("Could not initialize Cluster Process Group API instance error %d\n", result); |
| 196 | exit (1); |
| 197 | } |
| 198 | cpg_zcb_alloc (handle, BUFFER_SIZE, &buffer); |
| 199 | cpg_zcb_free (handle, buffer); |
| 200 | cpg_zcb_alloc (handle, BUFFER_SIZE, &buffer); |
| 201 | |
| 202 | result = cpg_local_get (handle, &nodeid); |
| 203 | if (result != CS_OK) { |
| 204 | printf ("Could not get local node id\n"); |
| 205 | exit (1); |
| 206 | } |
| 207 | |
| 208 | printf ("Local node id is " CS_PRI_NODE_ID "\n", nodeid); |
| 209 | result = cpg_join(handle, &group_name); |
| 210 | if (result != CS_OK) { |
| 211 | printf ("Could not join process group, error %d\n", result); |
| 212 | exit (1); |
| 213 | } |
| 214 | |
| 215 | FD_ZERO (&read_fds); |
| 216 | cpg_fd_get(handle, &select_fd); |
| 217 | printf ("Type EXIT to finish\n"); |
nothing calls this directly
no test coverage detected