/*
AMarquee.library proto header
(c)Håkan Parting 2000
$VER: amarquee_protos.h 50.8 (26.02.2000)
*/
#ifndef AMARQUEE_PROTOS_H
#define AMARQUEE_PROTOS_H

#include <rexx/storage.h>

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

#ifndef UTILITY_TAGITEM_H
#include <utility/tagitem.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

/* NOTE: ************************
Programs compiled with this header 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. 
*/

/* Open a connection using the AMarquee protocol */
extern LibCall struct QSession * QNewSession(char * hostname, LONG port, char * progname, struct TagItem *taglist);
extern struct QSession * QNewSessionTags(char * hostname, LONG port, char * progname, unsigned long tag1type, ... );
extern LibCall struct QSession * QNewSessionAsync(char * hostname, LONG port, char * progname, struct TagItem *taglist);
extern struct QSession * QNewSessionAsyncTags(char * hostname, LONG port, char * progname, unsigned long tag1type, ...);

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

/* 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. */
extern LibCall struct QSession * QNewSocketSession(char * hostname, LONG port, struct TagItem *tags );
extern struct QSession * QNewSocketSessionTags(char * hostname, LONG port, unsigned long tag1type, ... );
extern LibCall struct QSession * QNewSocketSessionAsync(char * hostname, LONG port, struct TagItem *tags );
extern struct QSession * QNewSocketSessionAsyncTags(char * hostname, LONG port, unsigned long tag1type, ... );

/* 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. */
extern LibCall struct QSession * QNewSocketServerSession(LONG *port, struct TagItem *tags );
extern struct QSession * QNewSocketServerSessionTags(LONG *port, unsigned long tag1type, ... );

/* 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 QClearSubscriptionsOp(struct QSession * session, LONG which);
extern LibCall LONG QDebugOp(struct QSession * session, char * string);
extern LibCall LONG QDeleteOp(struct QSession * session, char * wildpath);
extern LibCall LONG QGetOp(struct QSession * session, char * wildpath, LONG maxBytes);
extern LibCall LONG QGetAndSubscribeOp(struct QSession * session, char * wildpath, LONG maxBytes);
extern LibCall LONG QInfoOp(struct QSession * session);
extern LibCall LONG QMessageOp(struct QSession * session, char * hosts, void * buffer, ULONG bufferLength);
extern LibCall LONG QPingOp(struct QSession * session);
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 QSetKeyAccessOp(struct QSession * session, char *path, char *newAccess);
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 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);

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

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

/* Manage shared message ports */
extern LibCall struct QSharedMessagePort *QCreateSharedMessagePort(void);
extern LibCall void QDeleteSharedMessagePort(struct QSharedMessagePort *mp);

/* 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 */
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);

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

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


#ifdef __cplusplus
}
#endif

#endif /* AMARQUEE_PROTOS_H */
