You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/01/09 05:50:57 UTC
svn commit: r367196 - /webservices/axis2/trunk/c/modules/util/file_diff.c
Author: samisa
Date: Sun Jan 8 20:50:54 2006
New Revision: 367196
URL: http://svn.apache.org/viewcvs?rev=367196&view=rev
Log:
New stream compliance
Modified:
webservices/axis2/trunk/c/modules/util/file_diff.c
Modified: webservices/axis2/trunk/c/modules/util/file_diff.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/file_diff.c?rev=367196&r1=367195&r2=367196&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/file_diff.c (original)
+++ webservices/axis2/trunk/c/modules/util/file_diff.c Sun Jan 8 20:50:54 2006
@@ -15,9 +15,12 @@
*/
#include <axis2_file_diff.h>
+#include <axis2_file_handler.h>
+#include <axis2_stream.h>
void *expected_file, *actual_file; /* File pointers */
-
+axis2_stream_t *expected_file_stream, *actual_file_stream; /* Streams corresponding to above files*/
+axis2_stream_t *output_stream;
/* private function header */
axis2_status_t axis2_file_diff_clean(axis2_env_t *env);
@@ -28,11 +31,9 @@
int j = 0, k = 0;
axis2_char_t *buffer1, *buffer2;
int flag1 = 0, flag2 = 0;
- expected_file = AXIS2_STREAM_FILE_OPEN (env->stream
- , expected_file_name, "rt");
+ expected_file = axis2_file_handler_open(expected_file_name,"rt", &env);
- actual_file = AXIS2_STREAM_FILE_OPEN (env->stream, actual_file_name
- , "rt");
+ actual_file = axis2_file_handler_open(actual_file_name,"rt", &env);
if( expected_file == NULL || actual_file == NULL ) {
/*printf("Unable to open one of datafile %s, %s\n", expected_file_name
@@ -41,12 +42,21 @@
return AXIS2_ERROR_COULD_NOT_OPEN_FILE;
}
-
+ expected_file_stream = axis2_stream_create_file(&env, expected_file);
+ actual_file_stream = axis2_stream_create_file(&env, actual_file);
+ output_stream = axis2_stream_create_file(&env, stdout);
+
+ if( expected_file_stream == NULL || actual_file_stream == NULL ) {
+ /*printf("Unable to open one of datafile %s, %s\n", expected_file_name
+ , actual_file_name );*/
+ axis2_file_diff_clean(env);
+ return AXIS2_FAILURE;
+ }
buffer1 = (axis2_char_t*) AXIS2_MALLOC(env->allocator, 8096 * sizeof(axis2_char_t));
buffer2 = (axis2_char_t*) AXIS2_MALLOC(env->allocator, 8096 * sizeof(axis2_char_t));
- ch1 = AXIS2_STREAM_FILE_GET_CHAR (env->stream, expected_file);
- ch2 = AXIS2_STREAM_FILE_GET_CHAR (env->stream, actual_file);
+ ch1 = AXIS2_STREAM_GET_CHAR (expected_file_stream, &env);
+ ch2 = AXIS2_STREAM_GET_CHAR (actual_file_stream, &env);
while(1)
@@ -68,13 +78,13 @@
if(flag1 == 1 && flag2 == 0)
{
- AXIS2_STREAM_FILE_UNGET_CHAR(env->stream, ch2, actual_file);
+ AXIS2_STREAM_UNGET_CHAR(actual_file_stream, &env, ch2);
j++;
buffer1[j] = ch1;
}
if(flag1 == 0 && flag2 == 1)
{
- AXIS2_STREAM_FILE_UNGET_CHAR(env->stream, ch1, expected_file);
+ AXIS2_STREAM_UNGET_CHAR(expected_file_stream, &env, ch1);
k++;
buffer2[k] = ch2;
}
@@ -82,25 +92,25 @@
{
if(ch1 != ch2)
{
- AXIS2_STREAM_WRITE(env->stream
+ AXIS2_STREAM_WRITE(output_stream, &env
, "\n****************************** TEST FAILED *********" \
"**************************\n", 80);
*buffer1 = '\n';
*buffer2 = '\n';
- AXIS2_STREAM_WRITE(env->stream
+ AXIS2_STREAM_WRITE(output_stream, &env
, "\n---------------------- Expected file read upto: ----" \
"--------------------------\n", 80);
/*printf("%s\n", buffer1); */
- AXIS2_STREAM_WRITE(env->stream, buffer1, j);
- AXIS2_STREAM_WRITE(env->stream
+ AXIS2_STREAM_WRITE(output_stream, &env, buffer1, j);
+ AXIS2_STREAM_WRITE(output_stream, &env
, "\n---------------------- Actual file read upto: ------" \
"--------------------------\n", 80);
/* printf("%s\n", buffer2); */
- AXIS2_STREAM_WRITE(env->stream, buffer2, k);
- AXIS2_STREAM_WRITE(env->stream, "\n", 1);
+ AXIS2_STREAM_WRITE(output_stream, &env, buffer2, k);
+ AXIS2_STREAM_WRITE(output_stream, &env, "\n", 1);
axis2_file_diff_clean(env);
}
@@ -118,13 +128,13 @@
}
- if(ch1 == env->stream->axis2_eof || ch2 == env->stream->axis2_eof)
+ if(ch1 == expected_file_stream->axis2_eof || ch2 == actual_file_stream->axis2_eof)
break;
- ch1 = AXIS2_STREAM_FILE_GET_CHAR(env->stream, expected_file );
- ch2 = AXIS2_STREAM_FILE_GET_CHAR(env->stream, actual_file);
+ ch1 = AXIS2_STREAM_GET_CHAR(expected_file_stream, &env);
+ ch2 = AXIS2_STREAM_GET_CHAR(actual_file_stream, &env);
}
- AXIS2_STREAM_WRITE(env->stream
+ AXIS2_STREAM_WRITE(output_stream, &env
, "\n************************* TEST PASSED **************************" \
"**************\n", 80);
@@ -133,9 +143,25 @@
axis2_status_t axis2_file_diff_clean (axis2_env_t *env)
{
+ if(NULL != expected_file_stream)
+ {
+ AXIS2_STREAM_FREE(expected_file_stream, &env);
+ expected_file_stream = NULL;
+ }
+ if(NULL != actual_file_stream)
+ {
+ AXIS2_STREAM_FREE(actual_file_stream, &env);
+ actual_file_stream = NULL;
+ }
+ if(NULL != output_stream)
+ {
+ AXIS2_STREAM_FREE(output_stream, &env);
+ output_stream = NULL;
+ }
+
if(expected_file != NULL )
- AXIS2_STREAM_FILE_CLOSE(env->stream, expected_file);
+ axis2_file_handler_close(expected_file);
if(actual_file != NULL )
- AXIS2_STREAM_FILE_CLOSE(env->stream, actual_file);
+ axis2_file_handler_close(actual_file);
return AXIS2_SUCCESS;
}