#ifndef PA__ARGS_H
#define PA__ARGS_H

/*
 * PaVS - Pasky's Version System, advanced version control system
 * Copyright (C) 2003  Petr Baudis
 *
 * 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; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifdef __cplusplus
extern "C" {
#endif


/* Routines for convient work with argc/argv arguments can be found here. */


/* This structure is for fast arg-pairs passing. */
struct args {
	int argc;
	char **argv;
};


#include <assert.h>

/* This shifts the argument list and returns the fetched value. */
static inline char *
args_shift (struct args *args)
{
	assert (args->argc > 0);
	args->argc --; args->argv ++;
	return args->argv [-1];
}

/* This unshifts the argument list, restoring the value originally stored
 * there. Note that NO bounds-checking is done so it is your responsibility to
 * prevent underflow. */
/* Returns the original value just unshifted. */
static inline char *
args_unshift (struct args *args)
{
	args->argc ++; args->argv --;
	return args->argv [0];
}


#ifdef __cplusplus
}
#endif

#endif
