client.c
author viric@llimona
Sat, 09 Feb 2008 11:56:03 +0100
changeset 196 bca29e2a1a86
parent 180 a35159b7009a
child 203 664044b1de73
permissions -rw-r--r--
Fixing a bug related to a message on -t on last job, when it was skipped.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
09bb8a5583e9 Added the license.
lbatlle@npdl268.bpo.hp.com
parents: 44
diff changeset
     1
/*
09bb8a5583e9 Added the license.
lbatlle@npdl268.bpo.hp.com
parents: 44
diff changeset
     2
    Task Spooler - a task queue system for the unix user
09bb8a5583e9 Added the license.
lbatlle@npdl268.bpo.hp.com
parents: 44
diff changeset
     3
    Copyright (C) 2007  LluĂ­s Batlle i Rossell
09bb8a5583e9 Added the license.
lbatlle@npdl268.bpo.hp.com
parents: 44
diff changeset
     4
09bb8a5583e9 Added the license.
lbatlle@npdl268.bpo.hp.com
parents: 44
diff changeset
     5
    Please find the license in the provided COPYING file.
09bb8a5583e9 Added the license.
lbatlle@npdl268.bpo.hp.com
parents: 44
diff changeset
     6
*/
9
9acd8ae3190c First usable version!
lbatlle@npdl268.bpo.hp.com
parents: 8
diff changeset
     7
#include <stdio.h>
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
     8
#include <string.h>
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
     9
#include <unistd.h>
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
    10
#include <stdlib.h>
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
    11
#include <sys/types.h>
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
    12
#include <sys/socket.h>
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
    13
#include <sys/time.h>
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
    14
#include "main.h"
1
74928e2b27f4 Honta versio de ia strukturo.
viric@llimona
parents:
diff changeset
    15
110
2726c92a5cb3 Half-code for 'times'
viric@mandarina
parents: 92
diff changeset
    16
static void c_end_of_job(const struct Result *res);
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
    17
71
531666e297d7 Send e-letter implemented.
viric@llimona
parents: 69
diff changeset
    18
char *build_command_string()
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    19
{
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    20
    int size;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    21
    int i;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    22
    int num;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    23
    char **array;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    24
    char *commandstring;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    25
    
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    26
    size = 0;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    27
    num = command_line.command.num;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    28
    array = command_line.command.array;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    29
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    30
    /* Count bytes needed */
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    31
    for (i = 0; i < num; ++i)
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    32
    {
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    33
        /* The '1' is for spaces, and at the last i,
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    34
         * for the null character */
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    35
        size = size + strlen(array[i]) + 1;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    36
    }
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    37
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    38
    /* Alloc */
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    39
    commandstring = (char *) malloc(size);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
    40
    if(commandstring == NULL)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
    41
        error("Error in malloc for commandstring");
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    42
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    43
    /* Build the command */
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    44
    strcpy(commandstring, array[0]);
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    45
    for (i = 1; i < num; ++i)
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    46
    {
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    47
        strcat(commandstring, " ");
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    48
        strcat(commandstring, array[i]);
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    49
    }
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    50
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    51
    return commandstring;
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    52
}
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    53
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    54
void c_new_job()
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
    55
{
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
    56
    struct msg m;
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    57
    char *new_command;
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    58
    char *myenv;
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
    59
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
    60
    m.type = NEWJOB;
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
    61
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    62
    new_command = build_command_string();
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    63
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    64
    myenv = get_environment();
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    65
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
    66
    /* global */
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    67
    m.u.newjob.command_size = strlen(new_command) + 1; /* add null */
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    68
    if (myenv)
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    69
        m.u.newjob.env_size = strlen(myenv) + 1; /* add null */
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    70
    else
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    71
        m.u.newjob.env_size = 0;
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
    72
    if (command_line.label)
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
    73
        m.u.newjob.label_size = strlen(command_line.label) + 1; /* add null */
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
    74
    else
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
    75
        m.u.newjob.label_size = 0;
30
ab88478a7e9b The commandline parameters are centered in a struct.
viric@llimona
parents: 27
diff changeset
    76
    m.u.newjob.store_output = command_line.store_output;
155
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 153
diff changeset
    77
    m.u.newjob.depend = command_line.depend;
55
678ca291d545 Now the '-nf' doesn't leave a job in 'finished' state.
viric@llimona
parents: 53
diff changeset
    78
    m.u.newjob.should_keep_finished = command_line.should_keep_finished;
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    79
    m.u.newjob.command_size = strlen(new_command) + 1; /* add null */
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
    80
18
af4898956964 Now commands of any-length are accepted.
viric@llimona
parents: 11
diff changeset
    81
    /* Send the message */
af4898956964 Now commands of any-length are accepted.
viric@llimona
parents: 11
diff changeset
    82
    send_msg(server_socket, &m);
af4898956964 Now commands of any-length are accepted.
viric@llimona
parents: 11
diff changeset
    83
af4898956964 Now commands of any-length are accepted.
viric@llimona
parents: 11
diff changeset
    84
    /* Send the command */
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    85
    send_bytes(server_socket, new_command, m.u.newjob.command_size);
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    86
150
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
    87
    /* Send the label */
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
    88
    send_bytes(server_socket, command_line.label, m.u.newjob.label_size);
a615d7971bf6 Added -L (label)
viric@llimona
parents: 147
diff changeset
    89
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    90
    /* Send the environment */
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    91
    send_bytes(server_socket, myenv, m.u.newjob.env_size);
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    92
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
    93
    free(new_command);
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
    94
    free(myenv);
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
    95
}
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
    96
