Subversion Repositories DevTools

Rev

Rev 1606 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1606 Rev 1607
Line 1... Line -...
1
 
-
 
2
// Include header files /////////////////////////////////////////////////////
1
// Include header files /////////////////////////////////////////////////////
3
 
2
 
4
#include "ishieldlib.h"          
3
#include "ishieldlib.h"          
5
                               
4
                               
6
                                                                                      
5
                                                                                      
Line 3046... Line 3045...
3046
    szPatchIDLogFileName     = PATCHID_LOGFILE_NAME;
3045
    szPatchIDLogFileName     = PATCHID_LOGFILE_NAME;
3047
    
3046
    
3048
    
3047
    
3049
    // Set the file mode to read-write
3048
    // Set the file mode to read-write
3050
    //
3049
    //
3051
    OpenFileMode (FILE_MODE_NORMAL);
3050
    OpenFileMode (FILE_MODE_BINARY);
3052
             
3051
             
3053
             
3052
             
3054
    // lets check to see if the file
3053
    // lets check to see if the file
3055
    // already exists.
3054
    // already exists.
3056
    //        
3055
    //        
Line 3068... Line 3067...
3068
        endif;                         
3067
        endif;                         
3069
                         
3068
                         
3070
                         
3069
                         
3071
        // Get lines from the file into the list.
3070
        // Get lines from the file into the list.
3072
        // 
3071
        // 
3073
        nzRetVal = GetLine (nzFileHandle, szLine);
3072
        nzRetVal = islib_getline (nzFileHandle, szLine);
3074
        while (nzRetVal = 0)
3073
        while (nzRetVal = 0)
3075
        
3074
        
3076
            ListAddString (lzPatchSavedItemsListID, szLine, AFTER);                                                                                       
3075
            ListAddString (lzPatchSavedItemsListID, szLine, AFTER);                                                                                       
3077
            nzRetVal = GetLine (nzFileHandle, szLine);
3076
            nzRetVal = islib_getline (nzFileHandle, szLine);
3078
            
3077
            
3079
        endwhile;                                            
3078
        endwhile;                                            
3080
                
3079
                
3081
        
3080
        
3082
        // Close the file.
3081
        // Close the file.
Line 4811... Line 4810...
4811
                    // lets load the bits so we can use the information
4810
                    // lets load the bits so we can use the information
4812
                    //                               
4811
                    //                               
4813
                    ListGetFirstString ( lzParseItemListID, szTmpStr );                                                                                                                                             
4812
                    ListGetFirstString ( lzParseItemListID, szTmpStr );                                                                                                                                             
4814
                    ListGetNextString ( lzParseItemListID, szTmpIPAddress );                                                                                                                                                                                                           
4813
                    ListGetNextString ( lzParseItemListID, szTmpIPAddress );                                                                                                                                                                                                           
4815
                    
4814
                    
4816
                    // we have our ip address but it contain some doggy
4815
                    // we have our ip address but it contains a leading space
4817
                    // newline characters that we do not like
-
 
4818
                    //
4816
                    //
4819
                    nzStrLength = StrLength(szTmpIPAddress);
4817
                    nzStrLength = StrLength(szTmpIPAddress);
4820
                    StrSub(szIPAddress,szTmpIPAddress,1,nzStrLength-2);
4818
                    StrSub(szIPAddress,szTmpIPAddress,1,nzStrLength);
4821
                                     
4819
                                     
4822
                    // lets free resources for the next item
4820
                    // lets free resources for the next item
4823
                    // 
4821
                    // 
4824
                    ListDestroy(lzParseItemListID); 
4822
                    ListDestroy(lzParseItemListID); 
4825
                                        
4823
                                        
Line 4950... Line 4948...
4950
    LaunchAppAndWait ( szCmdFileLocation, "", WAIT );    
4948
    LaunchAppAndWait ( szCmdFileLocation, "", WAIT );    
4951
    
4949
    
4952
    
4950
    
4953
    // Set the file mode to read-only
4951
    // Set the file mode to read-only
4954
    //
4952
    //
4955
    OpenFileMode (FILE_MODE_NORMAL);
4953
    OpenFileMode (FILE_MODE_BINARY);
4956
      
4954
      
4957
      
4955
      
4958
    // lets check to see if the output file
4956
    // lets check to see if the output file
4959
    // exists.
4957
    // exists.
4960
    //        
4958
    //        
Line 4973... Line 4971...
4973
        endif;  
4971
        endif;  
4974
       
4972
       
4975
       
