Greenbone Security Assistant  8.0.0
gsad_credentials.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 "gsad_credentials.h"
26 
27 #include "gsad_user.h"
28 
29 #include <glib.h>
30 
35 {
36  struct timeval cmd_start;
37  gchar *language;
39 };
40 
42 credentials_new (user_t *user, const gchar *language)
43 {
45 
46  credentials = g_malloc0 (sizeof (credentials_t));
48  credentials->language = g_strdup (language);
49 
50  return credentials;
51 }
52 
53 void
55 {
56  if (!creds)
57  return;
58 
59  g_free (creds->language);
60 
61  user_free (creds->user);
62 
63  g_free (creds);
64 }
65 
66 user_t *
68 {
69  return cred->user;
70 }
71 
72 const gchar *
74 {
75  return cred->language;
76 }
77 
78 void
80 {
81  gettimeofday (&creds->cmd_start, NULL);
82 }
83 
84 double
86 {
87  struct timeval tv;
88  gettimeofday (&tv, NULL);
89  return ((double) ((tv.tv_sec - cred->cmd_start.tv_sec) * 1000000L + tv.tv_usec
90  - cred->cmd_start.tv_usec)
91  / 1000000.0);
92 }
GSAD credentials handling.
Structure of credential related information.
void credentials_start_cmd(credentials_t *creds)
gchar * language
Language for this request.
void user_free(user_t *user)
Definition: gsad_user.c:102
user_t * user_copy(user_t *user)
Definition: gsad_user.c:124
const gchar * credentials_get_language(credentials_t *cred)
user_t * user
Current user.
credentials_t * credentials_new(user_t *user, const gchar *language)
double credentials_get_cmd_duration(credentials_t *cred)
User information structure, for sessions.
Definition: gsad_user.c:42
GSAD user handling.
void credentials_free(credentials_t *creds)
struct timeval cmd_start
Seconds since command page handler started.
user_t * credentials_get_user(credentials_t *cred)