2 * Copyright © 2016 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 #include "libaltos_private.h"
23 return LIBALTOS_SUCCESS;
31 struct altos_error altos_last_error;
34 altos_set_last_error(int code, char *string)
36 altos_last_error.code = code;
37 strncpy(altos_last_error.string, string, sizeof (altos_last_error.string) -1);
38 altos_last_error.string[sizeof(altos_last_error.string)-1] = '\0';
42 altos_get_last_error(struct altos_error *error)
44 *error = altos_last_error;
48 altos_getchar(struct altos_file *file, int timeout)
51 while (file->in_read == file->in_used) {
52 ret = altos_fill(file, timeout);
56 return file->in_data[file->in_read++];
60 altos_putchar(struct altos_file *file, char c)
64 if (file->out_used == USB_BUF_SIZE) {
65 ret = altos_flush(file);
70 file->out_data[file->out_used++] = c;
72 if (file->out_used == USB_BUF_SIZE)
73 ret = altos_flush(file);
79 altos_free(struct altos_file *file)