-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwla_template.def
84 lines (67 loc) · 2.33 KB
/
pwla_template.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* -*- mode: c -*- */
#include "pwla.h"
#include <stdio.h>
#include "ate_handle.h"
#include "ate_utilities.h"
#include "ate_errors.h"
#include "word_list_stack.h"
/**
* @brief FAKE ACTION template
*/
int pwla_template(ARG_LIST *alist)
{
const char *handle_name = NULL;
const char *value_name = NULL;
const char *array_name = NULL;
const char *start_row_str = NULL;
ARG_TARGET template_targets[] = {
{ "handle_name", AL_ARG, &handle_name},
{ "v", AL_OPT, &value_name},
{ "a", AL_OPT, &array_name},
{ "-s", AL_ARG, &start_row_str},
{ NULL }
};
int retval;
if ((retval = process_word_list_args(template_targets, alist, 0)))
goto early_exit;
// Gotta do this (with a couple of exceptions):
// get the handle variable
SHELL_VAR *handle_var;
if ((retval = get_handle_var_by_name_or_fail(&handle_var,
handle_name,
"template")))
goto early_exit;
// For actions that return a discrete (single) value
SHELL_VAR *value_var;
if ((retval = create_var_by_given_or_default_name(&value_var,
value_name,
DEFAULT_VALUE_NAME,
"template")))
goto early_exit;
// For actions that return an array value
SHELL_VAR *array_var;
if ((retval = create_array_var_by_given_or_default_name(&array_var,
array_name,
DEFAULT_ARRAY_NAME,
"template")))
goto early_exit;
retval = EX_USAGE;
// For actions that use a number-valued argument
int start_row = -1;
if (get_int_from_string(&start_row, start_row_str))
{
// validate the number
}
else
{
ate_register_not_an_int(start_row_str, "template");
goto early_exit;
}
// For actions that create an array for callback functions
SHELL_VAR *new_array = NULL;
if ((retval = create_array_var_by_stem(&new_array, "ATE_USER_ARRAY_", "template")))
goto early_exit;
// Use the values aquired above
early_exit:
return retval;
}