4973
       
4976
        // Get lines from the file into the list.
4974
        // Get lines from the file into the list.
4977
        // 
4975
        // 
4978
        nzRetVal = GetLine (nzFileHandle, szLine);
4976
        nzRetVal = islib_getline (nzFileHandle, szLine);
4979
        while (nzRetVal = 0)                                               
4977
        while (nzRetVal = 0)                                               
4980
        
4978
        
4981
            ListAddString (lzListID, szLine, AFTER);                                                                                       
4979
            ListAddString (lzListID, szLine, AFTER);                                                                                       
4982
            nzRetVal = GetLine (nzFileHandle, szLine);
4980
            nzRetVal = islib_getline (nzFileHandle, szLine);
4983
            
4981
            
4984
        endwhile; 
4982
        endwhile; 
4985
    
4983
    
4986
        
4984
        
4987
        // Close the file.
4985
        // Close the file.
Line 5653... Line 5651...
5653
  
5651
  
5654
  return ISLIB_SUCCESS;
5652
  return ISLIB_SUCCESS;
5655
  
5653
  
5656
end; 	                      	                   
5654
end; 	                      	                   
5657
 	                                                   	                                                  	                                                 
5655
 	                                                   	                                                  	                                                 
-
 
5656
 
-
 
5657
//////////////////////////////////////////////////////////////////////////////
-
 
5658
//                                                                   
-
 
5659
// FUNCTION:  islib_getline(NUMBER, BYREF STRING)
-
 
5660
//	                                                                 
-
 
5661
// DESCRIPTION:                                           			 
-
 
5662
//				Replace the flawed GetLine() function
-
 
5663
//
-
 
5664
//              This version will treat /r and /n as line endings
-
 
5665
//              GetLine only works on lines that have both
-
 
5666
//
-
 
5667
//              NOTE: The file MUSt be opened with OpenFileMode(FILE_MODE_BINARY)
-
 
5668
//                    as NORMAL mode appears to confuse line endings.
-
 
5669
//				
-
 
5670
//
-
 
5671
// Return Values:
-
 
5672
//    0 - Not end of file (there's more to read)
-
 
5673
//    1 - End of file is reached
-
 
5674
//                                                                             
-
 
5675
//                                                                   
-
 
5676
//////////////////////////////////////////////////////////////////////////////
-
 
5677
function islib_getline(nzFileHandle, szLine)
-
 
5678
	STRING szChar;
-
 
5679
	BOOL bzMore, bzNotEof;
-
 
5680
	
-
 
5681
begin
-
 
5682
 
-
 
5683
	bzMore = 1;
-
 
5684
    bzNotEof = 1;
-
 
5685
	szLine = "";
-
 
5686
 
-
 
5687
    //
-
 
5688
    //  Read data skipping /r and /n charcaters
-
 
5689
    //
-
 
5690
    while ( bzMore && bzNotEof )
-
 
5691
        if ( ReadBytes (nzFileHandle, szChar, 0, 1) > 0)
-
 
5692
        then
-
 
5693
            if ((szChar != "\n") &&  (szChar != "\r"))
-
 
5694
            then
-
 
5695
                bzMore = 0;
-
 
5696
                szLine = szLine + szChar;
-
 
5697
            endif;
-
 
5698
        else
-
 
5699
            bzNotEof = 0;
-
 
5700
        endif;
-
 
5701
	endwhile;
-
 
5702
 
-
 
5703
    //
-
 
5704
    //  Now read data up until the end of the line or end of file
-
 
5705
    //
-
 
5706
	bzMore = 1;
-
 
5707
    while ( bzMore && bzNotEof )
-
 
5708
        if ( ReadBytes (nzFileHandle, szChar, 0, 1) > 0)
-
 
5709
        then
-
 
5710
            if ((szChar = "\n") ||  (szChar = "\r"))
-
 
5711
            then
-
 
5712
                bzMore = 0;
-
 
5713
            else
-
 
5714
                szLine = szLine + szChar;
-
 
5715
            endif;
-
 
5716
        else
-
 
5717
            bzNotEof = 0;
-
 
5718
        endif;
-
 
5719
	endwhile;
-
 
5720
 
-
 
5721
    //
-
 
5722
    //  Determine if we are at the end of the file
-
 
5723
    //  If bzMore is True then we have been looking for characters, but have not
-
 
5724
    //  bean able to read any. Thus we are at the end of the file.
-
 
5725
    //
-
 
5726
    return bzMore;
-
 
5727
 
-
 
5728
end;