summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2008-12-09 00:34:11 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2008-12-09 00:34:11 +0100
commite4bd72e98083987d26cd6570786fa30fb984ef57 (patch)
treec32e810b6eb834d563dc1891939ba18d46f4dee9 /common
parent4dc615cff484c4c11b2ef5b848595d83a0118329 (diff)
downloadeurephia-e4bd72e98083987d26cd6570786fa30fb984ef57.tar.gz
eurephia-e4bd72e98083987d26cd6570786fa30fb984ef57.tar.xz
eurephia-e4bd72e98083987d26cd6570786fa30fb984ef57.zip
Added eurephiaCERTINFO and eurephiaCERTLIST structs functions
New functions to simplify using these structs in the code. Extended eurephiaUSERINFO to also have a eurephiaCERTLIST pointer, which can be used to store all associated certificates to this user.
Diffstat (limited to 'common')
-rw-r--r--common/eurephia_admin_common.c69
-rw-r--r--common/eurephia_admin_common.h14
-rw-r--r--common/eurephia_admin_struct.h36
3 files changed, 101 insertions, 18 deletions
diff --git a/common/eurephia_admin_common.c b/common/eurephia_admin_common.c
index 8a51ca4..3297b86 100644
--- a/common/eurephia_admin_common.c
+++ b/common/eurephia_admin_common.c
@@ -56,6 +56,7 @@ void _eAdminFreeUSERINFO_func(eurephiaUSERINFO *p) {
if( p == NULL ) {
return;
}
+ eAdminFreeCERTLIST(p->certlist);
eAdminFreeUSERINFO(p->next);
free_nullsafe(p->username);
free_nullsafe(p->password);
@@ -74,3 +75,71 @@ void _eAdminFreeUSERLIST_func(eurephiaUSERLIST *p) {
eAdminFreeUSERINFO(p->users);
free(p);
}
+
+
+eurephiaCERTLIST *eAdminCreateCERTLIST() {
+ eurephiaCERTLIST *lst = NULL;
+
+ lst = (eurephiaCERTLIST *) malloc(sizeof(eurephiaCERTLIST)+2);
+ memset(lst, 0, sizeof(eurephiaCERTLIST)+2);
+ lst->num_certs = 0;
+ return lst;
+}
+
+eurephiaCERTINFO *eAdminPopulateCERTINFO(int certid, int depth, const char *digest,
+ const char *cname, const char *org, const char *email, const char *reg)
+{
+ eurephiaCERTINFO *newrec = NULL;
+
+ newrec = (eurephiaCERTINFO *) malloc(sizeof(eurephiaCERTINFO)+2);
+ assert( newrec != NULL );
+ memset(newrec, 0, sizeof(eurephiaCERTINFO)+2);
+
+ newrec->certid = certid;
+ newrec->depth = depth;
+ newrec->digest = strdup_nullsafe(digest);
+ newrec->common_name = strdup_nullsafe(cname);
+ newrec->organisation = strdup_nullsafe(org);
+ newrec->email = strdup_nullsafe(email);
+ newrec->registered = strdup_nullsafe(reg);
+ newrec->next = NULL;
+
+ return newrec;
+}
+
+void eAdminInsertCERTINFO(eurephiaCERTLIST *list, eurephiaCERTINFO *cert) {
+ assert( list != NULL );
+
+ if( list->certs != NULL ) {
+ cert->next = list->certs;
+ list->certs = cert;
+ list->num_certs++;
+ } else {
+ list->certs = cert;
+ list->num_certs = 1;
+ }
+}
+
+void _eAdminFreeCERTINFO_func(eurephiaCERTINFO *p) {
+ if( p == NULL ) {
+ return;
+ }
+ eAdminFreeCERTINFO(p->next);
+ free_nullsafe(p->digest);
+ free_nullsafe(p->common_name);
+ free_nullsafe(p->organisation);
+ free_nullsafe(p->email);
+ free_nullsafe(p->registered);
+ p->next = NULL;
+ free(p);
+}
+
+void _eAdminFreeCERTLIST_func(eurephiaCERTLIST *p) {
+ if( p == NULL ) {
+ return;
+ }
+
+ eAdminFreeCERTINFO(p->certs);
+ free(p);
+}
+
diff --git a/common/eurephia_admin_common.h b/common/eurephia_admin_common.h
index 58bbd96..e389968 100644
--- a/common/eurephia_admin_common.h
+++ b/common/eurephia_admin_common.h
@@ -30,4 +30,18 @@ void _eAdminFreeUSERINFO_func(eurephiaUSERINFO *);
void _eAdminFreeUSERLIST_func(eurephiaUSERLIST *);
#define eAdminFreeUSERLIST(x) { _eAdminFreeUSERLIST_func(x); x = NULL; }
+
+eurephiaCERTLIST *eAdminCreateCERTLIST();
+
+eurephiaCERTINFO *eAdminPopulateCERTINFO(int certid, int depth, const char *digest,
+ const char *cname, const char *org, const char *email, const char *reg);
+
+void eAdminInsertCERTINFO(eurephiaCERTLIST *list, eurephiaCERTINFO *cert);
+
+void _eAdminFreeCERTINFO_func(eurephiaCERTINFO *);
+#define eAdminFreeCERTINFO(x) { _eAdminFreeCERTINFO_func(x); x = NULL; }
+
+void _eAdminFreeCERTLIST_func(eurephiaCERTLIST *);
+#define eAdminFreeCERTLIST(x) { _eAdminFreeCERTLIST_func(x); x = NULL; }
+
#endif /* !EUREPHIA_ADMIN_COMMON_H_ */
diff --git a/common/eurephia_admin_struct.h b/common/eurephia_admin_struct.h
index c4fe6b8..b52ce64 100644
--- a/common/eurephia_admin_struct.h
+++ b/common/eurephia_admin_struct.h
@@ -21,23 +21,6 @@
#ifndef EUREPHIA_ADMIN_STRUCT_H
#define EUREPHIA_ADMIN_STRUCT_H
-typedef struct _eurephiaUSERINFO_s {
- char *username;
- char *password;
- char *activated;
- char *deactivated;
- char *last_accessed;
- int uid;
- long int setnull_flags;
- struct _eurephiaUSERINFO_s *next;
-} eurephiaUSERINFO;
-
-typedef struct {
- eurephiaUSERINFO *users;
- int num_users;
- int maxlen[];
-} eurephiaUSERLIST;
-
typedef struct _eurephiaCERTINFO_s {
int depth;
char *digest;
@@ -51,11 +34,28 @@ typedef struct _eurephiaCERTINFO_s {
} eurephiaCERTINFO;
typedef struct {
- eurephiaUSERINFO *certs;
+ eurephiaCERTINFO *certs;
int num_certs;
int maxlen[];
} eurephiaCERTLIST;
+typedef struct _eurephiaUSERINFO_s {
+ char *username;
+ char *password;
+ char *activated;
+ char *deactivated;
+ char *last_accessed;
+ int uid;
+ long int setnull_flags;
+ eurephiaCERTLIST *certlist;
+ struct _eurephiaUSERINFO_s *next;
+} eurephiaUSERINFO;
+
+typedef struct {
+ eurephiaUSERINFO *users;
+ int num_users;
+ int maxlen[];
+} eurephiaUSERLIST;
typedef struct _eurephiaLOGENTRY_s {
int id;