Main Page | Data Structures | File List | Data Fields | Globals

error.c File Reference

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <glib.h>
#include "util.h"
#include "error.h"

Go to the source code of this file.

Functions

void defaultErrorFunc (const char *string, const char *filename, const char *function, int lineno)
int defaultPromptFunc (const char *title, const char *msg, int nTotal, int nDefault, const char *choice1, va_list args)
void lutil_error_setErrorFunc (UErrorFunc errorFunc)
 Set a new function to display errors with.

void lutil_error_setPromptFunc (UPromptFunc promptFunc)
 Set a new function to prompt the user with.

void lutil_error_resetErrorFunc (void)
 Reset the error function to the default error function.

void lutil_error_resetPromptFunc (void)
 Reset the prompt function to the default prompt function.

void lutil_error_fatal (const char *string, const char *filename, const char *function, int lineno)
 Display an error and die.

int lutil_error_prompt (const char *title, const char *msg, int nTotal, int nDefault, const char *choice1,...)
 Prompt the user for input.

void lutil_error (const char *filename, const char *function, int lineno, const char *template,...)
 Display an error and continue.


Variables

UErrorFunc errorFunc_global = defaultErrorFunc
UPromptFunc promptFunc_global = defaultPromptFunc


Function Documentation

void defaultErrorFunc const char *  string,
const char *  filename,
const char *  function,
int  lineno
[static]
 

Definition at line 176 of file error.c.

Referenced by lutil_error_resetErrorFunc().

int defaultPromptFunc const char *  title,
const char *  msg,
int  nTotal,
int  nDefault,
const char *  choice1,
va_list  args
[static]
 

Definition at line 182 of file error.c.

Referenced by lutil_error_resetPromptFunc().

void lutil_error const char *  filename,
const char *  function,
int  lineno,
const char *  template,
... 
 

Display an error and continue.

Display an error using the defined error function (or the default, if none is defined). Default behavior (as defined by defaultErrorFunc) is to simply display the error to STDERR in the following format:

 *** ERROR ***
 luau: FILENAME: FUNCTION: STRING

  • filename is the name of the source file where the error occured
  • function is the name of the function where the error occured
  • lineno is the line number where the error occured
  • template is the (printf) template for the error string
  • ... is the arguments to the (printf) template.

Definition at line 159 of file error.c.

References errorFunc_global, and lutil_valistToString().

void lutil_error_fatal const char *  string,
const char *  filename,
const char *  function,
int  lineno
 

Display an error and die.

Display a fatal error message and die. Cannot be overridden. Only called internally when there is a memory failure.

  • string is the error string
  • filename is the name of the source file where the error occured
  • function is the name of the function where the error occured
  • lineno is the line number where the error occured
    Returns:
    ... Never.

Definition at line 111 of file error.c.

int lutil_error_prompt const char *  title,
const char *  msg,
int  nTotal,
int  nDefault,
const char *  choice1,
... 
 

Prompt the user for input.

Prompt the user for input, using the defined prompt function (or the default, if none is defined). Default behavior is not to prompt the user at all, but instead to return the default value.

  • title is the name of the prompt
  • msg is the prompt to ask the user
  • nTotal is the number of options given
  • nDefault is the id of the default option (must be provided)
  • choice1 is the first choice
  • args is the rest of the choices
See also:
lutil_error_setPromptFunc

Definition at line 131 of file error.c.

References promptFunc_global.

Referenced by luau_downloadUpdate(), and luau_net_downloadUpdate().

void lutil_error_resetErrorFunc void   ) 
 

Reset the error function to the default error function.

Definition at line 91 of file error.c.

References defaultErrorFunc(), and errorFunc_global.

Referenced by luau_resetErrorFunc().

void lutil_error_resetPromptFunc void   ) 
 

Reset the prompt function to the default prompt function.

Definition at line 96 of file error.c.

References defaultPromptFunc(), and promptFunc_global.

Referenced by luau_resetPromptFunc().

void lutil_error_setErrorFunc UErrorFunc  errorFunc  ) 
 

Set a new function to display errors with.

Define a new function to be used for error output. The error function takes a number of pieces of information concerning where the error concerned, but any or all of them may be ignored in accordance with the user's discretion. Function should handle NULL values cleanly. Default behavior (as defined by defaultErrorFunc) is to simply display the error to STDERR in the following format:

 *** ERROR ***
 luau: FILENAME: FUNCTION: STRING

  • errorFunc is the new error function to use
  • string is the error string
  • filename is the name of the source file where the error occured
  • function is the name of the function where the error occured
  • lineno is the line number where the error occured
See also:
lutil_error

Definition at line 66 of file error.c.

References errorFunc_global.

Referenced by luau_registerErrorFunc().

void lutil_error_setPromptFunc UPromptFunc  promptFunc  ) 
 

Set a new function to prompt the user with.

Define a new function to be used for prompting the user for input. The default value, specified by nDefault, and the title (title) may be ignored. The prompt function should return the id of the value picked (first = 1, second = 2, etc.). Default behavior is to not prompt the user at all, and simply return the default value.

  • promptFunc is the new prompting function to use
  • title is the name of the prompt
  • msg is the prompt to ask the user
  • nTotal is the number of options given
  • nDefault is the id of the default option (must be provided)
  • choice1 is the first choice
  • args is the rest of the choices
See also:
lutil_error_prompt

Definition at line 86 of file error.c.

References promptFunc_global.

Referenced by luau_registerPromptFunc().


Variable Documentation

UErrorFunc errorFunc_global = defaultErrorFunc [static]
 

Definition at line 43 of file error.c.

Referenced by lutil_error(), lutil_error_resetErrorFunc(), and lutil_error_setErrorFunc().

UPromptFunc promptFunc_global = defaultPromptFunc [static]
 

Definition at line 44 of file error.c.

Referenced by lutil_error_prompt(), lutil_error_resetPromptFunc(), and lutil_error_setPromptFunc().


Generated on Mon Apr 12 22:17:11 2004 for luau by doxygen 1.3.2