Update of /cvsroot/digraphanalysis/digraphanalysis/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18429
Added Files:
alias.c alias.h
Log Message:
initial add; This is for the upcomming seperation of nodes and alias'
--- NEW FILE: alias.h ---
/* $Id: alias.h,v 1.1 2005/04/15 03:43:23 jbreker Exp $
*
* Copyright (C) 2005 Jeff Breker <jb...@sy...>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _ALIAS_H_
#define _ALIAS_H_
#include "list.h"
struct alias
{
char *uid;
char *name;
struct node *node;
};
struct aliaslink
{
struct alias alias;
LIST_ENTRY(aliaslink) list;
};
LIST_HEAD(aliaslist, aliaslink);
alias *alias_new(char *, char *, struct node *);
aliaslist *aliaslist_new(void);
#endif /* _ALIAS_H_ */
--- NEW FILE: alias.c ---
/* $Id: alias.c,v 1.1 2005/04/15 03:43:23 jbreker Exp $
*
* Copyright (C) 2005 Jeff Breker <jb...@sy...>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "alias.h"
alias *alias_new(char *uid, char *name, struct node *node)
{
alias *alias;
if((alias = (alias *) malloc(sizeof(alias))) != NULL)
{
if(((alias->uid = (char *) malloc(strlen(uid) + 1)) == NULL) ||
((alias->name = (char *) malloc(strlen(name) + 1)) == NULL))
{
free(alias->name);
free(alias->uid);
free(alias);
alias = NULL;
}
else
{
strncpy(alias->uid, uid, strlen(uid));
*(alias->uid + strlen(uid)) = '\0';
strncpy(alias->name, name, strlen(uid));
*(alias->name + strlen(name)) = '\0';
alias->node = node;
}
}
return alias;
}
aliaslist *aliaslist_new()
{
aliaslist *list;
if((list = (aliaslist *) malloc(sizeof(aliaslist))) != NULL)
LIST_INIT(list);
return list;
}
|