1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
/*
* Player - One Hell of a Robot Server
* Copyright (C) 2000
* Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/********************************************************************
*
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
********************************************************************/
/** @ingroup libplayerinterface
@{ */
#ifndef _INTERFACE_UTIL_H
#define _INTERFACE_UTIL_H
#if defined (WIN32)
#if defined (PLAYER_STATIC)
#define PLAYERINTERFACE_EXPORT
#elif defined (playerinterface_EXPORTS)
#define PLAYERINTERFACE_EXPORT __declspec (dllexport)
#else
#define PLAYERINTERFACE_EXPORT __declspec (dllimport)
#endif
#else
#define PLAYERINTERFACE_EXPORT
#endif
#include <playerconfig.h> // for uint16_t type
#ifdef __cplusplus
extern "C" {
#endif
// available interfaces are stored in an array of these, defined in
// interface_util.c
typedef struct
{
uint16_t interf;
char* name;
} player_interface_t;
/*
* Initialises the interface names/codes table.
*/
PLAYERINTERFACE_EXPORT int itable_init (void);
/*
* Grows the interface table to newSize, filling each interface between the
* old end and the new end with (0xFFFF, "nointerfXX").
*/
PLAYERINTERFACE_EXPORT int itable_grow (int newSize);
/*
* Destroys the interface names/codes table.
*/
PLAYERINTERFACE_EXPORT void itable_destroy (void);
/*
* Add a new interface to the interface table.
*/
PLAYERINTERFACE_EXPORT int itable_add (const char *name, unsigned int code, int replace);
/*
* looks through the array of available interfaces for one which the given
* name. if found, interface is filled out (the caller must provide storage)
* and zero is returned. otherwise, -1 is returned.
*/
PLAYERINTERFACE_EXPORT int lookup_interface(const char* name, player_interface_t* interf);
/*
* looks through the array of available interfaces for one which the given
* code. if found, interface is filled out (the caller must provide storage)
* and zero is returned. otherwise, -1 is returned.
*/
PLAYERINTERFACE_EXPORT int
lookup_interface_code(int code, player_interface_t* interf);
/*
* looks through the array of interfaces, starting at startpos, for the first
* entry that has the given code, and returns the name.
* returns 0 if the device is not found.
*/
PLAYERINTERFACE_EXPORT const char*
lookup_interface_name(unsigned int startpos, int code);
/*
* Returns the name of an interface given its code. The result string must
* not be altered.
*/
PLAYERINTERFACE_EXPORT const char*
interf_to_str(uint16_t code);
/*
* Returns the code for an interface, given a string. If the name is not found,
* 0xFFFF is returned.
*/
PLAYERINTERFACE_EXPORT uint16_t
str_to_interf(const char *name);
/*
* Returns the name of a message type given its code. The result string must
* not be altered.
*/
PLAYERINTERFACE_EXPORT const char*
msgtype_to_str(uint8_t code);
/*
* Returns the code for a message type, given a string. If the name is not
* found, 0xFF is returned.
*/
PLAYERINTERFACE_EXPORT uint8_t
str_to_msgtype(const char *name);
#ifdef __cplusplus
}
#endif
/** @} */
#endif
|