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/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 \
--- /dev/null
+/* $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
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 \
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 \
$(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 \
$(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_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 \
@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__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
-/* $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. */
#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
**/
-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';
}
-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;
- buff_empty(res);
+ xbt_strbuff_empty(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);
}
}
-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;
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)
}
}
-void buff_trim(buff_t b) {
+void xbt_strbuff_trim(xbt_strbuff_t b) {
xbt_str_trim(b->data," ");
b->used = strlen(b->data);
}
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
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
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 \
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@
+++ /dev/null
-/* $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
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);
- 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;
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);
}
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;
- 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 '!':
}
if (posr>0) {
buffout[posr]='\0';
- buff_append(rctx->output_got,buffout);
+ xbt_strbuff_append(rctx->output_got,buffout);
} else {
usleep(100);
}
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)
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 */
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();
}
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);
- buff_empty(buff);
+ xbt_strbuff_empty(buff);
}
} else {
/* Clear buffers */
if (line)
free(line);
- buff_free(buff);
+ xbt_strbuff_free(buff);
}
#define TESH_H
#include "xbt/xbt_os_thread.h"
-/*** Buffers ***/
-/***************/
-#include "buff.h"
+#include "xbt/strbuff.h"
/*** What we need to know about signals ***/
/******************************************/