summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-12-20 21:19:55 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2014-12-20 21:19:55 +0100
commitbdb7e3800ccd7d04efb6bdb6535919c9de133541 (patch)
tree208cca87439b9ca92abd75b4042b51f17115f76f
parent6667d3c47662c03145c79aeed6ebe616a9f63f53 (diff)
downloadbiruda-bdb7e3800ccd7d04efb6bdb6535919c9de133541.tar.gz
biruda-bdb7e3800ccd7d04efb6bdb6535919c9de133541.tar.bz2
some advances in message output
-rw-r--r--src/master.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/master.c b/src/master.c
index 45aa7d3..b807e81 100644
--- a/src/master.c
+++ b/src/master.c
@@ -450,7 +450,31 @@ static int master_output_write_terminated( const char *spool_dir, const char *na
void master_output_tail( const char *name, char *s, size_t len )
{
- //~ snprintf( s, len, "messages worker '%s'..\n", name );
+ worker_t *w = worker_by_name( name );
+
+ *s = '\0';
+
+ if( w == NULL ) return;
+
+ execution_worker_data_t *wed = (execution_worker_data_t *)w->execution_data;
+
+ if( wed->spool_file == NULL ) return;
+
+ long end_pos = ftell( wed->spool_file );
+ if( len < end_pos - wed->read_pos + 3 ) {
+ wed->read_pos = end_pos - len + 3;
+ }
+ fseek( wed->spool_file, wed->read_pos, SEEK_SET );
+
+ char line[100];
+ char *cur = s;
+ char *end = s + len;
+ while( wed->read_pos < end_pos ) {
+ fgets( line, sizeof( line ), wed->spool_file );
+ cur += snprintf( cur, end - cur, "%s", line );
+ wed->read_pos += strlen( line );
+ fprintf( stderr, "%lu %lu %s", wed->read_pos, end_pos, line );
+ }
}
static void *master_func( void *thread_data )