3 * Copyright (C) 2016-2020 William Morrow
5 * This program is free software; you can redistribute it and/or modify it
6 * by the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
31 AdCuts(int pid, int fd, const char *fn)
35 memset(this->filename,0,sizeof(this->filename));
36 if( fn ) strcpy(this->filename,fn);
45 char cut_filename[BCTEXTLEN];
46 strcpy(cut_filename, filename);
47 strcpy(strrchr(cut_filename, '.'),".cut");
48 write_cuts(cut_filename);
49 printf(_("cuts to %s complete\n"),cut_filename);
60 if( xml.read_tag() != 0 ) return 1;
61 if( !xml.tag.title_is("CUT") ) break;
62 double time = xml.tag.get_property("TIME", (double)0.0);
63 int action = xml.tag.get_property("ACTION", (int)0);
64 append(new AdCut(time, action));
70 read_cuts(const char *filename)
73 if( xml.read_from_file(filename, 1) ) return 0;
75 if( xml.read_tag() ) return 0;
76 } while( !xml.tag.title_is("CUTS") );
78 int pid = xml.tag.get_property("PID", (int)-1);
79 const char *file = xml.tag.get_property("FILE");
80 AdCuts *cuts = new AdCuts(pid, -1, file);
81 if( cuts->load(xml) || !xml.tag.title_is("/CUTS") ) {
82 delete cuts; cuts = 0;
90 xml.tag.set_title("CUTS");
91 xml.tag.set_property("PID", pid);
92 xml.tag.set_property("FILE", filename);
96 for( AdCut *cut=first; cut; cut=cut->next ) {
97 xml.tag.set_title("CUT");
98 xml.tag.set_property("TIME", cut->time);
99 xml.tag.set_property("ACTION", cut->action);
101 xml.tag.set_title("/CUT");
103 xml.append_newline();
106 xml.tag.set_title("/CUTS");
108 xml.append_newline();
113 write_cuts(const char *filename)
115 FILE *fp = fopen(filename, "wb");
119 xml.terminate_string();
120 xml.write_to_file(fp);