00001 #ifndef DEBUGGER_IMPLEMENTATION_FILE
00002 #define DEBUGGER_IMPLEMENTATION_FILE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "debugger.h"
00019 #include "win_ext.rh"
00020
00021 #include <basis/convert_utf.h>
00022 #include <basis/function.h>
00023 #include <basis/istring.h>
00024 #include <basis/packable.h>
00025 #include <basis/portable.h>
00026
00027 debugger::debugger(void *recipient, synchronicity synch,
00028 line_ending ending, time_stamp_method stamp)
00029 : log_base(),
00030 _recipient(recipient),
00031 _synch(synch),
00032 _stamp(stamp)
00033 {
00034 eol(ending);
00035 }
00036
00037 debugger::~debugger() {}
00038
00039 const u_int &debugger::EVENT()
00040 {
00041 #ifdef __WIN32__
00042
00043
00044 const char *DEBUG_UNIQUIFIER = "dbg_interprocess_event";
00045 static u_int ev = RegisterWindowMessage(to_unicode_temp(DEBUG_UNIQUIFIER));
00046 #else
00047 static u_int ev = 0;
00048 #endif
00049 return ev;
00050 }
00051
00052 outcome debugger::log(u_int string_table_id, void *instance, int filter)
00053 {
00054 #ifdef __WIN32__
00055 return log(portable::rc_string(string_table_id,
00056 (application_instance)instance), filter);
00057 #else
00058 if (string_table_id || instance || filter) {}
00059 return common::NOT_IMPLEMENTED;
00060 #endif
00061 }
00062
00063 void *debugger::recipient() const { return _recipient; }
00064
00065 byte_array *debugger::create_debug_message(const istring &info,
00066 line_ending ending, int filter, time_stamp_method stamp)
00067 {
00068
00069
00070
00071
00072
00073 byte_array *to_send = new byte_array;
00074 basis::attach(*to_send, short(ending));
00075 basis::attach(*to_send, filter);
00076 istring real_info;
00077 if (info.t() && (stamp == ADD_STAMP) )
00078 real_info = timestamp(true, true);
00079 real_info += info;
00080 real_info.pack(*to_send);
00081 return to_send;
00082 }
00083
00084 istring debugger::crack_debug_message(void *lparam,
00085 line_ending &ending, int &filter)
00086 {
00087
00088 byte_array *received = (byte_array *)lparam;
00089
00090 short the_end;
00091 basis::detach(*received, the_end);
00092 ending = line_ending(the_end);
00093
00094 basis::detach(*received, filter);
00095
00096 istring to_return;
00097 to_return.unpack(*received);
00098 WHACK(received);
00099 return to_return;
00100 }
00101
00102 outcome debugger::log(const istring &info, int filter)
00103 {
00104
00105
00106 if (!_recipient) return common::BAD_INPUT;
00107 #ifdef __WIN32__
00108 if (!IsWindow((HWND)_recipient)) {
00109
00110 _recipient = NIL;
00111 return common::BAD_INPUT;
00112 }
00113 HGLOBAL holder = create_debug_message(info, eol(), filter, _stamp);
00114
00115 if (_synch == immediate)
00116 ::SendMessage((window_handle)_recipient, debugger::EVENT(), 0,
00117 (LPARAM)holder);
00118 else
00119 ::PostMessage((window_handle)_recipient, debugger::EVENT(), 0,
00120 (LPARAM)holder);
00121 return common::OKAY;
00122 #else
00123 if (!info || filter) {}
00124 return common::NOT_IMPLEMENTED;
00125 #endif
00126 }
00127
00128
00129 #endif //DEBUGGER_IMPLEMENTATION_FILE
00130