File: oxml.c

package info (click to toggle)
lsdvd 0.16-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, squeeze, wheezy
  • size: 456 kB
  • ctags: 156
  • sloc: sh: 3,509; ansic: 944; makefile: 56
file content (174 lines) | stat: -rw-r--r-- 4,743 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include "oxml.h"

static int _xlvl = 0;
char *_xlvl_type[256];

int XMLDEF_(char *name, const char *format, ...) {
	va_list argp;
	XMLINDENT;
	printf("<%s>", name);
	
	va_start(argp, format);
	vprintf(format, argp);
	va_end(argp);
	printf("</%s>\n", name);
	return 0;
}

// int XMLBOX_(char *name) {
//	XMLINDENT;
//	printf("<%s>\n", name);
//	_xlvl++; 
//	_xlvl_type[_xlvl] = malloc(20 * sizeof(char));
//	sprintf(_xlvl_type[_xlvl], "</%s>", name);
//	return 0;
//}

//void XMLRETURN_()  {
//	_xlvl--; 
//	XMLINDENT;
//	printf("%s\n", _xlvl_type[_xlvl+1] );
//	free(_xlvl_type[_xlvl+1]);
//}

void XMLBOX_(char *name) {
	XMLINDENT;
	printf("<%s>\n", name);
	_xlvl++;
	_xlvl_type[_xlvl] = name;
}

void XMLRETURN_()  {
	_xlvl--;
	XMLINDENT;
	printf("</%s>\n", _xlvl_type[_xlvl+1]);
}


void XMLSTART_() {
	printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
	XMLBOX("lsdvd");
}

void XMLSTOP_() {
	while(_xlvl) XMLRETURN;
}

void oxml_print(struct dvd_info *dvd_info) {
	int j, i;

	XMLSTART;
	XMLDEF("device", "%s", dvd_info->discinfo.device);
	XMLDEF("title", "%s", dvd_info->discinfo.disc_title);
	XMLDEF("vmg_id", "%.12s", dvd_info->discinfo.vmg_id);
	XMLDEF("provider_id", "%.32s", dvd_info->discinfo.provider_id);

	for (j=0; j < dvd_info->title_count; j++)
	{
	if ( opt_t == j+1 || opt_t == 0 ) {

	// GENERAL
	if (dvd_info->titles[j].enabled) {

		XMLBOX("track");
		XMLDEF("ix", "%d", j+1);
		XMLDEF("length", "%.3f", dvd_info->titles[j].general.length);
		XMLDEF("vts_id", "%.12s", dvd_info->titles[j].general.vts_id);

		if (dvd_info->titles[j].parameter.format != NULL ) {
			XMLDEF("vts", "%d", dvd_info->titles[j].parameter.vts);
			XMLDEF("ttn", "%d", dvd_info->titles[j].parameter.ttn);
			XMLDEF("fps", "%.2f", dvd_info->titles[j].parameter.fps);
			XMLDEF("format", "%s", dvd_info->titles[j].parameter.format);
			XMLDEF("aspect", "%s", dvd_info->titles[j].parameter.aspect);
			XMLDEF("width", "%s", dvd_info->titles[j].parameter.width);
			XMLDEF("height", "%s", dvd_info->titles[j].parameter.height);
			XMLDEF("df", "%s", dvd_info->titles[j].parameter.df);
		}
		
		// PALETTE
		if (dvd_info->titles[j].palette != NULL ) {
			XMLBOX("palette");
			for (i=0; i < 16; i++) {
				XMLDEF("color","%06x", dvd_info->titles[j].palette[i]);
			}
			XMLRETURN;
		}

		// ANGLES
		if (dvd_info->titles[j].angle_count) { // poor check, but there's no other info anyway.
			XMLDEF("angles", "%d", dvd_info->titles[j].angle_count);
		}

		// AUDIO
		if (dvd_info->titles[j].audiostreams != NULL ) {
			for (i=0; i<dvd_info->titles[j].audiostream_count; i++)
			{
				XMLBOX("audio");
				XMLDEF("ix", "%d", i+1);
				XMLDEF("langcode", "%s", dvd_info->titles[j].audiostreams[i].langcode);
				XMLDEF("language", "%s", dvd_info->titles[j].audiostreams[i].language);
				XMLDEF("format", "%s", dvd_info->titles[j].audiostreams[i].format);
				XMLDEF("frequency", "%s", dvd_info->titles[j].audiostreams[i].frequency);
				XMLDEF("quantization", "%s", dvd_info->titles[j].audiostreams[i].quantization);
				XMLDEF("channels", "%d", dvd_info->titles[j].audiostreams[i].channels);
				XMLDEF("ap_mode", "%d", dvd_info->titles[j].audiostreams[i].ap_mode);
				XMLDEF("content", "%s", dvd_info->titles[j].audiostreams[i].content);
				XMLDEF("streamid", "0x%x", dvd_info->titles[j].audiostreams[i].streamid);
				XMLRETURN;
			}
		}

		// CHAPTERS
		if (dvd_info->titles[j].chapters != NULL) {
			for (i=0; i<dvd_info->titles[j].chapter_count; i++)
			{
				XMLBOX("chapter");
				XMLDEF("ix", "%d", i+1);
				XMLDEF("length", "%.3f", dvd_info->titles[j].chapters[i].length);
				XMLDEF("startcell", "%d", dvd_info->titles[j].chapters[i].startcell);
				XMLRETURN;
			}
		}

		// CELLS
		if (dvd_info->titles[j].cells != NULL) {
			for (i=0; i<dvd_info->titles[j].cell_count; i++)
			{
				XMLBOX("cell");
				XMLDEF("ix", "%d", i+1);
				XMLDEF("length", "%.3f", dvd_info->titles[j].cells[i].length);
				XMLRETURN;
			}
		}

		// SUBTITLES
		if (dvd_info->titles[j].subtitles != NULL) {
			for (i=0; i<dvd_info->titles[j].subtitle_count; i++)
			{
				XMLBOX("subp");
				XMLDEF("ix", "%d", i+1);
				XMLDEF("langcode", "%s", dvd_info->titles[j].subtitles[i].langcode);
				XMLDEF("language", "%s", dvd_info->titles[j].subtitles[i].language);
				XMLDEF("content", "%s", dvd_info->titles[j].subtitles[i].content);
				XMLDEF("streamid", "0x%x", dvd_info->titles[j].subtitles[i].streamid);
				XMLRETURN;
			}
		}
	XMLRETURN;	
	}
	}
	}

	if (! opt_t) {
		int max_length = 0, max_track = 0;
		for (j=0; j < dvd_info->title_count; j++) {
			if (dvd_info->titles[j].general.length > max_length) {
				max_length = dvd_info->titles[j].general.length;
				max_track = j+1;
			}
		}
		XMLDEF("longest_track", "%d", max_track);
	}
	XMLSTOP;
}