static void KplNetInterfaceChanged(void *refCon); #endif /* TARGET_OS_KPL */ // --------------------------------------------------------------------- #if TARGET_OS_WIN32 UINT gNetworkInterfaceChangedMessage; #endif /* TARGET_OS_WIN32 */ #if SUPPORT_INSTRUMENTATION static Boolean doFormatMessageFskNetInterfaceNotifier(FskInstrumentedType dispatch, UInt32 msg, void *msgData, char *buffer, UInt32 bufferSize); static FskInstrumentedTypeRecord gNetInterfaceNotifierTypeInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "netinterfacenotifier", FskInstrumentationOffset(FskNetInterfaceNotifierRec), NULL, 0, NULL, doFormatMessageFskNetInterfaceNotifier }; #endif /* SUPPORT_INSTRUMENTATION */ // --------------------------------------------------------------------- #if TARGET_OS_WIN32 static HANDLE networkInterfaceChangeThread = NULL; static HWND networkInterfaceTrackerWindow = NULL; static HANDLE networkInterfaceChangeQuitEvent = NULL; DWORD WINAPI networkInterfaceChangeThreadFunc( LPVOID lpParam )
#include "FskNetUtils.h" #include "FskSSL.h" #include "FskEndian.h" #include "kpr.h" #include "kprShell.h" #include "kprUtilities.h" #include "kprWebSocketEndpoint.h" //-------------------------------------------------- // INSTRUMENTATION //-------------------------------------------------- #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord gKprWebSocketEndpointInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprWebSocketEndpoint", FskInstrumentationOffset(KprWebSocketEndpointRecord), NULL, 0, NULL, NULL, NULL, 0 }; #endif //-------------------------------------------------- // WebSocket Interface //-------------------------------------------------- #define kSocketBufferSize (128 * 1024) #define CALLBACK(x) if (self->x) self->x enum { kKprWebSocketEndpoint_onHeader = 1, kKprWebSocketEndpoint_onFrameOpcode, kKprWebSocketEndpoint_onFrameLength,
* 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. */ #include "kpr.h" #include "kprZeroconfCommon.h" #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprZeroconfServiceInfoInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprZeroconfServiceInfo", FskInstrumentationOffset(KprZeroconfServiceInfoRecord), NULL, 0, NULL, NULL, NULL, 0 }; #endif #if 0 #pragma mark - KprBonjourServiceInfo #endif FskErr KprZeroconfServiceInfoNew(KprZeroconfServiceInfo *it, const char* type, const char* name, const char* host, const char* ip, UInt32 port, const UInt32 interfaceIndex, char* txt) { FskErr err = kFskErrNone; KprZeroconfServiceInfo self = NULL; bailIfError(FskMemPtrNewClear(sizeof(KprZeroconfServiceInfoRecord), it)); self = *it; self->type = FskStrDoCopy(type); bailIfNULL(self->type);
mxFrameCommand, mxGlobalCommand, mxInstanceCommand, mxListBreakpointsCommand, mxClearAllBreakpointsCommand, mxClearBreakpointCommand, mxSetBreakpointCommand, mxListFilesCommand }; #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprDebugInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprDebug", FskInstrumentationOffset(KprDebugRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; static FskInstrumentedTypeRecord KprDebugMachineInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprDebugMachine", FskInstrumentationOffset(KprDebugMachineRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; #endif static FskErr KprDebugNew(KprDebug* it, UInt32 port); static void KprDebugDispose(KprDebug self); static KprDebugMachine KprDebugFindMachine(KprDebug self, char* address); static void KprDebugMachineCallback(KprDebugMachine machine, char* function); static void KprDebugMachineCallbackText(KprDebugMachine machine, char* function, int view, char* text); static void KprDebugMachineCallbackView(KprDebugMachine machine, char* function, int view); static FskErr KprDebugMachineNew(KprDebugMachine* it, KprDebug debug, FskSocket skt); static void KprDebugMachineDispose(KprDebugMachine self); static void KprDebugMachineDispatchCommand(KprDebugMachine self, int theCommand, char* name, char* value, SInt32 number);
* 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. */ #include "kpr.h" #include "kprShell.h" #include "kprZeroconf.h" #include "kprZeroconfCommon.h" #include "kprZeroconfBrowser.h" #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprZeroconfBrowserInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprZeroconfBrowser", FskInstrumentationOffset(KprZeroconfBrowserRecord), NULL, 0, NULL, NULL, NULL, 0 }; #endif FskList gZeroconfBrowsers = NULL; #if 0 #pragma mark - KprZeroconfBrowser #endif FskErr KprZeroconfBrowserNew(KprZeroconfBrowser *it, const char* serviceType) { FskErr err = kFskErrNone; KprZeroconfBrowser self = NULL; if (KprZeroconfBrowserFind(NULL, serviceType)) { bailIfError(kFskErrDuplicateElement); // only one browser per serviceType
kprServicesThread, "xkpr://services/proxy", NULL, NULL, KprServiceAccept, KprProxyServiceCancel, KprProxyServiceInvoke, KprProxyServiceStart, KprProxyServiceStop, NULL, NULL, NULL }; #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprProxyServiceBehaviorInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprBehavior", FskInstrumentationOffset(KprBehaviorRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; #endif KprDelegateRecord kprProxyServiceBehaviorDelegateRecord = { KprDefaultBehaviorAccept, KprDefaultBehaviorActivated, KprDefaultBehaviorAdapt, KprDefaultBehaviorCancel, KprDefaultBehaviorComplete, KprDefaultBehaviorDisplayed, KprDefaultBehaviorDisplaying, KprProxyServiceBehaviorDispose, KprDefaultBehaviorFinished, KprDefaultBehaviorFocused, KprProxyServiceBehaviorInvoke, KprDefaultBehaviorKeyDown, KprDefaultBehaviorKeyUp,
#ifdef mxDebug fxDebugLoop(the, thePath, theLine, "C: xsDebugger"); #endif } /* Machine */ #if __FSK_LAYER__ && SUPPORT_INSTRUMENTATION static Boolean doFormatMessageXS(FskInstrumentedType dispatch, UInt32 msg, void *msgData, char *buffer, UInt32 bufferSize); static FskInstrumentedTypeRecord gXSTypeInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "xs", FskInstrumentationOffset(txMachine), NULL, 0, NULL, doFormatMessageXS }; Boolean doFormatMessageXS(FskInstrumentedType dispatch, UInt32 msg, void *msgData, char *buffer, UInt32 bufferSize) { txMachine *the = (txMachine *)msgData; switch (msg) { case kFskXSInstrAllocateChunks: snprintf(buffer, bufferSize, "Chunk allocation: reserved=%d, used=%d, peak=%d", the->maximumChunksSize, the->currentChunksSize, the->peakChunksSize); return true;
{ #if K4GEN2 FskHardwarePinsInit(); #endif KprServiceRegister(&gPinsService); return kFskErrNone; } FskExport(FskErr) kprPins_fskUnload(FskLibrary it) { return kFskErrNone; } #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprPinsInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprPins", FskInstrumentationOffset(KprPinsRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; #endif FskErr KprPinsNew(KprPins *it) { FskErr err = kFskErrNone; bailIfError(FskMemPtrNewClear(sizeof(KprPinsRecord), it)); FskInstrumentedItemNew((KprPins)*it, NULL, &KprPinsInstrumentation); bail: return err; } void KprPinsCancel(KprService service UNUSED, KprMessage message UNUSED) { }
#include "kprHTTPClient.h" #include "kprMessage.h" #include "kprUtilities.h" #include "kprLibrary.h" #include "kprLibraryServer.h" static FskErr KprLibraryServerRequestConditionCallback(FskHTTPServerRequest request, UInt32 condition, void *refCon); static FskErr KprLibraryServerRequestBodyCallback(FskHTTPServerRequest request UNUSED, char *data, UInt32 size, UInt32 *consumed, void *refCon); static FskErr KprLibraryServerResponseBodyCallback(FskHTTPServerRequest request UNUSED, char *data, UInt32 size, UInt32 *generated, void *refCon); static FskErr KprLibrarySessionNew(KprLibrarySession* it, FskHTTPServerRequest request); static void KprLibrarySessionDispose(KprLibrarySession self); static void KprLibrarySessionRedirectCallback(KprMessage message, void* it); #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprLibraryQueryInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprLibraryQuery", FskInstrumentationOffset(KprLibraryQueryRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; static FskInstrumentedTypeRecord KprLibraryServerInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprLibraryServer", FskInstrumentationOffset(KprLibraryServerRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; static FskInstrumentedTypeRecord KprLibrarySessionInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprLibrarySession", FskInstrumentationOffset(KprLibrarySessionRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; #endif static KprLibraryServer gLibraryServer = NULL; static FskErr KprLibraryQueryNew(KprLibraryQuery* it) { FskErr err = kFskErrNone; bailIfError(FskMemPtrNewClear(sizeof(KprLibraryQueryRecord), it)); FskInstrumentedItemNew((KprLibraryQuery)*it, NULL, &KprLibraryQueryInstrumentation); bail: return err; }
char* txt; #if KPR_ZEROCONF_EMBEDDED #elif TARGET_OS_MAC CFSocketRef socket; CFRunLoopSourceRef source; #else FskThreadDataHandler handler; FskThreadDataSource source; #endif UInt32 port; DNSServiceRef serviceRef; FskInstrumentedItemDeclaration }; #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprZeroconfPlatformAdvertisementInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprZeroconfPlatformAdvertisement", FskInstrumentationOffset(KprZeroconfPlatformAdvertisementRecord), NULL, 0, NULL, NULL, NULL, 0 }; static FskInstrumentedTypeRecord KprZeroconfPlatformBrowserInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprZeroconfPlatformBrowser", FskInstrumentationOffset(KprZeroconfPlatformBrowserRecord), NULL, 0, NULL, NULL, NULL, 0 }; static FskInstrumentedTypeRecord KprZeroconfPlatformServiceInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprZeroconfPlatformService", FskInstrumentationOffset(KprZeroconfPlatformServiceRecord), NULL, 0, NULL, NULL, NULL, 0 }; #endif #if TARGET_OS_MAC void KprZeroconfPlatformCallBack(CFSocketRef socketRef, CFSocketCallBackType cbType, CFDataRef addr, const void* data, void* context) #else void KprZeroconfPlatformCallBack(FskThreadDataHandler handler, FskThreadDataSource source, void* context) #endif { DNSServiceRef serviceRef = context; DNSServiceErrorType error = kDNSServiceErr_NoError; error = DNSServiceProcessResult(serviceRef); if (error) FskDebugStr("!!! KprZeroconfPlatformCallBack error %d", error);
#define kFskHTTPKeepAliveTimeout 30 #define kFskHTTPSSLHandshakeTimeout (30*1000) static void httpServerEngineCycle(void *param); static void httpServerTimeCycle(FskTimeCallBack cb, const FskTime when, void *param); #if SUPPORT_INSTRUMENTATION static Boolean doFormatMessageHTTPServer(FskInstrumentedType dispatch, UInt32 msg, void *msgData, char *buffer, UInt32 bufferSize); static FskInstrumentedTypeRecord gFskHTTPServerTypeInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "httpserver", FskInstrumentationOffset(FskHTTPServerRecord), NULL, 0, NULL, doFormatMessageHTTPServer }; static FskInstrumentedTypeRecord gFskHTTPServerRequestTypeInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "httpserverrequest", FskInstrumentationOffset(FskHTTPServerRequestRecord), NULL, 0, NULL, doFormatMessageHTTPServer
#include "kprHTTPServer.h" #include "kprURL.h" #include "kprShell.h" #include "kprTransition.h" #include "kprUtilities.h" #include "kprApplication.h" /* HOST */ static void KprHostDispose(void* it); static void KprHostPlaced(void* it); static void KprHostSetWindow(void* it, KprShell shell, KprStyle style); #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprHostInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprHost", FskInstrumentationOffset(KprHostRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; #endif static KprDispatchRecord KprHostDispatchRecord = { "host", KprContainerActivated, KprContainerAdded, KprContainerCascade, KprHostDispose, KprContentDraw, KprContainerFitHorizontally, KprContainerFitVertically, KprContentGetBitmap, KprContainerHit, KprContentIdle, KprContainerInvalidated, KprContainerLayered,
#include "FskString.h" #include "FskSynchronization.h" #if TARGET_OS_KPL #include "KplSynchronization.h" #endif #if SUPPORT_INSTRUMENTATION static Boolean doFormatMessageSynchronization(FskInstrumentedType dispatch, UInt32 msg, void *msgData, char *buffer, UInt32 bufferSize); static FskInstrumentedTypeRecord gFskMutexTypeInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "mutex", FskInstrumentationOffset(FskMutexRecord), NULL, 0, NULL, doFormatMessageSynchronization }; static FskInstrumentedTypeRecord gFskSemaphoreTypeInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "semaphore", FskInstrumentationOffset(FskSemaphoreRecord), NULL, 0, NULL, doFormatMessageSynchronization
{ return KprServicesGetThread(); } FskThread KprServicesGetThread() { return gServicesThread; } xsMachine *KprServicesGetMachine() { return gServiceMachine; } #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprMessageInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprMessage", FskInstrumentationOffset(KprMessageRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; #endif FskErr KprMessageNew(KprMessage *it, char* url) { FskErr err = kFskErrNone; KprMessage self = NULL; bailIfError(FskMemPtrNewClear(sizeof(KprMessageRecord), it)); self = *it; self->url = FskStrDoCopy(url); bailIfNULL(self->url); FskInstrumentedItemNew(self, self->url, &KprMessageInstrumentation); KprURLSplit(self->url, &self->parts); self->priority = 256; bail: if (err)
* 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. */ #include "kpr.h" #include "kprHTTPClient.h" #include "kprSSDPCommon.h" #include "kprSSDPClient.h" #include "FskList.h" #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprSSDPClientInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprSSDPClient", FskInstrumentationOffset(KprSSDPClientRecord), NULL, 0, NULL, NULL, NULL, 0 }; #endif #if 0 #pragma mark - KprSSDPClient #endif static KprSSDPClient gKprSSDPClients = NULL; FskErr KprSSDPClientNew(KprSSDPClient *it, const char* type) { FskErr err = kFskErrNone; KprSSDPClient self = NULL; bailIfError(FskMemPtrNewClear(sizeof(KprSSDPClientRecord), it)); self = *it;
return kFskErrNone; } /* Audio decompression manager */ #if SUPPORT_INSTRUMENTATION static Boolean doFormatMessageAudioDecompress(FskInstrumentedType dispatch, UInt32 msg, void *msgData, char *buffer, UInt32 bufferSize); static FskInstrumentedTypeRecord gAudioDecompressTypeInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "audiodecompress", FskInstrumentationOffset(FskAudioDecompressRecord), NULL, 0, NULL, doFormatMessageAudioDecompress }; #endif FskErr FskAudioDecompressNew(FskAudioDecompress *decoOut, UInt32 audioFormat, const char *mimeType, UInt32 sampleRate, UInt32 channelCount, void *formatInfo, UInt32 formatInfoSize) { FskErr err; FskAudioDecompressor decoder; FskAudioDecompress deco; UInt32 i = 0; while (true) {
* limitations under the License. */ #include "kprSQLite.h" #include "kprURL.h" #include "kprUtilities.h" //-------------------------------------------------- //-------------------------------------------------- // DB //-------------------------------------------------- //-------------------------------------------------- static int gDBCount = 0; #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprDBInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprDB", FskInstrumentationOffset(KprDBRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; #endif FskErr KprDBNew(KprDB* it, char* path, Boolean rw) { FskErr err = kFskErrNone; KprDB self = NULL; if (!gDBCount) bailIfError(sqlite3_initialize()); bailIfError(KprMemPtrNewClear(sizeof(KprDBRecord), it)); self = *it; FskInstrumentedItemNew(self, NULL, &KprDBInstrumentation); bailIfError(sqlite3_open_v2(path, &self->data, rw ? SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE : SQLITE_OPEN_READONLY, NULL)); gDBCount++; bail: return err;
* limitations under the License. */ #define __FSKAUDIOFILTER_PRIV__ #include "FskAudioFilter.h" #include "FskExtensions.h" #include "FskUtilities.h" #if SUPPORT_INSTRUMENTATION #include <stdio.h> static Boolean doFormatMessageAudioFilter(FskInstrumentedType dispatch, UInt32 msg, void *msgData, char *buffer, UInt32 bufferSize); static FskInstrumentedTypeRecord gAudioFilterTypeInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "audiofilter", FskInstrumentationOffset(FskAudioFilterRecord), NULL, 0, NULL, doFormatMessageAudioFilter }; #endif FskErr FskAudioFilterNew(FskAudioFilter *filterOut, const char *filterType) { FskErr err = kFskErrNone; FskAudioFilter filter = NULL; UInt32 i = 0; FskAudioFilterDispatch dispatch; while (true) {
static FskErr KprHTTPConnectionSendingCallback(FskHTTPClientRequest request, char** data, int* size, FskInt64 offset, void* context); static FskErr KprHTTPConnectionAuthCallback(FskHTTPClient client, FskHTTPClientRequest request, char *url, char *realm, FskHTTPAuth auth, void *refCon); static FskErr KprHTTPConnectionHeadersCallback(FskHTTPClientRequest request, FskHeaders* responseHeaders, void* context); static FskErr KprHTTPConnectionReceivingCallback(FskHTTPClientRequest request, char* data, int size, void* context); static FskErr KprHTTPConnectionCompleteCallback(FskHTTPClient client, FskHTTPClientRequest request, void* context); static FskErr KprHTTPConnectionClosedCallback(FskHTTPClient client, void* context); /* HTTP TARGET */ static FskErr KprHTTPTargetNew(KprHTTPTarget* it, KprMessage message); static void KprHTTPTargetDispose(void* it); /* HTTP CLIENT */ #if SUPPORT_INSTRUMENTATION static FskInstrumentedTypeRecord KprHTTPClientInstrumentation = { NULL, sizeof(FskInstrumentedTypeRecord), "KprHTTPClient", FskInstrumentationOffset(KprHTTPClientRecord), NULL, 0, NULL, KprInsrumentationFormatMessage, NULL, 0 }; #endif #define kprHTTPCacheDiskSize 0x10000000 //#define kprHTTPCacheDiskSize 0x10000 KprHTTPClient gKprHTTPClient = NULL; KprServiceRecord gHTTPService = { NULL, kprServicesThread, "http:", NULL, NULL, KprServiceAccept, KprHTTPClientCancel,