Changeset e2ea8d7e in mainline for uspace/app/bdsh/errors.c


Ignore:
Timestamp:
2008-08-27T05:36:12Z (16 years ago)
Author:
Tim Post <echo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b4b7b6
Parents:
b510d52
Message:

Housekeeping list, complete lingering things before they get forgotten:

  • cli_*() now sets a global cli_errno, error functions cleaned up
  • Finish internal cli_*() functions in util.c
  • Don't expose cli_init() or cli_finit()
  • Get rid of unused globals
  • Don't set globals in commands themselves
  • Update README files
  • Fix stale comments
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/errors.c

    rb510d52 re2ea8d7e  
    3939#include "errstr.h"
    4040
     41volatile int cli_errno = CL_EOK;
     42extern volatile unsigned int cli_quit;
     43
    4144/* Error printing, translation and handling functions */
    4245
    43 volatile int cli_lasterr = 0;
    44 extern volatile unsigned int cli_verbocity;
    4546
    4647/* Look up errno in cl_errors and return the corresponding string.
    4748 * Return NULL if not found */
    48 char *err2str(int errno)
     49static char *err2str(int err)
    4950{
    5051
    51         if (NULL != cl_errors[errno])
    52                 return cl_errors[errno];
     52        if (NULL != cl_errors[err])
     53                return cl_errors[err];
    5354
    5455        return (char *)NULL;
     
    5960 * cli_quit int that tells the main program loop to exit immediately */
    6061
    61 void cli_error(int errno, const char *fmt, ...)
     62void cli_error(int err, const char *fmt, ...)
    6263{
    6364        va_list vargs;
     
    6667        va_end(vargs);
    6768
    68         if (NULL != err2str(errno))
    69                 printf(" (%s)\n", err2str(errno));
     69        if (NULL != err2str(err))
     70                printf(" (%s)\n", err2str(err));
    7071        else
    71                 printf(" (Unknown Error %d)\n", errno);
     72                printf(" (Unknown Error %d)\n", err);
    7273
    73         if (errno < 0)
    74                 exit(EXIT_FAILURE);
     74        /* If fatal, raise cli_quit so that we try to exit
     75         * gracefully. This will break the main loop and
     76         * invoke the destructor */
     77        if (err == CL_EFATAL)
     78                cli_quit = 1;
    7579
    76 }
     80        return;
    7781
    78 /* Just a smart printf(), print the string only if cli_verbocity is high */
    79 void cli_verbose(const char *fmt, ...)
    80 {
    81         if (cli_verbocity) {
    82                 va_list vargs;
    83 
    84                 printf("[*] ");
    85                 va_start(vargs, fmt);
    86                 vprintf(fmt, vargs);
    87                 va_end(vargs);
    88                 printf("\n");
    89         }
    90         return;
    9182}
    9283
     
    9485
    9586
     87
Note: See TracChangeset for help on using the changeset viewer.