list.c
author viric <viriketo@gmail.com>
Sun, 20 Mar 2016 11:25:28 +0100
changeset 344 9be22a4aa695
parent 267 11631dd11ff8
permissions -rw-r--r--
Description: Respect external CFLAGS and CPPFLAGS Author: Alexander Inyukhin <shurick@sectorb.msk.ru> Forwarded: yes Last-Update: 2012-06-09
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
125
b60f173b1489 Copyright for list.c
viric@llimona
parents: 122
diff changeset
     1
/*
b60f173b1489 Copyright for list.c
viric@llimona
parents: 122
diff changeset
     2
    Task Spooler - a task queue system for the unix user
267
11631dd11ff8 Updating copyright years in the source.
viric@mandarina
parents: 259
diff changeset
     3
    Copyright (C) 2007-2009  LluĂ­s Batlle i Rossell
125
b60f173b1489 Copyright for list.c
viric@llimona
parents: 122
diff changeset
     4
b60f173b1489 Copyright for list.c
viric@llimona
parents: 122
diff changeset
     5
    Please find the license in the provided COPYING file.
b60f173b1489 Copyright for list.c
viric@llimona
parents: 122
diff changeset
     6
*/
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
     7
#include <stdio.h>
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
     8
#include <stdlib.h>
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
     9
#include <string.h>
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 125
diff changeset
    10
#include <sys/time.h>
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    11
#include "main.h"
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    12
219
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 170
diff changeset
    13
/* From jobs.c */
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 170
diff changeset
    14
extern int busy_slots;
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 170
diff changeset
    15
extern int max_slots;
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 170
diff changeset
    16
120
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    17
char * joblistdump_headers()
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    18
{
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    19
    char * line;
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    20
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    21
    line = malloc(600);
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
    22
    snprintf(line, 600, "#!/bin/sh\n# - task spooler (ts) job dump\n"
120
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    23
            "# This file has been created because a SIGTERM killed\n"
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    24
            "# your queue server.\n"
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    25
            "# The finished commands are listed first.\n"
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    26
            "# The commands running or to be run are stored as you would\n"
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    27
            "# probably run them. Take care - some quotes may have got"
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    28
            " broken\n\n");
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    29
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    30
    return line;
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    31
}
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
    32
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    33
char * joblist_headers()
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    34
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    35
    char * line;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    36
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    37
    line = malloc(100);
229
fac290a405e6 Changing the list output from [slot=x/x] to [run=x/x] to
llbatlle@taga
parents: 219
diff changeset
    38
    snprintf(line, 100, "%-4s %-10s %-20s %-8s %-14s %s [run=%i/%i]\n",
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    39
            "ID",
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    40
            "State",
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    41
            "Output",
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    42
            "E-Level",
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    43
            "Times(r/u/s)",
219
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 170
diff changeset
    44
            "Command",
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 170
diff changeset
    45
            busy_slots,
c24a1f5c1715 Adding hot-switchable amount of max_slots.
viric@mandarina
parents: 170
diff changeset
    46
            max_slots);
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    47
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    48
    return line;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    49
}
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    50
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    51
static int max(int a, int b)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    52
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    53
    if (a > b)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    54
        return a;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    55
    return b;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    56
}
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    57
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    58
static const char * ofilename_shown(const struct Job *p)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    59
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    60
    const char * output_filename;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    61
156
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
    62
    if (p->state == SKIPPED)
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
    63
    {
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
    64
        output_filename = "(no output)";
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
    65
    } else if (p->store_output)
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    66
    {
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    67
        if (p->state == QUEUED)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    68
        {
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    69
            output_filename = "(file)";
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    70
        } else
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    71
        {
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    72
            if (p->output_filename == 0)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    73
                /* This may happen due to concurrency
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    74
                 * problems */
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    75
                output_filename = "(...)";
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    76
            else
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    77
                output_filename = p->output_filename;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    78
        }
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    79
    } else
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    80
        output_filename = "stdout";
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    81
156
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
    82
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    83
    return output_filename;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    84
}
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    85
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    86
static char * print_noresult(const struct Job *p)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    87
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    88
    const char * jobstate;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    89
    const char * output_filename;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    90
    int maxlen;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    91
    char * line;
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
    92
    /* 18 chars should suffice for a string like "[int]&& " */
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
    93
    char dependstr[18] = "";
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    94
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    95
    jobstate = jstate2string(p->state);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    96
    output_filename = ofilename_shown(p);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    97
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    98
    maxlen = 4 + 1 + 10 + 1 + max(20, strlen(output_filename)) + 1 + 8 + 1
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
    99
        + 14 + 1 + strlen(p->command) + 20; /* 20 is the margin for errors */
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   100
170
dbe96af9e310 The labels where not considered in size when listing.
lbatlle@npdl268.bpo.hp.com
parents: 156
diff changeset
   101
    if (p->label)
dbe96af9e310 The labels where not considered in size when listing.
lbatlle@npdl268.bpo.hp.com
parents: 156
diff changeset
   102
        maxlen += 3 + strlen(p->label);
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   103
    if (p->do_depend)
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   104
    {
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   105
        maxlen += sizeof(dependstr);
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   106
        if (p->depend_on == -1)
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   107
            snprintf(dependstr, sizeof(dependstr), "&& ");
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   108
        else
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   109
            snprintf(dependstr, sizeof(dependstr), "[%i]&& ", p->depend_on);
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   110
    }
