#ifdef WIN32
#ifndef _PSLib_Header
#define _PSLib_Header
#include <windows.h>
#ifndef BELOWNORMAL_PRIORITY_CLASS
#define BELOWNORMAL_PRIORITY_CLASS 16384
#endif
#ifndef ABOVENORMAL_PRIORITY_CLASS
#define ABOVENORMAL_PRIORITY_CLASS 32768
#endif
#define PSLIB_ERROR_BFSZ 201
#define PSLIB_MAX_LIST	1024
enum {
	PSLIB_SUCCESS,

	/* pslib_init errors */
	PSLIB_LIBRARY,				/* psapi library failed to load */
	PSLIB_ENUM_PROCESSES,		/* failed to get EnumProcesses fn ptr */
	PSLIB_ENUM_PROCESS_MODULES,	/* failed to get EnumProcessModules fn ptr */
	PSLIB_GET_MODULE_FILENAME,	/* failed to get GetModuleFileNameExA fn ptr */

	/* pslib_list/pslib_find errors */
	PSLIB_ENUM_FAILED,			/* call to EnumProcesses failed */

	/* pslib_priority errors */
	PSLIB_PRIORITY_PERMISSION,	/* failed to handle on process to set priority */
	PSLIB_PRIORITY_FAILED,		/* call to SetPriorityClass failed */

	/* pslib_terminate errors */
	PSLIB_TERMINATE_PERMISSION,	/* failed to handle on process to terminate */
	PSLIB_TERMINATE_FAILED,		/* call to TerminateProcess failed */

	/* pslib_find errors */
	PSLIB_FIND_NOTARGET			/* pslib_find was not given a filename to find */
};

/* Loads dll and obtains fn pointers, returns PSLIB_SUCCESS (or zero) on success.
   Returns above error codes on failure, use pslib_error to get error string 
*/
int pslib_init(void);

/* Releases dll */
void pslib_free(void);

/* Get all processes, call the callbk fn.
   The callback function is expected to return either:
     TRUE meaning continue
     FALSE meaning stop
   The callback is passed the process name, a handle, a pid, and it's data.
   Both the handle and the pid can be used with the following functions.
*/
int pslib_list(int (*callbk)(void *, char *,int), void *data);

/* Sets the process priority.
   priority is one of the following:
      IDLE_PRIORITY_CLASS
	  BELOWNORMAL_PRIORITY_CLASS
	  NORMAL_PRIORITY_CLASS
	  ABOVENORMAL_PRIORITY_CLASS
	  HIGH_PRIORITY_CLASS
	  REALTIME_PRIORITY_CLASS

   Returns PSLIB_SUCCESS on success.
   Or errors above, use pslib_error to get error string.
*/
int pslib_priority(int pid, DWORD priority);

/* Terminate the process.
   Returns PSLIB_SUCCESS on success.
   Or errors above, use pslib_error to get error string.
*/
int pslib_terminate(int pid);

/* Finds a specific process's pid, puts it in pid
   Returns PSLIB_SUCCESS on success
   Or errors above, use pslib_error to get error string.
*/
int pslib_find(char *filename, int *pid);

/* Lowers priority of one specific process
*/
int pslib_lower_priority(char *process, char *reason, int bfsz);

/* Fills result with an error, result is assumed to be at least
   PSLIB_ERROR_BFSZ large
*/
char *pslib_error(int errcode, char *result);

#endif
#endif /*WIN32*/
