Remove unused code

This commit is contained in:
Greg Shuflin 2023-07-23 21:01:43 -07:00
parent 9feeb6782b
commit d1b289ff8e
2 changed files with 1 additions and 86 deletions

View File

@ -81,86 +81,3 @@ int input_get(unsigned char** dest, char *prompt)
return input_len;
}
int input_get_str(char** dest, char *prompt)
{
int r, i, input_len;
unsigned char *input;
r = input_get(&input, prompt);
if (r < 0)
{
error_log("Could not get input.");
return -1;
}
if (r > 0)
{
if (input[r - 1] == '\n')
{
--r;
if (r > 0 && input[r - 1] == '\r')
{
--r;
}
}
}
if (r == 0)
{
error_log("No input provided.");
return -1;
}
input_len = r;
*dest = malloc(input_len + 1);
if (*dest == NULL)
{
error_log("Memory allocation error.");
return -1;
}
memset(*dest, 0, input_len + 1);
for (i = 0; i < input_len; ++i)
{
if (isascii(input[i]))
{
(*dest)[i] = input[i];
}
else
{
error_log("Input contains non-ascii characters.");
return -1;
}
}
free(input);
return input_len;
}
int input_get_from_pipe(unsigned char** dest)
{
int r;
if (isatty(STDIN_FILENO))
{
error_log("Input data from a piped or redirected source is required.");
return -1;
}
r = input_get(dest, NULL);
if (r < 0)
{
error_log("Could not get input.");
return -1;
}
if (r == 0)
{
error_log("No input provided.");
return -1;
}
return r;
}

View File

@ -9,7 +9,5 @@
#define INPUT_H 1
int input_get(unsigned char** dest, char *prompt);
int input_get_str(char** dest, char *prompt);
int input_get_from_pipe(unsigned char** dest);
#endif
#endif