-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjob-list-mutators.c
171 lines (157 loc) · 4.87 KB
/
job-list-mutators.c
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/***************************************************************************
* This file is automatically generated by gen-get-set. Be sure to keep
* track of any manual changes.
*
* These generated functions are not expected to be perfect. Check and
* edit as needed before adding to your code.
***************************************************************************/
#include <string.h>
#include <ctype.h>
#include <stdbool.h> // In case of bool
#include <stdint.h> // In case of int64_t, etc
#include <xtend/string.h> // strlcpy() on Linux
#include "job-list-private.h"
/***************************************************************************
* Library:
* #include <job-list.h>
*
*
* Description:
* Mutator for count member in a job_list_t structure.
* Use this function to set count in a job_list_t object
* from non-member functions. This function performs a direct
* assignment for scalar or pointer structure members. If
* count is a pointer, data previously pointed to should
* be freed before calling this function to avoid memory
* leaks.
*
* Arguments:
* job_list_ptr Pointer to the structure to set
* new_count The new value for count
*
* Returns:
* JOB_LIST_DATA_OK if the new value is acceptable and assigned
* JOB_LIST_DATA_OUT_OF_RANGE otherwise
*
* Examples:
* job_list_t job_list;
* unsigned long new_count;
*
* if ( job_list_set_count(&job_list, new_count)
* == JOB_LIST_DATA_OK )
* {
* }
*
* See also:
* (3)
*
* History:
* Date Name Modification
* 2024-04-28 gen-get-set Auto-generated from job-list-private.h
***************************************************************************/
int job_list_set_count(job_list_t *job_list_ptr, unsigned long new_count)
{
if ( false )
return JOB_LIST_DATA_OUT_OF_RANGE;
else
{
job_list_ptr->count = new_count;
return JOB_LIST_DATA_OK;
}
}
/***************************************************************************
* Library:
* #include <job-list.h>
*
*
* Description:
* Mutator for an array element of jobs member in a job_list_t
* structure. Use this function to set job_list_ptr->jobs[c]
* in a job_list_t object from non-member functions.
*
* Arguments:
* job_list_ptr Pointer to the structure to set
* c Subscript to the jobs array
* new_jobs_element The new value for jobs[c]
*
* Returns:
* JOB_LIST_DATA_OK if the new value is acceptable and assigned
* JOB_LIST_DATA_OUT_OF_RANGE otherwise
*
* Examples:
* job_list_t job_list;
* size_t c;
* job_t * new_jobs_element;
*
* if ( job_list_set_jobs_ae(&job_list, c, new_jobs_element)
* == JOB_LIST_DATA_OK )
* {
* }
*
* See also:
* JOB_LIST_SET_JOBS_AE(3)
*
* History:
* Date Name Modification
* 2024-04-28 gen-get-set Auto-generated from job-list-private.h
***************************************************************************/
int job_list_set_jobs_ae(job_list_t *job_list_ptr, size_t c, job_t *new_jobs_element)
{
if ( false )
return JOB_LIST_DATA_OUT_OF_RANGE;
else
{
job_list_ptr->jobs[c] = new_jobs_element;
return JOB_LIST_DATA_OK;
}
}
/***************************************************************************
* Library:
* #include <job-list.h>
*
*
* Description:
* Mutator for jobs member in a job_list_t structure.
* Use this function to set jobs in a job_list_t object
* from non-member functions. This function copies the array pointed to
* by new_jobs to job_list_ptr->jobs.
*
* Arguments:
* job_list_ptr Pointer to the structure to set
* new_jobs The new value for jobs
* array_size Size of the jobs array.
*
* Returns:
* JOB_LIST_DATA_OK if the new value is acceptable and assigned
* JOB_LIST_DATA_OUT_OF_RANGE otherwise
*
* Examples:
* job_list_t job_list;
* job_t * new_jobs;
* size_t array_size;
*
* if ( job_list_set_jobs_cpy(&job_list, new_jobs, array_size)
* == JOB_LIST_DATA_OK )
* {
* }
*
* See also:
* JOB_LIST_SET_JOBS(3)
*
* History:
* Date Name Modification
* 2024-04-28 gen-get-set Auto-generated from job-list-private.h
***************************************************************************/
int job_list_set_jobs_cpy(job_list_t *job_list_ptr, job_t * new_jobs[], size_t array_size)
{
if ( new_jobs == NULL )
return JOB_LIST_DATA_OUT_OF_RANGE;
else
{
size_t c;
// FIXME: Assuming all elements should be copied
for (c = 0; c < array_size; ++c)
job_list_ptr->jobs[c] = new_jobs[c];
return JOB_LIST_DATA_OK;
}
}