Greenbone Security Assistant  8.0.0
utils.c
Go to the documentation of this file.
1 /* Copyright (C) 2018 Greenbone Networks GmbH
2  *
3  * SPDX-License-Identifier: GPL-2.0-or-later
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
25 #include "utils.h"
26 
27 #include <string.h> // For strcmp
28 
34 gboolean
35 str_equal (const gchar *str1, const gchar *str2)
36 {
37  return strcmp (str1, str2) == 0;
38 }
39 
47 gchar *
48 capitalize (const char *input)
49 {
50  gchar *output;
51  if (input == NULL)
52  return NULL;
53  else
54  {
55  int first_letter = 1;
56  int pos = 0;
57  output = g_strdup (input);
58 
59  while (output[pos])
60  {
61  if (g_ascii_isalpha (output[pos]) && first_letter)
62  {
63  output[pos] = g_ascii_toupper (output[pos]);
64  first_letter = 0;
65  }
66  else if (output[pos] == '_')
67  {
68  output[pos] = ' ';
69  first_letter = 1;
70  }
71  pos++;
72  }
73  return output;
74  }
75 }
gboolean str_equal(const gchar *str1, const gchar *str2)
Check if two strings are equal.
Definition: utils.c:35
gchar * capitalize(const char *input)
Capitalize a type or command name and replace underscores.
Definition: utils.c:48
Headers/structs for utility functions in GSAD.