Lines Matching refs:input
2 * \file input.c
3 * \brief Generic stdio-like input interface
7 * Generic stdio-like input interface
39 int (*close)(snd_input_t *input);
40 int (*scan)(snd_input_t *input, const char *format, va_list args);
41 char *(*(gets))(snd_input_t *input, char *str, size_t size);
42 int (*getch)(snd_input_t *input);
43 int (*ungetch)(snd_input_t *input, int c);
54 * \brief Closes an input handle.
55 * \param input The input handle to be closed.
58 int snd_input_close(snd_input_t *input)
60 int err = input->ops->close(input);
61 free(input);
66 * \brief Reads formatted input (like \c fscanf(3)) from an input handle.
67 * \param input The input handle.
70 * \return The number of input items assigned, or \c EOF.
74 int snd_input_scanf(snd_input_t *input, const char *format, ...)
79 result = input->ops->scan(input, format, args);
85 * \brief Reads a line from an input handle (like \c fgets(3)).
86 * \param input The input handle.
94 char *snd_input_gets(snd_input_t *input, char *str, size_t size)
96 return (input->ops->gets)(input, str, size);
100 * \brief Reads a character from an input handle (like \c fgetc(3)).
101 * \param input The input handle.
104 int snd_input_getc(snd_input_t *input)
106 return input->ops->getch(input);
110 * \brief Puts the last character read back to an input handle (like \c ungetc(3)).
111 * \param input The input handle.
115 int snd_input_ungetc(snd_input_t *input, int c)
117 return input->ops->ungetch(input, c);
126 static int snd_input_stdio_close(snd_input_t *input ATTRIBUTE_UNUSED)
128 snd_input_stdio_t *stdio = input->private_data;
135 static int snd_input_stdio_scan(snd_input_t *input, const char *format, va_list args)
137 snd_input_stdio_t *stdio = input->private_data;
142 static char *snd_input_stdio_gets(snd_input_t *input, char *str, size_t size)
144 snd_input_stdio_t *stdio = input->private_data;
148 static int snd_input_stdio_getc(snd_input_t *input)
150 snd_input_stdio_t *stdio = input->private_data;
154 static int snd_input_stdio_ungetc(snd_input_t *input, int c)
156 snd_input_stdio_t *stdio = input->private_data;
170 * \brief Creates a new input object using an existing stdio \c FILE pointer.
171 * \param inputp The function puts the pointer to the new input object
181 snd_input_t *input;
187 input = calloc(1, sizeof(*input));
188 if (!input) {
194 input->type = SND_INPUT_STDIO;
195 input->ops = &snd_input_stdio_ops;
196 input->private_data = stdio;
197 *inputp = input;
202 * \brief Creates a new input object reading from a file.
203 * \param inputp The functions puts the pointer to the new input object
231 static int snd_input_buffer_close(snd_input_t *input)
233 snd_input_buffer_t *buffer = input->private_data;
239 static int snd_input_buffer_scan(snd_input_t *input, const char *format, va_list args)
241 snd_input_buffer_t *buffer = input->private_data;
248 static char *snd_input_buffer_gets(snd_input_t *input, char *str, size_t size)
250 snd_input_buffer_t *buffer = input->private_data;
266 static int snd_input_buffer_getc(snd_input_t *input)
268 snd_input_buffer_t *buffer = input->private_data;
275 static int snd_input_buffer_ungetc(snd_input_t *input, int c)
277 snd_input_buffer_t *buffer = input->private_data;
296 * \brief Creates a new input object from a memory buffer.
297 * \param inputp The function puts the pointer to the new input object
299 * \param buf Address of the input buffer.
300 * \param size Size of the input buffer.
303 * This functions creates a copy of the input buffer, so the application is
308 snd_input_t *input;
314 input = calloc(1, sizeof(*input));
315 if (!input) {
323 free(input);
331 input->type = SND_INPUT_BUFFER;
332 input->ops = &snd_input_buffer_ops;
333 input->private_data = buffer;
334 *inputp = input;