/*
 * pxtools.h
 *
 * Copyright (C) 2006  Joshua Hoblitt
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * program; see the file COPYING. If not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef PXTOOLS_H
#define PXTOOLS_H 1

#include <stdio.h>
#include <strings.h>  // for strcasecmp
#include <unistd.h>   // for unlink
#include <pslib.h>
#include <psmodules.h>
#include <ippdb.h>

#include "pxtoolsErrorCodes.h"
#include "pxio.h"
#include "pxdata.h"
#include "pxtag.h"
#include "pxregister.h"
#include "pxchip.h"
#include "pxcam.h"
#include "pxtree.h"
#include "pxconfig.h"

# define MAX_ROWS 10e9
# define PXTOOL_MODE_NONE 0x0

bool pxCreateTables (pxConfig *config);
bool pxDeleteTables (pxConfig *config);

bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code);

psExit pxerrorGetExitStatus ();

void pxUsage(FILE *stream, int argc, char **argv, const char *modeName, psMetadata *argSet);
bool pxGetOptions(FILE *stream, int argc, char **argv, pxConfig *config, psMetadata *modes, psMetadata *argSets);

#define PXTOOL_ADD_MODE(option, comment, modeval, argset) \
{ \
    if (!psMetadataAddMetadata(argSets, PS_LIST_TAIL, option, 0, comment, argset)) {;\
        psError(PS_ERR_UNKNOWN, false, "failed to add argset for %s", option); \
    } \
    psFree(argset); \
\
    if (!psMetadataAddU32(modes, PS_LIST_TAIL, option, 0, comment, modeval)) {;\
        psError(PS_ERR_UNKNOWN, false, "failed to add argset for %s", option); \
    } \
}

#endif // PXTOOLS_H
