/* * MainStateChange: signals a state change on both B-channels (connected, * disconnected). Whenever a channel changes his state this function is called */ static void MainStateChange(ConnectionID Connection, ConnectionState State) { faxNCPI_t *faxNCPI; assert (Connection != INVALID_CONNECTION_ID); if (State == Disconnected) { unsigned short r3 = GetB3Reason(Connection); unsigned short r = GetReason(Connection); Slot = INVALID_CONNECTION_ID; reason = r; reason_b3 = r3; #if 0 printf("Disconnected.\n"); printf(" Reason : %04x %s\n", r, Decode_Info(r)); printf(" Reason-B3 : %04x %s\n", r3, Decode_Info(r3)); #endif if ((faxNCPI = GetFaxNCPI(Connection))) { strcpy(rid, faxNCPI->id); rres = faxNCPI->resolution; rpages = faxNCPI->pages; #if 0 printf(" Remote Station ID : %s\n", faxNCPI->id); printf(" Transfer-Rate : %d bps\n", faxNCPI->rate); printf(" Resolution : %s\n", faxNCPI->resolution ? "high" : "low"); printf(" Number of Pages : %d\n", faxNCPI->pages); #endif } } }
/** * * Method Name: FormatByeReport * * * Inputs: unsigned long ulBufferSize - length allocated for the buffer * * Outputs: unsigned char *puchReportBuffer * - Buffer to receive the contents of the Sender Report * * Returns: unsigned long - number of octets written into the buffer. * * Description: Constructs a Bye report using the buffer passed in by the * caller. * * Usage Notes: The header of the RTCP Report shall be formatted by * delegating to the base class. * * */ unsigned long CByeReport::FormatByeReport(unsigned char *puchReportBuffer, unsigned long ulBufferSize) { unsigned long ulReportLength, ulCSRCCount = 0; unsigned char *puchPayloadBuffer; unsigned long l = GetHeaderLength(); // Let's offset into the Formatting buffer enough to // start depositing payload puchPayloadBuffer = puchReportBuffer + l; // OsSysLog::add(FAC_MP, PRI_DEBUG, "CByeReport::FormatByeReport: GetHeaderLength() = %ld", l); // Let's load the field information based upon the period. // Conversion to NBO done in GetCSRC(). ulCSRCCount = GetCSRC((ssrc_t *)puchPayloadBuffer, TRUE); puchPayloadBuffer += (ulCSRCCount * sizeof(ssrc_t)); // Let's load the field information based upon the period unsigned long ulReasonLength = GetReason(puchPayloadBuffer+1); bool bPadded = FALSE; if(ulReasonLength > 0) { // Adjust the count and payload pointer *puchPayloadBuffer++ = (unsigned char)ulReasonLength; puchPayloadBuffer += ulReasonLength; // Let's load padding onto the end of the packet to // ensure 4 byte alignment puchPayloadBuffer += LoadPadding(puchPayloadBuffer, &bPadded); } // Set the report length ulReportLength = puchPayloadBuffer - puchReportBuffer; // Let's call the RTCP Header base class's formatter so we can prepend // a header to this Bye Payload FormatRTCPHeader(puchReportBuffer, // RTCP Report Buffer bPadded, // Padding Flag ulCSRCCount+1, // SSRC/CSRC Count ulReportLength); // Report Length return(ulReportLength); }
bool LockDirectory(const fs::path& directory, const std::string lockfile_name, bool probe_only) { std::lock_guard<std::mutex> ulock(cs_dir_locks); fs::path pathLockFile = directory / lockfile_name; // If a lock for this directory already exists in the map, don't try to re-lock it if (dir_locks.count(pathLockFile.string())) { return true; } // Create empty lock file if it doesn't exist. FILE* file = fsbridge::fopen(pathLockFile, "a"); if (file) fclose(file); auto lock = MakeUnique<fsbridge::FileLock>(pathLockFile); if (!lock->TryLock()) { return error("Error while attempting to lock directory %s: %s", directory.string(), lock->GetReason()); } if (!probe_only) { // Lock successful and we're not just probing, put it into the map dir_locks.emplace(pathLockFile.string(), std::move(lock)); } return true; }