#ifndef AMARQUEE_PROTOS_H
#define AMARQUEE_PROTOS_H

#include <rexx/storage.h>

#ifndef AMARQUEE_H
#include <libraries/Amarquee.h>
#endif

#ifdef __SASC_60
#define LibCall libcall
#else
#define LibCall __geta4 __regargs
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Open or close a connection */
extern LibCall struct QSession * QNewSession(char * hostname, LONG port, char * progname);  /* returns socket descriptor */
extern LibCall struct QSession * QNewSessionAsync(char * hostname, LONG port, char * progname);  /* returns socket descriptor */
extern LibCall LONG QFreeSession(struct QSession * session);

/* Transactions--these return their transaction ID #, or zero on no memory. */
extern LibCall LONG QDebugOp(struct QSession * session, char * string);
extern LibCall LONG QGetOp(struct QSession * session, char * wildpath, LONG maxBytes);
extern LibCall LONG QDeleteOp(struct QSession * session, char * wildpath);
extern LibCall LONG QRenameOp(struct QSession * session, char * path, char * label);
extern LibCall LONG QSubscribeOp(struct QSession * session, char * wildpath, LONG maxBytes);
extern LibCall LONG QSetOp(struct QSession * session, char * path, void * buffer, ULONG bufferLength);
extern LibCall LONG QClearSubscriptionsOp(struct QSession * session, LONG which);
extern LibCall LONG QPingOp(struct QSession * session);
extern LibCall LONG QInfoOp(struct QSession * session);
extern LibCall LONG QSetAccessOp(struct QSession * session, char * newAccess);
extern LibCall LONG QGo(struct QSession * session, ULONG flags);

/* Call this function to free your QMessage! */
extern LibCall void FreeQMessage(struct QSession * session, struct QMessage * qmsg);

/* Use this to open a host QSession to receive connections on. */
extern LibCall struct QSession * QNewHostSession(char * hostnames, LONG * port, char * progNames);
extern LibCall LONG QStreamOp(struct QSession * session, char * path, void * buffer, ULONG bufferLength);
extern LibCall struct QSession * QNewServerSession(char * hostNames, char * progNames);

extern LibCall LONG QSetMessageAccessOp(struct QSession * session, char * newAccess, LONG maxBytes);
extern LibCall LONG QMessageOp(struct QSession * session, char * hosts, void * buffer, ULONG bufferLength);

extern LibCall ULONG QNumQueuedPackets(struct QSession * session);
extern LibCall ULONG QNumQueuedBytes(struct QSession * session);

extern LibCall char * QErrorName(LONG error);

/* Administrative calls, introduced for v1.45 */
extern LibCall LONG QRequestPrivilegesOp(struct QSession * session, ULONG privBits);
extern LibCall LONG QReleasePrivilegesOp(struct QSession * session, ULONG privBits);
extern LibCall LONG QKillClientsOp(struct QSession * session, char * hosts);
extern LibCall LONG QSetParameterOp(struct QSession * session, char * paramName, char * newValue);
extern LibCall LONG QGetParameterOp(struct QSession * session, char * paramName);
extern LibCall LONG QSysMessageOp(struct QSession * session, char * hosts, char * message);

/* Convenience method, introduced for v1.46 */
extern LibCall LONG QGetAndSubscribeOp(struct QSession * session, char * wildpath, LONG maxBytes);

/* Introduced for v1.47, to support sharing QSessions between threads */
extern LibCall BOOL QDetachSession(struct QSession * session, ULONG flags);
extern LibCall BOOL QReattachSession(struct QSession * session, ULONG flags);

#ifdef __cplusplus
}
#endif

#endif /* AMARQUEE_PROTOS_H */