#ifndef CLIB_AMARQUEE_PROTOS_H
#define CLIB_AMARQUEE_PROTOS_H

/*
**  $VER: amarquee_protos.h 53.0 (24.03.2002)
**
**  C prototypes. For use with 32 bit integers only.
**
**  Copyright © 2001 Håkan Parting
**      All Rights Reserved
**
** Note:
** Programs compiled with this protos and pragmas won't work with
** amarquee.library less than v.50. So you'd require v.50 in OpenLibrary() !
**
** From v.50 QNewSession, QNewSessionAsync(), QNewHostSession and QNewServerSession()
** have a fourth argument.
** Set it to NULL in old source code.
*/

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef REXX_STORAGE_H
#include <rexx/storage.h>
#endif

#ifndef UTILITY_TAGITEM_H
#include <utility/tagitem.h>
#endif

#ifndef LIBRARIES_AMARQUEE_H
#include <libraries/AMarquee.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* Open a connection using the AMarquee protocol */
struct QSession * QNewSession(STRPTR hostname, LONG port, STRPTR progname, struct TagItem *taglist);
struct QSession * QNewSessionTags(STRPTR hostname, LONG port, STRPTR progname, Tag tag1, ... );
struct QSession * QNewSessionAsync(STRPTR hostname, LONG port, STRPTR progname, struct TagItem *taglist);
struct QSession * QNewSessionAsyncTags(STRPTR hostname, LONG port, STRPTR progname, Tag tag1, ...);

/* Use this to open a host QSession to receive connections using the AMarquee protocol. */
struct QSession * QNewHostSession(STRPTR hostnames, LONG * port, STRPTR progNames, struct TagItem *taglist);
struct QSession * QNewHostSessionTags(STRPTR hostnames, LONG * port, STRPTR progNames, Tag tag1, ...);
/* Receive connection using the AMarquee protocol through INETD */
struct QSession * QNewServerSession(STRPTR hostNames, STRPTR progNames, struct TagItem *taglist);
struct QSession * QNewServerSessionTags(STRPTR hostNames, STRPTR progNames, Tag tag1, ...);

/* Open a connection for raw data. (A Socket-Session)*/
/* These functions don't use any protocol, i.e. it can be used to connect to HTTP, FTP or any other TCP service. */
struct QSession * QNewSocketSession(STRPTR hostname, LONG port, struct TagItem *tags );
struct QSession * QNewSocketSessionTags(STRPTR hostname, LONG port, Tag tag1, ... );
struct QSession * QNewSocketSessionAsync(STRPTR hostname, LONG port, struct TagItem *tags );
struct QSession * QNewSocketSessionAsyncTags(STRPTR hostname, LONG port, Tag tag1, ... );

/* Use this to open a Socket-Session server QSession to receive connections on. */
/* This function doesn't use any protocol, i.e. it can be used to receive connections from clients
not using the AMarquee protocol. */
struct QSession * QNewSocketServerSession(LONG *port, struct TagItem *tags );
struct QSession * QNewSocketServerSessionTags(LONG *port, Tag tag1, ... );

/* Closes a QNew*Session */
LONG QFreeSession(struct QSession * session);

/* Transactions--these return their transaction ID #, or zero on no memory. */
LONG QClearSubscriptionsOp(struct QSession * session, LONG which);
LONG QDebugOp(struct QSession * session, STRPTR string);
LONG QDeleteOp(struct QSession * session, STRPTR wildpath);
LONG QGetOp(struct QSession * session, STRPTR wildpath, LONG maxBytes);
LONG QGetAndSubscribeOp(struct QSession * session, STRPTR wildpath, LONG maxBytes);
LONG QInfoOp(struct QSession * session);
LONG QMessageOp(struct QSession * session, STRPTR hosts, VOID * buffer, ULONG bufferLength);
LONG QPingOp(struct QSession * session);
LONG QRenameOp(struct QSession * session, STRPTR path, STRPTR label);
LONG QSubscribeOp(struct QSession * session, STRPTR wildpath, LONG maxBytes);
LONG QSetKeyAccessOp(struct QSession * session, STRPTR path, STRPTR newAccess);
LONG QSetOp(struct QSession * session, STRPTR path, VOID * buffer, ULONG bufferLength);
LONG QStreamOp(struct QSession * session, STRPTR path, VOID * buffer, ULONG bufferLength);
LONG QSetAccessOp(struct QSession * session, STRPTR newAccess);
LONG QSetMessageAccessOp(struct QSession * session, STRPTR newAccess, LONG maxBytes);
LONG QGo(struct QSession * session, ULONG flags);

/* The only transaction that can be used with with Socket-Sessions and not for AMarquee-protocol sessions  */
LONG QSendRawOp(struct QSession * session, VOID * buffer, ULONG bufferLength);

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

/* Manage shared message ports */
struct QSharedMessagePort * QCreateSharedMessagePort(VOID);
VOID QDeleteSharedMessagePort(struct QSharedMessagePort *mp);

/* Get data about the session */
ULONG QNumQueuedPackets(struct QSession * session);
ULONG QNumQueuedBytes(struct QSession * session);
STRPTR QGetHostName(struct QSession * session);
STRPTR QGetProgName(struct QSession * session);
STRPTR QErrorName(LONG error);
STRPTR QGetLocalIP(struct QSession * session);

/* Administrative calls */
LONG QRequestPrivilegesOp(struct QSession * session, ULONG privBits);
LONG QReleasePrivilegesOp(struct QSession * session, ULONG privBits);
LONG QKillClientsOp(struct QSession * session, STRPTR hosts);
LONG QSetParameterOp(struct QSession * session, STRPTR paramName, STRPTR newValue);
LONG QGetParameterOp(struct QSession * session, STRPTR paramName);
LONG QSysMessageOp(struct QSession * session, STRPTR hosts, STRPTR message);

/* Support sharing QSessions between threads */
BOOL QDetachSession(struct QSession * session, ULONG flags);
BOOL QReattachSession(struct QSession * session, ULONG flags);

/* set data about Socket-Sessions */
VOID QSetMaxRawBufSize(struct QSession * session, ULONG maxBufSize);


#ifdef __cplusplus
}
#endif

#endif /* CLIB_AMARQUEE_PROTOS_H */
