/* $Id: dumprest.pc 3956 2010-01-05 20:56:56Z zacheiss $
 *
 * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
 * For copying and distribution information, please see the file
 * <mit-copyright.h>.
 */

#include <mit-copyright.h>
#include <moira.h>
#include "dump_db.h"

#include <stdio.h>

RCSID("$HeadURL: svn+ssh://svn.mit.edu/moira/trunk/moira/backup/dumprest.pc $ $Id: dumprest.pc 3956 2010-01-05 20:56:56Z zacheiss $");

extern void sqlglm(char *, unsigned int *, unsigned int *);

void punt(char *msg)
{
  perror(msg);
  exit(1);
}

void dbmserr(void)
{
  EXEC SQL BEGIN DECLARE SECTION;
  char err_msg[256];
  EXEC SQL END DECLARE SECTION;
  int bufsize = 256, msglength = 0;

  sqlglm(err_msg, &bufsize, &msglength);
  err_msg[msglength] = '\0';
  fprintf(stderr, "Fatal SQL error:\n%s", err_msg);
  exit(1);
}