170
dbe96af9e310 The labels where not considered in size when listing.
lbatlle@npdl268.bpo.hp.com
parents: 156
diff changeset
   111
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   112
    line = (char *) malloc(maxlen);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   113
    if (line == NULL)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   114
        error("Malloc for %i failed.\n", maxlen);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   115
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   116
    if (p->label)
155
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 150
diff changeset
   117
        snprintf(line, maxlen, "%-4i %-10s %-20s %-8s %14s %s[%s]%s\n",
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   118
                p->jobid,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   119
                jobstate,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   120
                output_filename,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   121
                "",
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   122
                "",
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   123
		        dependstr,
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   124
                p->label,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   125
                p->command);
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   126
    else
155
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 150
diff changeset
   127
        snprintf(line, maxlen, "%-4i %-10s %-20s %-8s %14s %s%s\n",
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   128
                p->jobid,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   129
                jobstate,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   130
                output_filename,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   131
                "",
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   132
                "",
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   133
		        dependstr,
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   134
                p->command);
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   135
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   136
    return line;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   137
}
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   138
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   139
static char * print_result(const struct Job *p)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   140
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   141
    const char * jobstate;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   142
    int maxlen;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   143
    char * line;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   144
    const char * output_filename;
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   145
    /* 18 chars should suffice for a string like "[int]&& " */
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   146
    char dependstr[18] = "";
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   147
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   148
    jobstate = jstate2string(p->state);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   149
    output_filename = ofilename_shown(p);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   150
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   151
    maxlen = 4 + 1 + 10 + 1 + max(20, strlen(output_filename)) + 1 + 8 + 1
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   152
        + 14 + 1 + strlen(p->command) + 20; /* 20 is the margin for errors */
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   153
170
dbe96af9e310 The labels where not considered in size when listing.
lbatlle@npdl268.bpo.hp.com
parents: 156
diff changeset
   154
    if (p->label)
dbe96af9e310 The labels where not considered in size when listing.
lbatlle@npdl268.bpo.hp.com
parents: 156
diff changeset
   155
        maxlen += 3 + strlen(p->label);
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   156
    if (p->do_depend)
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   157
    {
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   158
        maxlen += sizeof(dependstr);
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   159
        if (p->depend_on == -1)
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   160
            snprintf(dependstr, sizeof(dependstr), "&& ");
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   161
        else
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   162
            snprintf(dependstr, sizeof(dependstr), "[%i]&& ", p->depend_on);
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   163
    }
170
dbe96af9e310 The labels where not considered in size when listing.
lbatlle@npdl268.bpo.hp.com
parents: 156
diff changeset
   164
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   165
    line = (char *) malloc(maxlen);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   166
    if (line == NULL)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   167
        error("Malloc for %i failed.\n", maxlen);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   168
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   169
    if (p->label)
155
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 150
diff changeset
   170
        snprintf(line, maxlen, "%-4i %-10s %-20s %-8i %0.2f/%0.2f/%0.2f %s[%s]"
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   171
                "%s\n",
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   172
                p->jobid,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   173
                jobstate,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   174
                output_filename,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   175
                p->result.errorlevel,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   176
                p->result.real_ms,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   177
                p->result.user_ms,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   178
                p->result.system_ms,
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   179
                dependstr,
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   180
                p->label,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   181
                p->command);
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   182
    else
155
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 150
diff changeset
   183
        snprintf(line, maxlen, "%-4i %-10s %-20s %-8i %0.2f/%0.2f/%0.2f %s%s\n",
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   184
                p->jobid,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   185
                jobstate,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   186
                output_filename,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   187
                p->result.errorlevel,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   188
                p->result.real_ms,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   189
                p->result.user_ms,
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   190
                p->result.system_ms,
259
ba3827aa8f25 Adding -D. Forward to 0.6.3.
viric@mandarina
parents: 231
diff changeset
   191
                dependstr,
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   192
                p->command);
117
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   193
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   194
    return line;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   195
}
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   196
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   197
char * joblist_line(const struct Job *p)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   198
{
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   199
    char * line;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   200
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   201
    if (p->state == FINISHED)
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   202
        line = print_result(p);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   203
    else
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   204
        line = print_noresult(p);
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   205
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   206
    return line;
db479ef293d3 Making "-l" not to trunc the commands.
viric@llimona
parents:
diff changeset
   207
}
120
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   208
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   209
char * joblistdump_torun(const struct Job *p)
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   210
{
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   211
    int maxlen;
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   212
    char * line;
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   213
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   214
    maxlen = 10 + strlen(p->command) + 20; /* 20 is the margin for errors */
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   215
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   216
    line = (char *) malloc(maxlen);
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   217
    if (line == NULL)
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   218
        error("Malloc for %i failed.\n", maxlen);
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   219
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 146
diff changeset
   220
    snprintf(line, maxlen, "ts %s\n", p->command);
120
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   221
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   222
    return line;
790bc4cecd3b Added TS_SAVELIST.
viric@llimona
parents: 117
diff changeset
   223
}