121 |
|
check(write(file, password, strlen(password)), environment); |
122 |
|
check(close(file), environment); |
123 |
|
} |
124 |
+ |
|
125 |
+ |
void get(const char *prompt, regex_t *regex, char **string, jmp_buf environment) |
126 |
+ |
{ |
127 |
+ |
do |
128 |
+ |
{ |
129 |
+ |
printf("%s: ", prompt); |
130 |
+ |
|
131 |
+ |
size_t size; |
132 |
+ |
char *string_ = fcheck(fgetln(stdin, &size), stdin, environment); |
133 |
+ |
|
134 |
+ |
*string = *string ? realloc(*string, size) : malloc(size); |
135 |
+ |
|
136 |
+ |
strlcpy(*string, string_, size); |
137 |
+ |
} |
138 |
+ |
while (regcheck(regexec(regex, *string, 0, NULL, 0), regex, environment)); |
139 |
+ |
} |