From 069d217aaa49e9dc285a264d2dce7eeb554a84e2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 12 Sep 2009 14:54:36 -0400 Subject: I'm getting tirede of working on this --- wrapper/TODO | 14 +++++ wrapper/debug.h | 82 -------------------------- wrapper/plugin-debug.h | 101 ++++++++++++++++++++++++++++++++ wrapper/plugin-depend.h | 153 ++++++++++++++++++++++++++++++++++++++++++++++++ wrapper/plugin-find.h | 105 +++++++++++++++++++++++++++++++++ wrapper/plugin-load.h | 97 ++++++++++++++++++++++++++++++ wrapper/plugin-parse.h | 143 ++++++++++++++++++++++++++++++++++++++++++++ wrapper/plugins | 1 + wrapper/plugins.h | 112 +++++++++++++++++++++++++++++++++++ wrapper/rvs | Bin 0 -> 25759 bytes wrapper/rvs.c | 1 + wrapper/rvs.h | 15 +---- 12 files changed, 729 insertions(+), 95 deletions(-) create mode 100644 wrapper/TODO delete mode 100644 wrapper/debug.h create mode 100644 wrapper/plugin-debug.h create mode 100644 wrapper/plugin-depend.h create mode 100644 wrapper/plugin-find.h create mode 100644 wrapper/plugin-load.h create mode 100644 wrapper/plugin-parse.h create mode 120000 wrapper/plugins create mode 100644 wrapper/plugins.h create mode 100755 wrapper/rvs diff --git a/wrapper/TODO b/wrapper/TODO new file mode 100644 index 0000000..577c252 --- /dev/null +++ b/wrapper/TODO @@ -0,0 +1,14 @@ +#! /bin/more + +plugin-load.h: + The function `load_plugins' must loop through sub-directories in the + directory `libexecdir'. They way it does this is an ugly kludge, and + should be rewritten. + The way it does it requires dissproportionatly many system libraries, + all increasing the odds that it won't run on another system. This isn't + as much of a concern if it was using them, but they can't all be + nescessary: + +~ Luke Shumaker +Happy Hacking! + diff --git a/wrapper/debug.h b/wrapper/debug.h deleted file mode 100644 index 882ae11..0000000 --- a/wrapper/debug.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2009 Luke Shumaker - - This file is part of rvs. - - rvs is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your - option) any later version. - - rvs 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 rvs; see the file COPYING. - If not, write to the Free Software Foundation, - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ -#ifndef FILE_plugin_debug_c_SEEN -#define FILE_plugin_debug_c_SEEN - -#include -#include "structures.h" - -size_t -xstrlen (const char *s) -{ - printf("xstrlen(%p)\n",s); - size_t size=0; - while (s[size] != '\0') { - printf("%i = %p `%c'\n",size,&s[size],s[size]); - size++; - } - return size; -} - -void -print_tree_list (struct tree_list *node, unsigned int ind) -{ - if (node != NULL) { - unsigned int i; - for (i=0; i < ind; i++) printf(" "); - puts(node->node); - print_tree_list(node->child,ind++); - print_tree_list(node->next ,ind ); - } -} - -/* hack of the above */ - -void -_plugin_print_command (struct tree_list *command) -{ - if (command != NULL) { - struct command_plugin *node=(struct command_plugin *)command->node; - printf(" - %s\n",node->name); - if (node->depends != NULL) - printf(" depend string: %s\n",node->depends); - if (node->depend->plugin == NULL) { - puts (" depend: "); - } else { - printf(" depend: %s / %s\n", - node->depend->plugin->name, - node->depend->name); - } - _plugin_print_plugin_command(command->next); - } -} - -void -_plugin_print_plugin (struct tree_list *node) -{ - if (node != NULL ) { - puts(node->node); - _plugin_print_command(node->child,ind++); - _plugin_print_plugin(node->next ,ind ); - } -} - -#endif - diff --git a/wrapper/plugin-debug.h b/wrapper/plugin-debug.h new file mode 100644 index 0000000..d7c3541 --- /dev/null +++ b/wrapper/plugin-debug.h @@ -0,0 +1,101 @@ +/* Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs 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 rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_debug_h_SEEN +#define FILE_plugin_debug_h_SEEN + +#include +#include "rvs.h" +#include "plugins.h" + +size_t +xstrlen (const char *s) +{ + printf("xstrlen(%p)\n",s); + size_t size=0; + while (s[size] != '\0') { + printf("%i = %p `%c'\n",size,&s[size],s[size]); + size++; + } + return size; +} + +void plugin_print_ind(int ind) +{ + unsigned int i; + for (i=0; i < ind; i++) printf(" "); +} +void plugin_print_string(char *string) +{ + printf("%p",string); + if (string != NULL) + printf(" \"%s\"\n",string); + else + puts(""); +} + +void +plugin_print_command (struct plugin_command *command, int ind) +{ + plugin_print_ind(ind); + printf("pointer: %p\n",command); + if (command != NULL ) { + ind++; + plugin_print_ind(ind); + printf("name: "); + plugin_print_string(command->name); + plugin_print_ind(ind); + printf("depends: "); + plugin_print_string(command->depends); + plugin_print_ind(ind); + printf("depend: %p - ",command->depend); + if (command->depend!=NULL) + plugin_print_string(command->depend->name); + else + puts(""); + plugin_print_ind(ind); + printf("next: %p - ",command->next); + if (command->next!=NULL) + plugin_print_string(command->next->name); + else + puts(""); + } + +} + +void +plugin_print_plugin (struct plugin *plugin, int ind) +{ + plugin_print_ind(ind); + printf("pointer: %p\n",plugin); + if (plugin != NULL ) { + plugin_print_ind(ind); + if (plugin->name==NULL) + puts("noname"); + else + printf("name: %s\n",plugin->name); + plugin_print_ind(ind); + printf("commands: %p\n",plugin->commands); + plugin_print_ind(ind); + printf("next: %p\n",plugin->next); + } +} + +#endif + diff --git a/wrapper/plugin-depend.h b/wrapper/plugin-depend.h new file mode 100644 index 0000000..7dc7f29 --- /dev/null +++ b/wrapper/plugin-depend.h @@ -0,0 +1,153 @@ +/* Copyright (C) 2009 Luke Shumaker + system depends: + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs 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 rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_depend_h_SEEN +#define FILE_plugin_depend_h_SEEN + +#include +#include + +#include "rvs.h" +#include "plugin-find.h" + +/* translates a string in format `plugin/command' into a pointer to the command + DON'T plan on using the string again, it will be mutilated! + (so we go ahead and free() it and set the pointer to NULL) */ +struct plugin_command * +plugin_depend_parse (char **string, + struct plugin *plugins, + struct plugin_command *root) +{ + struct plugin_command *command=NULL; + + if (*string==NULL) + command=root; + else { + /* *string is in the format `plugin/command' */ + /* char *del=delimeter */ + char *del=strchr(*string,'/'); + del[0]='\0'; + /* *string = PLUGIN_NAME */ + /* &del[1] = COMMAND_NAME */ + struct plugin *plugin; + plugin =plugin_find_plugin(plugins, *string ); + if (plugin==NULL) + error(EXIT_FAILURE,0,"cannot find plugin `%s'",*string); + command=plugin_find_plugin_command(plugin->commands, &del[1] ); + if (command==NULL) + error(EXIT_FAILURE,0, + "plugin `%s' does not contain command `%s'", + *string,&del[1]); + xfree(*string); + *string=NULL; + } + return command; +} + +/* used by plugin_depend_add */ +void +_plugin_depend_add (struct plugin_command *prev, + struct plugin_command *next) +{ + if (prev->d_next==NULL) { + prev->d_next=next; + } else { + _plugin_depend_add(prev->d_next,next); + } +} + +/* plugin_depend_add(depend,depender) */ +void +plugin_depend_add (struct plugin_command *depend, + struct plugin_command *depender) +{ + if (depend->d_child==NULL) { + depend->d_child=depender; + } else { + _plugin_depend_add(depend->d_child,depender); + } +} + +/* take care of depends for `command' */ +void +plugin_depend_command (struct plugin_command *command, + struct plugin *plugins, + struct plugin_command *root, int ind) +{ + if (command!=NULL) { + #ifdef DEBUG + plugin_print_command(command,ind); + #endif + if (command->depend == NULL) { + /* the depend still needs to be parsed */ + command->depend=plugin_depend_parse( + &(command->depends),plugins,root); + } + plugin_depend_add(command->depend,command); + } +} + +/* take care of commands for a `plugin', and those after it (linked list) */ +void +plugin_depend_plugin_all (struct plugin *plugin, + struct plugin *plugins, + struct plugin_command *root) +{ + plugin_depend_command(plugin->commands,plugins,root,0); + if (plugin->next != NULL) { + plugin_depend_plugin_all(plugin->next,plugins,root); + } +} + +/* take care of all depends */ +struct plugin_command * +plugin_depend_all (struct plugin *plugins) +{ + struct plugin_command *root=plugin_mk_command(); + + plugin_depend_plugin_all(plugins,plugins,root); + return root; +} + +void +_plugin_depend_list (struct plugin_command_list *commands, + struct plugin *plugins, + struct plugin_command *root,int ind) +{ + if (commands!=NULL) { + #ifdef DEBUG + plugin_print_command(commands->command,ind); + printf("%p\n",commands->next); + #endif + plugin_depend_command(commands->command,plugins,root,ind++); + _plugin_depend_list(commands->next,plugins,root,ind++); + } +} + +struct plugin_command * +plugin_depend_list (struct plugin_command_list *commands, + struct plugin *plugins) +{ + struct plugin_command *root=plugin_mk_command(); + _plugin_depend_list(commands->next,plugins,root,0); + return root; +} + +#endif + diff --git a/wrapper/plugin-find.h b/wrapper/plugin-find.h new file mode 100644 index 0000000..afd2e2c --- /dev/null +++ b/wrapper/plugin-find.h @@ -0,0 +1,105 @@ +/* wrapper/plugin-find.h -- search functions for rvs plugins + system depends: + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs 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 rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_find_h_SEEN +#define FILE_plugin_find_h_SEEN + +#include /* only uses `strcmp' */ + +#include "rvs.h" +#include "plugins.h" + +/*------------------------------struct------------------------------*/ +/* a linked list of commands, for use by `plugin_find_commands' */ +struct plugin_command_list +{ + struct plugin_command *command; + struct plugin_command_list *next; +}; + +/*-----------------------------function-----------------------------*/ +/* returns first plugin with `name' (duplicates are... unwise) */ +struct plugin * +plugin_find_plugin(struct plugin *node, char *name) +{ + + if (node==NULL) + return node; + else { + if (strcmp(node->name,name) == 0) + return node; + else + return plugin_find_plugin(node->next,name); + } +} + +/* returns plugin `name within plugin `node' */ +struct plugin_command * +plugin_find_plugin_command(struct plugin_command *node, char *name) +{ + if (node==NULL) + return node; + else { + if (strcmp(node->name,name) == 0) + return node; + else + return plugin_find_plugin_command(node->next,name); + } +} + +/* returns the first command with `name' it finds */ +struct plugin_command * +plugin_find_command(struct plugin *plugin, char *name) +{ + if (plugin==NULL) + return NULL; + else { + struct plugin_command *ret; + ret=plugin_find_plugin_command(plugin->commands,name); + if (ret == NULL) + ret=plugin_find_command(plugin->next,name); + return ret; + } +} + +/* returns a linked list of all commands with `name' it finds */ +struct plugin_command_list * +plugin_find_commands(struct plugin *plugin, char *name) +{ + struct plugin_command_list *command=xmalloc( sizeof *command ); + command->command=plugin_find_command(plugin,name); + if (plugin==NULL) + command->next=NULL; + else + command->next=plugin_find_commands(plugin->next,name); + return command; +} + +#ifdef DEBUG +void +plugin_print_command_list(struct command_list *list, ind) +{ + +} +#endif /*DEBUG*/ + +#endif + diff --git a/wrapper/plugin-load.h b/wrapper/plugin-load.h new file mode 100644 index 0000000..504057c --- /dev/null +++ b/wrapper/plugin-load.h @@ -0,0 +1,97 @@ +/* wrapper/plugin-load.h -- load rvs plugins into mem + system depens: + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs 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 rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_load_h_SEEN +#define FILE_plugin_load_h_SEEN + +#include "rvs.h" +#include "plugins.h" +#include "plugin-parse.h" + +/*- plugin_load ----------------------------------------------------*\ + assume we're in rvs's libexecdir, where plugins are + now, load plugin plug_name, +\* whose configuration file is plugin_conf */ +struct plugin * +plugin_load (const char *plug_name, const char *plugin_conf) +{ + struct plugin *plugin=xmalloc( sizeof(*plugin) ); + plugin->name=stralloc(plug_name); + puts(plugin->name); + plugin->next=NULL; + + xchdir(plug_name); + FILE *file = xfopen(plugin_conf,"r"); + plugin->commands=plugin_parse(file); + fclose( file ); + xchdir(".."); + + return plugin; +} + +/*- load_plugins ---------------------------------------------------*\ + Load all the plugins in `libexecdir' + Use `plugin_conf' as the name of the config file for each plugin + Note that the method we use to loop through all the directories in + `libexecdir' is a horible kludge, uses a ton of system functions, +\* and generally needs to be rewritten. */ +#include +#include +#include +#include +#include + +struct plugin * +load_plugins (const char *libexecdir, const char *plugin_conf) +{ + struct plugin *first=NULL; /* we return this */ + struct plugin **prev=&first; /* this is the previous plugin->next */ + struct plugin *plugin; /* this is the current plugin */ + + xchdir(libexecdir); + + /* Yeah, I know this next bit is pretty ugly. */ + DIR *cwd; + struct dirent *dirent; + int serr; + struct stat sbuf; + const char *dirname="./"; + cwd = opendir (dirname); + if (cwd == NULL) error(EXIT_FAILURE,errno,"%s/",dirname); + while ( (dirent = readdir (cwd)) != NULL ) { + if ((strcmp(dirent->d_name,"." )!=0)&& + (strcmp(dirent->d_name,"..")!=0)) { + serr = stat(dirent->d_name, &sbuf); + if (!serr && S_ISDIR(sbuf.st_mode)) { + plugin=plugin_load(dirent->d_name,plugin_conf); + *prev=plugin;/* this sets the last's `next' */ + prev=&plugin->next; + } + } + } + closedir (cwd); + + xchdir(".."); + return first; +} + +#endif + diff --git a/wrapper/plugin-parse.h b/wrapper/plugin-parse.h new file mode 100644 index 0000000..c75b1fe --- /dev/null +++ b/wrapper/plugin-parse.h @@ -0,0 +1,143 @@ +/* wrapper/plugin-parse.c -- parse rvs plugin config files + system depends: + Copyright (C) 2009 Luke Shumaker + + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs 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 rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugin_parse_h_SEEN +#define FILE_plugin_parse_h_SEEN + +#include +#include /* only used in `plugin_parse_escape' for `error' */ + +#include "rvs.h" +#include "plugins.h" + +void +plugin_parse_comment (FILE *file) +{ + char c; + while ( (c=getc(file)) != EOF ) { + if ( c == '\n' ) { + ungetc (c, file); + break; + } + } +} + +char +plugin_parse_escape(FILE *file) +{ + char c=getc(file); + switch (c) { + case 'n': + c = '\n'; + case '\\': + case '#': + case ':': + break; + default: + error(EXIT_FAILURE,0,"syntax error"); + break; + } + return c; +} + +char * +plugin_parse_depend (FILE *file) +{ + size_t nbytes = 10; + char *string = (char *)xmalloc(nbytes); + string[0]='\0'; + + char c[2] = " \0"; + char *cs = (char *)&c; + while ( (c[0]=getc(file)) != EOF ) { + if (c[0] == '\n') { + ungetc (c[0], file); + break; + } else { + switch (c[0]) { + case '\\': + c[0]=plugin_parse_escape(file); + stradds(&nbytes,&string,cs); + break; + case '#': + plugin_parse_comment(file); + break; + default: + stradds(&nbytes,&string,cs); + break; + } + } + } + return string; +} + +struct plugin_command * +plugin_parse (FILE *file) +{ + struct plugin_command *command=plugin_mk_command(); + + size_t nbytes = 10; + char *string = (char *)xmalloc(nbytes); + string[0]='\0'; + + char c[2] = " \0"; + char *cs = (char *)&c; + + if ( (c[0]=getc(file)) == EOF ) + return NULL; + else + ungetc (c[0], file); + + while ( (c[0]=getc(file)) != EOF ) { + if (c[0] == '\n') { + if (strlen(string)==0) { + xfree(command); + xfree(string); + command=plugin_parse(file); + } else { + command->name=string; + command->next=plugin_parse(file); + } + break; + } else { + switch (c[0]) { + case '\\': + c[0]=plugin_parse_escape(file); + stradds(&nbytes,&string,cs); + break; + case '#': + plugin_parse_comment(file); + break; + case ':': + command->depends=plugin_parse_depend( + file); + break; + default: + stradds(&nbytes,&string,cs); + break; + } + } + } + return command; +} + +#endif + diff --git a/wrapper/plugins b/wrapper/plugins new file mode 120000 index 0000000..b1f2dbf --- /dev/null +++ b/wrapper/plugins @@ -0,0 +1 @@ +../plugins/ \ No newline at end of file diff --git a/wrapper/plugins.h b/wrapper/plugins.h new file mode 100644 index 0000000..a643715 --- /dev/null +++ b/wrapper/plugins.h @@ -0,0 +1,112 @@ +/* wrapper/plugins.h -- struct definitions and basic functions for rvs plugins + system depends: this file is truly system-independant + Copyright (C) 2009 Luke Shumaker + system depends: this file is completely system-independant + This file is part of rvs. + + rvs is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your + option) any later version. + + rvs 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 rvs; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#ifndef FILE_plugins_h_SEEN +#define FILE_plugins_h_SEEN + +#include "rvs.h" + +/* a plugin */ +/* a generic binary tree emulating a n-ary tree via linked list */ +struct plugin +{ + char *name; + struct plugin_command *commands;/* left leaf */ + struct plugin *next; /* right leaf */ +}; + +/* a single plugin command */ +struct plugin_command +{ + /* node */ + char *name; + struct plugin *plugin; /* which plugin does it belong to? */ + struct plugin_command *depend; /* what does this depend on? */ + char *depends;/* what does this depend on? (string) */ + + /* linked list */ + struct plugin_command *next; + + /* depends, linked list */ + /* for a dependancy tree, this seems like it should be a *\ + \* separate struct, but this is the simplest way. */ + struct plugin_command *d_child; + struct plugin_command *d_next; +}; + +#ifdef DEBUG +#include "plugin-debug.h" +#endif + +/* create a blank plugin_command */ +struct plugin_command * +plugin_mk_command() +{ + struct plugin_command *command; + command=(struct plugin_command *)xmalloc(sizeof(*command)); + + /* node */ + command->name=NULL; + command->plugin=NULL; + command->depend=NULL; + command->depends=NULL; + + /* linked list */ + command->next=NULL; + + /* depends */ + command->d_child=NULL; + command->d_next=NULL; + + return command; +} + +void +plugin_free_command(struct plugin_command *command) +{ + if (command!=NULL) { + #ifdef DEBUG + plugin_print_command(command,2); + #endif + plugin_free_command(command->next); + xfree(command->name); + xfree(command->depends); + xfree(command->depend); + xfree(command); + } +} + +void +plugin_free_plugin(struct plugin *plugin) +{ + if (plugin!=NULL) { + #ifdef DEBUG + plugin_print_plugin(plugin,1); + #endif + xfree(plugin->name); + plugin_free_command(plugin->commands); + plugin_free_plugin(plugin->next); + xfree(plugin); + } +} + +#endif + diff --git a/wrapper/rvs b/wrapper/rvs new file mode 100755 index 0000000..e186226 Binary files /dev/null and b/wrapper/rvs differ diff --git a/wrapper/rvs.c b/wrapper/rvs.c index 881b65f..9414475 100644 --- a/wrapper/rvs.c +++ b/wrapper/rvs.c @@ -41,6 +41,7 @@ main ( int argc, char *argv[] ) list=plugin_find_commands(plugins,argv[1]); plugin_depend_list(list,plugins); } + puts("freeing..."); plugin_free_plugin(plugins); foobar(); return 0; diff --git a/wrapper/rvs.h b/wrapper/rvs.h index bf8c1f5..008b94a 100644 --- a/wrapper/rvs.h +++ b/wrapper/rvs.h @@ -111,23 +111,12 @@ stradds(size_t *size, char **dest, char *str) strcat(*dest, str); } } -size_t -xstrlen (const char *s) -{ - printf("xstrlen(%p)\n",s); - size_t size=0; - while (s[size] != '\0') { - printf("%i = %p `%c'\n",size,&s[size],s[size]); - size++; - } - return size; -} + char * stralloc (const char *string) { - char *copy = (char *)xmalloc(xstrlen(string)+1); + char *copy = (char *)xmalloc(strlen(string)+1); strcpy(copy,string); - puts(copy); return copy; } -- cgit v1.1-4-g5e80