1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
4 * Copyright (c) 2015-2017 Intel, Inc. All rights reserved.
5 * Copyright (c) 2015 Research Organization for Information Science
6 * and Technology (RIST). All rights reserved.
7 * $COPYRIGHT$
8 *
9 * Additional copyrights may follow
10 *
11 * $HEADER$
12 */
13
14 /**
15 * @file
16 *
17 * This interface is for regex support. This is a multi-select framework.
18 *
19 * Available plugins may be defined at runtime via the typical MCA parameter
20 * syntax.
21 */
22
23 #ifndef PMIX_PREG_H
24 #define PMIX_PREG_H
25
26 #include <src/include/pmix_config.h>
27
28 #include "src/mca/mca.h"
29 #include "src/mca/base/pmix_mca_base_var.h"
30 #include "src/mca/base/pmix_mca_base_framework.h"
31
32 #include "src/mca/preg/preg_types.h"
33
34 BEGIN_C_DECLS
35
36 /****** MODULE DEFINITION ******/
37
38 #define PMIX_MAX_NODE_PREFIX 50
39
40 /* given a semicolon-separated list of input values, generate
41 * a regex that can be passed down to a client for parsing.
42 * The caller is responsible for free'ing the resulting
43 * string
44 *
45 * If values have leading zero's, then that is preserved.
46 * Example:
47 *
48 * Input: odin009;odin010;odin011;odin012;odin017;odin018;thor176
49 *
50 * Output:
51 * "foo:odin[009-012,017-018],thor176"
52 *
53 * Note that the "foo" at the beginning of the regex indicates
54 * that the "foo" regex component is to be used to parse the
55 * provided regex.
56 */
57 typedef pmix_status_t (*pmix_preg_base_module_generate_node_regex_fn_t)(const char *input,
58 char **regex);
59
60 /* The input is expected to consist of a comma-separated list
61 * of ranges. Thus, an input of:
62 * "1-4;2-5;8,10,11,12;6,7,9"
63 * would generate a regex of
64 * "[pmix:2x(3);8,10-12;6-7,9]"
65 *
66 * Note that the "pmix" at the beginning of each regex indicates
67 * that the PMIx native parser is to be used by the client for
68 * parsing the provided regex. Other parsers may be supported - see
69 * the pmix_client.h header for a list.
70 */
71 typedef pmix_status_t (*pmix_preg_base_module_generate_ppn_fn_t)(const char *input,
72 char **ppn);
73
74
75 typedef pmix_status_t (*pmix_preg_base_module_parse_nodes_fn_t)(const char *regexp,
76 char ***names);
77
78 typedef pmix_status_t (*pmix_preg_base_module_parse_procs_fn_t)(const char *regexp,
79 char ***procs);
80
81 typedef pmix_status_t (*pmix_preg_base_module_resolve_peers_fn_t)(const char *nodename,
82 const char *nspace,
83 pmix_proc_t **procs, size_t *nprocs);
84
85 typedef pmix_status_t (*pmix_preg_base_module_resolve_nodes_fn_t)(const char *nspace,
86 char **nodelist);
87
88 /**
89 * Base structure for a PREG module
90 */
91 typedef struct {
92 char *name;
93 pmix_preg_base_module_generate_node_regex_fn_t generate_node_regex;
94 pmix_preg_base_module_generate_ppn_fn_t generate_ppn;
95 pmix_preg_base_module_parse_nodes_fn_t parse_nodes;
96 pmix_preg_base_module_parse_procs_fn_t parse_procs;
97 pmix_preg_base_module_resolve_peers_fn_t resolve_peers;
98 pmix_preg_base_module_resolve_nodes_fn_t resolve_nodes;
99 } pmix_preg_module_t;
100
101 /* we just use the standard component definition */
102
103 PMIX_EXPORT extern pmix_preg_module_t pmix_preg;
104
105 /*
106 * Macro for use in components that are of type preg
107 */
108 #define PMIX_PREG_BASE_VERSION_1_0_0 \
109 PMIX_MCA_BASE_VERSION_1_0_0("preg", 1, 0, 0)
110
111 END_C_DECLS
112
113 #endif