From b4c2ef53cf5a608a9488ed5cf53da908e9553d21 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 5 Feb 2011 10:11:58 -0800 Subject: [PATCH] added missing #includes and missing prototypes to filebrowser thanks to Max Funk for reporting. Now using HAVE_DIRENT_H. Also cleaned up missing prototypes and some casts. --- filebrowser/dir.c | 18 +++------ filebrowser/draw.c | 34 ++++++++++------- filebrowser/path.c | 99 +++++++++++++++++++++++++------------------------ filebrowser/selfile.c | 12 +++++- 4 files changed, 88 insertions(+), 75 deletions(-) diff --git a/filebrowser/dir.c b/filebrowser/dir.c index 102187e..2ff5307 100644 --- a/filebrowser/dir.c +++ b/filebrowser/dir.c @@ -25,6 +25,8 @@ */ #include +#include /* for qsort */ +#include "../config.h" /* to check for dirent.h */ #ifdef SEL_FILE_IGNORE_CASE #include @@ -32,19 +34,15 @@ #include "selfile.h" -#if defined(SVR4) || defined(SYSV) || defined(USG) || defined(__osf__) +#ifdef HAVE_DIRENT_H #include -#else /* defined(SVR4) || defined(SYSV) || defined(USG) */ +#else #include #define dirent direct -#endif /* defined(SVR4) || defined(SYSV) || defined(USG) */ +#endif #include -#if defined(SVR4) || defined(SYSV) || defined(USG) -extern void qsort(); -#endif /* defined(SVR4) || defined(SYSV) || defined(USG) */ - #ifdef SEL_FILE_IGNORE_CASE int SFcompareEntries(p, q) @@ -147,11 +145,7 @@ SFgetDir(dir) i++; } -#if defined(SVR4) || defined(SYSV) || defined(USG) - qsort((char *) result, (unsigned) i, sizeof(SFEntry), SFcompareEntries); -#else /* defined(SVR4) || defined(SYSV) || defined(USG) */ - qsort((char *) result, i, sizeof(SFEntry), SFcompareEntries); -#endif /* defined(SVR4) || defined(SYSV) || defined(USG) */ + qsort((char *) result, (size_t) i, sizeof(SFEntry), SFcompareEntries); dir->entries = result; dir->nEntries = i; diff --git a/filebrowser/draw.c b/filebrowser/draw.c index a5b85f5..b21d170 100644 --- a/filebrowser/draw.c +++ b/filebrowser/draw.c @@ -38,6 +38,11 @@ #endif #define ABS(x) (((x) < 0) ? (-(x)) : (x)) +/* added missing prototypes */ +extern char SFstatChar(struct stat*); +extern int SFchdir(char *); +void SFvSliderMovedCallback(Widget, int, int); + typedef struct { char *fontname; } TextData, *textPtr; @@ -639,20 +644,6 @@ SFmotionList(w, n, event) /* ARGSUSED */ void -SFvFloatSliderMovedCallback(w, n, fnew) - Widget w; - int n; - float *fnew; -{ - int new; - - new = (*fnew) * SFdirs[SFdirPtr + n].nEntries; - - SFvSliderMovedCallback(w, n, new); -} - -/* ARGSUSED */ -void SFvSliderMovedCallback(w, n, new) Widget w; int n; @@ -739,6 +730,21 @@ SFvSliderMovedCallback(w, n, new) /* ARGSUSED */ void +SFvFloatSliderMovedCallback(w, n, fnew) + Widget w; + int n; + float *fnew; +{ + int new; + + new = (*fnew) * SFdirs[SFdirPtr + n].nEntries; + + SFvSliderMovedCallback(w, n, new); +} + + +/* ARGSUSED */ +void SFvAreaSelectedCallback(w, n, pnew) Widget w; int n; diff --git a/filebrowser/path.c b/filebrowser/path.c index a3d6b46..5aac90c 100644 --- a/filebrowser/path.c +++ b/filebrowser/path.c @@ -25,6 +25,8 @@ */ #include +#include /* for qsort */ +#include "../config.h" #ifdef SEL_FILE_IGNORE_CASE #include @@ -40,11 +42,17 @@ #define MAXPATHLEN 1024 #endif /* ndef MAXPATHLEN */ - -#if defined(SVR4) || defined(SYSV) || defined(USG) +#ifdef HAS_DIRENT_H extern uid_t getuid(); -extern void qsort(); -#endif /* defined(SVR4) || defined(SYSV) || defined(USG) */ +#endif /* def HAS_DIRENT_H */ + +/* added missing prototypes */ +extern void SFtextChanged(); +extern int SFgetDir(SFDir *); +extern void SFdrawLists(int); +extern void SFdrawList(int, int); +extern void SFclearList(int, int); +extern void SFmotionList(Widget, int, XMotionEvent*); typedef struct { char *name; @@ -180,6 +188,23 @@ SFstrncmp(p, q, n) } #endif /* def SEL_FILE_IGNORE_CASE */ +void +SFsetText(path) + char *path; +{ + XawTextBlock text; + + text.firstPos = 0; + text.length = strlen(path); + text.ptr = path; + text.format = FMT8BIT; + + XawTextReplace(selFileField, 0, strlen(SFtextBuffer), &text); + XawTextSetInsertionPoint(selFileField, strlen(SFtextBuffer)); + + return; +} + static void SFreplaceText(dir, str) SFDir *dir; @@ -451,13 +476,8 @@ SFgetHomeDirs() SFhomeDir.beginSelection = -1 ; SFhomeDir.endSelection = -1 ; -#if defined(SVR4) || defined(SYSV) || defined(USG) - qsort((char *) entries, (unsigned)i, sizeof(SFEntry), SFcompareEntries); - qsort((char *) SFlogins, (unsigned)i, sizeof(SFLogin), SFcompareLogins); -#else /* defined(SVR4) || defined(SYSV) || defined(USG) */ - qsort((char *) entries, i, sizeof(SFEntry), SFcompareEntries); - qsort((char *) SFlogins, i, sizeof(SFLogin), SFcompareLogins); -#endif /* defined(SVR4) || defined(SYSV) || defined(USG) */ + qsort((char *) entries, (size_t)i, sizeof(SFEntry), SFcompareEntries); + qsort((char *) SFlogins, (size_t)i, sizeof(SFLogin), SFcompareLogins); for (i--; i >= 0; i--) { (void) strcat(entries[i].real, "/"); @@ -686,23 +706,6 @@ SFupdatePath() return; } -void -SFsetText(path) - char *path; -{ - XawTextBlock text; - - text.firstPos = 0; - text.length = strlen(path); - text.ptr = path; - text.format = FMT8BIT; - - XawTextReplace(selFileField, 0, strlen(SFtextBuffer), &text); - XawTextSetInsertionPoint(selFileField, strlen(SFtextBuffer)); - - return; -} - /* ARGSUSED */ void SFbuttonPressList(w, n, event) @@ -734,7 +737,7 @@ SFbuttonReleaseList(w, n, event) dir, dir->entries[dir->vOrigin + SFcurrentInvert[n]].shown ); - SFmotionList(w, n, event); + SFmotionList(w, n, (XMotionEvent *) event); } } @@ -812,6 +815,25 @@ SFcheckDir(n, dir) return 0; } +/* Return a single character describing what kind of file STATBUF is. */ + +char +SFstatChar (statBuf) + struct stat *statBuf; +{ + if (S_ISDIR (statBuf->st_mode)) { + return '/'; + } else if (S_ISREG (statBuf->st_mode)) { + return S_ISXXX (statBuf->st_mode) ? '*' : ' '; +#ifdef S_ISSOCK + } else if (S_ISSOCK (statBuf->st_mode)) { + return '='; +#endif /* S_ISSOCK */ + } else { + return ' '; + } +} + static int SFcheckFiles(dir) SFDir *dir; @@ -896,22 +918,3 @@ SFdirModTimer(cl, id) SFdirModTimerId = XtAppAddTimeOut(SFapp, (unsigned long) 1000, SFdirModTimer, (XtPointer) NULL); } - -/* Return a single character describing what kind of file STATBUF is. */ - -char -SFstatChar (statBuf) - struct stat *statBuf; -{ - if (S_ISDIR (statBuf->st_mode)) { - return '/'; - } else if (S_ISREG (statBuf->st_mode)) { - return S_ISXXX (statBuf->st_mode) ? '*' : ' '; -#ifdef S_ISSOCK - } else if (S_ISSOCK (statBuf->st_mode)) { - return '='; -#endif /* S_ISSOCK */ - } else { - return ' '; - } -} diff --git a/filebrowser/selfile.c b/filebrowser/selfile.c index 91f39a9..860ed8b 100644 --- a/filebrowser/selfile.c +++ b/filebrowser/selfile.c @@ -61,6 +61,16 @@ extern int errno; #include #include "selfile.h" +#include "xstat.h" + +/* added missing prototypes */ +extern void SFdrawList(int,int); +extern void SFinitFont(); +extern void SFcreateGC(); +extern int SFchdir(char *); +extern void SFupdatePath(); +extern void SFsetText(char *); +extern char SFstatChar(struct stat*); #ifndef MAXPATHLEN #define MAXPATHLEN 1024 @@ -146,7 +156,7 @@ SFexposeList(w, n, event, cont) return; } - SFdrawList(n, SF_DO_NOT_SCROLL); + SFdrawList((int)n, SF_DO_NOT_SCROLL); } /* ARGSUSED */ -- 1.7.0.4