Greenbone Security Assistant  8.0.0
utils.c File Reference

Utility functions in GSAD. More...

#include "utils.h"
#include <string.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Functions

gboolean str_equal (const gchar *str1, const gchar *str2)
 Check if two strings are equal. More...
 
gchar * capitalize (const char *input)
 Capitalize a type or command name and replace underscores. More...
 

Detailed Description

Utility functions in GSAD.

Definition in file utils.c.

Function Documentation

◆ capitalize()

gchar* capitalize ( const char *  input)

Capitalize a type or command name and replace underscores.

Parameters
[in]inputThe input string.
Returns
The newly allocated capitalized type or command name.

Definition at line 48 of file utils.c.

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 }

Referenced by delete_resource(), and resource_action().

Here is the caller graph for this function:

◆ str_equal()

gboolean str_equal ( const gchar *  str1,
const gchar *  str2 
)