int EmClipboardWidget::handle (int event) { // It's a "paste" event, meaning that our application has requested // data to paste, and it just showed up from the X server. if (event == FL_PASTE) { // Get exclusive access to our clipboard data. omni_mutex_lock lock (gClipboardMutex); // Say that the data is here. gClipboardPendingIncomingData = false; gClipboardHaveIncomingData = true; // Copy the data to the host data clipboard. The Palm-specific // clipboard will remain empty, and the host data will get // convert to it on demand. gClipboardDataPalm.clear (); gClipboardDataHost.clear (); copy ((char*) Fl::e_text, (char*) Fl::e_text + Fl::e_length, back_inserter (gClipboardDataHost)); // Tell the CPU thread that the new data is here. gClipboardCondition.broadcast (); // Return that we handled the event. return 1; } // Return that we didn't handle the event. return 0; }
static void fuzzPacket(const char *hex, size_t start = 0) { ByteList buf{HexToRawData(hex)}; ByteList result; EXPECT_GE(buf.size(), 14); // Insert two zero bytes at the beginning. MatchPacket expects packet data // to be aligned at 2 bytes past the 8-byte alignment. buf.insertZeros(buf.begin(), 2); const UInt8 kFuzzValues[] = {0x00, 0xFF}; // Mutate each byte one at a time. for (size_t i = start + 2; i < buf.size(); ++i) { UInt8 saved = buf[i]; for (UInt8 val : kFuzzValues) { if (buf[i] == val) continue; buf[i] = val; ByteRange pkt{buf.data() + 2, buf.size() - 2}; MatchPacket match{pkt}; EXPECT_GT(match.size(), 0); MatchPacketBuilder builder{match.toRange()}; size_t offset = match.toRange().get<X_PKT_POS>(); if (offset == 0) { offset = buf.size() - 2; } ByteRange remaining = SafeByteRange(buf.data() + 2, buf.size() - 2, offset); result.clear(); builder.build(&result, remaining); EXPECT_GT(result.size(), 0); } buf[i] = saved; } }