X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=filebrowser%2Fpath.c;h=5aac90c56ef33edbdc08fb1da9febe3ed664e407;hb=1905bc8511d3e2bed714c77c82dba7847cf05c30;hp=4e13ea3c553097011e77c15d0e1eb7aa44597226;hpb=18c9024957df2892adb21cd851cb7a27b9502d54;p=xboard.git diff --git a/filebrowser/path.c b/filebrowser/path.c index 4e13ea3..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 @@ -36,10 +38,21 @@ #include "xstat.h" #include -#if defined(SVR4) || defined(SYSV) || defined(USG) +#ifndef MAXPATHLEN +#define MAXPATHLEN 1024 +#endif /* ndef MAXPATHLEN */ + +#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; @@ -75,7 +88,7 @@ SFchdir(path) if (strcmp(path, SFcurrentDir)) { result = chdir(path); if (!result) { - (void) strcpy(SFcurrentDir, path); + (void) strncpy(SFcurrentDir, path, MAXPATHLEN); } } @@ -175,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; @@ -446,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, "/"); @@ -475,8 +500,9 @@ SFfindHomeDir(begin, end) if (!strcmp(SFhomeDir.entries[i].real, begin)) { *end = save; SFstrdup(&theRest, end); - (void) strcat(strcat(strcpy(SFcurrentPath, - SFlogins[i].dir), "/"), theRest); + (void) strcat(strcat(strncpy(SFcurrentPath,SFlogins[i].dir, + MAXPATHLEN), "/"), + theRest); XtFree(theRest); SFsetText(SFcurrentPath); SFtextChanged(); @@ -680,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) @@ -728,7 +737,7 @@ SFbuttonReleaseList(w, n, event) dir, dir->entries[dir->vOrigin + SFcurrentInvert[n]].shown ); - SFmotionList(w, n, event); + SFmotionList(w, n, (XMotionEvent *) event); } } @@ -806,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; @@ -890,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 ' '; - } -}