/*****************************************************************************\
 *  checkpoint.h - implementation-independent checkpoint API definitions. 
 *****************************************************************************
 *  Copyright (C) 2004 The Regents of the University of California.
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
 *  Written by Morris Jette <jette1@llnl.com>
 *  UCRL-CODE-2002-040.
 *  
 *  This file is part of SLURM, a resource management program.
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 *  
 *  SLURM 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.
 *  
 *  SLURM 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 SLURM; if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
\*****************************************************************************/

#ifndef __CHECKPOINT_H__
#define __CHECKPOINT_H__

#include "slurm/slurm.h"
#include "src/common/macros.h"
#include "src/common/pack.h"

/* Define checkpoint options */
enum check_opts {
	CHECK_DISABLE,		/* disable checkpointing */
	CHECK_ENABLE,		/* enable checkpointing */
	CHECK_CREATE,		/* create a checkpoint for this job, 
				 * job continues execution afterwards */
	CHECK_VACATE,		/* create a checkpoint for this job,
				 * job terminates afterwards */
	CHECK_RESUME,		/* resume a previously checkpointed job */
	CHECK_COMPLETE,		/* a checkpoint of this job has completed */
	CHECK_FAILED,		/* a checkpoint of this job has failed */
	CHECK_ERROR		/* get error info */
};

/* opaque data structures - no peeking! */
#ifndef __check_jobinfo_t_defined
#  define __check_jobinfo_t_defined
   typedef struct check_jobinfo *check_jobinfo_t;
#endif
typedef struct slurm_checkpoint_context * slurm_checkpoint_context_t;

/* initialize checkpoint plugin */
extern int checkpoint_init(char *checkpoint_type);

/* shutdown checkpoint plugin */
extern void checkpoint_fini(void);

/* perform some checkpoint operation */
extern int checkpoint_op(uint16_t op, uint16_t data,
		void * step_ptr);

/* gather checkpoint error info */
extern int checkpoint_error(void * step_ptr, 
		uint16_t *ckpt_errno, char **ckpt_strerror);

/* allocate and initialize a job step's checkpoint context */
extern int checkpoint_alloc_jobinfo(check_jobinfo_t *jobinfo);

/* free storage for a job step's checkpoint context */
extern int checkpoint_free_jobinfo(check_jobinfo_t jobinfo);

/* un/pack a job step's checkpoint context */
extern int  checkpoint_pack_jobinfo  (check_jobinfo_t jobinfo, Buf buffer);
extern int  checkpoint_unpack_jobinfo  (check_jobinfo_t jobinfo, Buf buffer);

#endif /*__CHECKPOINT_H__*/

