source: branches/v2.9/mediafolder/c/helper/cddbhelper.cpp

Last change on this file was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 2.2 KB
Line 
1/*
2 * This file is (C) Chris Wohlgemuth 1999/2000
3 */
4/* These functions are used by PMCDDB to output error messages and
5 CDDB data to the appropriate log and data files.
6 */
7/*
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <os2.h>
24#include <stdio.h> /* For stderr */
25#include <string.h>
26#include <io.h>
27#include <fcntl.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30
31extern HWND hwndError;
32extern char cddbDataFile[];
33
34extern "C" void writeLog(char* logText);
35
36/**********************************************************/
37/* Some helper functions
38 */
39
40void extern printError(char* errorString)
41{
42 char buffer[CCHMAXPATH];
43 char *ptr;
44
45 fprintf(stderr,"%s",errorString);
46
47 writeLog(errorString);
48 if(hwndError) {
49 strncpy(buffer, errorString, sizeof(buffer));
50 ptr=strchr(buffer,'\n');
51 if(ptr) {
52 *ptr=0;
53 }
54 }
55}
56
57void extern printErrorCR(char* errorString)
58{
59 fprintf(stderr,"%s\n",errorString);
60 writeLog(errorString);
61 writeLog("\n");
62}
63
64
65void extern printData(char* outString)
66{
67 int fileHandle;
68 int rc;
69
70 /* The name cddbDataFile is defined in the main pmcddb.cpp file. It is
71 the discid (this is the native format of the data hold by a cddb server) */
72 fileHandle=open(cddbDataFile,O_APPEND|O_TEXT|O_WRONLY|O_CREAT,S_IWRITE);
73 if(fileHandle==-1) {
74 printError("Cannot open cddb outfile");/* Disk full? */
75 return;
76 }
77 rc= write(fileHandle,outString,strlen(outString));
78 // write(fileHandle,"\n",sizeof("\n"));
79 close(fileHandle);
80 return;
81}
82
83
84
85
86
87
88
89
90
91
92
Note: See TracBrowser for help on using the repository browser.