Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, April 19, 2024

File: [Platon] / ep / src / message.c (download)

Revision 1.18, Fri Nov 28 17:35:11 2003 UTC (20 years, 4 months ago) by nepto


Changes since 1.17: +5 -5 lines

Changed URL from www.platon.sk to platon.sk.

/*
 * ep - extended pipelining
 *
 * message.c - output messages functions
 * ____________________________________________________________
 *
 * Developed by Ondrej Jombik <nepto@platon.sk>
 *          and Lubomir Host <rajo@platon.sk>
 * Copyright (c) 2000-2003 Platon SDG, http://platon.sk/
 * All rights reserved.
 *
 * See README file for more information about this software.
 * See COPYING file for license information.
 *
 * Download the latest version from
 * http://platon.sk/projects/ep/
 */

/* $Platon: ep/src/message.c,v 1.17 2003/05/03 09:58:19 nepto Exp $ */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <stdio.h>
#ifdef STDC_HEADERS
#  include <stdlib.h>
#  include <string.h>
#  include <stdarg.h>
#endif

#include <errno.h>

#if MENU
#  include <curses.h>
#endif

#include "main.h"
#include "message.h"

    void
msg_print(char *fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
#if MENU
    vwprintw(stdscr, fmt, ap);
    refresh();
#else
#if HAVE_VPRINTF
    vprintf(fmt, ap);
    fflush(stdout);
#else
    fprintf(stderr, "%s: warning: vfprintf() function not available\n", argv0);
    fprintf(stderr, "%s: [%s]\n", argv0, fmt);
    fflush(stderr);
#endif
#endif
    va_end(ap);
}


    void
msg_error_print(char *fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
#if MENU

#if DEBUG
    printw( "%s: ERROR: ", argv0);
#else
    printw( "%s: error: ", argv0);
#endif

    vwprintw(stdscr, fmt, ap);
    refresh();
#else
#if HAVE_VPRINTF

#if DEBUG
    fprintf(stderr, "%s: ERROR: ", argv0);
#else
    fprintf(stderr, "%s: error: ", argv0);
#endif

    vfprintf(stderr, fmt, ap);
#else
    fprintf(stderr, "%s: warning: vfprintf() function not available\n", argv0);
    fprintf(stderr, "%s: error: [%s]\n", argv0, fmt);
#endif
    fflush(stderr);
#endif
    va_end(ap);
}



    void
msg_warn_print(char *fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
#if MENU
    printw( "%s: warning: ", argv0);
    vwprintw(stdscr, fmt, ap);
    refresh();
#else
#if HAVE_VPRINTF
    fprintf(stderr, "%s: warning: ", argv0);
    vfprintf(stderr, fmt, ap);
#else
    fprintf(stderr, "%s: warning: vfprintf() function not available\n", argv0);
    fprintf(stderr, "%s: warning: [%s]\n", argv0, fmt);
#endif
    fflush(stderr);
#endif
    va_end(ap);
}

#if DEBUG
    void
msg_debug_print(char *fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
#if MENU
    printw("%s: debug: ", argv0);
    vwprintw(stdscr, fmt, ap);
    refresh();
#else
#if HAVE_VPRINTF
    fprintf(stderr, "%s: debug: ", argv0);
    vfprintf(stderr, fmt, ap);
#else
    fprintf(stderr, "%s: warning: vfprintf() function not available\n", argv0);
    fprintf(stderr, "%s: debug: [%s]\n", argv0, fmt);
#endif
    fflush(stderr);
#endif
    va_end(ap);
}
#endif

    void
msg_errno_print(void)
{
    msg_error_print("%s", strerror(errno));
}

    void
msg_array_print(array)
    char **array;
{
    if (array != NULL) {
        register int i;

        for (i = 0; array[i] != NULL; i++) {
#if DEBUG
            msg_print("[%s]", array[i]);
#else
            if (i != 0)
                msg_print(" ");
            msg_print("%s", array[i]);
#endif
        }
    }
}

    void
msg_usage_print(void)
{
    fprintf(stderr, "\nextended pipelining v%s / %s %s\n", VERSION, __DATE__, __TIME__);
    fprintf(stderr, "\nUsage\n  %s [ GLOBALS -- ]  [ [ [ PROCS_1 cmd_1 ] -- PROCS_2 cmd_2 ] ... ]\n", argv0);
    fprintf(stderr, "\nGlobal options (GLOBALS)\n");
    fprintf(stderr, "  -h, --help               show this help screen\n");
    fprintf(stderr, "  -q, --quiet              quiet mode\n");
    fprintf(stderr, "  -v, --verbose            verbose (more -v means more verbose)\n");
    fprintf(stderr, "  -f, --config-file        load user defined config file\n");
    fprintf(stderr, "  --disable-global-config  disable global config file loading\n");
    fprintf(stderr, "                           global config file is: %s\n",
            conf_global_filename);
    fprintf(stderr, "  --disable-user-config    disable user config file loading\n");
    fprintf(stderr, "                           user config file is: ~/%s\n",
            conf_user_filename);
    fprintf(stderr, "\nProcess options (PROCS_n)\n");
    fprintf(stderr, "  -i, --input              input links\n");
    fprintf(stderr, "  -o, --output             output links\n");
    fprintf(stderr, "  -e, --errput             errput links\n");
    fprintf(stderr, "  -n, --name               process names\n");
    fprintf(stderr, "  -N, --nice               process run priority (from 20 to -20)\n");
    fprintf(stderr, "                           only superuser may specify negative values\n");
    fprintf(stderr, "\nCommand (cmd_n)\n");
    fprintf(stderr, "  After process options you must specify command to run. That command could\n");
    fprintf(stderr, "  contain its own options and parameters. They would not be parsed by ep.\n");
    fprintf(stderr, "\nNotes\n");
    fprintf(stderr, "  Developed by Ondrej Jombik, http://nepto.sk/\n");
    fprintf(stderr, "  Copyright (c) 2000-2003 Platon SDG, http://platon.sk/\n");
    fprintf(stderr, "  See README file for more information about this software.\n");
    fprintf(stderr, "  See COPYING file for license information.\n");

    fprintf(stderr, "\n");
}


Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top