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
|
/*
* Copyright 2006 Nick White
*
* This mediagz is part of GetHT
*
* GetHT is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GetHT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GetHT; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <stdio.h>
#include <string.h>
#include <zlib.h>
#include "getht.h"
#include "issue.h"
int smilurl(char * smilurl, med * cur_media);
void getquote(char * input, char * label);
void removeleadingspace(char * cur_line);
int parsemediagz(char * media_path, med * cur_media, int * no_of_media)
/* Parses gzipped adobe pagemaker files for media urls and metadata,
* filling cur_media with the information. */
{
char cur_line[STR_MAX];
gzFile mediagz;
strcpy(cur_line,""); /* reset cur_line */
mediagz = gzopen(media_path, "r");
while(gzeof(mediagz)==0)
{
gzgets(mediagz, cur_line, STR_MAX);
cur_line[strlen(cur_line)-1] = '\0'; /* get rid of trailing newline */
if(!strcmp(cur_line,"on mouseUp"))
{
strcpy(cur_line,""); /* reset cur_line */
while(strcmp(cur_line,"end mouseUp") && gzeof(mediagz)==0)
{
strcpy(cur_line,""); /* reset cur_line */
gzgets(mediagz, cur_line, STR_MAX);
cur_line[strlen(cur_line)-1] = '\0'; /* remove trailing newline */
removeleadingspace(cur_line);
if(!strncmp(cur_line,"set the filename of player \"player1\" to \"",41))
{
/* todo: check if smil, if so follow to find uri */
sscanf(cur_line,"set the filename of player \"player1\" to \"%s\"",cur_media->uri);
cur_media->uri[strlen(cur_media->uri)-1] = '\0'; /* workaround extra character */
}
else if(!strncmp(cur_line,"set the label of this stack to \"",32))
{
getquote(cur_line,cur_media->title);
}
else if(!strncmp(cur_line,"statusMsg \(\"",12))
{
getquote(cur_line,cur_media->comment);
}
}
*cur_media++;
(*no_of_media)++;
}
strcpy(cur_line,""); /* reset cur_line */
}
return 0;
}
int smilurl(char * smilurl, med * cur_media)
/* Extracts url and other data from remote smil file, storing
* the info in the cur_media structure. */
{
return 0;
}
void getquote(char * input, char * quote)
/* sets quote from a line of the format:
* `something "quote" something' */
{
char * cur_pos;
cur_pos = quote;
/* advance until " character is reached */
while(*input != '"' && *input)
input++;
input++;
/* copy characters in until next '"' */
while(*input != '"' && *input)
{
*cur_pos = *input;
cur_pos++;
input++;
}
*cur_pos = '\0';
}
void removeleadingspace(char * cur_line)
{
int tmp, newpos;
char temp_str[STR_MAX];
/* advance past whitespace */
tmp = 0;
while (cur_line[tmp] == ' ' || cur_line[tmp] == '\t')
tmp++;
/* copy from there to temp_str */
for(newpos = 0; cur_line[tmp]; tmp++, newpos++)
temp_str[newpos] = cur_line[tmp];
temp_str[newpos] = '\0';
/* copy temp_str to cur_line */
strncpy(cur_line, temp_str, sizeof(temp_str));
}
|