61 lines
1.9 KiB
C
61 lines
1.9 KiB
C
/* ****************************************************************************
|
|
* stream/list.c -- find out serial devices.
|
|
* Copyright (C) 2016-2018 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of libcasio.
|
|
* libcasio is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation; either version 3.0 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* libcasio is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with libcasio; if not, see <http://www.gnu.org/licenses/>.
|
|
* ************************************************************************* */
|
|
#include "stream.h"
|
|
|
|
#if !defined(LIBCASIO_DISABLED_LINUX_SERIAL)
|
|
# define ISF &casio_iter_linux_serial
|
|
#elif !defined(LIBCASIO_DISABLED_WINDOWS)
|
|
# define ISF &casio_iter_windows_serial
|
|
#elif !defined(LIBCASIO_DISABLED_MAC_SERIAL)
|
|
# define ISF &casio_iter_mac_serial
|
|
#else
|
|
# define ISF NULL
|
|
#endif
|
|
|
|
CASIO_LOCAL casio_iter_serial_t *iter_serial_func = ISF;
|
|
|
|
/**
|
|
* casio_set_iter_serial_func:
|
|
* Set the function to iterate on serial devices.
|
|
*
|
|
* @arg func the function.
|
|
* @return the error code (0 if ok).
|
|
*/
|
|
|
|
int CASIO_EXPORT casio_set_iter_serial_func(casio_iter_serial_t *func)
|
|
{
|
|
iter_serial_func = func ? func : ISF;
|
|
return (0);
|
|
}
|
|
|
|
/**
|
|
* casio_iter_serial:
|
|
* Get available serial ports.
|
|
*
|
|
* @arg iterp the iterator to make.
|
|
* @return the error (if any).
|
|
*/
|
|
|
|
int CASIO_EXPORT casio_iter_serial(casio_iter_t **iterp)
|
|
{
|
|
if (!iter_serial_func)
|
|
return (casio_error_op);
|
|
return ((*iter_serial_func)(iterp));
|
|
}
|