Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members

mxcpcStreamStandardIn.cpp

00001 //           ///          //
00002 //          /////        ////
00003 //         /// XXX     XXX ///
00004 //        ///    XXX XXX    ///     $RCSfile: mxcpcStreamStandardIn.cpp,v $  
00005 //       ///       XXX       ///     $Revision: 1.1 $
00006 //      ///      XXX XXX      ///     $Date: 2005/08/09 13:57:26 $
00007 //     ////    XXX     XXX    ////     $Author: cvs-steve $
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems ///////////////////////////////////////////////
00011 
00012 // Copyright (c) 2005, MOBOTIX AG.
00013 // This software is made available under the BSD licence. Please refer 
00014 // to the file LICENCE.TXT contained in this distribution for details.
00015 
00016 
00017 #include <mxcpcStreamStandardIn.h>
00018 #include <mxcpc_exceptions.h>
00019 
00020 #ifdef WIN32
00021 #include <fcntl.h>
00022 #include <io.h>
00023 #else
00024 #include <unistd.h>
00025 #endif
00026 
00027 
00028 mxcpcStreamStandardIn::mxcpcStreamStandardIn() {
00029   
00030   InFile = fileno(stdin);
00031   if(InFile == -1) throw mxcpcIOFailure();
00032 
00033 #ifdef O_BINARY // Windows
00034   // Set "stdin" to have binary mode:
00035   setmode( fileno(stdin), O_BINARY );
00036 #endif
00037 
00038   StillUp = true;
00039 }
00040 
00041 
00042 mxcpcStreamStandardIn::~mxcpcStreamStandardIn() {
00043 
00044   
00045 }
00046 
00047 
00048 
00049 int mxcpcStreamStandardIn::fetchBytes(unsigned char *buffer, int num) {
00050 
00051    int actually_read;
00052   
00053   if(!StillUp) return(0);
00054   
00055   actually_read = read(InFile, buffer, num);
00056    
00057   if(actually_read <= 0) {
00058   
00059     StillUp = false;
00060     return(0);
00061   }
00062   
00063   return(actually_read);
00064 }
00065 

Generated on Mon Aug 15 03:39:31 2005 for mxcpc by  doxygen 1.4.2-20050421