/*
 * N2 CLIENT LIBRARY
 * $Id: n2lib.h,v 804.2 2004/02/26 15:02:28 joe_dry2 Exp $
 *
 * declarations for the N2 client library
 *
 * Copyright (c) 2002-2003 by Secret Labs AB.  All rights reserved.
 */

#ifndef N2LIB_H
#define N2LIB_H

#include "Python.h"


#ifdef __cplusplus
extern "C" {
#endif

/* objects */

#define N2Object void
#define N2None Py_None

#define N2Release(o) Py_XDECREF((PyObject*) (o))

#define N2PrintError PyErr_Print

/* -------------------------------------------------------------------- */
/* controller */

/* factory */

extern N2Object* N2Controller(
    const char* target
    );

/* methods */

extern int N2ControllerLogin(
    N2Object* controller,
    const char* name
    );

extern int N2ControllerLoginUserPassword(
    N2Object* controller,
    const char* name,
    const char* password
    );

extern int N2ControllerLogout(
    N2Object* controller
    );

extern N2Object* N2ControllerFetchData(
    N2Object* controller,
    const char* identifier
    );

extern N2Object* N2ControllerFetchInfo(
    N2Object* controller,
    const char* identifier
    );

extern N2Object* N2ControllerStoreData(
    N2Object* controller,
    const char* identifier,
    N2Object* info
    );

/* -------------------------------------------------------------------- */
/* file management api */

extern N2Object* N2RadarImageOpen(
    const char* filename
    );

extern N2Object* N2RadarImageGetAttribute(
    N2Object* image,
    const char* attribute
    );

extern N2Object* N2RadarImageGetData(
    N2Object* image,
    const char* identifier
    );

extern N2Object* N2RadarImageSetAttribute(
    N2Object* image,
    const char* attribute,
    N2Object* value
    );

extern N2Object* N2RadarImageSetAttributeString(
    N2Object* image,
    const char* attribute,
    const char* value
    );

extern N2Object* N2RadarImageSetData(
    N2Object* image,
    const char* identifier,
    const char* buffer,
    int buffer_size
    );

extern N2Object* N2RadarImageClose(
    N2Object* image
    );


/* -------------------------------------------------------------------- */
/* generic object services */

/* library management */

extern void N2Init(void);

extern void N2InitLib(
    const char* library_root
    );

/* call functions and methods */

extern N2Object* N2Call(
    N2Object* self,
    const char* method,
    const char* format,
    ...
    );

extern N2Object* N2CallObject(
    N2Object* callable,
    const char* format,
    ...
    );

extern N2Object* N2Get(
    N2Object* object,
    const char* attribute
    );

extern N2Object* N2FindFunction(
    const char* module_and_name
    );

extern N2Object* N2FindFunction2(
    const char* module,
    const char* function
    );

/* error/exception management */

extern char* N2Error(void);

extern void N2ErrorClear(void);

#ifdef __cplusplus
}
#endif
/* -------------------------------------------------------------------- */

#endif /* N2LIB_H */
