home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 December
/
PCWorld_1998-12_cd.iso
/
software
/
sybase
/
ASA
/
asa60.exe
/
data1.cab
/
h_files
/
dbrmt.h
next >
Wrap
C/C++ Source or Header
|
1998-07-27
|
7KB
|
179 lines
/****************************************************************
* Copyright (C) 1988-1998, by Sybase, Inc. *
* All rights reserved. No part of this software may be *
* reproduced in any form or by any means - graphic, *
* electronic or mechanical, including photocopying, *
* recording, taping or information storage and retrieval *
* systems - except with the written permission of *
* Sybase, Inc. *
****************************************************************/
#ifndef _DBRMT_H_INCLUDED
#define _DBRMT_H_INCLUDED
#define II_DBRMT_H
#include "sqlca.h"
#if defined(__unix) || defined(_AIX)
#if !defined(a_bit_field)
#define a_bit_field unsigned int
#define a_bit_short unsigned int
#endif
#else
#if !defined(a_bit_field)
#define a_bit_field unsigned char
#define a_bit_short unsigned short
#endif
#endif
// The purpose of the message queue callback is to process messages
// while SQL Remote is running. The parameter is a number of milliseconds
// to sleep. When SQL Remote is busy, the value of this parameter will be 0.
// When SQL Remote is idle, waiting for incoming messages or for the time
// to process the transaction log, the parameter will be non-zero.
// This routine should return 1 normally, or 0 to stop SQL Remote processing.
#if defined( _SQL_PACK_STRUCTURES )
#include "pshpk1.h"
#endif
#if !defined( _DLLAPI_H_INCLUDED )
#include "dllapi.h"
#endif
#if defined( __cplusplus )
extern "C" {
typedef short _callback_pref (_callback MSG_QUEUE_ROUTINE)( unsigned long );
}
#elif defined( MAC )
typedef _callback short (MSG_QUEUE_ROUTINE)( unsigned long );
#else
typedef short (_callback MSG_QUEUE_ROUTINE)( unsigned long );
#endif
typedef MSG_QUEUE_ROUTINE * MSG_QUEUE_CALLBACK;
typedef struct a_remote_sql {
unsigned short version;
MSG_CALLBACK confirmrtn;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
MSG_QUEUE_CALLBACK msgqueuertn;
char * connectparms;
char * transaction_logs; // directory with transaction logs (dbremote)
a_bit_field receive : 1;
a_bit_field send : 1;
a_bit_field verbose : 1;
a_bit_field deleted : 1;
a_bit_field apply : 1;
a_bit_field batch : 1;
a_bit_field more : 1; // more fields after this (5.0.02)
a_bit_field triggers : 1; // replicate trigger actions
a_bit_field debug : 1;
a_bit_field rename_log : 1; // rename and restart transaction log (dbremote)
a_bit_field latest_backup : 1; // process log until latest backup
a_bit_field scan_log : 1; // scan transaction log (ssremote)
a_bit_field link_debug : 1; // debug for links
a_bit_field unused_bits : 3;
unsigned long max_length; // max length of messages
unsigned long memory; // max memory used building messages
unsigned long frequency; // polling frequency for incoming messages
unsigned long threads; // worker threads applying messages
unsigned long operations; // grouping incoming transactions
char * queueparms; // stable queue connect parms (ssremote)
char * locale; // locale (ssremote)
} a_remote_sql;
#define SEND_ONLY 0
#define RECEIVE_ONLY 1
#define SEND_AND_RECEIVE 2
typedef struct a_message_sync {
unsigned short version;
MSG_CALLBACK confirmrtn;
MSG_CALLBACK errorrtn;
MSG_CALLBACK msgrtn;
a_bit_field link_debug :1;
a_bit_field unused_bits : 7;
char * scriptfile;
short debug;
unsigned short comm_mode; // send or receive or both, etc.
unsigned long max_length; // max length of messages
unsigned long memory; // max memory used building messages
} a_message_sync;
#if defined( _SQL_PACK_STRUCTURES )
#include "poppk.h"
#endif
extern _crtn short _entry DBMessageSync( a_message_sync * );
extern _crtn short _entry DBRemoteSQL( a_remote_sql * );
//************* SQL Remote message encoding interface *******************
// =====================================
//
// This is an interface for encoding SQL Remote messages
// When SQL Remote generates a message it is in the form of random looking
// bytes. It is sometimes necessary to transform this message into a format
// more suitable for sending through a communications channel.
// one example would be translating the message bytes into uuencoded text
// for transport on a medium which only supports ascii characters.
// SQL Remote ships with an encoding DLL that does something similar to
// this.
//
// Any code which handles a Text message should assume that it may be corrupt
// and return ENCODE_CORRUPT if it is. It is not necessary that this
// level ensures the message is not corrupt (ie. by including a
// crc in the message) SQL Remote will do corruption detection on the
// message after this level is done with it.
//
// If the functionality of the existing dll is required in a new dll
// the new dll can load and call the existing dll
typedef enum encode_ret {
ENCODE_SUCCESS,
ENCODE_CORRUPT,
ENCODE_OUT_OF_MEM
} encode_ret;
typedef void a_encode_info;
extern _crtn a_encode_info * _entry EncodeInit( unsigned long max_encoded_len,
unsigned long * max_unencoded_len,
MSG_CALLBACK msgcb,
char * local_user );
// EncodeInit() is passed the max_encoded_len and needs to fill in
// max_unendoed_len.
// max_unencoded_len must be set to the maximum length of an unencoded
// message that will produce an encoded message of size less that or
// equal to max_encoded_len
// for example if encoding a message doubles its size then EncodedInit()
// would contain the line
// => *max_unencoded_len = max_encoded_len/2;
extern _crtn void _entry EncodeFini( a_encode_info * info );
extern _crtn encode_ret _entry EncodeMessage( a_encode_info* info,
char * remote_user,
char * inmessage,
unsigned long inmessage_len,
char * outbuf,
unsigned long outbuf_len,
unsigned long * outmessage_len );
// outbuf is preallocated to the length passed in as outbuflen
// the resulting message size should be placed in *outmessagelen
extern _crtn encode_ret _entry DecodeMessage( a_encode_info * info,
char * inmessage,
unsigned long inmessage_len,
char * outbuf,
unsigned long outbuf_len,
unsigned long * outmessage_len );
// this function is very similar to EncodeMessage, in this case
// inbuf contains an encoded messag and upon exit outbuf
// should contain the decoded message, outmessage_len should
// be the length of the decoded message
// NOTE: see comments above about detecting corrupt messages
#endif