/* -*- mode: C++; tab-width: 4 -*- */ /* ===================================================================== *\ Copyright (c) 2000-2001 Palm, Inc. or its subsidiaries. All rights reserved. This file is part of the Palm OS Emulator. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. \* ===================================================================== */ #include "EmCommon.h" #include "TracerCommon.h" #include "PreferenceMgr.h" // --------------------------------------------------------------------------- // ¥ TracerBase::TracerBase // --------------------------------------------------------------------------- TracerBase::TracerBase(void) { tracerRefCounter = 0; } // --------------------------------------------------------------------------- // ¥ TracerBase::~TracerBase // --------------------------------------------------------------------------- TracerBase::~TracerBase(void) { } // --------------------------------------------------------------------------- // ¥ TracerBase::GetTracerTypeCount // --------------------------------------------------------------------------- unsigned short TracerBase::GetTracerTypeCount (void) { return supportedTypesCount; } // --------------------------------------------------------------------------- // ¥ TracerBase::GetTracerTypeInfo // --------------------------------------------------------------------------- TracerTypeInfo* TracerBase::GetTracerTypeInfo (unsigned short index) { if (index < 1 || index > supportedTypesCount) { return 0; } return &supportedTypesTable[index-1]; // Types are numbered starting from 1 } // --------------------------------------------------------------------------- // ¥ TracerBase::GetCurrentTracerTypeInfo // --------------------------------------------------------------------------- TracerTypeInfo* TracerBase::GetCurrentTracerTypeInfo (void) { return GetTracerTypeInfo (runningTracerType); } // --------------------------------------------------------------------------- // ¥ TracerBase::GetCurrentTracerTypeIndex // --------------------------------------------------------------------------- unsigned short TracerBase::GetCurrentTracerTypeIndex (void) { return runningTracerType; } // --------------------------------------------------------------------------- // ¥ TracerBase::GetCapsToken // --------------------------------------------------------------------------- void TracerBase::GetCapsToken (char* src, char* tag, char* dst, size_t dstSize) { int copiedBytes = 0; src = strstr(src,tag); if (!src) { *dst= 0; return; } src += strlen(tag); while (*src != ',' && *src != 0 && copiedBytes < dstSize-1) { *dst++ = *src++; copiedBytes++; } *dst= 0; } // --------------------------------------------------------------------------- // ¥ TracerBase::LoadTracerTypeList // --------------------------------------------------------------------------- void TracerBase::LoadTracerTypeList (void) { char tracerCaps[4096]; size_t bufferLen = 4096; char *cursor; int i; char buff[2]; // Get last used Type from prefs Preference prefLastTracerType (kPrefKeyLastTracerType); string lastTypeName = *prefLastTracerType; supportedTypesCount = 0; supportedTypesTable = 0; // Ask PalmTrace for supported tracer Types // The expected result is a set of strings terminated by a double 0. Here is a possible one: // "Type=tcp,name=Palm Reporter,paramdescr=Target:,paramdefval=localhost,autoconnect=1" GetTracerCapabilities (tracerCaps, &bufferLen); // The string can't be void cursor = tracerCaps; if (*cursor == 0) { return; } while (cursor && *cursor) { supportedTypesCount++; // Seek next 0 ; the end marker is a double zero cursor += strlen(cursor)+1; } if (supportedTypesCount > 0) { cursor = tracerCaps; supportedTypesTable = new TracerTypeInfo [supportedTypesCount]; // Set up a tracer Type table in memory for (i=0; i", t->type, t->autoConnectCurState, t->paramCurVal); s += buffer; } prefTracerTypes = s; } // --------------------------------------------------------------------------- // ¥ TracerBase::DisposeTracerTypeList // --------------------------------------------------------------------------- void TracerBase::DisposeTracerTypeList (void) { SaveTracerPrefs (); delete supportedTypesTable; supportedTypesTable = 0; supportedTypesCount = 0; }