Exemplo n.º 1
0
Arquivo: printk.c Projeto: borlox/kos2
int vprintk(const char *fmt, va_list args)
{
	int loglvl = LOGLVL_DEFAULT;
	if (fmt[0] == '<') {
		if (!fmt[1])
			return -E_INVALID;
		if (fmt[2] != '>')
				return -E_INVALID;

		loglvl = getlvl(fmt[1]);
		fmt += 3;
	}

	char buffer[2048] = "";
	int num = strafmt(buffer, fmt, args);
	bool put_nl = buffer[num-1] != '\n';

	int written = num;
	if (loglvl <= cur_console->loglevel()) {
		written = cur_console->puts(buffer);
		if (put_nl)
			cur_console->putc('\n');
	}
	if (num != written)
		return -geterr();
	return num;
}
Exemplo n.º 2
0
Arquivo: error.c Projeto: beanhome/dev
char *
PQgeterror(void)
{
	static char _empty[1] = {0};
	pqterr_t *err = geterr();
	return err ? err->msg : _empty;
}
Exemplo n.º 3
0
Arquivo: error.c Projeto: beanhome/dev
char *
PQgetErrorField(int fieldcode)
{
	pqterr_t *err = geterr();

	if (!err)
		return NULL;

	switch (fieldcode)
	{
		case PG_DIAG_SEVERITY:
			return err->severity;

		case PG_DIAG_SQLSTATE:
			return err->sqlstate;

		case PG_DIAG_MESSAGE_PRIMARY:
			return err->message_primary;

		case PG_DIAG_MESSAGE_DETAIL:
			return err->message_detail;

		case PG_DIAG_MESSAGE_HINT:
			return err->message_hint;

		case PG_DIAG_STATEMENT_POSITION:
			return err->stmt_position;

		case PG_DIAG_INTERNAL_POSITION:
			return err->internal_position;

		case PG_DIAG_INTERNAL_QUERY:
			return err->internal_query;

		case PG_DIAG_CONTEXT:
			return err->context;

		case PG_DIAG_SOURCE_FILE:
			return err->source_file;

		case PG_DIAG_SOURCE_LINE:
			return err->source_line;

		case PG_DIAG_SOURCE_FUNCTION:
			return err->source_function;

		default:
			return NULL;
	}
}
Exemplo n.º 4
0
Arquivo: error.c Projeto: beanhome/dev
void
PQseterror(const char *format, ...)
{
	/* clear error message by passing in NULL, PQseterror(NULL).*/
	if (!format)
	{
		pqterr_t *err = geterr();

		if (err)
			memset(err, 0, sizeof(pqterr_t));
	}
	else
	{
		va_list ap;
		va_start(ap, format);
		vseterror(format, ap, FALSE);
	}
}
Exemplo n.º 5
0
VOID
diag()
{
        char *p,*errstr;

        if (eb != ep) {
                p = eb;
                if (!is_sdas()) {
                        fprintf(stderr, "?ASxxxx-Error-<");
                        while (p < ep) {
                                fprintf(stderr, "%c", *p++);
                        }
                        fprintf(stderr, "> in line ");
                        if (incfil >= 0) {
                                fprintf(stderr, "%d", incline[incfil]);
                                fprintf(stderr, " of %s\n", incfn[incfil]);
                        } else {
                                fprintf(stderr, "%d", srcline[cfile]);
                                fprintf(stderr, " of %s\n", srcfn[cfile]);
                        }
                        p = eb;
                }
                while (p < ep) {
                        if ((errstr = geterr(*p++)) != NULL) {
                                if (!is_sdas()) {
                                        fprintf(stderr, "              %s\n", errstr);
                                } else {
                                        /* Modified to conform to gcc error standard, M. Hope, 7 Feb 98. */
                                        if (incfil >= 0) {
                                                fprintf(stderr, "%s:", incfn[incfil]);
                                                fprintf(stderr, "%d: Error:", incline[incfil]);
                                        }
                                        else {
                                                fprintf(stderr, "%s:", srcfn[cfile]);
                                                fprintf(stderr, "%d: Error:", srcline[cfile]);
                                        }
                                        fprintf(stderr, " %s\n", errstr);
                                }
                        }
                }
        }
}
Exemplo n.º 6
0
Arquivo: error.c Projeto: beanhome/dev
void
pqt_setresultfields(const PGresult *res)
{
	char *value;
	pqterr_t *err = geterr();

	if (!err)
		return;

	geterrfield(err->severity,          PG_DIAG_SEVERITY);
	geterrfield(err->sqlstate,          PG_DIAG_SQLSTATE);
	geterrfield(err->message_primary,   PG_DIAG_MESSAGE_PRIMARY);
	geterrfield(err->message_detail,    PG_DIAG_MESSAGE_DETAIL);
	geterrfield(err->message_hint,      PG_DIAG_MESSAGE_HINT);
	geterrfield(err->stmt_position,     PG_DIAG_STATEMENT_POSITION);
	geterrfield(err->internal_position, PG_DIAG_INTERNAL_POSITION);
	geterrfield(err->internal_query,    PG_DIAG_INTERNAL_QUERY);
	geterrfield(err->context,           PG_DIAG_CONTEXT);
	geterrfield(err->source_file,       PG_DIAG_SOURCE_FILE);
	geterrfield(err->source_line,       PG_DIAG_SOURCE_LINE);
	geterrfield(err->source_function,   PG_DIAG_SOURCE_FUNCTION);
}
Exemplo n.º 7
0
Arquivo: error.c Projeto: beanhome/dev
static void
vseterror(const char *format, va_list ap, int append)
{
	int n;
	int curlen = 0;
	int size;
	va_list ap2;
	char *msg = NULL;
	pqterr_t *err = geterr();

	if (!err)
		return;

	if (append)
		curlen = (int) strlen(err->msg);
	else
		*err->msg = 0;

	va_copy(ap2, ap);
	n = pqt_vsnprintf(err->msg + curlen, sizeof(err->msg) - curlen, format, ap2);
	va_end(ap2);

	if (n > -1)
		return;

	/* pqterr_t msg buffer is too small for the complete message.  We have
	 * use a temporary buffer to get a successful sprintf so we can
	 * pqt_strcpy() the result; which truncates to fit.
	 */
	size = (int) sizeof(err->msg) * 2;
	if (!(msg = (char *) malloc(size)))
		return;

  while (1)
	{
		char *p;

		va_copy(ap2, ap);
		n = pqt_vsnprintf(msg + curlen, size - curlen, format, ap2);
		va_end(ap2);

		/* success */
		if (n > -1)
			break;

		/* need more space */
		n = size * 2;
		if (!(p = pqt_realloc(msg, n)))
		{
			/* we're here because sprintf failed, don't trust buffer contents */
			*msg = 0;
			break;
		}

		msg = p;
		size = n;
	}

	pqt_strcpy(err->msg, sizeof(err->msg), msg);
	free(msg);
}
Exemplo n.º 8
0
void remesp()
{
int i, j, k, ip;
double a, b, x, y, z, xm, ym;
double approx(), func(), geterr();

j = 0;	/* Printout variable */
ip = 0;	/* Solution vector counter */
printf( "Numerator coefficients:\n" );
for( i=0; i<=n; i++, j++, ip++ )
	{
	if( j >= 3 )
		{
		printf( "\n" );
		j = 0;
		}
	printf( "%23.15E ", param[ip] );
	}
if( d > 0 )
	{
	j = 0;
	printf( "\nDenominator coefficients:\n" );
	for( i=0; i<d; i++, j++, ip++ )
		{
		if( j >= 3 )
			{
			printf( "\n" );
			j = 0;
			}
		printf( "%23.15E ", param[ip] );
		}
	if( j >= 3 )
		printf( "\n" );
/* Leading denominator coefficient always = 1. */
	printf( "%9.1E", 1.0 );
	}
else
	printf( "\nDeviation: %.4E", param[n+1] );

/* Display table of function and approximation error. */
printf(
"\n\n     x         func      approx      error\n"
);
a = apwidt/N;
b = apstrt;
k = 0;
j = 0;
for( i=0; i<=N; i++ )
	{
	x = b + i * a;
	if( x >= mm[k] )
		{
		xm = mm[k];
		y = geterr(xm);
		z = qyaprx;
		ym = qy;
		printf( "%11.3E %11.3E %11.3E %11.3E*\n",
			xm, ym, z, y*esign );
		k += 1;
		} 
/* Fill in the zeros also. */
	if( (d > 0) && (x >= xx[j]) )
		{
		xm = xx[j];
		y = geterr(xm);
		z = qyaprx;
		ym = qy;
		printf( "%11.3E %11.3E %11.3E %11.3Eo\n",
			 xm, ym, z, y*esign );
		j += 1;
		} 
	y = geterr(x);
	z = qyaprx;
	ym = qy;
	printf( "%11.3E %11.3E %11.3E %11.3E\n",
		x, ym, z, y*esign );
	}
}