~ubuntu-branches/ubuntu/natty/mp3val/natty

« back to all changes in this revision

Viewing changes to main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2008-01-23 09:11:35 UTC
  • mfrom: (3.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080123091135-r10vczs51d63e8p0
Tags: 0.1.7-3
* debian/control
  - bump Standards-Version to 3.7.3
  - bump dependency against debhelper to >=5
* debian/compat
  - bump to 5
* debian/dirs
  - removed since not needed
* debian/rules
  - do not ignore anymore clean error due to missing makefile
* debian/copyright
  - clear separation of upstream author, license and copyright
  - link to /usr/share/common-licenses/GPL file
* debian/mp3val.1
  - escaped minus signs (lintian warning)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * MP3val - a program for MPEG audio file validation
3
 
 * Copyright (C) 2005-2006 Alexey Kuznetsov (ring0) and Eugen Tikhonov (jetsys)
 
3
 * Copyright (C) 2005-2007 Alexey Kuznetsov (ring0) and Eugen Tikhonov (jetsys)
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License as published by
33
33
bool FixErrors=false;
34
34
bool bSuppressInfo=false;
35
35
bool bPipeMode=false;
 
36
bool bDeleteBaks=false;
 
37
bool bKeepTimestamps=false;
36
38
 
37
39
extern int iMappingLength;
38
40
 
64
66
 
65
67
        if(help) {
66
68
                cerr<<"MP3val - a program for MPEG audio stream validation.\n";
67
 
                cerr<<"Version 0.1.4.\n\n";
 
69
                cerr<<"Version 0.1.7.\n\n";
68
70
                cerr<<"Usage: "<<argv[0]<<" <files to validate> [options]\n\n";
69
71
                cerr<<"Options:\n\n";
70
72
                cerr<<"\t-f                try to fix errors\n";
71
73
                cerr<<"\t-l<file name>     write log to the specified file (default: stdout)\n";
72
74
                cerr<<"\t-si               suppress INFO messages\n";
 
75
                cerr<<"\t-nb               delete .bak files (suitable with -f)\n";
 
76
                cerr<<"\t-t                keep file timestamps (suitable with -f)\n";
73
77
                cerr<<"\t-p                pipe mode (receive input file names from stdin)\n";
74
78
                cerr<<"\t-v                print version number and exit\n";
75
79
                cerr<<"\n";
76
80
                cerr<<"Wildcards are allowed.\n\n";
77
 
                cerr<<"(c) ring0, jetsys, 2005-2006.\n";
 
81
                cerr<<"(c) ring0, jetsys, 2005-2007.\n";
78
82
                cerr<<"This program is released under GPL, see the attached file for details.\n";
79
83
                return 0;
80
84
        }
90
94
                else if(!strcmp(argv[i],"-si")) {
91
95
                        bSuppressInfo=true;
92
96
                }
 
97
                else if(!strcmp(argv[i],"-nb")) {
 
98
                        bDeleteBaks=true;
 
99
                }
 
100
                else if(!strcmp(argv[i],"-t")) {
 
101
                        bKeepTimestamps=true;
 
102
                }
93
103
                else if(!strcmp(argv[i],"-p")) {
94
104
                        bPipeMode=true;
95
105
                }
96
106
                else if(!strcmp(argv[i],"-v")) {
97
 
                        cout<<"MP3val 0.1.4\n";
 
107
                        cout<<"MP3val 0.1.7\n";
98
108
                        return 0;
99
109
                }
100
110
                else {
103
113
                }
104
114
        }
105
115
        
 
116
        if(bDeleteBaks&&!FixErrors) cerr<<"Note: using -nb doesn't make sense as long as -f isn't used\n";
 
117
        
106
118
        if(szLogFile) CrossAPI_GetFullPathName(szLogFile,szFullLogFile,CROSSAPI_MAX_PATH+2);
107
119
        
108
120
        if(bPipeMode) {
160
172
        ofstream log_out;
161
173
        int hData;
162
174
        ostream *out;
 
175
        CROSSAPI_FILE_ATTRIBUTES cfa;
 
176
        
 
177
        CrossAPI_GetFileAttr(szFileName,&cfa);
163
178
        
164
179
        pImage=(unsigned char *)CrossAPI_MapFile(szFileName);
165
180
 
200
215
 
201
216
                cout<<"Rebuilding file \""<<szFileName<<"\"...\n";
202
217
 
203
 
                ValidateFile(pImage,iMappingLength,&mpginfo,NULL,NULL,true,(int)hData);
 
218
                if(ValidateFile(pImage,iMappingLength,&mpginfo,NULL,NULL,true,(int)hData)==-1) {
 
219
                        cerr<<"Error writing to temporary file\n";
 
220
                        CrossAPI_CloseFile(hData);
 
221
                        CrossAPI_UnmapFile(pImage);
 
222
                        CrossAPI_DeleteFile(pcBuffer);
 
223
                        return 0;
 
224
                }
204
225
 
205
226
                CrossAPI_CloseFile(hData);
206
227
        }
212
233
                strcat((char *)pcBuffer2,".bak");
213
234
                if(!CrossAPI_MoveFile((char *)pcBuffer2,szFileName)) {
214
235
                        cerr<<"Error renaming \""<<szFileName<<"\"\n";
215
 
                        CrossAPI_UnmapFile(pImage);
216
236
                        log_out.close();
217
237
                        return 0;
218
238
                }
219
239
                if(!CrossAPI_MoveFile(szFileName,pcBuffer)) {
220
240
                        cerr<<"Error renaming temporary file\n";
221
 
                        CrossAPI_UnmapFile(pImage);
222
241
                        log_out.close();
223
242
                        return 0;
224
243
                }
225
 
 
 
244
                CrossAPI_SetFileAttr(szFileName,&cfa,bKeepTimestamps);
 
245
                if(bDeleteBaks) CrossAPI_DeleteFile((char *)pcBuffer2);
226
246
        }
227
247
 
228
248
        if(FixErrors&&mpginfo.iErrors) {