[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Killing duplicated code from gsm-filetypes.c
From: |
Pavel Machek |
Subject: |
Killing duplicated code from gsm-filetypes.c |
Date: |
Mon, 20 May 2002 20:28:44 +0200 |
User-agent: |
Mutt/1.3.28i |
Hi!
gsm-filetypes.c contained two copies of file reading, with
bugs. Merged.
Pavel
Index: common/gsm-filetypes.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-filetypes.c,v
retrieving revision 1.26
diff -u -u -r1.26 gsm-filetypes.c
--- common/gsm-filetypes.c 30 Apr 2002 18:56:12 -0000 1.26
+++ common/gsm-filetypes.c 20 May 2002 18:27:00 -0000
@@ -531,12 +531,13 @@
case BMP:
error = loadbmp(file, bitmap);
break;
-#ifdef XPM
case XPMF:
- fclose(file);
+#ifdef XPM
error = loadxpm(FileName, bitmap);
- file = NULL;
break;
+#else
+ fprintf(stderr, "Sorry, gnokii was not compiled with XPM
support.\n");
+ /* FALLTHRU */
#endif
default:
error = GE_INVALIDFILEFORMAT;
@@ -549,7 +550,6 @@
#ifdef XPM
-
GSM_Error loadxpm(char *filename, GSM_Bitmap *bitmap)
{
int error, x, y;
@@ -597,10 +597,8 @@
return GE_NONE;
}
-
#endif
-
/* Based on the article from the Polish Magazine "Bajtek" 11/92 */
/* address@hidden */
@@ -1309,70 +1307,11 @@
GSM_Error GSM_ShowBitmapFile(char *FileName)
{
- FILE *file;
- unsigned char buffer[300];
- int error;
- GSM_Filetypes filetype = None;
int i, j;
GSM_Bitmap bitmap;
+ GSM_Error error;
- file = fopen(FileName, "rb");
-
- if (!file)
- return (GE_CANTOPENFILE);
-
- fread(buffer, 1, 9, file);
-
- if (memcmp(buffer, "NOL", 3) == 0) {
- filetype = NOL;
- } else if (memcmp(buffer, "NGG", 3) == 0) {
- filetype = NGG;
- } else if (memcmp(buffer, "FORM", 4) == 0) {
- filetype = NSL;
- } else if (memcmp(buffer, "NLM", 3) == 0) {
- filetype = NLM;
- } else if (memcmp(buffer, "BM", 2) == 0) {
- filetype = BMP;
- } else if (memcmp(buffer, "XPM", 3) == 0) {
- filetype = XPMF;
- } else filetype = None;
-
- if (strstr(FileName, ".otb")) filetype = OTA;
-
- rewind(file);
-
- switch (filetype) {
- case NOL:
- error = loadnol(file, &bitmap, NULL);
- fclose(file);
- break;
- case NGG:
- error = loadngg(file, &bitmap, NULL);
- fclose(file);
- break;
- case NSL:
- error = loadnsl(file, &bitmap);
- fclose(file);
- break;
- case OTA:
- error = loadota(file, &bitmap, NULL);
- fclose(file);
- break;
- case BMP:
- error = loadbmp(file, &bitmap);
- fclose(file);
- break;
-#ifdef XPM
- case XPMF:
- fclose(file);
- error = loadxpm(FileName, &bitmap);
- break;
-#endif
- default:
- error = GE_INVALIDFILEFORMAT;
- break;
- }
-
+ error = GSM_ReadBitmapFile(FileName, &bitmap, NULL);
if (error != GE_NONE)
return (error);
--
(about SSSCA) "I don't say this lightly. However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
- Killing duplicated code from gsm-filetypes.c,
Pavel Machek <=