2011-06-02 11:40:42 +02:00
|
|
|
|
--- SRC/consume.c.orig
|
|
|
|
|
+++ SRC/consume.c
|
|
|
|
|
@@ -140,7 +140,7 @@ consumeUptoBreak
|
2006-12-19 00:15:55 +01:00
|
|
|
|
{
|
|
|
|
|
break; /* line break detected */
|
|
|
|
|
}
|
|
|
|
|
- else if( *buffer == EOF )
|
|
|
|
|
+ else if( *buffer == 0 )
|
|
|
|
|
{
|
|
|
|
|
break; /* End-Of-File detected */
|
|
|
|
|
}
|
2011-06-02 11:40:42 +02:00
|
|
|
|
--- SRC/file.c.orig
|
|
|
|
|
+++ SRC/file.c
|
|
|
|
|
@@ -35,18 +35,34 @@ readFile
|
2006-12-19 00:15:55 +01:00
|
|
|
|
File_t returnValue;
|
|
|
|
|
FILE * filePointer;
|
|
|
|
|
long fileLength;
|
|
|
|
|
- char * buffer = NULL;
|
|
|
|
|
|
|
|
|
|
if( FileOpened == openFileForReading( filename, &filePointer ) )
|
|
|
|
|
{
|
|
|
|
|
if( Success == getFileLength( filePointer, &fileLength ) )
|
|
|
|
|
{
|
|
|
|
|
- if( Success ==
|
|
|
|
|
- allocateBuffer( fileLength, ( void ** )&buffer ) )
|
|
|
|
|
+ void * ptr;
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Allocate one byte more if a newline must be added
|
|
|
|
|
+ */
|
|
|
|
|
+ if( Success == allocateBuffer( fileLength + 1 , &ptr ) )
|
|
|
|
|
{
|
|
|
|
|
- if( Success ==
|
|
|
|
|
- readFileToBuffer( filePointer, fileLength, &buffer ) )
|
|
|
|
|
- {
|
|
|
|
|
+ char * buffer = ( char * )ptr;
|
|
|
|
|
+
|
|
|
|
|
+ if( Success == readFileToBuffer( filePointer, fileLength, &buffer ) )
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ if ( FALSE == queryParameter( IgnoreEOF ) )
|
|
|
|
|
+ {
|
|
|
|
|
+ char * eof = (buffer + fileLength - 1);
|
|
|
|
|
+
|
|
|
|
|
+ if ( *eof != '\n' )
|
|
|
|
|
+ {
|
|
|
|
|
+ *( eof + 1 ) = '\n';
|
|
|
|
|
+ fileLength++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
addToWatchdog( fileLength );
|
|
|
|
|
associateBuffer( fileSpecifier, fileLength, &buffer );
|
|
|
|
|
returnValue = FileOperationsSuccessful;
|
2011-06-02 11:40:42 +02:00
|
|
|
|
--- SRC/parameters.c.orig
|
|
|
|
|
+++ SRC/parameters.c
|
|
|
|
|
@@ -368,6 +368,13 @@ queryParameter
|
2006-12-19 00:15:55 +01:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
+ case IgnoreEOF:
|
|
|
|
|
+ if( parameterIgnoreEOF == IsSet )
|
|
|
|
|
+ {
|
|
|
|
|
+ returnValue = TRUE;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
case IgnoreDefinites:
|
|
|
|
|
if( parameterIgnoreDefinites == IsSet )
|
|
|
|
|
{
|
2011-06-02 11:40:42 +02:00
|
|
|
|
--- SRC/parser.c.orig
|
|
|
|
|
+++ SRC/parser.c
|
|
|
|
|
@@ -19,7 +19,7 @@
|
|
|
|
|
/*--------------------------------- IMPORTS ----------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
-
|
|
|
|
|
+#include <unistd.h>
|
|
|
|
|
#include "portab.h"
|
|
|
|
|
#include "variableblock.h"
|
|
|
|
|
#include "parameters.h"
|
|
|
|
|
@@ -296,6 +296,7 @@ createAdministrationInfo
|
2006-12-19 00:15:55 +01:00
|
|
|
|
unsigned long Size;
|
|
|
|
|
char * delimiterString;
|
|
|
|
|
char delimiterChar;
|
|
|
|
|
+ void * ptr;
|
|
|
|
|
|
|
|
|
|
queryStringParameter( Delimiter, &delimiterString );
|
|
|
|
|
delimiterChar = delimiterString[ 0 ];
|
2011-06-02 11:40:42 +02:00
|
|
|
|
@@ -305,23 +306,25 @@ createAdministrationInfo
|
2006-12-19 00:15:55 +01:00
|
|
|
|
countDelimiters( delimiterChar, baseFileBuffer, baseFileBufferLength );
|
|
|
|
|
baseFileBlocksLength++; /* add possible trailing comment */
|
|
|
|
|
Size = baseFileBlocksLength * sizeof( VariableBlock_t );
|
|
|
|
|
- if( Success != allocateBuffer( Size, ( void ** )&baseFileBlock ) )
|
|
|
|
|
+ if( Success != allocateBuffer( Size, &ptr ) )
|
|
|
|
|
{
|
|
|
|
|
fillup_exception( __FILE__, __LINE__, ConfigurationException,
|
|
|
|
|
"createAdministrationInfo" );
|
|
|
|
|
exitOnFailure( );
|
|
|
|
|
}
|
|
|
|
|
+ baseFileBlock = ( VariableBlock_t * )ptr;
|
|
|
|
|
|
|
|
|
|
additionalFileBlocksLength = countDelimiters(
|
|
|
|
|
delimiterChar, additionalFileBuffer, additionalFileBufferLength );
|
|
|
|
|
additionalFileBlocksLength++; /* add possible trailing comment */
|
|
|
|
|
Size = additionalFileBlocksLength * sizeof( VariableBlock_t );
|
|
|
|
|
- if( Success != allocateBuffer( Size, ( void ** )&additionalFileBlock ) )
|
|
|
|
|
+ if( Success != allocateBuffer( Size, &ptr ) )
|
|
|
|
|
{
|
|
|
|
|
fillup_exception( __FILE__, __LINE__, ConfigurationException,
|
|
|
|
|
"createAdministrationInfo" );
|
|
|
|
|
exitOnFailure( );
|
|
|
|
|
}
|
|
|
|
|
+ additionalFileBlock = ( VariableBlock_t * )ptr;
|
|
|
|
|
|
|
|
|
|
if( queryParameter( ForbiddenFile ) == TRUE )
|
|
|
|
|
{
|
2011-06-02 11:40:42 +02:00
|
|
|
|
@@ -329,12 +332,13 @@ createAdministrationInfo
|
2006-12-19 00:15:55 +01:00
|
|
|
|
delimiterChar, forbiddenFileBuffer, forbiddenFileBufferLength );
|
|
|
|
|
forbiddenFileBlocksLength++; /* add possible trailing comment */
|
|
|
|
|
Size = forbiddenFileBlocksLength * sizeof( VariableBlock_t );
|
|
|
|
|
- if( Success != allocateBuffer( Size, ( void ** )&forbiddenFileBlock ) )
|
|
|
|
|
+ if( Success != allocateBuffer( Size, &ptr ) )
|
|
|
|
|
{
|
|
|
|
|
fillup_exception( __FILE__, __LINE__, ConfigurationException,
|
|
|
|
|
"createAdministrationInfo" );
|
|
|
|
|
exitOnFailure( );
|
|
|
|
|
}
|
|
|
|
|
+ forbiddenFileBlock = ( VariableBlock_t * )ptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-02 11:40:42 +02:00
|
|
|
|
@@ -477,8 +481,8 @@ getVariable
|
2006-12-19 00:15:55 +01:00
|
|
|
|
getVBeginOfBlock( outputBuffer, &Line );
|
|
|
|
|
Line = Line + getVLength( outputBuffer );
|
|
|
|
|
LinePointer = Line;
|
|
|
|
|
- for( lineIndex = 0;
|
|
|
|
|
- ( *LinePointer != EOF ) && ( *LinePointer != '\n' );
|
|
|
|
|
+ for( lineIndex = 0;
|
|
|
|
|
+ ( *LinePointer != 0 ) && ( *LinePointer != '\n' ) ;
|
|
|
|
|
lineIndex++ )
|
|
|
|
|
{
|
|
|
|
|
LinePointer++; /* concerns only the current line */
|
2011-06-02 11:40:42 +02:00
|
|
|
|
@@ -1768,6 +1772,8 @@ writeOutput
|
|
|
|
|
}
|
|
|
|
|
listPointer++;
|
|
|
|
|
}
|
|
|
|
|
+ if(fflush( filePointer ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot flush stream");
|
|
|
|
|
+ if(fdatasync ( fileno(filePointer) ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot sync stream");
|
|
|
|
|
closeFile( filePointer );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1830,7 +1836,9 @@ writeOutput
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
listPointer++;
|
|
|
|
|
- }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(fflush( filePointer ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot flush stream");
|
|
|
|
|
+ if(fdatasync ( fileno(filePointer) ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot sync stream");
|
|
|
|
|
closeFile( filePointer );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
--- SRC/services.c.orig
|
|
|
|
|
+++ SRC/services.c
|
|
|
|
|
@@ -444,8 +444,9 @@ readFileToBuffer
|
2006-12-19 00:15:55 +01:00
|
|
|
|
|
|
|
|
|
if( 0 == fseek( filePointer, 0L, SEEK_SET ) )
|
|
|
|
|
{
|
|
|
|
|
- if( fileLength ==
|
|
|
|
|
- ( long )fread( *fileBuffer, sizeof( char ), fileLength, filePointer ) )
|
|
|
|
|
+ if( ( fileLength ==
|
|
|
|
|
+ ( long )fread( *fileBuffer, sizeof( char ), fileLength, filePointer ) )
|
|
|
|
|
+ && ( 0 == ferror( filePointer ) ) )
|
|
|
|
|
{
|
|
|
|
|
returnValue = Success;
|
|
|
|
|
}
|
2011-06-02 11:40:42 +02:00
|
|
|
|
@@ -558,23 +559,22 @@ dumpBlock
|
2006-12-19 00:15:55 +01:00
|
|
|
|
Service_t
|
|
|
|
|
allocateBuffer
|
|
|
|
|
(
|
|
|
|
|
- long fileLength, /* in */
|
|
|
|
|
+ long Length, /* in */
|
|
|
|
|
void ** buffer /* out */
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
Service_t returnValue;
|
|
|
|
|
|
|
|
|
|
- *buffer = malloc( fileLength + 1 );
|
|
|
|
|
+ *buffer = malloc( Length + 1 );
|
|
|
|
|
if( *buffer == NULL )
|
|
|
|
|
{
|
|
|
|
|
- fillup_exception( __FILE__, __LINE__, ServiceException,
|
|
|
|
|
- "malloc" );
|
|
|
|
|
+ fillup_exception( __FILE__, __LINE__, ServiceException, "malloc" );
|
|
|
|
|
returnValue = Error;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* reset the buffer */
|
|
|
|
|
- ( void )memset( *buffer, EOF, fileLength + 1 );
|
|
|
|
|
+ ( void )memset( *buffer, 0, Length + 1 );
|
|
|
|
|
|
|
|
|
|
returnValue = Success;
|
|
|
|
|
}
|
2011-06-02 11:40:42 +02:00
|
|
|
|
--- SRC/metadata.c.orig
|
|
|
|
|
+++ SRC/metadata.c
|
|
|
|
|
@@ -17,7 +17,7 @@
|
|
|
|
|
/*--------------------------------- IMPORTS ----------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
-
|
|
|
|
|
+#include <unistd.h>
|
|
|
|
|
#include "variableblock.h"
|
|
|
|
|
#include "services.h"
|
|
|
|
|
#include "parser.h"
|
|
|
|
|
@@ -392,7 +392,8 @@ setMetadataInfo
|
|
|
|
|
logfile );
|
|
|
|
|
fprintf( logfile, ">\n\n" );
|
|
|
|
|
}
|
|
|
|
|
-
|
|
|
|
|
+ if(fflush( logfile ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot flush stream");
|
|
|
|
|
+ if(fdatasync( fileno(logfile) ) != 0) fillup_exception( __FILE__, __LINE__, ServiceException, "cannot sync stream");
|
|
|
|
|
closeFile( logfile );
|
|
|
|
|
}
|
|
|
|
|
}
|