#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
#ifndef __GNUC__
#define LibCall __geta4 __regargs
#else
#define LibCall
#define extern
#endif
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Open or close a connection */
extern LibCall struct QSession * QNewSession(char * hostname, LONG port, char * progname);
extern LibCall struct QSession * QNewSessionAsync(char * hostname, LONG port, char * progname);
/* Closes a QNew*Session */
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 QMessageOp(struct QSession * session, char * hosts, void * buffer, ULONG bufferLength);
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 QStreamOp(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 QSetMessageAccessOp(struct QSession * session, char * newAccess, LONG maxBytes);
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);
/* Receive connection through INETD */
extern LibCall struct QSession * QNewServerSession(char * hostNames, char * progNames);

/* Get data about the session */
extern LibCall ULONG QNumQueuedPackets(struct QSession * session);
extern LibCall ULONG QNumQueuedBytes(struct QSession * session);
extern LibCall char *QGetHostName(struct QSession * session);
extern LibCall char *QGetProgName(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);

/* These functions are wrappers for normal bsdsocket.library calls which makes it possible */
/* to connect to standard servers, like FTP and HTTP. You could also open a socket which */
/* listens on a specified port. Use it to make a server that also programs not using */
/* amarquee.library may connect to. */

/* Open a raw socket connection. Introduced in v1.49 */
extern LibCall struct QSession * QNewSocketSession(char * hostname, LONG port, struct TagItem *taglist);
extern LibCall struct QSession * QNewSocketSessionAsync(char * hostname, LONG port, struct TagItem *taglist);

/* Use this to open a raw socket server QSession to receive connections on. */
extern LibCall struct QSession * QNewSocketServerSession(LONG *port, struct TagItem *taglist);

/* Transactions allowed on raw socket connections. All these return an ID #, or 0 on no memory */
extern LibCall LONG QSendRawOp(struct QSession * session, void * buffer, ULONG bufferLength);
/* QGo must be called to send queued transactions */

/* Transactions--these return their transaction ID #, or zero on no memory. */
/* Not for use with a raw Socket Session */
extern LibCall LONG QSetKeyAccessOp(struct QSession * session, char *path, char *newAccess);
 

#ifdef __cplusplus
}
#endif

#endif /* AMARQUEE_PROTOS_H */
