Annotation of truecrypt/platform/unix/poller.cpp, revision 1.1.1.1

1.1       root        1: /*
                      2:  Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
                      3: 
                      4:  Governed by the TrueCrypt License 2.4 the full text of which is contained
                      5:  in the file License.txt included in TrueCrypt binary and source code
                      6:  distribution packages.
                      7: */
                      8: 
                      9: #include <poll.h>
                     10: #include <unistd.h>
                     11: #include "Poller.h"
                     12: #include "Platform/SystemException.h"
                     13: 
                     14: namespace TrueCrypt
                     15: {
                     16:        Poller::Poller (int fileDescriptor1, int fileDescriptor2, int fileDescriptor3, int fileDescriptor4)
                     17:        {
                     18:                FileDescriptors.push_back (fileDescriptor1);
                     19: 
                     20:                if (fileDescriptor2 != -1)
                     21:                        FileDescriptors.push_back (fileDescriptor2);
                     22: 
                     23:                if (fileDescriptor3 != -1)
                     24:                        FileDescriptors.push_back (fileDescriptor3);
                     25: 
                     26:                if (fileDescriptor4 != -1)
                     27:                        FileDescriptors.push_back (fileDescriptor4);
                     28:        }
                     29: 
                     30:        list <int> Poller::WaitForData (int timeOut) const
                     31:        {
                     32:                vector <pollfd> pfd (FileDescriptors.size());
                     33:                for (int i = 0; i < FileDescriptors.size(); i++)
                     34:                {
                     35:                        pfd[i].fd = FileDescriptors[i];
                     36:                        pfd[i].events = POLLIN;
                     37:                }
                     38: 
                     39:                list <int> descList;
                     40: 
                     41:                int pollRes = poll (&pfd[0], pfd.size(), timeOut);
                     42: 
                     43:                if (pollRes == 0 && timeOut != -1)
                     44:                        throw TimeOut (SRC_POS);
                     45: 
                     46:                if (pollRes > 0)
                     47:                {
                     48:                        for (int i = 0; i < pfd.size(); i++)
                     49:                        {
                     50:                                if (pfd[i].revents & POLLIN)
                     51:                                        descList.push_back (pfd[i].fd);
                     52:                        }
                     53:                }
                     54: 
                     55:                return descList;
                     56:        }
                     57: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.