error.c
author viric <viriketo@gmail.com>
Sun, 20 Mar 2016 11:25:28 +0100
changeset 344 9be22a4aa695
parent 343 23242cea443d
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:
102
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 92
diff changeset
     1
/*
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 92
diff changeset
     2
    Task Spooler - a task queue system for the unix user
267
11631dd11ff8 Updating copyright years in the source.
viric@mandarina
parents: 254
diff changeset
     3
    Copyright (C) 2007-2009  LluĂ­s Batlle i Rossell
102
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 92
diff changeset
     4
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 92
diff changeset
     5
    Please find the license in the provided COPYING file.
27b0f0e44de8 Added copyright headers to the new files. I always forget that.
viric@llimona
parents: 92
diff changeset
     6
*/
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
     7
#include <unistd.h>
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
     8
#include <stdio.h>
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
     9
#include <time.h>
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    10
#include <sys/types.h>
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    11
#include <errno.h>
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    12
#include <string.h>
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    13
#include <fcntl.h>
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    14
#include <sys/stat.h>
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    15
#include <stdarg.h>
105
98b6955472dd Fixed warning in error.c
viric@llimona
parents: 104
diff changeset
    16
#include <stdlib.h>
146
5e689cb593aa Bones of the "-i" parameter, job info.
viric@llimona
parents: 117
diff changeset
    17
#include <sys/time.h>
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    18
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    19
#include "main.h"
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    20
111
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
    21
enum Etype
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
    22
{
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
    23
    WARNING,
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
    24
    ERROR
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
    25
};
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
    26
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    27
/* Declared in main.h as extern */
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    28
enum Process_type process_type;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    29
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    30
static int real_errno;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    31
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    32
/* Local protos */
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    33
static void dump_structs(FILE *out);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    34
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    35
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    36
static void print_date(FILE *out)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    37
{
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    38
    time_t t;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    39
    const char *tstr;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    40
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    41
    t = time(NULL);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    42
    tstr = ctime(&t);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    43
104
dc4dd9939238 Fixed error reporting.
viric@llimona
parents: 102
diff changeset
    44
    fprintf(out, "date %s", tstr);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    45
}
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    46
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    47
static void dump_proc_info(FILE *out)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    48
{
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    49
    print_date(out);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    50
    fprintf(out, "pid %i\n", getpid());
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    51
    if (process_type == SERVER)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    52
        fprintf(out, "type SERVER\n");
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    53
    else if (process_type == CLIENT)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    54
        fprintf(out, "type CLIENT\n");
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    55
    else
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    56
        fprintf(out, "type UNKNOWN\n");
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    57
}
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    58
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    59
static FILE * open_error_file()
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    60
{
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    61
    int fd;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    62
    FILE* out;
251
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    63
    char *path;
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    64
    int new_size;
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    65
    char *new_path;
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    66
251
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    67
    create_socket_path(&path);
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    68
    new_size = strlen(path)+10;
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    69
    new_path = malloc(new_size);
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    70
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    71
    strncpy(new_path, path, new_size);
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    72
    strncat(new_path, ".error", (new_size - strlen(path)) - 1);
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    73
    free(path);
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    74
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    75
    fd = open(new_path, O_CREAT | O_APPEND | O_WRONLY, 0600);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    76
    if (fd == -1)
343
23242cea443d Description: Fix memory leak
viric <viriketo@gmail.com>
parents: 295
diff changeset
    77
    {
23242cea443d Description: Fix memory leak
viric <viriketo@gmail.com>
parents: 295
diff changeset
    78
        free(new_path);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    79
        return 0;
343
23242cea443d Description: Fix memory leak
viric <viriketo@gmail.com>
parents: 295
diff changeset
    80
    }
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    81
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    82
    out = fdopen(fd, "a");
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    83
    if (out == NULL)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    84
    {
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    85
        close(fd);
343
23242cea443d Description: Fix memory leak
viric <viriketo@gmail.com>
parents: 295
diff changeset
    86
        free(new_path);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    87
        return 0;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    88
    }
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    89
251
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    90
    free(new_path);
5e0802df5788 Making a ts.error file for each socket ($TS_SOCKET.error)
viric@mandarina
parents: 231
diff changeset
    91
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    92
    return out;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    93
}
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    94
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    95
static void print_error(FILE *out, enum Etype type, const char *str, va_list ap)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    96
{
295
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 267
diff changeset
    97
    fprintf(out, "-------------------");
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    98
    if (type == ERROR)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
    99
        fprintf(out, "Error\n");
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   100
    else if (type == WARNING)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   101
        fprintf(out, "Warning\n");
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   102
    else
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   103
        fprintf(out, "Unknown kind of error\n");
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   104
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   105
    fprintf(out, " Msg: ");
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   106
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   107
    vfprintf(out, str, ap);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   108
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   109
    fprintf(out, "\n");
104
dc4dd9939238 Fixed error reporting.
viric@llimona
parents: 102
diff changeset
   110
    fprintf(out, " errno %i, \"%s\"\n", real_errno, strerror(real_errno));
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   111
}
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   112
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   113
static void problem(enum Etype type, const char *str, va_list ap)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   114
{
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   115
    FILE *out;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   116
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   117
    out = open_error_file();
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   118
    if (out == 0)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   119
        return;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   120
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   121
    /* out is ready */
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   122
    print_error(out, type, str, ap);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   123
    dump_structs(out);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   124
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   125
    /* this will close the fd also */
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   126
    fclose(out);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   127
}
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   128
111
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   129
static void problem_msg(enum Etype type, const struct msg *m, const char *str, va_list ap)
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   130
{
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   131
    FILE *out;
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   132
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   133
    out = open_error_file();
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   134
    if (out == 0)
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   135
        return;
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   136
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   137
    /* out is ready */
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   138
    print_error(out, type, str, ap);
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   139
    msgdump(out, m);
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   140
    dump_structs(out);
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   141
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   142
    /* this will close the fd also */
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   143
    fclose(out);
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   144
}
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   145
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   146
void error(const char *str, ...)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   147
{
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   148
    va_list ap;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   149
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   150
    va_start(ap, str);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   151
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   152
    real_errno = errno;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   153
295
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 267
diff changeset
   154
    if (process_type == CLIENT)
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 267
diff changeset
   155
    {
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 267
diff changeset
   156
        vfprintf(stderr, str, ap);
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 267
diff changeset
   157
        fputc('\n', stderr);
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 267
diff changeset
   158
    }
a63f43a17fd7 Adding the option '-B' for Mark, that will make ts quit if it cannot enqueue a
viric <viriketo@gmail.com>
parents: 267
diff changeset
   159
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   160
    problem(ERROR, str, ap);
104
dc4dd9939238 Fixed error reporting.
viric@llimona
parents: 102
diff changeset
   161
    exit(-1);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   162
}
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   163
111
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   164
void error_msg(const struct msg *m, const char *str, ...)
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   165
{
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   166
    va_list ap;
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   167
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   168
    va_start(ap, str);
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   169
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   170
    real_errno = errno;
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   171
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   172
    problem_msg(ERROR, m, str, ap);
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   173
    exit(-1);
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   174
}
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   175
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   176
void warning(const char *str, ...)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   177
{
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   178
    va_list ap;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   179
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   180
    va_start(ap, str);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   181
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   182
    real_errno = errno;
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   183
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   184
    problem(WARNING, str, ap);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   185
}
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   186
111
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   187
void warning_msg(const struct msg *m, const char *str, ...)
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   188
{
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   189
    va_list ap;
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   190
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   191
    va_start(ap, str);
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   192
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   193
    real_errno = errno;
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   194
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   195
    problem_msg(WARNING, m, str, ap);
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   196
}
d6bc62904b5a Fixed a buffer overflow in jobs.c, when sending the lines for LISTJOBS.
viric@mandarina
parents: 105
diff changeset
   197
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   198
static void dump_structs(FILE *out)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   199
{
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   200
    dump_proc_info(out);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   201
    if (process_type == SERVER)
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   202
    {
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   203
        dump_jobs_struct(out);
254
41252d5e85f5 Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents: 251
diff changeset
   204
        dump_notifies_struct(out);
92
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   205
        dump_conns_struct(out);
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   206
    }
05004c52ecff Better error reports on internal handled errors.
viric@llimona
parents:
diff changeset
   207
}