source: tags/1.0/src/core/RpResult.cc @ 1723

Last change on this file since 1723 was 115, checked in by mmc, 19 years ago

Updated all copyright notices.

File size: 1.3 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  FUNCTION: rpResult
4 *
5 *  Clients call this function at the end of their simulation, to
6 *  pass the simulation result back to the Rappture GUI.  It writes
7 *  out the given XML object to a runXXX.xml file, and then writes
8 *  out the name of that file to stdout.
9 * ======================================================================
10 *  AUTHOR:  Michael McLennan, Purdue University
11 *  Copyright (c) 2004-2005  Purdue Research Foundation
12 *
13 *  See the file "license.terms" for information on usage and
14 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15 * ======================================================================
16 */
17#include <stdlib.h>
18#include <time.h>
19
20void
21rpResult(PyObject* lib) {
22    char outputFile[100];
23    char* xtext;
24    FILE* fp;
25    time_t t;
26
27    xtext = rpXml(lib);
28
29    // create output filename
30    snprintf(outputFile, 50, "run%d.xml", (int)time(&t));
31
32    // write out the result file
33    fp = fopen(outputFile, "w");
34    if(!fp) {
35        fprintf(stderr,"can't save results (err=%d)\n", errno);
36        return;
37    }
38    int fsize = fwrite(xtext, strlen(xtext), sizeof(char), fp);
39    fclose(fp);
40
41    // tell Rappture the file name
42    printf("=RAPPTURE-RUN=>%s\n", outputFile);
43}
Note: See TracBrowser for help on using the repository browser.