remote 3.43 KB
Newer Older
ROOL's avatar
ROOL committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/************************************************************************/
Simon Middleton's avatar
Simon Middleton committed
16
/*                  Copyright 1997-1999 Element 14 Ltd                  */
ROOL's avatar
ROOL committed
17 18
/*                                                                      */
/*  This material is the confidential trade secret and proprietary      */
Simon Middleton's avatar
Simon Middleton committed
19
/*  information of Element 14 Ltd.  It may not be reproduced, used      */
ROOL's avatar
ROOL committed
20
/*  sold, or transferred to any third party without the prior written   */
Simon Middleton's avatar
Simon Middleton committed
21
/*  consent of Element 14 Ltd.  All rights reserved.                    */
ROOL's avatar
ROOL committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
/*                                                                      */
/************************************************************************/

#ifndef __debug_remote_h
#define __debug_remote_h

#include <stdarg.h>

#ifdef REMOTE_DEBUG

/*
 * Function typedef for handlign commands sent from the server end
 */

typedef int (*remote_debug_cmd_handler)(int argc, char *argv[], void *handle);

/*
 * structure to fold session data
 */
typedef struct
{
  int  sock;
  char *info;
  unsigned char priority;
  remote_debug_cmd_handler cmd_handler;
  void *cmd_handle;
} debug_session;

/*
 * Open a connection to host specified by Inet$DebugHost and send an initial
 * connection message. All future sends via this interface will be prefixed by
 * info. A copy of info is made internally. This call will return a pointer to
 * a session structure to be used in subsequent calls.
 */
void remote_debug_open(char *info, debug_session **sess);

/*
 * Send an printf formatted string upto a max of 1024 characters to the debug
 * host. If string is prefixed by (n), this is treated as the debug priority
 * level.
 *
 * Also versions to send a neat string and one passed as a va_list.
 */
void debug_printf(debug_session *sess, char *format, ...);
void debug_vprintf(debug_session *sess, const char *format, va_list list);
void debug_dvprintf(debug_session *sess, int priority, const char *file, int line, const char *format, va_list list);
68 69 70
void debug_print_line(debug_session *sess, const char *line);

void remote_debug_print_line (unsigned int flags, debug_session *sess, const char *line, size_t len);
ROOL's avatar
ROOL committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

/*
 * Register a command handler to handle commands sent from the server
 */

void remote_debug_register_cmd_handler(debug_session *sess, remote_debug_cmd_handler fn, void *handle);
/*
 * Close a previously open debug channel.
 */
void remote_debug_close(debug_session *sess);

/*
 * check the input port for any data. Call this every so often to ensure commands
 * get executed when entered rather than on the next debug write.
 */
int debug_poll(debug_session *sess);

88
const char *remote_debug_version (void);
89

ROOL's avatar
ROOL committed
90 91 92 93 94 95
#else

#define remote_debug_open(x,y)
#define debug_printf 1?0:printf
#define debug_vprintf(s,f,l)
#define debug_print_line(s,d)
96
#define remote_debug_print_line(f,s,l,le)
ROOL's avatar
ROOL committed
97
#define remote_debug_close(x)
98
#define remote_debug_version()
ROOL's avatar
ROOL committed
99 100 101 102

#endif /* REMOTE_DEBUG */

#endif