taskrambler  0.1.9
Web server and task management solution.
credential.c File Reference
#include <stdarg.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include "class.h"
#include "utils/memory.h"
#include "auth/credential.h"
+ Include dependency graph for credential.c:

Go to the source code of this file.

Functions

static int credentialCtor (void *_this, va_list *params)
 
static void credentialDtor (void *_this)
 
 INIT_IFACE (Class, credentialCtor, credentialDtor, NULL)
 
 CREATE_CLASS (Credential, NULL, IFACE(Class))
 

Detailed Description

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file credential.c.

Function Documentation

CREATE_CLASS ( Credential  ,
NULL  ,
IFACE(Class)   
)
static int credentialCtor ( void *  _this,
va_list *  params 
)
static

Definition at line 35 of file credential.c.

References CRED_PASSWORD, CRED_PWD, and memMalloc().

36 {
37  Credential this = _this;
38 
39  this->type = va_arg(* params, CredentialType);
40 
41  switch(this->type) {
42  case CRED_PASSWORD:
43  {
44  char * user, *pass;
45 
46  user = va_arg(* params, char*);
47  CRED_PWD(this).nuser = va_arg(* params, size_t);
48  pass = va_arg(* params, char*);
49  CRED_PWD(this).npass = va_arg(* params, size_t);
50 
51  CRED_PWD(this).user = memMalloc(CRED_PWD(this).nuser + 1);
52  CRED_PWD(this).user[CRED_PWD(this).nuser] = 0;
53  memcpy(CRED_PWD(this).user, user, CRED_PWD(this).nuser);
54 
55  CRED_PWD(this).pass = memMalloc(CRED_PWD(this).npass + 1);
56  CRED_PWD(this).pass[CRED_PWD(this).npass] = 0;
57  memcpy(CRED_PWD(this).pass, pass, CRED_PWD(this).npass);
58  }
59  break;
60 
61  default:
62  return -1;
63  }
64 
65  return 0;
66 }
void * memMalloc(size_t)
Definition: memory.c:783
CredentialType
Definition: credential.h:32
#define CRED_PWD(c)
Definition: credential.h:30

+ Here is the call graph for this function:

static void credentialDtor ( void *  _this)
static

Definition at line 70 of file credential.c.

References CRED_PASSWORD, CRED_PWD, and MEM_FREE.

71 {
72  Credential this = _this;
73 
74  switch(this->type) {
75  case CRED_PASSWORD:
76  MEM_FREE(CRED_PWD(this).user);
77  MEM_FREE(CRED_PWD(this).pass);
78  break;
79  }
80 }
#define MEM_FREE(seg)
Definition: memory.h:28
#define CRED_PWD(c)
Definition: credential.h:30
INIT_IFACE ( Class  ,
credentialCtor  ,
credentialDtor  ,
NULL   
)