"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "html/muscle-by-example/examples/iogateway/example_3_text_to_file.cpp" between
muscle8.20.zip and muscle8.30.zip

About: MUSCLE (Multi User Server Client Linking Environment) is a messaging server and networking API. The included server program ("muscled") lets its clients message each other, and/or store information in its serverside hierarchical database.

example_3_text_to_file.cpp  (muscle8.20):example_3_text_to_file.cpp  (muscle8.30)
skipping to change at line 38 skipping to change at line 38
// Set up a FileDataIO so we can output our stream to a file // Set up a FileDataIO so we can output our stream to a file
FileDataIO fileOutput(fopen("example_3_output.txt", "w")); FileDataIO fileOutput(fopen("example_3_output.txt", "w"));
if (fileOutput.GetFile() == NULL) if (fileOutput.GetFile() == NULL)
{ {
printf("Error, couldn't open example_3_output.txt for writing!\n"); printf("Error, couldn't open example_3_output.txt for writing!\n");
return 10; return 10;
} }
// Set up our gateway to use the FileDataIO // Set up our gateway to use the FileDataIO
PlainTextMessageIOGateway outputGateway; PlainTextMessageIOGateway outputGateway;
outputGateway.SetDataIO(DataIORef(&fileOutput, false)); // false == don't delete pointer! outputGateway.SetDataIO(DummyDataIORef(fileOutput));
// Create a couple of dummy Messages to test with // Create a couple of dummy Messages to test with
MessageRef msg1 = GetMessageFromPool(PR_COMMAND_TEXT_STRINGS); MessageRef msg1 = GetMessageFromPool(PR_COMMAND_TEXT_STRINGS);
msg1()->AddString(PR_NAME_TEXT_LINE, "This is a line of text."); msg1()->AddString(PR_NAME_TEXT_LINE, "This is a line of text.");
msg1()->AddString(PR_NAME_TEXT_LINE, "There are many like it."); msg1()->AddString(PR_NAME_TEXT_LINE, "There are many like it.");
msg1()->AddString(PR_NAME_TEXT_LINE, "But this one is mine."); msg1()->AddString(PR_NAME_TEXT_LINE, "But this one is mine.");
MessageRef msg2 = GetMessageFromPool(PR_COMMAND_TEXT_STRINGS); MessageRef msg2 = GetMessageFromPool(PR_COMMAND_TEXT_STRINGS);
msg1()->AddString(PR_NAME_TEXT_LINE, "Here is some more text"); msg1()->AddString(PR_NAME_TEXT_LINE, "Here is some more text");
msg1()->AddString(PR_NAME_TEXT_LINE, "From the second Message"); msg1()->AddString(PR_NAME_TEXT_LINE, "From the second Message");
skipping to change at line 73 skipping to change at line 73
// Set up a FileDataIO so we can read our stream in from a file // Set up a FileDataIO so we can read our stream in from a file
FileDataIO fileInput(fopen("example_3_output.txt", "r")); FileDataIO fileInput(fopen("example_3_output.txt", "r"));
if (fileInput.GetFile() == NULL) if (fileInput.GetFile() == NULL)
{ {
printf("Error, couldn't open example_3_output.txt for readingk!\n"); printf("Error, couldn't open example_3_output.txt for readingk!\n");
return 10; return 10;
} }
// Set up our gateway to use the FileDataIO // Set up our gateway to use the FileDataIO
PlainTextMessageIOGateway inputGateway; PlainTextMessageIOGateway inputGateway;
inputGateway.SetDataIO(DataIORef(&fileInput, false)); // false == don't d elete pointer! inputGateway.SetDataIO(DummyDataIORef(fileInput));
// Turn the crank to eat the sausage // Turn the crank to eat the sausage
QueueGatewayMessageReceiver qReceiver; // we'll collect the parsed Messag es in this QueueGatewayMessageReceiver qReceiver; // we'll collect the parsed Messag es in this
printf("Read some text-stream data from example_3_output.txt ...\n"); printf("Read some text-stream data from example_3_output.txt ...\n");
while(inputGateway.DoInput(qReceiver) > 0) {/* empty */} while(inputGateway.DoInput(qReceiver) > 0) {/* empty */}
// And finally, we'll print out the Messages that our gateway read in // And finally, we'll print out the Messages that our gateway read in
printf("Here are the Messages I read back in from example_3_output.txt:\n" ); printf("Here are the Messages I read back in from example_3_output.txt:\n" );
MessageRef nextMsg; MessageRef nextMsg;
while(qReceiver.RemoveHead(nextMsg).IsOK()) while(qReceiver.RemoveHead(nextMsg).IsOK())
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)