summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-11-08 13:38:10 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-11-08 13:38:10 +0000
commit3e489c14c143bb2f193e97fa66385e8a285d43ff (patch)
tree81287c64b91f3776a400241386fcad0c27718d33
parent92fb1df03aa1d7cd33bb07f7222e36e954409e52 (diff)
downloadrockbox-3e489c14c143bb2f193e97fa66385e8a285d43ff.tar.gz
rockbox-3e489c14c143bb2f193e97fa66385e8a285d43ff.zip
Rename print_error() in ipodpatcher and sansapatcher.
Both patchers use the same function name with one being removed when building for rbutil. This gets in the way trying to move the patchers to libraries, and it also results a linking dependency of sansapatcher on ipodpatcher. Renaming the function makes both more self-contained and avoids potential issues if the functions happen to not do the same. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23568 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/ipodpatcher/ipodio-posix.c2
-rw-r--r--rbutil/ipodpatcher/ipodio-win32.c20
-rw-r--r--rbutil/ipodpatcher/ipodio.h2
-rw-r--r--rbutil/ipodpatcher/ipodpatcher.c6
-rw-r--r--rbutil/sansapatcher/sansaio-posix.c4
-rw-r--r--rbutil/sansapatcher/sansaio-win32.c23
-rw-r--r--rbutil/sansapatcher/sansaio.h2
-rw-r--r--rbutil/sansapatcher/sansapatcher.c2
8 files changed, 29 insertions, 32 deletions
diff --git a/rbutil/ipodpatcher/ipodio-posix.c b/rbutil/ipodpatcher/ipodio-posix.c
index be048fc986..8398eca566 100644
--- a/rbutil/ipodpatcher/ipodio-posix.c
+++ b/rbutil/ipodpatcher/ipodio-posix.c
@@ -160,7 +160,7 @@ static int ipod_unmount(struct ipod_t* ipod)
160} 160}
161#endif 161#endif
162 162
163void print_error(char* msg) 163void ipod_print_error(char* msg)
164{ 164{
165 perror(msg); 165 perror(msg);
166} 166}
diff --git a/rbutil/ipodpatcher/ipodio-win32.c b/rbutil/ipodpatcher/ipodio-win32.c
index 29391bfa4f..abf7bdf46e 100644
--- a/rbutil/ipodpatcher/ipodio-win32.c
+++ b/rbutil/ipodpatcher/ipodio-win32.c
@@ -54,7 +54,7 @@ static int unlock_volume(HANDLE hDisk)
54 &dummy, NULL); 54 &dummy, NULL);
55} 55}
56 56
57void print_error(char* msg) 57void ipod_print_error(char* msg)
58{ 58{
59 LPSTR pMsgBuf = NULL; 59 LPSTR pMsgBuf = NULL;
60 60
@@ -78,7 +78,7 @@ int ipod_open(struct ipod_t* ipod, int silent)
78 FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, NULL); 78 FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, NULL);
79 79
80 if (ipod->dh == INVALID_HANDLE_VALUE) { 80 if (ipod->dh == INVALID_HANDLE_VALUE) {
81 if (!silent) print_error(" Error opening disk: "); 81 if (!silent) ipod_print_error(" Error opening disk: ");
82 if(GetLastError() == ERROR_ACCESS_DENIED) 82 if(GetLastError() == ERROR_ACCESS_DENIED)
83 return -2; 83 return -2;
84 else 84 else
@@ -86,7 +86,7 @@ int ipod_open(struct ipod_t* ipod, int silent)
86 } 86 }
87 87
88 if (!lock_volume(ipod->dh)) { 88 if (!lock_volume(ipod->dh)) {
89 if (!silent) print_error(" Error locking disk: "); 89 if (!silent) ipod_print_error(" Error locking disk: ");
90 return -1; 90 return -1;
91 } 91 }
92 92
@@ -110,7 +110,7 @@ int ipod_open(struct ipod_t* ipod, int silent)
110 sizeof(diskgeometry), 110 sizeof(diskgeometry),
111 &n, 111 &n,
112 NULL)) { 112 NULL)) {
113 if (!silent) print_error(" Error reading disk geometry: "); 113 if (!silent) ipod_print_error(" Error reading disk geometry: ");
114 return -1; 114 return -1;
115 } else { 115 } else {
116 ipod->sector_size = diskgeometry.BytesPerSector; 116 ipod->sector_size = diskgeometry.BytesPerSector;
@@ -137,12 +137,12 @@ int ipod_reopen_rw(struct ipod_t* ipod)
137 FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, NULL); 137 FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, NULL);
138 138
139 if (ipod->dh == INVALID_HANDLE_VALUE) { 139 if (ipod->dh == INVALID_HANDLE_VALUE) {
140 print_error(" Error opening disk: "); 140 ipod_print_error(" Error opening disk: ");
141 return -1; 141 return -1;
142 } 142 }
143 143
144 if (!lock_volume(ipod->dh)) { 144 if (!lock_volume(ipod->dh)) {
145 print_error(" Error locking disk: "); 145 ipod_print_error(" Error locking disk: ");
146 return -1; 146 return -1;
147 } 147 }
148 148
@@ -162,7 +162,7 @@ int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize)
162 the disk sector size. */ 162 the disk sector size. */
163 *sectorbuf = (unsigned char*)VirtualAlloc(NULL, bufsize, MEM_COMMIT, PAGE_READWRITE); 163 *sectorbuf = (unsigned char*)VirtualAlloc(NULL, bufsize, MEM_COMMIT, PAGE_READWRITE);
164 if (*sectorbuf == NULL) { 164 if (*sectorbuf == NULL) {
165 print_error(" Error allocating a buffer: "); 165 ipod_print_error(" Error allocating a buffer: ");
166 return -1; 166 return -1;
167 } 167 }
168 return 0; 168 return 0;
@@ -171,7 +171,7 @@ int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize)
171int ipod_seek(struct ipod_t* ipod, unsigned long pos) 171int ipod_seek(struct ipod_t* ipod, unsigned long pos)
172{ 172{
173 if (SetFilePointer(ipod->dh, pos, NULL, FILE_BEGIN)==0xffffffff) { 173 if (SetFilePointer(ipod->dh, pos, NULL, FILE_BEGIN)==0xffffffff) {
174 print_error(" Seek error "); 174 ipod_print_error(" Seek error ");
175 return -1; 175 return -1;
176 } 176 }
177 return 0; 177 return 0;
@@ -182,7 +182,7 @@ ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes)
182 unsigned long count; 182 unsigned long count;
183 183
184 if (!ReadFile(ipod->dh, buf, nbytes, &count, NULL)) { 184 if (!ReadFile(ipod->dh, buf, nbytes, &count, NULL)) {
185 print_error(" Error reading from disk: "); 185 ipod_print_error(" Error reading from disk: ");
186 return -1; 186 return -1;
187 } 187 }
188 188
@@ -194,7 +194,7 @@ ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes)
194 unsigned long count; 194 unsigned long count;
195 195
196 if (!WriteFile(ipod->dh, buf, nbytes, &count, NULL)) { 196 if (!WriteFile(ipod->dh, buf, nbytes, &count, NULL)) {
197 print_error(" Error writing to disk: "); 197 ipod_print_error(" Error writing to disk: ");
198 return -1; 198 return -1;
199 } 199 }
200 200
diff --git a/rbutil/ipodpatcher/ipodio.h b/rbutil/ipodpatcher/ipodio.h
index 5c098ab60c..6aa675535a 100644
--- a/rbutil/ipodpatcher/ipodio.h
+++ b/rbutil/ipodpatcher/ipodio.h
@@ -91,7 +91,7 @@ struct ipod_t {
91#endif 91#endif
92}; 92};
93 93
94void print_error(char* msg); 94void ipod_print_error(char* msg);
95int ipod_open(struct ipod_t* ipod, int silent); 95int ipod_open(struct ipod_t* ipod, int silent);
96int ipod_reopen_rw(struct ipod_t* ipod); 96int ipod_reopen_rw(struct ipod_t* ipod);
97int ipod_close(struct ipod_t* ipod); 97int ipod_close(struct ipod_t* ipod);
diff --git a/rbutil/ipodpatcher/ipodpatcher.c b/rbutil/ipodpatcher/ipodpatcher.c
index 7116056350..dc023f0a51 100644
--- a/rbutil/ipodpatcher/ipodpatcher.c
+++ b/rbutil/ipodpatcher/ipodpatcher.c
@@ -175,7 +175,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
175 count = ipod_read(ipod,ipod_sectorbuf, ipod->sector_size); 175 count = ipod_read(ipod,ipod_sectorbuf, ipod->sector_size);
176 176
177 if (count <= 0) { 177 if (count <= 0) {
178 print_error(" Error reading from disk: "); 178 ipod_print_error(" Error reading from disk: ");
179 return -1; 179 return -1;
180 } 180 }
181 181
@@ -225,7 +225,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
225 count = ipod_read(ipod, ipod_sectorbuf, ipod->sector_size); 225 count = ipod_read(ipod, ipod_sectorbuf, ipod->sector_size);
226 226
227 if (count <= 0) { 227 if (count <= 0) {
228 print_error(" Error reading from disk: "); 228 ipod_print_error(" Error reading from disk: ");
229 return -1; 229 return -1;
230 } 230 }
231 231
@@ -372,7 +372,7 @@ int write_partition(struct ipod_t* ipod, int infile)
372 res = ipod_write(ipod, ipod_sectorbuf, n); 372 res = ipod_write(ipod, ipod_sectorbuf, n);
373 373
374 if (res < 0) { 374 if (res < 0) {
375 print_error(" Error writing to disk: "); 375 ipod_print_error(" Error writing to disk: ");
376 fprintf(stderr,"Bytes written: %d\n",byteswritten); 376 fprintf(stderr,"Bytes written: %d\n",byteswritten);
377 return -1; 377 return -1;
378 } 378 }
diff --git a/rbutil/sansapatcher/sansaio-posix.c b/rbutil/sansapatcher/sansaio-posix.c
index 4c28afa1c2..56f755ab9a 100644
--- a/rbutil/sansapatcher/sansaio-posix.c
+++ b/rbutil/sansapatcher/sansaio-posix.c
@@ -65,12 +65,10 @@ static int sansa_unmount(struct sansa_t* sansa)
65#endif 65#endif
66 66
67 67
68#ifndef RBUTIL 68void sansa_print_error(char* msg)
69void print_error(char* msg)
70{ 69{
71 perror(msg); 70 perror(msg);
72} 71}
73#endif
74 72
75int sansa_open(struct sansa_t* sansa, int silent) 73int sansa_open(struct sansa_t* sansa, int silent)
76{ 74{
diff --git a/rbutil/sansapatcher/sansaio-win32.c b/rbutil/sansapatcher/sansaio-win32.c
index 2b93d2807d..c27092762a 100644
--- a/rbutil/sansapatcher/sansaio-win32.c
+++ b/rbutil/sansapatcher/sansaio-win32.c
@@ -55,8 +55,7 @@ static int unlock_volume(HANDLE hDisk)
55 &dummy, NULL); 55 &dummy, NULL);
56} 56}
57 57
58#ifndef RBUTIL 58void sansa_print_error(char* msg)
59void print_error(char* msg)
60{ 59{
61 char* pMsgBuf; 60 char* pMsgBuf;
62 61
@@ -68,7 +67,7 @@ void print_error(char* msg)
68 printf(pMsgBuf); 67 printf(pMsgBuf);
69 LocalFree(pMsgBuf); 68 LocalFree(pMsgBuf);
70} 69}
71#endif 70
72int sansa_open(struct sansa_t* sansa, int silent) 71int sansa_open(struct sansa_t* sansa, int silent)
73{ 72{
74 DISK_GEOMETRY_EX diskgeometry_ex; 73 DISK_GEOMETRY_EX diskgeometry_ex;
@@ -80,7 +79,7 @@ int sansa_open(struct sansa_t* sansa, int silent)
80 FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, NULL); 79 FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, NULL);
81 80
82 if (sansa->dh == INVALID_HANDLE_VALUE) { 81 if (sansa->dh == INVALID_HANDLE_VALUE) {
83 if (!silent) print_error(" Error opening disk: "); 82 if (!silent) sansa_print_error(" Error opening disk: ");
84 if(GetLastError() == ERROR_ACCESS_DENIED) 83 if(GetLastError() == ERROR_ACCESS_DENIED)
85 return -2; 84 return -2;
86 else 85 else
@@ -88,7 +87,7 @@ int sansa_open(struct sansa_t* sansa, int silent)
88 } 87 }
89 88
90 if (!lock_volume(sansa->dh)) { 89 if (!lock_volume(sansa->dh)) {
91 if (!silent) print_error(" Error locking disk: "); 90 if (!silent) sansa_print_error(" Error locking disk: ");
92 return -1; 91 return -1;
93 } 92 }
94 93
@@ -108,7 +107,7 @@ int sansa_open(struct sansa_t* sansa, int silent)
108 sizeof(diskgeometry), 107 sizeof(diskgeometry),
109 &n, 108 &n,
110 NULL)) { 109 NULL)) {
111 if (!silent) print_error(" Error reading disk geometry: "); 110 if (!silent) sansa_print_error(" Error reading disk geometry: ");
112 return -1; 111 return -1;
113 } else { 112 } else {
114 sansa->sector_size=diskgeometry.BytesPerSector; 113 sansa->sector_size=diskgeometry.BytesPerSector;
@@ -131,12 +130,12 @@ int sansa_reopen_rw(struct sansa_t* sansa)
131 FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, NULL); 130 FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, NULL);
132 131
133 if (sansa->dh == INVALID_HANDLE_VALUE) { 132 if (sansa->dh == INVALID_HANDLE_VALUE) {
134 print_error(" Error opening disk: "); 133 sansa_print_error(" Error opening disk: ");
135 return -1; 134 return -1;
136 } 135 }
137 136
138 if (!lock_volume(sansa->dh)) { 137 if (!lock_volume(sansa->dh)) {
139 print_error(" Error locking disk: "); 138 sansa_print_error(" Error locking disk: ");
140 return -1; 139 return -1;
141 } 140 }
142 141
@@ -156,7 +155,7 @@ int sansa_alloc_buffer(unsigned char** sectorbuf, int bufsize)
156 the disk sector size. */ 155 the disk sector size. */
157 *sectorbuf = (unsigned char*)VirtualAlloc(NULL, bufsize, MEM_COMMIT, PAGE_READWRITE); 156 *sectorbuf = (unsigned char*)VirtualAlloc(NULL, bufsize, MEM_COMMIT, PAGE_READWRITE);
158 if (*sectorbuf == NULL) { 157 if (*sectorbuf == NULL) {
159 print_error(" Error allocating a buffer: "); 158 sansa_print_error(" Error allocating a buffer: ");
160 return -1; 159 return -1;
161 } 160 }
162 return 0; 161 return 0;
@@ -171,7 +170,7 @@ int sansa_seek(struct sansa_t* sansa, loff_t pos)
171 li.LowPart = SetFilePointer (sansa->dh, li.LowPart, &li.HighPart, FILE_BEGIN); 170 li.LowPart = SetFilePointer (sansa->dh, li.LowPart, &li.HighPart, FILE_BEGIN);
172 171
173 if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) { 172 if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) {
174 print_error(" Seek error "); 173 sansa_print_error(" Seek error ");
175 return -1; 174 return -1;
176 } 175 }
177 return 0; 176 return 0;
@@ -182,7 +181,7 @@ int sansa_read(struct sansa_t* sansa, unsigned char* buf, int nbytes)
182 unsigned long count; 181 unsigned long count;
183 182
184 if (!ReadFile(sansa->dh, buf, nbytes, &count, NULL)) { 183 if (!ReadFile(sansa->dh, buf, nbytes, &count, NULL)) {
185 print_error(" Error reading from disk: "); 184 sansa_print_error(" Error reading from disk: ");
186 return -1; 185 return -1;
187 } 186 }
188 187
@@ -194,7 +193,7 @@ int sansa_write(struct sansa_t* sansa, unsigned char* buf, int nbytes)
194 unsigned long count; 193 unsigned long count;
195 194
196 if (!WriteFile(sansa->dh, buf, nbytes, &count, NULL)) { 195 if (!WriteFile(sansa->dh, buf, nbytes, &count, NULL)) {
197 print_error(" Error writing to disk: "); 196 sansa_print_error(" Error writing to disk: ");
198 return -1; 197 return -1;
199 } 198 }
200 199
diff --git a/rbutil/sansapatcher/sansaio.h b/rbutil/sansapatcher/sansaio.h
index 5fd98a11ed..9563b572a7 100644
--- a/rbutil/sansapatcher/sansaio.h
+++ b/rbutil/sansapatcher/sansaio.h
@@ -65,7 +65,7 @@ struct sansa_t {
65 loff_t start; /* Offset in bytes of firmware partition from start of disk */ 65 loff_t start; /* Offset in bytes of firmware partition from start of disk */
66}; 66};
67 67
68void print_error(char* msg); 68void sansa_print_error(char* msg);
69int sansa_open(struct sansa_t* sansa, int silent); 69int sansa_open(struct sansa_t* sansa, int silent);
70int sansa_reopen_rw(struct sansa_t* sansa); 70int sansa_reopen_rw(struct sansa_t* sansa);
71int sansa_close(struct sansa_t* sansa); 71int sansa_close(struct sansa_t* sansa);
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c
index 015e5cbaf2..69e89e993e 100644
--- a/rbutil/sansapatcher/sansapatcher.c
+++ b/rbutil/sansapatcher/sansapatcher.c
@@ -99,7 +99,7 @@ int sansa_read_partinfo(struct sansa_t* sansa, int silent)
99 count = sansa_read(sansa,sansa_sectorbuf, sansa->sector_size); 99 count = sansa_read(sansa,sansa_sectorbuf, sansa->sector_size);
100 100
101 if (count <= 0) { 101 if (count <= 0) {
102 print_error(" Error reading from disk: "); 102 sansa_print_error(" Error reading from disk: ");
103 return -1; 103 return -1;
104 } 104 }
105 105