|
20 | 20 |
|
21 | 21 | #include <ctype.h> |
22 | 22 | #include <limits.h> |
| 23 | +#include <stdarg.h> |
23 | 24 | #include <stdint.h> |
24 | 25 | #include <stdlib.h> |
25 | 26 | #include <string.h> |
@@ -81,30 +82,54 @@ char *Strdup(const char *s) { |
81 | 82 | return p; |
82 | 83 | } |
83 | 84 |
|
84 | | -umf_result_t umfCtlGet(const char *name, void *ctx, void *arg) { |
85 | | - if (name == NULL || arg == NULL || ctx == NULL) { |
86 | | - return UMF_RESULT_ERROR_INVALID_ARGUMENT; |
87 | | - } |
| 85 | +umf_result_t umfCtlGet(const char *name, ...) { |
| 86 | + assert(name != NULL); |
| 87 | + |
| 88 | + va_list args; |
| 89 | + va_start(args, name); |
| 90 | + |
| 91 | + void *ctx = va_arg(args, void *); |
| 92 | + void *arg = va_arg(args, void *); |
| 93 | + va_end(args); |
| 94 | + |
| 95 | + assert(arg != NULL); |
| 96 | + assert(ctx != NULL); |
88 | 97 | return ctl_query(NULL, ctx, CTL_QUERY_PROGRAMMATIC, name, CTL_QUERY_READ, |
89 | 98 | arg) |
90 | 99 | ? UMF_RESULT_ERROR_UNKNOWN |
91 | 100 | : UMF_RESULT_SUCCESS; |
92 | 101 | } |
93 | 102 |
|
94 | | -umf_result_t umfCtlSet(const char *name, void *ctx, void *arg) { |
95 | | - if (name == NULL || arg == NULL || ctx == NULL) { |
96 | | - return UMF_RESULT_ERROR_INVALID_ARGUMENT; |
97 | | - } |
| 103 | +umf_result_t umfCtlSet(const char *name, ...) { |
| 104 | + assert(name != NULL); |
| 105 | + |
| 106 | + va_list args; |
| 107 | + va_start(args, name); |
| 108 | + |
| 109 | + void *ctx = va_arg(args, void *); |
| 110 | + void *arg = va_arg(args, void *); |
| 111 | + va_end(args); |
| 112 | + |
| 113 | + assert(arg != NULL); |
| 114 | + assert(ctx != NULL); |
98 | 115 | return ctl_query(NULL, ctx, CTL_QUERY_PROGRAMMATIC, name, CTL_QUERY_WRITE, |
99 | 116 | arg) |
100 | 117 | ? UMF_RESULT_ERROR_UNKNOWN |
101 | 118 | : UMF_RESULT_SUCCESS; |
102 | 119 | } |
103 | 120 |
|
104 | | -umf_result_t umfCtlExec(const char *name, void *ctx, void *arg) { |
105 | | - if (name == NULL || arg == NULL || ctx == NULL) { |
106 | | - return UMF_RESULT_ERROR_INVALID_ARGUMENT; |
107 | | - } |
| 121 | +umf_result_t umfCtlExec(const char *name, ...) { |
| 122 | + assert(name != NULL); |
| 123 | + |
| 124 | + va_list args; |
| 125 | + va_start(args, name); |
| 126 | + |
| 127 | + void *ctx = va_arg(args, void *); |
| 128 | + void *arg = va_arg(args, void *); |
| 129 | + va_end(args); |
| 130 | + |
| 131 | + assert(arg != NULL); |
| 132 | + assert(ctx != NULL); |
108 | 133 | return ctl_query(NULL, ctx, CTL_QUERY_PROGRAMMATIC, name, |
109 | 134 | CTL_QUERY_RUNNABLE, arg) |
110 | 135 | ? UMF_RESULT_ERROR_UNKNOWN |
|
0 commit comments