OSStatus CAComponent::Save (CFPropertyListRef *outData) const { OSStatus result = mDesc.Save (outData); if (result) return result; //add the name string of the component for a human readable name... // this name string is *not* restored when restoring the component CFStringRef name = GetCompName (); if (name && *outData) CFDictionarySetValue ((CFMutableDictionaryRef)(*outData), CFSTR("name"), name); return noErr; }
void vncHTTPConnectThread::DoHTTP(VSocket *socket) { char filename[1024]; char *line; // Read in the HTTP header if ((line = ReadLine(socket, '\n', 1024)) == NULL) return; // Scan the header for the filename and free the storage int result = sscanf(line, "GET %s ", (char*)&filename); delete [] line; if ((result == 0) || (result == EOF)) return; vnclog.Print(LL_CLIENTS, VNCLOG("file %s requested\n"), filename); // Read in the rest of the browser's request data and discard... BOOL emptyline=TRUE; for (;;) { char c; if (!socket->ReadExact(&c, 1)) return; if (c=='\n') { if (emptyline) break; emptyline = TRUE; } else if (c >= ' ') { emptyline = FALSE; } } vnclog.Print(LL_INTINFO, VNCLOG("parameters read\n")); if (filename[0] != '/') { vnclog.Print(LL_CONNERR, VNCLOG("filename didn't begin with '/'\n")); socket->SendExact(HTTP_MSG_NOSUCHFILE, strlen(HTTP_MSG_NOSUCHFILE)); return; } // Switch, dependent upon the filename: if (strcmp(filename, "/") == 0) { char indexpage[2048 + MAX_COMPUTERNAME_LENGTH + 1]; vnclog.Print(LL_CLIENTS, VNCLOG("sending main page\n")); // Send the OK notification message to the client if (!socket->SendExact(HTTP_MSG_OK, strlen(HTTP_MSG_OK))) return; // Compose the index page if (m_server->SockConnected()) { int width, height, depth; // Get the screen's dimensions m_server->GetScreenInfo(width, height, depth); // Get the name of this desktop char desktopname[MAX_COMPUTERNAME_LENGTH+1]; if (GetCompName(desktopname, MAX_COMPUTERNAME_LENGTH)) { // Make the name lowercase for (int x=0; x<strlen(desktopname); x++) { desktopname[x] = tolower(desktopname[x]); } } else { strcpy(desktopname, szAppName); } // Send the java applet page sprintf(indexpage, HTTP_FMT_INDEX, desktopname, width, height+32, m_server->GetPort() ); } else { // Send a "sorry, not allowed" page sprintf(indexpage, HTTP_MSG_NOSOCKCONN); } // Send the page if (socket->SendExact(indexpage, strlen(indexpage))) vnclog.Print(LL_INTINFO, VNCLOG("sent page\n")); return; } // File requested was not the index so check the mappings // list for a different file. // Now search the mappings for the desired file for (int x=0; x < filemappingsize; x++) { if (strcmp(filename, filemapping[x].filename) == 0) { VOID *resourceptr = NULL; vnclog.Print(LL_INTINFO, VNCLOG("requested file recognised\n")); // Load the resource APIRET rc = DosGetResource(NULLHANDLE, filemapping[x].type, filemapping[x].resourceID, &resourceptr); if ( (rc != 0) || (resourceptr==NULL) ) return; vnclog.Print(LL_INTINFO, VNCLOG("sending file...\n")); // Send the OK message if (!socket->SendExact(HTTP_MSG_OK, strlen(HTTP_MSG_OK))) { DosFreeResource( resourceptr ); return; } // Now send the entirety of the data to the client if (!socket->SendExact( (const char *)resourceptr, filemapping[x].rsize)) { DosFreeResource( resourceptr ); return; } vnclog.Print(LL_INTINFO, VNCLOG("file successfully sent\n")); DosFreeResource( resourceptr ); return; } } // Send the NoSuchFile notification message to the client if (!socket->SendExact(HTTP_MSG_NOSUCHFILE, strlen(HTTP_MSG_NOSUCHFILE))) return; }