MCPcopy Create free account
hub / github.com/SimHacker/micropolis / Tk_DeleteFileHandler

Function Tk_DeleteFileHandler

micropolis-activity/src/tk/tkevent.c:842–904  ·  view source on GitHub ↗
(fd)

Source from the content-addressed store, hash-verified

840 *
841 * Results:
842 * None.
843 *
844 * Side effects:
845 * If a callback was previously registered on fd, remove it.
846 *
847 *--------------------------------------------------------------
848 */
849
850void
851Tk_DeleteFileHandler(fd)
852 int fd; /* Stream id for which to remove
853 * callback procedure. */
854{
855 register FileEvent *filePtr;
856 FileEvent *prevPtr;
857 int index;
858
859 /*
860 * Find the entry for the given file (and return if there
861 * isn't one).
862 */
863
864 for (prevPtr = NULL, filePtr = fileList; ;
865 prevPtr = filePtr, filePtr = filePtr->nextPtr) {
866 if (filePtr == NULL) {
867 return;
868 }
869 if (filePtr->fd == fd) {
870 break;
871 }
872 }
873
874 /*
875 * Clean up information in the callback record.
876 */
877
878 index = filePtr->fd/(8*sizeof(int));
879 if (masks[index] & filePtr->mask) {
880 readCount--;
881 *filePtr->readPtr &= ~filePtr->mask;
882 masks[index] &= ~filePtr->mask;
883 }
884 if (masks[index+MASK_SIZE] & filePtr->mask) {
885 writeCount--;
886 *filePtr->writePtr &= ~filePtr->mask;
887 masks[index+MASK_SIZE] &= ~filePtr->mask;
888 }
889 if (masks[index+2*MASK_SIZE] & filePtr->mask) {
890 exceptCount--;
891 *filePtr->exceptPtr &= ~filePtr->mask;
892 masks[index+2*MASK_SIZE] &= ~filePtr->mask;
893 }
894 if (prevPtr == NULL) {
895 fileList = filePtr->nextPtr;
896 } else {
897 prevPtr->nextPtr = filePtr->nextPtr;
898 }
899 FreeFileEvent(filePtr);

Callers 5

Tcp_FileHandlerCmdFunction · 0.70
HandleSocketFunction · 0.70
simpleDeleteFileHandler2Function · 0.70
StdinProcFunction · 0.70
StdinProcFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected