| 210 | |
| 211 | |
| 212 | int main (int argc, char *argv[]) { |
| 213 | const char *options = "hd:ne"; |
| 214 | int opt; |
| 215 | const char *prog_name = basename(argv[0]); |
| 216 | char delimiter = 0; |
| 217 | int escape = 1; |
| 218 | operation_t operation = OPER_FULL_OUTPUT; |
| 219 | int result; |
| 220 | |
| 221 | while ( (opt = getopt(argc, argv, options)) != -1 ) { |
| 222 | switch (opt) { |
| 223 | case 'd': |
| 224 | if (strlen (optarg) > 0) { |
| 225 | delimiter = optarg[0]; |
| 226 | } |
| 227 | break; |
| 228 | |
| 229 | case 'n': |
| 230 | operation = OPER_NAMES_ONLY; |
| 231 | break; |
| 232 | |
| 233 | case 'e': |
| 234 | escape = 0; |
| 235 | break; |
| 236 | |
| 237 | case 'h': |
| 238 | usage_do (prog_name); |
| 239 | return (EXIT_SUCCESS); |
| 240 | break; |
| 241 | |
| 242 | case '?': |
| 243 | case ':': |
| 244 | return (EXIT_FAILURE); |
| 245 | break; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | result = cpg_initialize (&cpg_handle, NULL); |
| 250 | |
| 251 | if (result != CS_OK) { |
| 252 | fprintf (stderr, "Could not initialize corosync cpg API error %d\n", result); |
| 253 | return (EXIT_FAILURE); |
| 254 | } |
| 255 | |
| 256 | result = corosync_cfg_initialize (&cfg_handle, NULL); |
| 257 | if (result != CS_OK) { |
| 258 | fprintf (stderr, "Could not initialize corosync configuration API error %d\n", result); |
| 259 | return (EXIT_FAILURE); |
| 260 | } |
| 261 | |
| 262 | switch (operation) { |
| 263 | case OPER_NAMES_ONLY: |
| 264 | result = display_groups (delimiter, escape); |
| 265 | break; |
| 266 | |
| 267 | case OPER_FULL_OUTPUT: |
| 268 | result = display_groups_with_members (delimiter, escape); |
| 269 | break; |
nothing calls this directly
no test coverage detected