62
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
    97
int c_wait_newjob_ok()
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
    98
{
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
    99
    struct msg m;
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
   100
    int res;
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
   101
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
   102
    res = recv_msg(server_socket, &m);
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
   103
    if(res == -1)
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   104
        error("Error in wait_newjob_ok");
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   105
    if(m.type != NEWJOB_OK)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   106
        error("Error getting the newjob_ok");
62
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
   107
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
   108
    return m.u.jobid;
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
   109
}
2b29d4666f6c Return the jobid in stdout.
viric@llimona
parents: 55
diff changeset
   110
68
3ae9b38d7d30 Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents: 63
diff changeset
   111
int c_wait_server_commands()
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   112
{
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   113
    struct msg m;
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   114
    int res;
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   115
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   116
    while (1)
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   117
    {
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   118
        res = recv_msg(server_socket, &m);
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   119
        if(res == -1)
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   120
            error("Error in wait_server_commands");
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   121
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   122
        if (res == 0)
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   123
            break;
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   124
        if(res != sizeof(m))
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   125
            error("Error in wait_server_commands");
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   126
        if (m.type == RUNJOB)
5
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   127
        {
110
2726c92a5cb3 Half-code for 'times'
viric@mandarina
parents: 92
diff changeset
   128
            struct Result res;
156
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   129
            res.skipped = 0;
155
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 153
diff changeset
   130
            /* These will send RUNJOB_OK */
156
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   131
            if (command_line.depend && m.u.last_errorlevel != 0)
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   132
            {
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   133
                res.errorlevel = -1;
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   134
                res.user_ms = 0.;
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   135
                res.system_ms = 0.;
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   136
                res.real_ms = 0.;
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   137
                res.skipped = 1;
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   138
                c_send_runjob_ok(0, -1);
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   139
            }
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   140
            else
9ac3bd570159 Improved -d (depend) information.
viric@mandarina
parents: 155
diff changeset
   141
                run_job(&res);
110
2726c92a5cb3 Half-code for 'times'
viric@mandarina
parents: 92
diff changeset
   142
            c_end_of_job(&res);
2726c92a5cb3 Half-code for 'times'
viric@mandarina
parents: 92
diff changeset
   143
            return res.errorlevel;
5
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   144
        }
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   145
    }
38
768d009604b3 The program returns the errorlevel of the job, if it doesn't go to background.
viric@llimona
parents: 35
diff changeset
   146
    return -1;
5
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   147
}
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   148
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   149
void c_wait_server_lines()
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   150
{
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   151
    struct msg m;
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   152
    int res;
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   153
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   154
    while (1)
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   155
    {
21
a797f96a022f Lines for list doesn't have limit.
viric@llimona
parents: 20
diff changeset
   156
        res = recv_msg(server_socket, &m);
5
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   157
        if(res == -1)
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   158
            error("Error in wait_server_lines");
5
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   159
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   160
        if (res == 0)
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   161
            break;
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   162
        if(res != sizeof(m))
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   163
            error("Error in wait_server_lines 2");
5
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   164
        if (m.type == LIST_LINE)
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   165
        {
21
a797f96a022f Lines for list doesn't have limit.
viric@llimona
parents: 20
diff changeset
   166
            char * buffer;
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   167
            buffer = (char *) malloc(m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   168
            recv_bytes(server_socket, buffer, m.u.size);
21
a797f96a022f Lines for list doesn't have limit.
viric@llimona
parents: 20
diff changeset
   169
            printf("%s", buffer);
a797f96a022f Lines for list doesn't have limit.
viric@llimona
parents: 20
diff changeset
   170
            free(buffer);
5
bc5e251418f3 The LIST_LINEs are outputed by the client.
viric@llimona
parents: 4
diff changeset
   171
        }
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   172
    }
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   173
}
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   174
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   175
void c_list_jobs()
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   176
{
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   177
    struct msg m;
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   178
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   179
    m.type = LIST;
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   180
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   181
    send_msg(server_socket, &m);
3
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   182
}
2fb8a6bdd024 More code.
viric@llimona
parents: 2
diff changeset
   183
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   184
void c_show_info()
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   185
{
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   186
    struct msg m;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   187
    int res;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   188
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   189
    m.type = INFO;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   190
    m.u.jobid = command_line.jobid;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   191
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   192
    send_msg(server_socket, &m);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   193
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   194
    while (1)
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   195
    {
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   196
        res = recv_msg(server_socket, &m);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   197
        if(res == -1)
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   198
            error("Error in wait_server_lines");
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   199
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   200
        if (res == 0)
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   201
            break;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   202
        if(res != sizeof(m))
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   203
            error("Error in wait_server_lines 2");
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   204
        if (m.type == INFO_DATA)
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   205
        {
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   206
            char * buffer;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   207
            enum { DSIZE = 1000 };
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   208
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   209
            /* We're going to output data using the stdout fd */
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   210
            fflush(stdout);
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   211
            buffer = (char *) malloc(DSIZE);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   212
            do
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   213
            {
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   214
                res = recv(server_socket, buffer, DSIZE, 0);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   215
                if (res > 0)
147
e173645f5221 Added environment info through TS_ENV
viric@llimona
parents: 146
diff changeset
   216
                    write(1, buffer, res);
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   217
            } while(res > 0);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   218
            free(buffer);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   219
        }
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   220
    }
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   221
}
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   222
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   223
void c_send_runjob_ok(const char *ofname, int pid)
22
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   224
{
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   225
    struct msg m;
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   226
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   227
    /* Prepare the message */
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   228
    m.type = RUNJOB_OK;
155
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 153
diff changeset
   229
    if (ofname) /* ofname == 0, skipped execution */
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 153
diff changeset
   230
	m.u.output.store_output = command_line.store_output;
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 153
diff changeset
   231
    else
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 153
diff changeset
   232
	m.u.output.store_output = 0;
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   233
    m.u.output.pid = pid;
155
55515f9eac77 Added 'depend' -d
viric@vicerveza
parents: 153
diff changeset
   234
    if (m.u.output.store_output)
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   235
        m.u.output.ofilename_size = strlen(ofname) + 1;
22
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   236
    else
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   237
        m.u.output.ofilename_size = 0;
22
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   238
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   239
    send_msg(server_socket, &m);
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   240
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   241
    /* Send the filename */
30
ab88478a7e9b The commandline parameters are centered in a struct.
viric@llimona
parents: 27
diff changeset
   242
    if (command_line.store_output)
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   243
        send_bytes(server_socket, ofname, m.u.output.ofilename_size);
22
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   244
}
afdc8410633f Now output can go to filenames.
viric@llimona
parents: 21
diff changeset
   245
110
2726c92a5cb3 Half-code for 'times'
viric@mandarina
parents: 92
diff changeset
   246
static void c_end_of_job(const struct Result *res)
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   247
{
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   248
    struct msg m;
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   249
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   250
    m.type = ENDJOB;
110
2726c92a5cb3 Half-code for 'times'
viric@mandarina
parents: 92
diff changeset
   251
    m.u.result = *res; /* struct copy */
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   252
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   253
    send_msg(server_socket, &m);
8
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   254
}
03339adb7014 Some more code for execution.
viric@llimona
parents: 5
diff changeset
   255
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   256
void c_shutdown_server()
1
74928e2b27f4 Honta versio de ia strukturo.
viric@llimona
parents:
diff changeset
   257
{
2
602bd67df3aa Changed tabs to 4 spaces. Rule.
viric@llimona
parents: 1
diff changeset
   258
    struct msg m;
1
74928e2b27f4 Honta versio de ia strukturo.
viric@llimona
parents:
diff changeset
   259
31
1a6c732b0b71 The command line parsing has been simplified.
viric@llimona
parents: 30
diff changeset
   260
    m.type = KILL_SERVER;
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   261
    send_msg(server_socket, &m);
1
74928e2b27f4 Honta versio de ia strukturo.
viric@llimona
parents:
diff changeset
   262
}
20
d85b4c0745fa "-c" added, for clearing the finished tasks' list.
viric@llimona
parents: 19
diff changeset
   263
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   264
void c_clear_finished()
20
d85b4c0745fa "-c" added, for clearing the finished tasks' list.
viric@llimona
parents: 19
diff changeset
   265
{
d85b4c0745fa "-c" added, for clearing the finished tasks' list.
viric@llimona
parents: 19
diff changeset
   266
    struct msg m;
d85b4c0745fa "-c" added, for clearing the finished tasks' list.
viric@llimona
parents: 19
diff changeset
   267
d85b4c0745fa "-c" added, for clearing the finished tasks' list.
viric@llimona
parents: 19
diff changeset
   268
    m.type = CLEAR_FINISHED;
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   269
    send_msg(server_socket, &m);
20
d85b4c0745fa "-c" added, for clearing the finished tasks' list.
viric@llimona
parents: 19
diff changeset
   270
}
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   271
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   272
static char * get_output_file(int *pid)
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   273
{
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   274
    struct msg m;
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   275
    int res;
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   276
    char *string = 0;
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   277
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   278
    /* Send the request */
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   279
    m.type = ASK_OUTPUT;
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   280
    m.u.jobid = command_line.jobid;
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   281
    send_msg(server_socket, &m);
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   282
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   283
    /* Receive the answer */
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   284
    res = recv_msg(server_socket, &m);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   285
    if(res != sizeof(m))
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   286
        error("Error in get_output_file");
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   287
    switch(m.type)
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   288
    {
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   289
    case ANSWER_OUTPUT:
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   290
        if (m.u.output.store_output)
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   291
        {
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   292
            /* Receive the output file name */
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   293
            string = 0;
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   294
            if (m.u.output.ofilename_size > 0)
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   295
            {
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   296
                string = (char *) malloc(m.u.output.ofilename_size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   297
                recv_bytes(server_socket, string, m.u.output.ofilename_size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   298
            }
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   299
            *pid = m.u.output.pid;
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   300
            return string;
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   301
        }
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   302
        *pid = m.u.output.pid;
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   303
        return 0;
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   304
        /* WILL NOT GO FURTHER */
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   305
    case LIST_LINE: /* Only ONE line accepted */
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   306
        string = (char *) malloc(m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   307
        res = recv_bytes(server_socket, string, m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   308
        if(res != m.u.size)
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   309
            error("Error in get_output_file line size");
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   310
        fprintf(stderr, "Error in the request: %s", 
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   311
                string);
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   312
        exit(-1);
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   313
        /* WILL NOT GO FURTHER */
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   314
    default:
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   315
        warning("Wrong internal message in get_output_file line size");
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   316
    }
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   317
    /* This will never be reached */
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   318
    return 0;
32
3531439f2770 Tail works.
viric@llimona
parents: 31
diff changeset
   319
}
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   320
174
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   321
int c_tail()
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   322
{
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   323
    char *str;
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   324
    int pid;
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   325
    str = get_output_file(&pid);
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   326
    if (str == 0)
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   327
    {
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   328
        fprintf(stderr, "The output is not stored. Cannot tail.\n");
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   329
        exit(-1);
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   330
    }
174
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   331
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   332
    c_wait_job_send();
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   333
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   334
    return tail_file(str);
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   335
}
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   336
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   337
void c_cat()
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   338
{
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   339
    char *str;
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   340
    int pid;
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   341
    str = get_output_file(&pid);
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   342
    if (str == 0)
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   343
    {
153
3cc22be1ab95 Fixed a bug with -n and -p.
viric@llimona
parents: 150
diff changeset
   344
        fprintf(stderr, "The output is not stored. Cannot cat.\n");
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   345
        exit(-1);
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   346
    }
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   347
    c_run_cat(str);
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   348
}
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   349
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   350
void c_show_output_file()
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   351
{
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   352
    char *str;
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   353
    int pid;
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   354
    /* This will exit if there is any error */
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   355
    str = get_output_file(&pid);
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   356
    if (str == 0)
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   357
    {
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   358
        fprintf(stderr, "The output is not stored.\n");
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   359
        exit(-1);
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   360
    }
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   361
    printf("%s\n", str);
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   362
    free(str);
33
5c2d981f2f8e Added 'cat' and 'show output filename'
viric@llimona
parents: 32
diff changeset
   363
}
35
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   364
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   365
void c_show_pid()
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   366
{
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   367
    char *str;
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   368
    int pid;
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   369
    /* This will exit if there is any error */
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   370
    str = get_output_file(&pid);
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   371
    printf("%i\n", pid);
83d0da612dc4 Kill the running job works fine.
viric@llimona
parents: 33
diff changeset
   372
}
41
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   373
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   374
void c_remove_job()
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   375
{
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   376
    struct msg m;
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   377
    int res;
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   378
    char *string = 0;
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   379
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   380
    /* Send the request */
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   381
    m.type = REMOVEJOB;
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   382
    m.u.jobid = command_line.jobid;
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   383
    send_msg(server_socket, &m);
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   384
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   385
    /* Receive the answer */
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   386
    res = recv_msg(server_socket, &m);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   387
    if(res != sizeof(m))
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   388
        error("Error in remove_job");
41
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   389
    switch(m.type)
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   390
    {
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   391
    case REMOVEJOB_OK:
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   392
        return;
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   393
        /* WILL NOT GO FURTHER */
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   394
    case LIST_LINE: /* Only ONE line accepted */
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   395
        string = (char *) malloc(m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   396
        res = recv_bytes(server_socket, string, m.u.size);
41
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   397
        fprintf(stderr, "Error in the request: %s", 
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   398
                string);
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   399
        exit(-1);
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   400
        /* WILL NOT GO FURTHER */
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   401
    default:
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   402
        warning("Wrong internal message in remove_job");
41
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   403
    }
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   404
    /* This will never be reached */
cad41574feda Added 'remove job'.
viric@llimona
parents: 38
diff changeset
   405
}
42
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   406
174
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   407
int c_wait_job_recv()
42
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   408
{
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   409
    struct msg m;
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   410
    int res;
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   411
    char *string = 0;
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   412
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   413
    /* Receive the answer */
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   414
    res = recv_msg(server_socket, &m);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   415
    if(res != sizeof(m))
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   416
        error("Error in wait_job");
42
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   417
    switch(m.type)
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   418
    {
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   419
    case WAITJOB_OK:
110
2726c92a5cb3 Half-code for 'times'
viric@mandarina
parents: 92
diff changeset
   420
        return m.u.result.errorlevel;
42
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   421
        /* WILL NOT GO FURTHER */
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   422
    case LIST_LINE: /* Only ONE line accepted */
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   423
        string = (char *) malloc(m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   424
        res = recv_bytes(server_socket, string, m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   425
        if(res != m.u.size)
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   426
            error("Error in wait_job - line size");
42
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   427
        fprintf(stderr, "Error in the request: %s", 
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   428
                string);
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   429
        exit(-1);
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   430
        /* WILL NOT GO FURTHER */
44
4dcf05746ece Better include files.
viric@llimona
parents: 42
diff changeset
   431
    default:
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   432
        warning("Wrong internal message in c_wait_job");
42
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   433
    }
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   434
    /* This will never be reached */
51
aa6e05d77537 '-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents: 49
diff changeset
   435
    return -1;
42
f093d0964cf5 Added wait for jobs.
viric@llimona
parents: 41
diff changeset
   436
}
53
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   437
174
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   438
void c_wait_job_send()
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   439
{
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   440
    struct msg m;
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   441
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   442
    /* Send the request */
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   443
    m.type = WAITJOB;
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   444
    m.u.jobid = command_line.jobid;
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   445
    send_msg(server_socket, &m);
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   446
}
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   447
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   448
/* Returns the errorlevel */
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   449
int c_wait_job()
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   450
{
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   451
    c_wait_job_send();
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   452
    return c_wait_job_recv();
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   453
}
c112f67965fb Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents: 156
diff changeset
   454
53
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   455
void c_move_urgent()
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   456
{
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   457
    struct msg m;
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   458
    int res;
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   459
    char *string = 0;
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   460
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   461
    /* Send the request */
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   462
    m.type = URGENT;
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   463
    m.u.jobid = command_line.jobid;
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   464
    send_msg(server_socket, &m);
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   465
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   466
    /* Receive the answer */
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   467
    res = recv_msg(server_socket, &m);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   468
    if(res != sizeof(m))
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   469
        error("Error in move_urgent");
53
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   470
    switch(m.type)
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   471
    {
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   472
    case URGENT_OK:
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   473
        return;
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   474
        /* WILL NOT GO FURTHER */
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   475
    case LIST_LINE: /* Only ONE line accepted */
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   476
        string = (char *) malloc(m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   477
        res = recv_bytes(server_socket, string, m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   478
        if(res != m.u.size)
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   479
            error("Error in move_urgent - line size");
53
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   480
        fprintf(stderr, "Error in the request: %s", 
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   481
                string);
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   482
        exit(-1);
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   483
        /* WILL NOT GO FURTHER */
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   484
    default:
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   485
        warning("Wrong internal message in move_urgent");
53
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   486
    }
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   487
    /* This will never be reached */
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   488
    return;
731c41817842 '-u' (urgency) implemented.
viric@llimona
parents: 51
diff changeset
   489
}
63
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   490
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   491
void c_get_state()
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   492
{
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   493
    struct msg m;
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   494
    int res;
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   495
    char *string = 0;
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   496
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   497
    /* Send the request */
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   498
    m.type = GET_STATE;
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   499
    m.u.jobid = command_line.jobid;
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   500
    send_msg(server_socket, &m);
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   501
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   502
    /* Receive the answer */
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   503
    res = recv_msg(server_socket, &m);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   504
    if(res != sizeof(m))
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   505
        error("Error in get_state - line size");
63
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   506
    switch(m.type)
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   507
    {
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   508
    case ANSWER_STATE:
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   509
        printf("%s\n", jstate2string(m.u.state));
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   510
        return;
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   511
        /* WILL NOT GO FURTHER */
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   512
    case LIST_LINE: /* Only ONE line accepted */
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   513
        string = (char *) malloc(m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   514
        res = recv_bytes(server_socket, string, m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   515
        if(res != m.u.size)
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   516
            error("Error in get_state - line size");
63
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   517
        fprintf(stderr, "Error in the request: %s", 
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   518
                string);
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   519
        exit(-1);
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   520
        /* WILL NOT GO FURTHER */
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   521
    default:
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   522
        warning("Wrong internal message in get_state");
63
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   523
    }
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   524
    /* This will never be reached */
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   525
    return;
47be318f4cbc Added "-s" for querying the job state.
viric@llimona
parents: 62
diff changeset
   526
}
66
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   527
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   528
void c_swap_jobs()
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   529
{
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   530
    struct msg m;
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   531
    int res;
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   532
    char *string = 0;
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   533
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   534
    /* Send the request */
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   535
    m.type = SWAP_JOBS;
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   536
    m.u.swap.jobid1 = command_line.jobid;
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   537
    m.u.swap.jobid2 = command_line.jobid2;
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   538
    send_msg(server_socket, &m);
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   539
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   540
    /* Receive the answer */
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   541
    res = recv_msg(server_socket, &m);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   542
    if(res != sizeof(m))
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   543
        error("Error in swap_jobs");
66
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   544
    switch(m.type)
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   545
    {
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   546
    case SWAP_JOBS_OK:
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   547
        return;
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   548
        /* WILL NOT GO FURTHER */
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   549
    case LIST_LINE: /* Only ONE line accepted */
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   550
        string = (char *) malloc(m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   551
        res = recv_bytes(server_socket, string, m.u.size);
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
   552
        if(res != m.u.size)
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   553
            error("Error in swap_jobs - line size");
66
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   554
        fprintf(stderr, "Error in the request: %s", 
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   555
                string);
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   556
        exit(-1);
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   557
        /* WILL NOT GO FURTHER */
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   558
    default:
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents: 71
diff changeset
   559
        warning("Wrong internal message in swap_jobs");
66
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   560
    }
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   561
    /* This will never be reached */
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   562
    return;
f70a27afd92e Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents: 63
diff changeset
   563
}