All pastes #979703 Raw Edit

Untitled

public text v1 · immutable
·published 2008-04-10 15:19 UTC
rendered paste body
----------------------ACCOUNT.C-------------------
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//#include "../../mem/mem.h"
//#include "../../mem/shm_mem.h"
//#include "../../locking.h"
//#include "../../dprint.h"
//#include "../../error.h"

#include "account.h"
#include "list.h"  


Account * AccountNew(void){
	Account * new;
	new = (Account *) malloc(sizeof(Account));

	new->ListNetwork=ListNew();
	new->pRouteTable=NULL;
	return new;
}

void AccountFree(Account * account){
		free(account);
}

----------------------ACCOUNT.H-------------------

//#include <time.h>
#include "list.h"
#include "routetable.h"

#ifdef ACCOUNT_H
#define ACCOUNT_H
typedef struct _Account Account;

struct _Account{
	List * ListNetwork;			//list of allowed networks
	RouteTable * pRouteTable; 	//Routetable inuse by this account
	
	int id;
	int state;
	char prefix[15];
	int channels;
	float credit;
};

/**
 *  Create a new Account
 */
Account * AccountNew(void);

/**
 *	Free all memory used by account
 */
void AccountFree(Account * account);


#endif /* ACCOUNT.H */



-------------- LIST.H -------------------
#ifndef LIST_H
#define LIST_H
typedef struct _List List;
typedef struct _ListElement ListElement;

struct _ListElement{
		void * data;
		ListElement * next;
};

struct _List{
		ListElement * head;
};

List * ListNew();
void ListAppend(List * list, void * data);
ListElement * ListNext(ListElement * listElement);