wow, thx!
great!!
well it isn't really that special i guess. xD
the database file i'm talking about is from the program: "Alienbrain".
Alienbrain (@alienbrain.com):
"
Alienbrain is a digital asset management system for artists in the entertainment industry."
Because I couldn't get the SDK working, I decided to do it this way.
(luckily for me all changes are stored in a plain ASCII-file)
i'm not finished yet, but here's the code i've got so far.
(and it is not perfect and not yet minimized)
PHP Code:
/* lib includes */
/**************************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/* macro definitions */
/**************************************************************************************************/
#define LINE 10240
#define MAXY 20480
/* global vars */
/**************************************************************************************************/
char char_lines[MAXY][LINE];
int int_linecount;
/* searchFileLines */
/**************************************************************************************************/
int searchFileLines( const char *filename, const char *searchstring ) {
FILE *pFile;
char buffer[LINE];
if( ( pFile = fopen( filename, "r" ) ) == NULL ) {
fprintf( stderr, "error: could not open file: %s\n", filename );
return 0;
}
int_linecount = 0;
while( fgets( buffer, sizeof( buffer ), pFile ) != NULL ) {
if( strchr( buffer, '\n' ) == NULL )
fprintf( stderr, "input line too long: %d.\n", int_linecount );
if( strstr( buffer, searchstring ) != NULL ) {
//printf( "%s", buffer );
strcpy( char_lines[int_linecount], buffer );
}
int_linecount++;
}
return 1;
}
/* filterFileLines */
/**************************************************************************************************/
void filterFileLines() {
//working on it
}
/**************************************************************************************************/
int main( const int argc, const char *argv[] ) {
/* 1. check filepath */
/**************************************************************************/
if( argc != 2 ) {
printf( "dude, you need to give me a filepath!" );
return( 1 );
}
/* 2. search file */
/**************************************************************************/
if( !searchFileLines( argv[1], "NxNSignOff_ChangeStatusComment" ) )
fprintf( stderr, "error: could not search file: %s\n", argv[1] );
return 0;
}
---------- Post updated at 08:00 AM ---------- Previous update was at 12:38 AM ----------
hey,
it's me again. the above code is not really working.
my global array char_lines does not have the entrys that were found in the file
after the function searchFileLines was called.
i'm guessing because buffer does not longer exists after the function was called.
how can i bypass this problem?
by declaring buffer also as a global var?
Or is there a more elegant solution/approach?