nmxp_chan.c 825 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*! \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>

Matteo Quintiliani's avatar
Matteo Quintiliani committed
16
int nmxp_chan_lookupKey(char* name, NMXP_CHAN_LIST *channelList)
17
18
19
20
21
22
23
24
25
26
27
28
29
{
    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;
}

Matteo Quintiliani's avatar
Matteo Quintiliani committed
30
char *nmxp_chan_lookupName(uint32_t key, NMXP_CHAN_LIST *channelList)
31
32
33
34
35
36
37
38
39
40
41
42
43
{
    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;
}