summaryrefslogtreecommitdiff
path: root/src/nhm-helper.c
blob: dec3784bbb50ff9aa3531618c6de14c48a14d9eb (plain)
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
/* NHM - NodeHealthMonitor
 *
 * Copyright (C) 2013 Continental Automotive Systems, Inc.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com>
 */

/**
 * SECTION: nhm-helper
 * @title: NodeHealthMonitor (NHM) helper functions
 * @short_description: Functions commonly used by NHM
 *
 * The section implements common tasks of in NHM in separate functions.
 */


/******************************************************************************
*
* Header includes
*
******************************************************************************/

/* Own header files */
#include "nhm-helper.h"

/* System header files                   */
#include <dlt/dlt.h>       /* DLT trace  */
#include <glib-2.0/glib.h> /* Use GTypes */


/******************************************************************************
*
* Exported global variables and constants
*
******************************************************************************/

/* Context for Log'n'Trace */
DLT_DECLARE_CONTEXT(nhm_helper_trace_ctx);


/******************************************************************************
*
* Interfaces. Exported functions.
*
******************************************************************************/

/**
 * nhm_helper_str_in_strv:
 * @str:    String that is searched
 * @strv:   String array in which to search string
 * @return: %TRUE:  The string array contains the string.
 *          %FALSE: String is not in array.
 *
 * The function checks if a passed string is within the passed string array.
 */
gboolean
nhm_helper_str_in_strv(const gchar *str,
                       gchar       *strv[])
{
  gboolean retval = FALSE;
  guint    idx    = 0;

  if(strv != NULL)
  {
    for(idx = 0; (idx < g_strv_length(strv)) && (retval == FALSE); idx++)
    {
      retval = (g_strcmp0(str, strv[idx]) == 0);
    }
  }
  else
  {
    retval = FALSE;
  }

  return retval;
}