source: trunk/src/testing/app/hd-video-player/Utils2.h @ 4

Revision 4, 3.4 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Copyright (C) 2004 Electronic Visualization Laboratory,
5 * University of Illinois at Chicago
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above
15 *    copyright notice, this list of conditions and the following disclaimer
16 *    in the documentation and/or other materials provided with the distribution.
17 *  * Neither the name of the University of Illinois at Chicago nor
18 *    the names of its contributors may be used to endorse or promote
19 *    products derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/
34 *
35 *****************************************************************************/
36
37
38#ifndef _UTIL2_
39#define _UTIL2_
40
41#include <dvdmedia.h>
42
43HRESULT SaveGraphFile(IGraphBuilder *pGraph, WCHAR *wszPath);
44
45class C_SaveToLog {
46        FILE *fp;
47        char fileName[125];
48
49        int index;
50        char string[1024];
51
52public :
53        C_SaveToLog(char*str = NULL) {
54                if(str == NULL)
55                        strcpy(fileName, "log.txt");
56                else
57                        strcpy(fileName, str);
58
59                fp = fopen(fileName, "w");
60
61                fprintf(fp, "<Log file> \n ");
62
63                index = 0;
64        }
65
66        ~C_SaveToLog() {
67                if(fp)
68                        fclose(fp);
69        }
70
71        void ToLog(char* str) {
72                if(fp)
73                        fprintf(fp, "%s", str);
74        }
75
76        void ToLog(int input) {
77                if(fp)
78                        fprintf(fp, "%d", input);
79        }
80
81        void ToLog(char* str, int len) {
82                if(fp) {
83                        char tmp[1024];
84                        strncpy(tmp, str, len);
85                        strcat(tmp, "");
86                        fprintf(fp, "\n Len(%d) : %s", len, tmp);
87                }
88        }
89
90        void ToLog16(char* str, int len) {
91                if(fp) {
92                        char tmp[1024];
93                        strncpy(tmp, str, len);
94                        strcat(tmp, "");
95                        fprintf(fp, "\n Len(%d) : %d", len, tmp);
96                        for(int i = 0; i < len; i++)
97                                fprintf(fp, "\n %x", tmp[i]);
98                }
99        }
100
101        void CleanStr(void) {
102                index = 0;
103        }
104
105        void ToStr(char* str) {
106                strcpy(&string[index], str);
107                index += strlen(string);
108        }
109
110        void ToStr(int input) {
111                char str[100];
112
113                itoa(input, str, 10);
114                strcpy(&string[index], str);
115                index += strlen(string);
116        }
117
118        void SaveStr(void) {
119                if(fp)
120                        fprintf(fp, "\n%s", string);
121        }
122};
123
124
125#ifdef _MAIN_
126class C_SaveToLog SaveLog(NULL);
127#else
128extern class C_SaveToLog SaveLog;
129#endif
130
131
132#endif
Note: See TracBrowser for help on using the repository browser.