/*
 * This file is part of the Poliqarp suite.
 * 
 * Copyright (C) 2009 by Instytut Podstaw Informatyki Polskiej
 * Akademii Nauk (IPI PAN; Institute of Computer Science, Polish
 * Academy of Sciences; cf. www.ipipan.waw.pl).  All rights reserved.
 * 
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file gpl.txt included in the packaging
 * of this file.  (See http://www.gnu.org/licenses/translations.html for
 * unofficial translations.)
 * 
 * A commercial license is available from IPI PAN (contact
 * Michal.Ciesiolka@ipipan.waw.pl or ipi@ipipan.waw.pl for more
 * information).  Licensees holding a valid commercial license from IPI
 * PAN may use this file in accordance with that license.
 * 
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

#ifndef BP_COMMON_H
#define BP_COMMON_H

#include <poliqarp-config.h>

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

#include <sakura/common/memory-arena.h>

void bp_show_progress(unsigned int);
void bp_set_verbosity(unsigned int);
void bp_printf(const char *fmt, ...);

void bp_init(const char *command_name);
void bp_done(void);

/**
 * Output a warning message to stderr, without interrupting the program.
 */
void bp_warning(const char *msg, ...);

/**
 * Output an error message to stderr, attach a system error message
 * and terminate the program.
 */
void bp_system_error(const char *msg, ...);

/**
 * Output an error message to stderr and terminate the program.
 */
void bp_fatal(const char *msg, ...);


/**
 * A malloc() variant which is guaranteed to never return NULL.
 */
void *bp_malloc(size_t size);

/**
 * A marena_alloc() variant which is guaranteed to never return NULL.
 */
void *bp_marena_alloc(struct marena *marena, size_t size);

/**
 * A realloc() variant which is guaranteed to never return NULL.
 */
void *bp_realloc(void *ptr, size_t size);

/**
 * A strdup() variant which is guaranteed to never return NULL.
 */
char *bp_strdup(const char *s);

/**
 * Return the file size.
 */
off64_t bp_file_size(FILE *);

void bp_display_usage(const char *argv0, const char *option_summary,
   const char *summary, const char *option_list, const char *extra);

void bp_display_version();

#endif
