Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
seppel committed Apr 30, 2007
1 parent e243107 commit f609f9b
Show file tree
Hide file tree
Showing 100 changed files with 12,884 additions and 7,313 deletions.
19 changes: 19 additions & 0 deletions .cvsignore
@@ -0,0 +1,19 @@
.deps
Makefile
Makefile.in
aclocal.m4
autom4te.cache
config.h
config.h.in
config.cache
config.log
config.status
configure
stamp-h1
stamp-h
stamp-h.in
ht
ht_v
htdoc.h
htdoc.c
README
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -27,7 +27,7 @@ ht_SOURCES = atom.cc atom.h except.cc except.h data.cc data.h \
str.cc str.h strtools.cc strtools.h endianess.h endianess.cc \
htdoc.c htdoc.h blockop.cc blockop.h coff_s.h \
config.h cstream.cc cstream.h demangle.h elfstruc.h \
formats.cc formats.h global.h htanaly.cc htanaly.h htapp.cc \
formats.cc formats.h htanaly.cc htanaly.h htapp.cc \
htapp.h htcfg.cc htcfg.h htclipboard.cc htclipboard.h \
htcoff.cc htcoff.h htcoffhd.cc htcoffhd.h htctrl.cc htctrl.h \
htdebug.cc htdebug.h htdialog.cc htdialog.h htelf.cc htelf.h htelfhd.cc \
Expand Down
105 changes: 105 additions & 0 deletions atom.cc
@@ -0,0 +1,105 @@
/*
* HT Editor
* atom.cc
*
* Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <cstring>

#include "atom.h"
#include "data.h"
#include "snprintf.h"

static AVLTree atoms(true);

class Atom: public Object {
public:
uint id;
void *value;

Atom(uint i, void *v)
: id(i),
value(v)
{
}

int compareTo(const Object *obj) const
{
Atom *a = (Atom*)obj;
return id - a->id;
}

int toString(char *buf, int buflen) const
{
return ht_snprintf(buf, buflen, "[%08x, %p]\n", id, value);
}

};

void *getAtomValue(uint id)
{
if (id != invalid_atom_id) {
Atom a(id, NULL);
Atom *f = (Atom*)atoms.get(atoms.find(&a));
if (f) return f->value;
}
return NULL;
}

uint getAtomId(void *value)
{
if (value) {
foreach(Atom, a, atoms,
if (a->value == value) return a->id;
);
}
return invalid_atom_id;
}

#include "htdebug.h"

bool registerAtom(uint id, void *value)
{
Atom a(id, NULL);
if (atoms.contains(&a)) {
return false;
}
assert(value);
atoms.insert(new Atom(id, value));
return true;
}

bool unregisterAtom(uint id)
{
Atom a(id, NULL);
atoms.delObj(&a);
return true;
}

/*
* Module Init/Done
*/

bool init_atom()
{
return true;
}

void done_atom()
{
atoms.delAll();
}
32 changes: 14 additions & 18 deletions htatom.h → atom.h
@@ -1,8 +1,8 @@
/*
* HT Editor
* htatom.h
* atom.h
*
* Copyright (C) 1999-2002 Stefan Weyergraf
* Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
Expand All @@ -18,28 +18,24 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __HTATOM_H__
#define __HTATOM_H__
#ifndef __ATOM_H__
#define __ATOM_H__

#include "htdata.h"
#include "io/types.h"

typedef unsigned int HT_ATOM;
#define invalid_atom_id 0

void *find_atom(HT_ATOM atom);
HT_ATOM find_atom_rev(const void *data);
bool register_atom(HT_ATOM atom, const void *data);
bool unregister_atom(HT_ATOM atom);
void *getAtomValue(uint id);
uint getAtomId(void *value);
bool registerAtom(uint id, void *data);
bool unregisterAtom(uint id);

/*
* INIT
*/

bool init_atom();

/*
* DONE
* Module Init/Done
*/

bool init_atom();
void done_atom();

#endif /* !__HTATOM_H__ */
#endif /* !__ATOM_H__ */

142 changes: 0 additions & 142 deletions common.cc

This file was deleted.

0 comments on commit f609f9b

Please sign in to comment.