From 224b988ba0827b5ab35c0b223e9ffdef54227ef9 Mon Sep 17 00:00:00 2001 From: deadwood Date: Mon, 10 Oct 2016 19:42:16 +0000 Subject: [PATCH] tool/toollib: drop deprecated, not used code git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@52979 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- tools/toollib/Makefile | 58 ----------- tools/toollib/callback.h | 14 --- tools/toollib/error.c | 161 ----------------------------- tools/toollib/error.h | 32 ------ tools/toollib/filesup.c | 118 --------------------- tools/toollib/filesup.h | 39 ------- tools/toollib/hash.c | 168 ------------------------------ tools/toollib/hash.h | 26 ----- tools/toollib/lineparser.c | 128 ----------------------- tools/toollib/lineparser.h | 19 ---- tools/toollib/mmakefile.src | 35 ------- tools/toollib/mystream.c | 65 ------------ tools/toollib/mystream.h | 43 -------- tools/toollib/stdiocb.c | 141 -------------------------- tools/toollib/stdiocb.h | 30 ------ tools/toollib/stringcb.c | 112 -------------------- tools/toollib/stringcb.h | 33 ------ tools/toollib/toollib.c | 176 -------------------------------- tools/toollib/toollib.h | 125 ----------------------- tools/toollib/vstring.c | 242 -------------------------------------------- tools/toollib/vstring.h | 37 ------- 21 files changed, 1802 deletions(-) delete mode 100644 tools/toollib/Makefile delete mode 100644 tools/toollib/callback.h delete mode 100644 tools/toollib/error.c delete mode 100644 tools/toollib/error.h delete mode 100644 tools/toollib/filesup.c delete mode 100644 tools/toollib/filesup.h delete mode 100644 tools/toollib/hash.c delete mode 100644 tools/toollib/hash.h delete mode 100644 tools/toollib/lineparser.c delete mode 100644 tools/toollib/lineparser.h delete mode 100644 tools/toollib/mmakefile.src delete mode 100644 tools/toollib/mystream.c delete mode 100644 tools/toollib/mystream.h delete mode 100644 tools/toollib/stdiocb.c delete mode 100644 tools/toollib/stdiocb.h delete mode 100644 tools/toollib/stringcb.c delete mode 100644 tools/toollib/stringcb.h delete mode 100644 tools/toollib/toollib.c delete mode 100644 tools/toollib/toollib.h delete mode 100644 tools/toollib/vstring.c delete mode 100644 tools/toollib/vstring.h diff --git a/tools/toollib/Makefile b/tools/toollib/Makefile deleted file mode 100644 index 40b8590770..0000000000 --- a/tools/toollib/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright © 1995-2001, The AROS Development Team. All rights reserved. -# $Id$ -# -# Desc: Make the tool library. -# -SRC = error filesup hash lineparser mystream \ - stdiocb stringcb toollib vstring - -# Include the AROS build information. This will fail if $(TOP) is not -# set, and build in the current directory. --include $(TOP)/config/make.cfg - -# If the include above doesn't work, we need some defaults. -HOST_CC ?= $(CC) -HOST_AR ?= $(AR) cru -TOOLDIR ?= . -ifneq ($(HOSTGENDIR),) -OBJDIR := $(HOSTGENDIR)/$(CURDIR) -else -OBJDIR := $(TOOLDIR)/obj -endif -MKDIR ?= mkdir -MECHO ?= echo -TOOLLIB ?= $(TOOLDIR)/libtool.a -HOST_CFLAGS := $(HOST_CFLAGS) -Wall -g -DHAVE_VSNPRINTF -I.. -O - - -DEPS := $(foreach f,$(SRC),$(OBJDIR)/$(f).d) - -all : depend $(OBJDIR) $(TOOLLIB) - -$(TOOLLIB) : $(foreach f,$(SRC),$(OBJDIR)/$(f).o) - @$(MECHO) "Creating toollib/$(notdir $@)..." - @$(HOST_AR) $@ $? - -$(OBJDIR)/%.o : %.c - @$(MECHO) "Compiling toollib/$(notdir $@)..." - @$(HOST_CC) $(HOST_CFLAGS) -o $@ -c $< - -$(OBJDIR)/%.d : %.c - @$(MECHO) Finding dependencies for $<... - @$(MKDIR) -p $(dir $@) - @$(HOST_CC) $(HOST_CFLAGS) -M $< > $@ - -$(OBJDIR) : - @$(MKDIR) $(OBJDIR) - -clean : - -@$(RM) -r $(OBJDIR) $(TOOLLIB) - @sed '/^# DO NOT DELETE$$/,$$d' Makefile > Makefile.tmp - @echo "# DO NOT DELETE" >> Makefile.tmp - @mv -f Makefile.tmp Makefile - -@$(RM) Makefile.bak - -depend : $(DEPS) - --include $(DEPS) -# DO NOT DELETE diff --git a/tools/toollib/callback.h b/tools/toollib/callback.h deleted file mode 100644 index ecd461e1e4..0000000000 --- a/tools/toollib/callback.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TOOLLIB_CALLBACK_H -#define TOOLLIB_CALLBACK_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -typedef void * CBD; -typedef int (*CB) (void * obj, const void *data, CBD); - -#define CallCB(cb,obj,cmd,data) ((*(cb))(obj,cmd,data)) - -#endif /* TOOLLIB_CALLBACK_H */ diff --git a/tools/toollib/error.c b/tools/toollib/error.c deleted file mode 100644 index e79c8037b0..0000000000 --- a/tools/toollib/error.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#include -#include -#include - -void -Error (const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - fprintf (stderr, "Error: "); - vfprintf (stderr, fmt, args); - fprintf (stderr, "\n"); - va_end (args); -} - -void -Warn (const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - fprintf (stderr, "Warning: "); - vfprintf (stderr, fmt, args); - fprintf (stderr, "\n"); - va_end (args); -} - -void -StdError (const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - fprintf (stderr, "Error: "); - vfprintf (stderr, fmt, args); - fprintf (stderr, ": %s\n", strerror (errno)); - va_end (args); -} - -void -StdWarn (const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - fprintf (stderr, "Warning: "); - vfprintf (stderr, fmt, args); - fprintf (stderr, ": %s\n", strerror (errno)); - va_end (args); -} - -static int ErrorSP = 0; -static char * ErrorStack[32]; - -void -PushMsg (const char * pre, const char * fmt, va_list args, const char * post) -{ - char buffer[256]; - int len, rest; - - strcpy (buffer, pre); - len = strlen (buffer); - strcpy (buffer+len, ": "); - len += 2; - - rest = sizeof (buffer) - len; - -#ifdef HAVE_VSNPRINTF - len = vsnprintf (buffer+len, rest, fmt, args); -#else - len = vsprintf (buffer+len, fmt, args); -#endif - - rest -= len; - - if (post) - { - len = strlen (post); - - if (rest >= 2) - { - strcat (buffer, ": "); - rest -= 2; - } - - if (len < rest) - { - strcpy (buffer + sizeof(buffer) - rest, post); - } - else - { - strncpy (buffer + sizeof(buffer) - rest, post, rest-1); - buffer[sizeof (buffer) - 1] = 0; - } - } - - ErrorStack[ErrorSP++] = xstrdup (buffer); -} - -void -PrintErrorStack (void) -{ - while (ErrorSP--) - fprintf (stderr, "%s\n", ErrorStack[ErrorSP]); - - ErrorSP = 0; -} - -void -ClearErrorStack (void) -{ - ErrorSP = 0; -} - -void -PushError (const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - PushMsg ("Error", fmt, args, NULL); - va_end (args); -} - -void -PushWarn (const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - PushMsg ("Warning", fmt, args, NULL); - va_end (args); -} - -void -PushStdError (const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - PushMsg ("Error", fmt, args, strerror (errno)); - va_end (args); -} - -void -PushStdWarn (const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - PushMsg ("Warning", fmt, args, strerror (errno)); - va_end (args); -} - -void -ErrorExit (int ec) -{ - PrintErrorStack (); - - exit (ec); -} - diff --git a/tools/toollib/error.h b/tools/toollib/error.h deleted file mode 100644 index d851098be8..0000000000 --- a/tools/toollib/error.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef TOOLLIB_ERROR_H -#define TOOLLIB_ERROR_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#ifndef TOOLLIB_TOOLLIB_H -# include -#endif - -#ifndef __GNUC__ -# define __attribute__(x) /* eps */ -#endif - -extern void Error PARAMS ((const char * fmt, ...)); -extern void Warn PARAMS ((const char * fmt, ...)); -extern void StdError PARAMS ((const char * fmt, ...)); -extern void StdWarn PARAMS ((const char * fmt, ...)); -extern void PrintErrorStack PARAMS ((void)); -extern void ClearErrorStack PARAMS ((void)); -extern void PushMsg PARAMS ((const char * pre, const char * fmt, - va_list args, const char * post)); -extern void PushError PARAMS ((const char * fmt, ...)); -extern void PushWarn PARAMS ((const char * fmt, ...)); -extern void PushStdError PARAMS ((const char * fmt, ...)); -extern void PushStdWarn PARAMS ((const char * fmt, ...)); -extern void ErrorExit PARAMS ((int ec)) __attribute__ ((noreturn)); - -#endif /* TOOLLIB_ERROR_H */ - diff --git a/tools/toollib/filesup.c b/tools/toollib/filesup.c deleted file mode 100644 index 652ba96e56..0000000000 --- a/tools/toollib/filesup.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ - - Desc: Functions to do interesting things with files. -*/ - -#include -#include -#include -#include - -#include -#include - -int filesdiffer( char *file1, char *file2 ) -{ - FILE *fd1, *fd2; - int cnt1, cnt2; - - char buffer1[1], buffer2[1]; - int retval = 0; - - /* Do our files exist? */ - fd1 = fopen(file1,"rb"); - if(!fd1) - return -1; - fd2 = fopen(file2, "rb"); - if(!fd2) - return -2; - - /* Read and compare, character by character */ - do - { - cnt1 = fread(buffer1, 1, 1, fd1); - cnt2 = fread(buffer2, 1, 1, fd2); - } while( cnt1 && cnt2 && buffer1[0] == buffer2[0] ); - - /* - If the sizes are different, then one of the files must have hit - EOF, so they differ; otherwise it depends upon the data in the - file. - */ - if(buffer1[0] != buffer2[0] || cnt1 != cnt2) - retval = 1; - - fclose(fd1); - fclose(fd2); - return retval; -} - -int moveifchanged(char *old, char *new) -{ - struct stat *statold, *statnew; - char *bakname; - - statold = calloc(1, sizeof(struct stat)); - statnew = calloc(1, sizeof(struct stat)); - - if(stat(old, statold)) - { - /* Couldn't stat old file, assume non-existant */ - return rename(new, old); - } - - if(stat(new, statnew)) - { - /* Couldn't stat() new file, this shouldn't happen */ - fprintf(stderr, "Couldn't stat() file %s\n", new); - exit(-1); - } - - /* Fill an array with the old.bak filename */ - bakname = malloc( (strlen(old) + 5) * sizeof(char) ); - sprintf( bakname, "%s.bak", old ); - - if(statold->st_size != statnew->st_size) - { - rename(old, bakname); - rename(new, old); - } - else if( filesdiffer(old, new) ) - { - rename(old, bakname); - rename(new, old); - } - else - remove(new); - - free(bakname); - return 0; -} - -int copy(char *src, char *dest) -{ - FILE *in, *out; - int count; - char buffer[1024]; - - in = fopen(src, "rb"); - if(!in) - return -1; - - out = fopen(dest, "w"); - if(!out) - return -1; - - do - { - count = fread(buffer, 1, 1024, in); - fwrite(buffer, 1, count, out); - } while( count == 1024 ); - - fclose(in); - fclose(out); - - return 0; -} diff --git a/tools/toollib/filesup.h b/tools/toollib/filesup.h deleted file mode 100644 index efcdb36230..0000000000 --- a/tools/toollib/filesup.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef TOOLLIB_FILESUP_H -#define TOOLLIB_FILESUP_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ - - Desc: Some nifty functions to help with files. -*/ - -#ifndef TOOLLIB_TOOLLIB_H -#include -#endif - -/* - Compares two files - returns: 0 for equal files, - 1 for different files, - -1 for file 1 not present, - -2 for file 2 not present. -*/ -extern int filesdiffer PARAMS(( char * file1, char * file2 )); - -/* - Compares old and new file. If the old file is not found, or - it is different from the new file, the new file will be - renamed to the name of the old file, and the old files will - be renamed to old.bak - - Returns 0 on success -*/ -extern int moveifchanged PARAMS(( char *old, char *new )); - -/* - Copy file src to file dest, returns 0 on success -*/ -extern int copy PARAMS(( char *src, char *dest )); - -#endif /* TOOLLIB_FILESUP_H */ diff --git a/tools/toollib/hash.c b/tools/toollib/hash.c deleted file mode 100644 index f9027255aa..0000000000 --- a/tools/toollib/hash.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#include -#include -#include - -typedef struct _HashNode HashNode; - -struct _HashNode -{ - HashNode * Next; - const char * key; - const void * data; -}; - -struct _Hash -{ - HashNode * Nodes[256]; -}; - -static int calchash (const char * key) -{ - int code = 0; - - while (*key) - code = (code + *key++) & 0xFF; - - return code; -} - -static int calchashNC (const char * key) -{ - int code = 0; - - while (*key) - { - code = (code + toupper(*key)) & 0xFF; - key ++; - } - - return code; -} - -Hash * Hash_New (void) -{ - Hash * hash = xmalloc (sizeof (Hash)); - memset (hash, 0, sizeof(Hash)); - return hash; -} - -void Hash_Store (Hash * hash, const char * key, const void * data) -{ - int code = calchash (key); - HashNode * node, * newNode; - - for (node=hash->Nodes[code]; node; node=node->Next) - { - if (node->key[0] == *key && !strcmp (node->key, key)) - { - node->data = data; - return; - } - } - - newNode = xmalloc (sizeof (HashNode)); - - newNode->Next = hash->Nodes[code]; - newNode->key = key; - newNode->data = data; - - hash->Nodes[code] = newNode; -} - -void Hash_StoreNC (Hash * hash, const char * key, const void * data) -{ - int code = calchashNC (key); - HashNode * node, * newNode; - - for (node=hash->Nodes[code]; node; node=node->Next) - { - if (node->key[0] == *key && !strcmp (node->key, key)) - { - node->data = data; - return; - } - } - - newNode = xmalloc (sizeof (HashNode)); - - newNode->Next = hash->Nodes[code]; - newNode->key = key; - newNode->data = data; - - hash->Nodes[code] = newNode; -} - -void * Hash_Find (Hash * hash, const char * key) -{ - int code = calchash (key); - HashNode * node; - - for (node=hash->Nodes[code]; node; node=node->Next) - { - if (node->key[0] == *key && !strcmp (node->key, key)) - { - return ((void *)node->data); - } - } - - return NULL; -} - -void * Hash_FindNC (Hash * hash, const char * key) -{ - int code = calchashNC (key); - HashNode * node; - - for (node=hash->Nodes[code]; node; node=node->Next) - { - if (node->key[0] == *key && !strcmp (node->key, key)) - { - return ((void *)node->data); - } - } - - return NULL; -} - -void Hash_Traverse (Hash * hash, CB tp, CBD userdata) -{ - int t; - HashNode * node; - - for (t=0; t<256; t++) - { - for (node=hash->Nodes[t]; node; node=node->Next) - { - CallCB (tp, (void *)node->key, node->data, userdata); - } - } - - xfree (hash); -} - -void Hash_Delete (Hash * hash, CB dnp, CBD userdata) -{ - int t; - HashNode * node, * next; - - for (t=0; t<256; t++) - { - for (next=hash->Nodes[t]; (node=next); ) - { - next=next->Next; - - if (dnp) - CallCB (dnp, (void *)node->key, node->data, userdata); - - xfree (node); - } - } - - xfree (hash); -} diff --git a/tools/toollib/hash.h b/tools/toollib/hash.h deleted file mode 100644 index 871911b96f..0000000000 --- a/tools/toollib/hash.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef TOOLLIB_HASH_H -#define TOOLLIB_HASH_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#ifndef TOOLLIB_TOOLLIB_H -# include -#endif -#ifndef TOOLLIB_CALLBACK_H -# include -#endif - -typedef struct _Hash Hash; - -Hash * Hash_New (void); -void Hash_Delete (Hash *, CB delNode, CBD userdata); -void Hash_Store (Hash *, const char * key, const void * data); -void Hash_StoreNC (Hash *, const char * key, const void * data); -void * Hash_Find (Hash *, const char * key); -void * Hash_FindNC (Hash *, const char * key); -void Hash_Traverse (Hash *, CB traverseProc, CBD userdata); - -#endif /* TOOLLIB_HASH_H */ diff --git a/tools/toollib/lineparser.c b/tools/toollib/lineparser.c deleted file mode 100644 index d34a394d97..0000000000 --- a/tools/toollib/lineparser.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ - - Desc: A very simple line parser. Basically from archtool.c -*/ - -#include -#include -#include -#include - -#include - -char *get_line(FILE *fd) -{ - int count, len; - char *line; - char buffer; - - len = 0; - do - { - count = fread(&buffer, 1, 1, fd); - len += count; - } while(count != 0 && buffer != '\n'); - - if(len == 0 && count == 0) - return NULL; - - fseek(fd, -len, SEEK_CUR); - line = malloc( (len+1) * sizeof(char) ); - count = fread(line, 1, len, fd); - if (count != len) { - free(line); - return NULL; - } - line[len] = 0; - len--; - - while(isspace(line[len]) && len >= 0) - { - line[len] = 0; - len--; - } - - return line; -} - -char *keyword(char *line) -{ - char *key = NULL; - int len; - - if(line[0] == '#') - { - len = 1; - while(line[len] && !isspace(line[len])) - len++; - - key = malloc(len * sizeof(char)); - strncpy(key, &line[1], len - 1); - key[len - 1] = 0; - } - return key; -} - -int get_words(char *line, char ***outarray) -{ - char **array; - char *word; - int num, len; - - /* Make sure that we have valid input */ - if(!outarray || !line) - { - fprintf(stderr, "Passed NULL pointer to get_words()!\n"); - exit(-1); - } - - /* Free the old array */ - array = *outarray; - if(array) - { - while(*array) - { - free(*array); - array++; - } - free(*outarray); - } - array = NULL; - - /* Now scan the list of words */ - num = 0; - word = line; - while(*word != 0) - { - /* Find the start of this word */ - while(*word && isspace(*word) ) - word++; - - /* Find the end of this word */ - len = 0; - while( word[len] && !isspace(word[len]) ) - len++; - - /* - Copy this word into the array, making the array larger - in order to fit the pointer to the string. - */ - if(len) - { - num++; - array = realloc(array, num * sizeof(char *)); - array[num-1] = malloc((len+1) * sizeof(char)); - strncpy( array[num-1], word, len); - array[num-1][len] = 0; - word = &word[len]; - } - } - - array = realloc(array, (num+1) * sizeof(char *) ); - array[num] = NULL; - - *outarray = array; - return num; -} diff --git a/tools/toollib/lineparser.h b/tools/toollib/lineparser.h deleted file mode 100644 index 0247bca7aa..0000000000 --- a/tools/toollib/lineparser.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef TOOLLIB_LINEPARSER_H -#define TOOLLIB_LINEPARSER_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ - - Desc: Header for the simple line parser -*/ - -#ifndef TOOLLIB_TOOLLIB_H -#include -#endif - -extern char * get_line PARAMS((FILE *fd)); -extern char *keyword PARAMS((char *line)); -extern int get_words PARAMS((char *line, char ***outarray)); - -#endif /* TOOLLIB_LINEPARSER_H */ diff --git a/tools/toollib/mmakefile.src b/tools/toollib/mmakefile.src deleted file mode 100644 index 0d87bf2e49..0000000000 --- a/tools/toollib/mmakefile.src +++ /dev/null @@ -1,35 +0,0 @@ -include $(SRCDIR)/config/aros.cfg - -HFILES := \ - callback.h \ - error.h \ - filesup.h \ - hash.h \ - lineparser.h \ - mystream.h \ - stdiocb.h \ - stringcb.h \ - toollib.h \ - vstring.h - -FILES := \ - error \ - filesup \ - hash \ - lineparser \ - mystream \ - stdiocb \ - stringcb \ - toollib \ - vstring - -#MM- linklibs : linklibs-toollib -#MM linklibs-toollib : includes - -%build_linklib mmake=linklibs-toollib libname=toollib files=$(FILES) - -#MM -includes-copy : - %copy_includes includes=$(HFILES) path=toollib - -%common diff --git a/tools/toollib/mystream.c b/tools/toollib/mystream.c deleted file mode 100644 index 7f980f094b..0000000000 --- a/tools/toollib/mystream.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#include -#include - -int -Str_Init (MyStream * ms, const char * name) -{ - memset (ms, 0, sizeof (MyStream)); - - ms->line = 1; - ms->name = xstrdup (name); - - return 1; -} - -void -Str_Delete (MyStream * ms) -{ - xfree (ms->name); -} - -int -Str_Puts (MyStream * ms, const char * str, CBD data) -{ - int c; - - if (ms->puts) - c = CallCB (ms->puts, ms, str, data); - else - { - c = 0; - - while (*str && (c = Str_Put(ms,NULL + *str,data)) > 0) - str ++; - } - - return c; -} - -void -Str_PushError (MyStream * ms, const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - PushMsg (" ", fmt, args, NULL); - va_end (args); - PushError ("in %s:%d:", Str_GetName(ms), Str_GetLine(ms)); -} - -void -Str_PushWarn (MyStream * ms, const char * fmt, ...) -{ - va_list args; - VA_START (args, fmt); - PushMsg (" ", fmt, args, NULL); - va_end (args); - PushWarn ("in %s:%d:", Str_GetName(ms), Str_GetLine(ms)); -} - - diff --git a/tools/toollib/mystream.h b/tools/toollib/mystream.h deleted file mode 100644 index 0a63bc776f..0000000000 --- a/tools/toollib/mystream.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef TOOLLIB_MYSTREAM_H -#define TOOLLIB_MYSTREAM_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#ifndef TOOLLIB_TOOLLIB_H -# include -#endif -#ifndef TOOLLIB_CALLBACK_H -# include -#endif - -typedef struct -{ - CB get; - CB unget; - CB put; - CB puts; - char * name; - int line; -} -MyStream; - -#define Str_Get(str,d) CallCB(((MyStream *)str)->get, str, 0, d) -#define Str_Unget(str,c,d) CallCB(((MyStream *)str)->unget, str, c, d) -#define Str_Put(str,c,d) CallCB(((MyStream *)str)->put, str, c, d) - -#define Str_GetName(str) (((MyStream *)str)->name) -#define Str_GetLine(str) (((MyStream *)str)->line) -#define Str_SetLine(str,l) ((((MyStream *)str)->line) = (l)) -#define Str_NextLine(str) (((MyStream *)str)->line ++) - -extern int Str_Init PARAMS ((MyStream * ms, const char * name)); -extern void Str_Delete PARAMS ((MyStream * ms)); -extern int Str_Puts PARAMS ((MyStream * ms, const char * str, CBD data)); -extern void Str_PushError PARAMS ((MyStream * ms, const char * fmt, ...)); -extern void Str_PushWarn PARAMS ((MyStream * ms, const char * fmt, ...)); - -#endif /* TOOLLIB_MYSTREAM_H */ diff --git a/tools/toollib/stdiocb.c b/tools/toollib/stdiocb.c deleted file mode 100644 index 01cf1562b1..0000000000 --- a/tools/toollib/stdiocb.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#include -#include -#include - -static int -StdioGetCB (StdioStream * ss, int dummy, CBD data) -{ - if (ss->in) - { - int c = getc (ss->in); - - if (c == '\n') - Str_NextLine (ss); - - return c; - } - - errno = EINVAL; - return -1; -} - -static int -StdioUngetCB (StdioStream * ss, int c, CBD data) -{ - if (ss->in) - return ungetc (c, ss->in); - - errno = EINVAL; - return -1; -} - -static int -StdioPutCB (StdioStream * ss, int c, CBD data) -{ - if (ss->out) - return putc (c, ss->out); - - errno = EINVAL; - return -1; -} - -static int -StdioPutsCB (StdioStream * ss, const char * str, CBD data) -{ - if (ss->out) - return fputs (str, ss->out); - - errno = EINVAL; - return -1; -} - -StdioStream * -StdStr_New (const char * path, const char * mode) -{ - StdioStream * ss = new (StdioStream); - FILE * fh = NULL; - - if (strcmp (path, "-")) - { - fh = fopen (path, mode); - - if (!fh) - { - PushStdError ("Can't open \"%s\" with mode \"%s\"\n", path, mode); - return NULL; - } - } - - Str_Init (&ss->stream, path); - - ss->stream.get = (CB) StdioGetCB; - ss->stream.unget = (CB) StdioUngetCB; - ss->stream.put = (CB) StdioPutCB; - ss->stream.puts = (CB) StdioPutsCB; - - if (strchr (mode, 'r')) - { - if (strcmp (path, "-")) - { - ss->in = fh; - ss->closein = 1; - } - else - { - ss->in = stdin; - ss->closein = 0; - } - } - else - { - ss->in = NULL; - ss->closein = 0; - } - - if (strchr (mode, 'w') || strchr (mode, 'a')) - { - if (strcmp (path, "-")) - { - ss->out = fh; - ss->closeout = 1; - } - else - { - ss->out = stdout; - ss->closeout = 0; - } - } - else - { - ss->out = NULL; - ss->closeout = 0; - } - - if (ss->in && ss->out) - { - ss->closeout = 0; - } - - return ss; -} - -void -StdStr_Delete (StdioStream * ss) -{ - if (ss->closein) - fclose (ss->in); - - if (ss->closeout) - fclose (ss->out); - - Str_Delete (&ss->stream); - - xfree (ss); -} - diff --git a/tools/toollib/stdiocb.h b/tools/toollib/stdiocb.h deleted file mode 100644 index 19dae375bc..0000000000 --- a/tools/toollib/stdiocb.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef TOOLLIB_STDIOCB_H -#define TOOLLIB_STDIOCB_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#ifndef TOOLLIB_TOOLLIB_H -# include -#endif -#ifndef TOOLLIB_MYSTREAM_H -# include -#endif - -typedef struct -{ - MyStream stream; - - FILE * in; - FILE * out; - int closein, closeout; -} -StdioStream; - -extern StdioStream * StdStr_New PARAMS ((const char * path, const char * mode)); -extern void StdStr_Delete PARAMS ((StdioStream *)); - -#endif /* TOOLLIB_STDIOCB_H */ diff --git a/tools/toollib/stringcb.c b/tools/toollib/stringcb.c deleted file mode 100644 index 490dea1e04..0000000000 --- a/tools/toollib/stringcb.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#include -#include -#include - -static int -StringGetCB (StringStream * ss, int dummy, CBD data) -{ - int c; - - if (ss->pos == ss->max) - { - errno = 0; - c = -1; - } - else - c = ss->string[ss->pos++]; - - if (c == '\n') - Str_NextLine (ss); - - return c; -} - -static int -StringUngetCB (StringStream * ss, int c, CBD data) -{ - if (!ss->pos) - { - errno = EINVAL; - c = -2; - } - else if (c != -1) - { - ss->pos --; - - if (c != ss->string[ss->pos]) - { - errno = EINVAL; - c = -2; - } - } - else /* EOF */ - { - if (ss->pos != ss->max) - { - errno = EINVAL; - c = -2; - } - } - - return c; -} - -static int -StringPutCB (StringStream * ss, int c, CBD data) -{ - if (!ss->out) - ss->out = VS_New (NULL); - - VS_AppendChar (ss->out, c); - - return c; -} - -static int -StringPutsCB (StringStream * ss, const char * str, CBD data) -{ - if (!ss->out) - ss->out = VS_New (NULL); - - VS_AppendString (ss->out, str); - - return 1; -} - -StringStream * -StrStr_New (const char * string) -{ - StringStream * ss = new (StringStream); - - Str_Init (&ss->stream, "string"); - - ss->stream.get = (CB) StringGetCB; - ss->stream.unget = (CB) StringUngetCB; - ss->stream.put = (CB) StringPutCB; - ss->stream.puts = (CB) StringPutsCB; - - ss->string = string; - ss->out = NULL; - ss->pos = 0; - ss->max = strlen (string); - - return ss; -} - -void -StrStr_Delete (StringStream * ss) -{ - if (ss->out) - VS_Delete (ss->out); - - Str_Delete (&ss->stream); - - xfree (ss); -} - diff --git a/tools/toollib/stringcb.h b/tools/toollib/stringcb.h deleted file mode 100644 index 7cb334ae5c..0000000000 --- a/tools/toollib/stringcb.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef TOOLLIB_STRINGCB_H -#define TOOLLIB_STRINGCB_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#ifndef TOOLLIB_TOOLLIB_H -# include -#endif -#ifndef TOOLLIB_MYSTREAM_H -# include -#endif -#ifndef TOOLLIB_VSTRING_H -# include -#endif - -typedef struct -{ - MyStream stream; - const char * string; - String out; - int pos, - max, - line; -} -StringStream; - -extern StringStream * StrStr_New PARAMS ((const char * string)); -extern void StrStr_Delete PARAMS ((StringStream *)); - -#endif /* TOOLLIB_STRINGCB_H */ diff --git a/tools/toollib/toollib.c b/tools/toollib/toollib.c deleted file mode 100644 index d13069c9e1..0000000000 --- a/tools/toollib/toollib.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ -#include -#include -#include -#include -#include -#include - -int verbose; - -/* Functions */ -char * -_xstrdup (const char * str, const char * file, int line) -{ - char * nstr; - - assert (str); - - nstr = strdup (str); - - if (!nstr) - { - fprintf (stderr, "Out of memory in %s:%d", file, line); - exit (20); - } - - return nstr; -} - -void * -_xmalloc (size_t size, const char * file, int line) -{ - void * ptr; - - ptr = malloc (size); - - if (size && !ptr) - { - fprintf (stderr, "Out of memory in %s:%d", file, line); - exit (20); - } - - return ptr; -} - -void * -_xrealloc (void * optr, size_t size, const char * file, int line) -{ - void * ptr; - - ptr = realloc (optr, size); - - if (size && !ptr) - { - fprintf (stderr, "Out of memory in %s:%d", file, line); - exit (20); - } - - return ptr; -} - -void -_xfree (void * ptr, const char * file, int line) -{ - if (ptr) - free (ptr); - else - fprintf (stderr, "Illegal free(NULL) in %s:%d", file, line); -} - -void * -_xcalloc (size_t number, size_t size, const char * file, int line) -{ - void * ptr; - - ptr = calloc (number, size); - - if (size && !ptr) - { - fprintf (stderr, "Out of memory in %s:%d", file, line); - exit (20); - } - - return ptr; -} - -Node * -FindNode (const List * l, const char * name) -{ - Node * n; - - ForeachNode (l, n) - { - if (!strcmp (n->name, name)) - return n; - } - - return NULL; -} - -Node * -FindNodeNC (const List * l, const char * name) -{ - Node * n; - - ForeachNode (l, n) - { - if (!strcasecmp (n->name, name)) - return n; - } - - return NULL; -} - -void -printlist (const List * l) -{ - Node * n; - - ForeachNode (l,n) - { - printf (" \"%s\"\n", n->name); - } -} - -int -execute (const char * cmd, const char * args, - const char * in, const char * out) -{ - char buffer[4096]; - int rc; - - strcpy (buffer, cmd); - strcat (buffer, " "); - - if (strcmp (in, "-")) - { - strcat (buffer, "<"); - strcat (buffer, in); - strcat (buffer, " "); - } - - if (strcmp (out, "-")) - { - strcat (buffer, ">"); - strcat (buffer, out); - strcat (buffer, " "); - } - - strcat (buffer, args); - - if (verbose) - printf ("Executing %s...\n", buffer); - - rc = system (buffer); - - if (rc) - { - printf ("%s failed: %d\n", buffer, rc); - } - - return !rc; -} - -Node * -RemHead (List * l) -{ - Node * node = GetHead (l); - - Remove (node); - - return node; -} diff --git a/tools/toollib/toollib.h b/tools/toollib/toollib.h deleted file mode 100644 index af0dfe67cd..0000000000 --- a/tools/toollib/toollib.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef TOOLLIB_TOOLLIB_H -#define TOOLLIB_TOOLLIB_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include - -/* Do we have ? */ -#ifndef HAVE_STDARG_H -# define HAVE_STDARG_H -#endif - -#ifndef PROTOTYPES -# ifdef __STDC__ -# define PROTOTYPES -# endif -#endif - -#ifdef PROTOTYPES -# define PARAMS(x) x -#else -# define PARAMS(x) () -#endif /* PROTOTYPES */ - -#if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__ -# include -# define VA_START(args, lastarg) va_start(args, lastarg) -#else -# include -# define VA_START(args, lastarg) va_start(args) -#endif - -#include - -/* Types */ -typedef struct _Node Node; - -struct _Node -{ - Node * next, - * prev; - char * name; -}; - -typedef struct -{ - Node * first, - * last, - * prelast; -} -List; - -/* Macros */ -# define IsListEmpty(l) (((List *)l)->prelast == (Node *)(l)) -# define NewList(l) (((List *)l)->prelast = (Node *)(l), \ - ((List *)l)->last = 0, \ - ((List *)l)->first = (Node *)&(((List *)l)->last)) - -# define AddHead(l,n) ((void)(\ - ((Node *)n)->next = ((List *)l)->first, \ - ((Node *)n)->prev = (Node *)&((List *)l)->first, \ - ((List *)l)->first->prev = ((Node *)n), \ - ((List *)l)->first = ((Node *)n))) - -# define AddTail(l,n) ((void)(\ - ((Node *)n)->next = (Node *)&((List *)l)->last, \ - ((Node *)n)->prev = ((List *)l)->prelast, \ - ((List *)l)->prelast->next = ((Node *)n), \ - ((List *)l)->prelast = ((Node *)n) )) - -# define Remove(n) ((void)(\ - ((Node *)n)->prev->next = ((Node *)n)->next,\ - ((Node *)n)->next->prev = ((Node *)n)->prev )) - -# define GetHead(l) (void *)(((List *)l)->first->next \ - ? ((List *)l)->first \ - : (Node *)0) -# define GetTail(l) (void *)(((List *)l)->prelast->prev \ - ? ((List *)l)->prelast \ - : (Node *)0) -# define GetNext(n) (void *)(((Node *)n)->next->next \ - ? ((Node *)n)->next \ - : (Node *)0) -# define GetPrev(n) (void *)(((Node *)n)->prev->prev \ - ? ((Node *)n)->prev \ - : (Node *)0) -# define ForeachNode(l,n) \ - for (n=(void *)(((List *)(l))->first); \ - ((Node *)(n))->next; \ - n=(void *)(((Node *)(n))->next)) -# define ForeachNodeSafe(l,node,nextnode) \ - for (node=(void *)(((List *)(l))->first); \ - ((nextnode)=(void*)((Node *)(node))->next); \ - (node)=(void *)(nextnode)) - -#define cfree(x) if (x) free (x) -#define cstrdup(x) ((x) ? xstrdup (x) : NULL) -#define setstr(str,val) cfree (str); \ - str = cstrdup (val) -#define xstrdup(str) _xstrdup(str,__FILE__,__LINE__) -#define xmalloc(size) _xmalloc(size,__FILE__,__LINE__) -#define xrealloc(ptr,size) _xrealloc(ptr,size,__FILE__,__LINE__) -#define xfree(ptr) _xfree(ptr,__FILE__,__LINE__) -#define new(type) (type *)xmalloc(sizeof(type)) -#define ALIGN(x,y) ((x + (y-1)) & (-(y))) -#define hexval(c) (((c) > '9') ? (c) - 'a' + 10 : (c) - '0') -#define xcalloc(cnt,size) _xcalloc(cnt,size,__FILE__,__LINE__) - -/* Prototypes */ -extern int execute PARAMS ((const char * cmd, const char * args, - const char * in, const char * out)); -extern char * _xstrdup PARAMS ((const char * str, const char * file, int line)); -extern void * _xmalloc PARAMS ((size_t size, const char * file, int line)); -extern void * _xrealloc PARAMS ((void * ptr, size_t size, const char * file, int line)); -extern void _xfree PARAMS ((void * ptr, const char * file, int line)); -extern void * _xcalloc PARAMS ((size_t cnt, size_t size, const char * file, int line)); -extern Node * FindNode PARAMS ((const List * l, const char * name)); -extern Node * FindNodeNC PARAMS ((const List * l, const char * name)); -extern void printlist PARAMS ((const List * l)); -extern Node * RemHead PARAMS ((List * l)); - -#endif /* TOOLLIB_TOOLLIB_H */ diff --git a/tools/toollib/vstring.c b/tools/toollib/vstring.c deleted file mode 100644 index 7102ba6d8e..0000000000 --- a/tools/toollib/vstring.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#include -#include - -String -VS_New (const char * ini) -{ - String str = new (struct _String); - - if (ini && *ini) - { - int len = strlen (ini) + 1; - - str->maxlen = ALIGN(len,8); - str->buffer = xmalloc (str->maxlen); - str->len = len; - - strcpy (str->buffer, ini); - } - else - { - str->maxlen = 32; - str->buffer = xmalloc (str->maxlen); - str->len = 0; - - str->buffer[0] = 0; - } - - return str; -} - -void -VS_Delete (String str) -{ - cfree (str->buffer); - xfree (str); -} - -void -VS_Clear (String str) -{ - str->len = 0; -} - -void -VS_AppendChar (String str, int c) -{ - if (str->len + 2 >= str->maxlen) - { - str->maxlen += 32; - - str->buffer = xrealloc (str->buffer, str->maxlen); - } - - str->buffer[str->len ++] = c; - str->buffer[str->len] = 0; -} - -void -VS_AppendString (String str, const char * app) -{ - int len = strlen (app); - - if (str->len + len + 1 >= str->maxlen) - { - str->maxlen = ALIGN(str->len+len+1,8); - - str->buffer = xrealloc (str->buffer, str->maxlen); - } - - strcpy (str->buffer + str->len, app); - str->len += len; -} - -void -VS_ToUpper (String str) -{ - int t; - - for (t=0; tlen; t++) - str->buffer[t] = toupper (str->buffer[t]); -} - -void -VS_ToLower (String str) -{ - int t; - - for (t=0; tlen; t++) - str->buffer[t] = tolower (str->buffer[t]); -} - -String -VS_SubString (const char * str, int begin, int len) -{ - int n; - String nstr; - - n = strlen (str); - - if (begin >= n) - return VS_New (NULL); - - if (len == -1) - n -= begin; - else - { - if (begin+len > n) - n -= begin; - else - n = len; - } - - nstr = new (struct _String); - - nstr->maxlen = ALIGN(n+1,8); - nstr->buffer = xmalloc (nstr->maxlen); - nstr->len = n; - - strncpy (nstr->buffer, str + begin, n); - nstr->buffer[n] = 0; - - return nstr; -} - -char * -strdupsub (const char * str, int begin, int len) -{ - char * nstr; - int n; - - if (!str) - return NULL; - - n = strlen (str); - - if (begin >= n || len <= 0) - return strdup (""); - - if (begin+len > n) - n -= begin; - else - n = len; - - nstr = xmalloc (n+1); - - strncpy (nstr, str + begin, n); - nstr[n] = 0; - - return nstr; -} - -char * -stripquotes (const char * str) -{ - int begin; - int len; - - if (*str == '"') - { - begin = 1; - - len = strlen (str + begin); - - if (str[len] == '"') - len --; - - if (len <= 0) - len = -1; - - return strdupsub (str, begin, len); - } - - return xstrdup (str); -} - -char * -stripws (const char * str) -{ - int begin; - int len; - - for (begin=0; isspace (str[begin]); begin++); - - len = strlen (str + begin); - - for (len--; len > 0 && isspace (str[begin + len]); len --); - - len ++; - - return strdupsub (str, begin, len); -} - -char * -stripwsq (const char * str) -{ - int begin; - int len; - - for (begin=0; isspace (str[begin]); begin++); - - if (str[begin] == '"') - begin ++; - - len = strlen (str + begin); - - for (len--; len > 0 && isspace (str[begin + len]); len --); - - if (str[begin + len] == '"') - len --; - - len ++; - - return strdupsub (str, begin, len); -} - -char * -strupper (char * str) -{ - char * ptr; - - for (ptr=str; *ptr; ptr++) - *ptr = toupper (*ptr); - - return str; -} - -char * -strlower (char * str) -{ - char *ptr; - - for (ptr=str; *ptr; ptr++) - *ptr = tolower (*ptr); - - return str; -} diff --git a/tools/toollib/vstring.h b/tools/toollib/vstring.h deleted file mode 100644 index 8b649247dc..0000000000 --- a/tools/toollib/vstring.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef TOOLLIB_VSTRING_H -#define TOOLLIB_VSTRING_H - -/* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#ifndef TOOLLIB_TOOLLIB_H -# include -#endif - -typedef struct _String -{ - char * buffer; - int len; - int maxlen; -} -* String; - -extern String VS_New PARAMS ((const char * str)); -extern void VS_Delete PARAMS ((String str)); -extern void VS_Clear PARAMS ((String str)); -extern void VS_AppendChar PARAMS ((String str, int c)); -extern void VS_AppendString PARAMS ((String str, const char * app)); -extern void VS_ToUpper PARAMS ((String str)); -extern void VS_ToLower PARAMS ((String str)); -extern String VS_SubString PARAMS ((const char * str, int begin, int len)); - -extern char * strdupsub PARAMS((const char * str, int begin, int len)); -extern char * stripquotes PARAMS((const char * str)); -extern char * stripws PARAMS((const char * str)); -extern char * stripwsq PARAMS((const char * str)); -extern char * strupper PARAMS((char * str)); -extern char * strlower PARAMS((char * str)); - -#endif /* TOOLLIB_VSTRING_H */ -- 2.11.4.GIT