Commit 9ab82b3b authored by Matteo Quintiliani's avatar Matteo Quintiliani
Browse files

Moved functions related to channel from nmxp.[ch] into nmxp_chan.[ch]


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@16 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent fdbcf27c
/*! \file
*
* \brief Channels for Nanometrics Protocol Libray
*
* Author:
* Matteo Quintiliani
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
*/
#ifndef NMXP_CHAN_H
#define NMXP_CHAN_H 1
#include <sys/types.h>
/*! \brief The key/name info for one channel */
typedef struct nmxp_ChannelKey
{
uint32_t key;
char name[12];
} nmxp_ChannelKey;
#define MAX_N_CHAN 1000
/*! \brief Channel List */
typedef struct nmxp_ChannelList
{
uint32_t number;
nmxp_ChannelKey channel[MAX_N_CHAN];
} nmxp_ChannelList;
/*! \brief Looks up a channel key in the nmxp_ChannelList using the name
*
* \param name
* \param channelList
*
* \retval
*
*/
int lookupChannelKey(char* name, nmxp_ChannelList *channelList);
/*! \brief Looks up a channel name in the nmxp_ChannelList using a key
*
* \param key
* \param channelList
*
* \retval
*
*/
char *lookupChannelName(int key, nmxp_ChannelList *channelList);
#endif
/*! \file
*
* \brief Channels for Nanometrics Protocol Libray
*
* Author:
* Matteo Quintiliani
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
*/
#include "nmxp_chan.h"
#include <string.h>
int lookupChannelKey(char* name, nmxp_ChannelList *channelList)
{
int length = channelList->number;
int ich = 0;
for (ich = 0; ich < length; ich++)
{
if (strcasecmp(name, channelList->channel[ich].name) == 0)
return channelList->channel[ich].key;
}
return -1;
}
char *lookupChannelName(int key, nmxp_ChannelList *channelList)
{
int length = channelList->number;
int ich = 0;
for (ich = 0; ich < length; ich++)
{
if ( key == channelList->channel[ich].key )
return &channelList->channel[ich].name[0];
}
return NULL;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment