Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move string buffers from 'private to tesh' to 'public in xbt' (I'm gonna use them...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 11 Oct 2007 07:41:42 +0000 (07:41 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 11 Oct 2007 07:41:42 +0000 (07:41 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4807 48e7efb5-ca39-0410-a469-dd3cf9ba447f

13 files changed:
include/Makefile.am
include/Makefile.in
include/xbt/strbuff.h [new file with mode: 0644]
src/Makefile.am
src/Makefile.in
src/xbt/xbt_strbuff.c [moved from tools/tesh/buff.c with 67% similarity]
tools/tesh/Makefile.am
tools/tesh/Makefile.in
tools/tesh/buff.h [deleted file]
tools/tesh/run_context.c
tools/tesh/run_context.h
tools/tesh/tesh.c
tools/tesh/tesh.h

index 23c6aa9..7ad075d 100644 (file)
@@ -10,7 +10,7 @@ nobase_include_HEADERS = \
        xbt/misc.h \
        xbt/sysdep.h \
        xbt/virtu.h \
        xbt/misc.h \
        xbt/sysdep.h \
        xbt/virtu.h \
-       xbt/str.h \
+       xbt/str.h xbt/strbuff.h \
        xbt/function_types.h \
        xbt/asserts.h xbt/ex.h \
        xbt/log.h \
        xbt/function_types.h \
        xbt/asserts.h xbt/ex.h \
        xbt/log.h \
index 879c3ca..b2ede01 100644 (file)
@@ -217,7 +217,7 @@ nobase_include_HEADERS = \
        xbt/misc.h \
        xbt/sysdep.h \
        xbt/virtu.h \
        xbt/misc.h \
        xbt/sysdep.h \
        xbt/virtu.h \
-       xbt/str.h \
+       xbt/str.h xbt/strbuff.h \
        xbt/function_types.h \
        xbt/asserts.h xbt/ex.h \
        xbt/log.h \
        xbt/function_types.h \
        xbt/asserts.h xbt/ex.h \
        xbt/log.h \
diff --git a/include/xbt/strbuff.h b/include/xbt/strbuff.h
new file mode 100644 (file)
index 0000000..4a64e92
--- /dev/null
@@ -0,0 +1,36 @@
+/* $Id: buff.h 3483 2007-05-07 11:18:56Z mquinson $ */
+
+/* strbuff -- string buffers                                                */
+
+/* Copyright (c) 2007 Martin Quinson.                                       */
+/* All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef XBT_STRBUFF_H
+#define XBT_STRBUFF_H
+
+#include "portable.h"
+#include "xbt/sysdep.h"
+#include "xbt/function_types.h"
+#include "xbt/log.h"
+#include "xbt/str.h"
+
+/**
+ ** Buffer code
+ **/
+typedef struct {
+  char *data;
+  int used,size;
+} s_xbt_strbuff_t, *xbt_strbuff_t;
+
+
+XBT_PUBLIC(void)          xbt_strbuff_empty(xbt_strbuff_t b);
+XBT_PUBLIC(xbt_strbuff_t) xbt_strbuff_new(void);
+XBT_PUBLIC(void)          xbt_strbuff_free(xbt_strbuff_t b);
+XBT_PUBLIC(void)          xbt_strbuff_append(xbt_strbuff_t b, const char *toadd);
+XBT_PUBLIC(void)          xbt_strbuff_chomp(xbt_strbuff_t b);
+XBT_PUBLIC(void)          xbt_strbuff_trim(xbt_strbuff_t b);
+
+#endif
index 51157cd..2eee700 100644 (file)
@@ -120,7 +120,7 @@ VERSION_INFO= -version-info 2:0:0
 
 XBT_SRC=\
   \
 
 XBT_SRC=\
   \
-  xbt/snprintf.c    xbt/xbt_str.c                                            \
+  xbt/snprintf.c    xbt/xbt_str.c xbt/xbt_strbuff.c                          \
   xbt/ex.c                                                                   \
   \
   xbt_modinter.h    gras_modinter.h                                          \
   xbt/ex.c                                                                   \
   \
   xbt_modinter.h    gras_modinter.h                                          \
index 720535d..701da54 100644 (file)
@@ -95,13 +95,13 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
 libLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(lib_LTLIBRARIES)
 libgras_la_LIBADD =
 libLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(lib_LTLIBRARIES)
 libgras_la_LIBADD =
-am__objects_1 = snprintf.lo xbt_str.lo ex.lo xbt_virtu.lo \
-       xbt_os_time.lo asserts.lo log.lo xbt_log_appender_file.lo \
-       xbt_log_layout_simple.lo xbt_log_layout_format.lo \
-       mallocator.lo dynar.lo dict.lo dict_elm.lo dict_cursor.lo \
-       dict_multi.lo heap.lo fifo.lo swag.lo graph.lo set.lo \
-       xbt_matrix.lo xbt_queue.lo xbt_peer.lo xbt_main.lo config.lo \
-       cunit.lo graphxml_parse.lo
+am__objects_1 = snprintf.lo xbt_str.lo xbt_strbuff.lo ex.lo \
+       xbt_virtu.lo xbt_os_time.lo asserts.lo log.lo \
+       xbt_log_appender_file.lo xbt_log_layout_simple.lo \
+       xbt_log_layout_format.lo mallocator.lo dynar.lo dict.lo \
+       dict_elm.lo dict_cursor.lo dict_multi.lo heap.lo fifo.lo \
+       swag.lo graph.lo set.lo xbt_matrix.lo xbt_queue.lo xbt_peer.lo \
+       xbt_main.lo config.lo cunit.lo graphxml_parse.lo
 am__objects_2 = gras.lo transport.lo gras_msg_mod.lo gras_msg_types.lo \
        gras_msg_exchange.lo gras_msg_listener.lo rpc.lo timer.lo \
        process.lo gras_module.lo ddt_create.lo ddt_convert.lo \
 am__objects_2 = gras.lo transport.lo gras_msg_mod.lo gras_msg_types.lo \
        gras_msg_exchange.lo gras_msg_listener.lo rpc.lo timer.lo \
        process.lo gras_module.lo ddt_create.lo ddt_convert.lo \
@@ -120,9 +120,9 @@ libgras_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(libgras_la_LDFLAGS) $(LDFLAGS) -o $@
 libsimgrid_la_LIBADD =
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(libgras_la_LDFLAGS) $(LDFLAGS) -o $@
 libsimgrid_la_LIBADD =
-am__libsimgrid_la_SOURCES_DIST = xbt/snprintf.c xbt/xbt_str.c xbt/ex.c \
-       xbt_modinter.h gras_modinter.h xbt/xbt_virtu.c \
-       xbt/xbt_os_time.c xbt/asserts.c xbt/log.c \
+am__libsimgrid_la_SOURCES_DIST = xbt/snprintf.c xbt/xbt_str.c \
+       xbt/xbt_strbuff.c xbt/ex.c xbt_modinter.h gras_modinter.h \
+       xbt/xbt_virtu.c xbt/xbt_os_time.c xbt/asserts.c xbt/log.c \
        xbt/xbt_log_appender_file.c xbt/xbt_log_layout_simple.c \
        xbt/xbt_log_layout_format.c xbt/mallocator.c xbt/dynar.c \
        xbt/dict.c xbt/dict_elm.c xbt/dict_cursor.c xbt/dict_multi.c \
        xbt/xbt_log_appender_file.c xbt/xbt_log_layout_simple.c \
        xbt/xbt_log_layout_format.c xbt/mallocator.c xbt/dynar.c \
        xbt/dict.c xbt/dict_elm.c xbt/dict_cursor.c xbt/dict_multi.c \
@@ -190,8 +190,8 @@ libsimgrid_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
        $(CXXFLAGS) $(libsimgrid_la_LDFLAGS) $(LDFLAGS) -o $@
 libsimgrid4java_la_LIBADD =
 am__libsimgrid4java_la_SOURCES_DIST = xbt/snprintf.c xbt/xbt_str.c \
        $(CXXFLAGS) $(libsimgrid_la_LDFLAGS) $(LDFLAGS) -o $@
 libsimgrid4java_la_LIBADD =
 am__libsimgrid4java_la_SOURCES_DIST = xbt/snprintf.c xbt/xbt_str.c \
-       xbt/ex.c xbt_modinter.h gras_modinter.h xbt/xbt_virtu.c \
-       xbt/xbt_os_time.c xbt/asserts.c xbt/log.c \
+       xbt/xbt_strbuff.c xbt/ex.c xbt_modinter.h gras_modinter.h \
+       xbt/xbt_virtu.c xbt/xbt_os_time.c xbt/asserts.c xbt/log.c \
        xbt/xbt_log_appender_file.c xbt/xbt_log_layout_simple.c \
        xbt/xbt_log_layout_format.c xbt/mallocator.c xbt/dynar.c \
        xbt/dict.c xbt/dict_elm.c xbt/dict_cursor.c xbt/dict_multi.c \
        xbt/xbt_log_appender_file.c xbt/xbt_log_layout_simple.c \
        xbt/xbt_log_layout_format.c xbt/mallocator.c xbt/dynar.c \
        xbt/dict.c xbt/dict_elm.c xbt/dict_cursor.c xbt/dict_multi.c \
@@ -507,7 +507,7 @@ VERSION_INFO = -version-info 2:0:0
 ################################################
 XBT_SRC = \
   \
 ################################################
 XBT_SRC = \
   \
-  xbt/snprintf.c    xbt/xbt_str.c                                            \
+  xbt/snprintf.c    xbt/xbt_str.c xbt/xbt_strbuff.c                          \
   xbt/ex.c                                                                   \
   \
   xbt_modinter.h    gras_modinter.h                                          \
   xbt/ex.c                                                                   \
   \
   xbt_modinter.h    gras_modinter.h                                          \
@@ -956,6 +956,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_sg_time.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_str.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_str_unit.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_sg_time.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_str.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_str_unit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_strbuff.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_virtu.Plo@am__quote@
 
 .c.o:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbt_virtu.Plo@am__quote@
 
 .c.o:
@@ -993,6 +994,13 @@ xbt_str.lo: xbt/xbt_str.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbt_str.lo `test -f 'xbt/xbt_str.c' || echo '$(srcdir)/'`xbt/xbt_str.c
 
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbt_str.lo `test -f 'xbt/xbt_str.c' || echo '$(srcdir)/'`xbt/xbt_str.c
 
+xbt_strbuff.lo: xbt/xbt_strbuff.c
+@am__fastdepCC_TRUE@   $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbt_strbuff.lo -MD -MP -MF $(DEPDIR)/xbt_strbuff.Tpo -c -o xbt_strbuff.lo `test -f 'xbt/xbt_strbuff.c' || echo '$(srcdir)/'`xbt/xbt_strbuff.c
+@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/xbt_strbuff.Tpo $(DEPDIR)/xbt_strbuff.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='xbt/xbt_strbuff.c' object='xbt_strbuff.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbt_strbuff.lo `test -f 'xbt/xbt_strbuff.c' || echo '$(srcdir)/'`xbt/xbt_strbuff.c
+
 ex.lo: xbt/ex.c
 @am__fastdepCC_TRUE@   $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ex.lo -MD -MP -MF $(DEPDIR)/ex.Tpo -c -o ex.lo `test -f 'xbt/ex.c' || echo '$(srcdir)/'`xbt/ex.c
 @am__fastdepCC_TRUE@   mv -f $(DEPDIR)/ex.Tpo $(DEPDIR)/ex.Plo
 ex.lo: xbt/ex.c
 @am__fastdepCC_TRUE@   $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ex.lo -MD -MP -MF $(DEPDIR)/ex.Tpo -c -o ex.lo `test -f 'xbt/ex.c' || echo '$(srcdir)/'`xbt/ex.c
 @am__fastdepCC_TRUE@   mv -f $(DEPDIR)/ex.Tpo $(DEPDIR)/ex.Plo
similarity index 67%
rename from tools/tesh/buff.c
rename to src/xbt/xbt_strbuff.c
index 691d53d..12355c2 100644 (file)
@@ -1,6 +1,6 @@
-/* $Id$ */
+/* $Id: buff.c 3483 2007-05-07 11:18:56Z mquinson $ */
 
 
-/* buff -- buffers as needed by tesh                                        */
+/* strbuff -- string buffers                                                */
 
 /* Copyright (c) 2007 Martin Quinson.                                       */
 /* All rights reserved.                                                     */
 
 /* Copyright (c) 2007 Martin Quinson.                                       */
 /* All rights reserved.                                                     */
 #pragma hdrstop
 #endif
 
 #pragma hdrstop
 #endif
 
-#include "buff.h"
+#include "xbt/strbuff.h"
 
 
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(strbuff,xbt,"String buffers");
 
 /**
  ** Buffer code
  **/
 
 
 /**
  ** Buffer code
  **/
 
-void buff_empty(buff_t b) {
+void xbt_strbuff_empty(xbt_strbuff_t b) {
   b->used=0;
   b->data[0]='\n';
   b->data[1]='\0';
 }
   b->used=0;
   b->data[0]='\n';
   b->data[1]='\0';
 }
-buff_t buff_new(void) {
-  buff_t res=malloc(sizeof(s_buff_t));
+xbt_strbuff_t xbt_strbuff_new(void) {
+  xbt_strbuff_t res=malloc(sizeof(s_xbt_strbuff_t));
   res->data=malloc(512);
   res->size=512;
   res->data=malloc(512);
   res->size=512;
-  buff_empty(res);
+  xbt_strbuff_empty(res);
   return res;
 }
   return res;
 }
-void buff_free(buff_t b) {
+void xbt_strbuff_free(xbt_strbuff_t b) {
   if (b) {
     if (b->data)
       free(b->data);
     free(b);
   }
 }
   if (b) {
     if (b->data)
       free(b->data);
     free(b);
   }
 }
-void buff_append(buff_t b, const char *toadd) {
+void xbt_strbuff_append(xbt_strbuff_t b, const char *toadd) {
   int addlen;
   int needed_space;
 
   int addlen;
   int needed_space;
 
@@ -57,7 +57,7 @@ void buff_append(buff_t b, const char *toadd) {
   strcpy(b->data+b->used, toadd);
   b->used += addlen;  
 }
   strcpy(b->data+b->used, toadd);
   b->used += addlen;  
 }
-void buff_chomp(buff_t b) {
+void xbt_strbuff_chomp(xbt_strbuff_t b) {
   while (b->data[b->used] == '\n') {
     b->data[b->used] = '\0';
     if (b->used)
   while (b->data[b->used] == '\n') {
     b->data[b->used] = '\0';
     if (b->used)
@@ -65,7 +65,7 @@ void buff_chomp(buff_t b) {
   }
 }
 
   }
 }
 
-void buff_trim(buff_t b) {
+void xbt_strbuff_trim(xbt_strbuff_t b) {
   xbt_str_trim(b->data," ");
   b->used = strlen(b->data);
 }
   xbt_str_trim(b->data," ");
   b->used = strlen(b->data);
 }
index cab98ac..fdb844a 100644 (file)
@@ -11,7 +11,7 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/include -I$(top_srcdir)/s
 
 bin_PROGRAMS = tesh
 
 
 bin_PROGRAMS = tesh
 
-tesh_SOURCES = run_context.c run_context.h tesh.c tesh.h buff.h buff.c signal.c
+tesh_SOURCES = run_context.c run_context.h tesh.c tesh.h signal.c
 tesh_LDADD   = $(top_builddir)/src/libgras.la 
 
 TESTS_ENVIRONMENT=./tesh
 tesh_LDADD   = $(top_builddir)/src/libgras.la 
 
 TESTS_ENVIRONMENT=./tesh
index f2048a6..add46ff 100644 (file)
@@ -65,7 +65,7 @@ CONFIG_CLEAN_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
 am__installdirs = "$(DESTDIR)$(bindir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_tesh_OBJECTS = run_context.$(OBJEXT) tesh.$(OBJEXT) buff.$(OBJEXT) \
+am_tesh_OBJECTS = run_context.$(OBJEXT) tesh.$(OBJEXT) \
        signal.$(OBJEXT)
 tesh_OBJECTS = $(am_tesh_OBJECTS)
 tesh_DEPENDENCIES = $(top_builddir)/src/libgras.la
        signal.$(OBJEXT)
 tesh_OBJECTS = $(am_tesh_OBJECTS)
 tesh_DEPENDENCIES = $(top_builddir)/src/libgras.la
@@ -223,7 +223,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AM_CFLAGS = -g
 INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/include -I$(top_srcdir)/src
 top_srcdir = @top_srcdir@
 AM_CFLAGS = -g
 INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/include -I$(top_srcdir)/src
-tesh_SOURCES = run_context.c run_context.h tesh.c tesh.h buff.h buff.c signal.c
+tesh_SOURCES = run_context.c run_context.h tesh.c tesh.h signal.c
 tesh_LDADD = $(top_builddir)/src/libgras.la 
 TESTS_ENVIRONMENT = ./tesh
 TESTS = basic.tesh  cd.tesh \
 tesh_LDADD = $(top_builddir)/src/libgras.la 
 TESTS_ENVIRONMENT = ./tesh
 TESTS = basic.tesh  cd.tesh \
@@ -305,7 +305,6 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
 distclean-compile:
        -rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buff.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_context.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signal.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tesh.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_context.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signal.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tesh.Po@am__quote@
diff --git a/tools/tesh/buff.h b/tools/tesh/buff.h
deleted file mode 100644 (file)
index 55a2e9f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* $Id$ */
-
-/* buff -- buffers as needed by tesh                                        */
-
-/* Copyright (c) 2007 Martin Quinson.                                       */
-/* All rights reserved.                                                     */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef TESH_BUFF_H
-#define TESH_BUFF_H
-
-#include "portable.h"
-#include "xbt/sysdep.h"
-#include "xbt/function_types.h"
-#include "xbt/log.h"
-#include "xbt/str.h"
-
-/**
- ** Buffer code
- **/
-typedef struct {
-  char *data;
-  int used,size;
-} s_buff_t, *buff_t;
-
-
-void buff_empty(buff_t b);
-buff_t buff_new(void);
-void buff_free(buff_t b);
-void buff_append(buff_t b, const char *toadd);
-void buff_chomp(buff_t b);
-void buff_trim(buff_t b);
-
-#endif
index 645cae1..f9fbdae 100644 (file)
@@ -116,17 +116,17 @@ void rctx_empty(rctx_t rc) {
   rc->brokenpipe = 0;
   rc->timeout = 0;
   rc->interrupted = 0;
   rc->brokenpipe = 0;
   rc->timeout = 0;
   rc->interrupted = 0;
-  buff_empty(rc->input);
-  buff_empty(rc->output_wanted);
-  buff_empty(rc->output_got);
+  xbt_strbuff_empty(rc->input);
+  xbt_strbuff_empty(rc->output_wanted);
+  xbt_strbuff_empty(rc->output_got);
 }
 
 rctx_t rctx_new() {
   rctx_t res = xbt_new0(s_rctx_t,1);
 
 }
 
 rctx_t rctx_new() {
   rctx_t res = xbt_new0(s_rctx_t,1);
 
-  res->input=buff_new();
-  res->output_wanted=buff_new();
-  res->output_got=buff_new();
+  res->input=xbt_strbuff_new();
+  res->output_wanted=xbt_strbuff_new();
+  res->output_got=xbt_strbuff_new();
   res->interruption = xbt_os_mutex_init();
   rctx_empty(res);
   return res;
   res->interruption = xbt_os_mutex_init();
   rctx_empty(res);
   return res;
@@ -143,9 +143,9 @@ void rctx_free(rctx_t rctx) {
   if (rctx->filepos)
     free(rctx->filepos);
   xbt_os_mutex_destroy(rctx->interruption);
   if (rctx->filepos)
     free(rctx->filepos);
   xbt_os_mutex_destroy(rctx->interruption);
-  buff_free(rctx->input);
-  buff_free(rctx->output_got);
-  buff_free(rctx->output_wanted);
+  xbt_strbuff_free(rctx->input);
+  xbt_strbuff_free(rctx->output_got);
+  xbt_strbuff_free(rctx->output_wanted);
   free(rctx);
 }
 
   free(rctx);
 }
 
@@ -195,14 +195,14 @@ void rctx_pushline(const char* filepos, char kind, char *line) {
     
   case '<':
     rctx->is_empty = 0;
     
   case '<':
     rctx->is_empty = 0;
-    buff_append(rctx->input,line);
-    buff_append(rctx->input,"\n");
+    xbt_strbuff_append(rctx->input,line);
+    xbt_strbuff_append(rctx->input,"\n");
     break;
 
   case '>':
     rctx->is_empty = 0;
     break;
 
   case '>':
     rctx->is_empty = 0;
-    buff_append(rctx->output_wanted,line);
-    buff_append(rctx->output_wanted,"\n");
+    xbt_strbuff_append(rctx->output_wanted,line);
+    xbt_strbuff_append(rctx->output_wanted,"\n");
     break;
 
   case '!':
     break;
 
   case '!':
@@ -298,7 +298,7 @@ static void *thread_reader(void *r) {
     }
     if (posr>0) {
       buffout[posr]='\0';
     }
     if (posr>0) {
       buffout[posr]='\0';
-      buff_append(rctx->output_got,buffout);
+      xbt_strbuff_append(rctx->output_got,buffout);
     } else {
       usleep(100);
     }
     } else {
       usleep(100);
     }
@@ -435,10 +435,10 @@ void *rctx_wait(void* r) {
     return NULL;
     xbt_os_mutex_lock(rctx->interruption);*/
  
     return NULL;
     xbt_os_mutex_lock(rctx->interruption);*/
  
-  buff_chomp(rctx->output_got);
-  buff_chomp(rctx->output_wanted);
-  buff_trim(rctx->output_got);
-  buff_trim(rctx->output_wanted);
+  xbt_strbuff_chomp(rctx->output_got);
+  xbt_strbuff_chomp(rctx->output_wanted);
+  xbt_strbuff_trim(rctx->output_got);
+  xbt_strbuff_trim(rctx->output_wanted);
 
   /* Check for broken pipe */
   if (rctx->brokenpipe)
 
   /* Check for broken pipe */
   if (rctx->brokenpipe)
index 5704672..bc76e3b 100644 (file)
@@ -46,9 +46,9 @@ typedef struct {
   int expected_return; /* the exepeted return code of following command */
 
   /* buffers */
   int expected_return; /* the exepeted return code of following command */
 
   /* buffers */
-  buff_t input;
-  buff_t output_wanted;
-  buff_t output_got;
+  xbt_strbuff_t input;
+  xbt_strbuff_t output_wanted;
+  xbt_strbuff_t output_got;
 
   /* Threads */
   xbt_os_thread_t writer, reader; /* IO handlers */
 
   /* Threads */
   xbt_os_thread_t writer, reader; /* IO handlers */
index bfeb4c0..fa34d0b 100644 (file)
@@ -88,7 +88,7 @@ static void handle_suite(const char* filename, FILE* IN) {
   int line_num=0;
   char file_pos[256];
 
   int line_num=0;
   char file_pos[256];
 
-  buff_t buff=buff_new();
+  xbt_strbuff_t buff=xbt_strbuff_new();
   int buffbegin = 0;   
 
   rctx = rctx_new();
   int buffbegin = 0;   
 
   rctx = rctx_new();
@@ -135,12 +135,12 @@ static void handle_suite(const char* filename, FILE* IN) {
     }
 
     if (buff->used || to_be_continued) { 
     }
 
     if (buff->used || to_be_continued) { 
-      buff_append(buff,line);
+      xbt_strbuff_append(buff,line);
 
       if (!to_be_continued) {
        snprintf(file_pos,256,"%s:%d",filename,buffbegin);
        handle_line(file_pos, buff->data);    
 
       if (!to_be_continued) {
        snprintf(file_pos,256,"%s:%d",filename,buffbegin);
        handle_line(file_pos, buff->data);    
-       buff_empty(buff);
+       xbt_strbuff_empty(buff);
       }
        
     } else {
       }
        
     } else {
@@ -159,7 +159,7 @@ static void handle_suite(const char* filename, FILE* IN) {
   /* Clear buffers */
   if (line)
     free(line);
   /* Clear buffers */
   if (line)
     free(line);
-  buff_free(buff);
+  xbt_strbuff_free(buff);
 
 }
 
 
 }
 
index c0127ea..b957087 100644 (file)
@@ -12,9 +12,7 @@
 #define TESH_H
 
 #include "xbt/xbt_os_thread.h"
 #define TESH_H
 
 #include "xbt/xbt_os_thread.h"
-/*** Buffers ***/
-/***************/
-#include "buff.h"
+#include "xbt/strbuff.h"
 
 /*** What we need to know about signals ***/
 /******************************************/
 
 /*** What we need to know about signals ***/
 /******************************************/