From 654d0fe685cbc258df6f133138a9c93d631528ff Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Tue, 14 Nov 2006 01:40:22 +0000 Subject: [PATCH] PATH_MAX vs MAX_PATH fixes. Stupid windows. --- src/mp3-scanner.c | 16 +++++++------- src/os-win32.c | 52 +++++++++++++++++++++++----------------------- src/w32-eventlog.c | 8 +++---- src/w32-service.c | 4 ++-- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/mp3-scanner.c b/src/mp3-scanner.c index e048daa8..ae322423 100644 --- a/src/mp3-scanner.c +++ b/src/mp3-scanner.c @@ -82,7 +82,7 @@ typedef struct { static int scan_path(char *path); static int scan_get_info(char *file, MP3FILE *pmp3); static int scan_freetags(MP3FILE *pmp3); -static void scan_music_file(char *path, char *fname,struct stat *psb, int is_compdir); +static void scan_music_file(char *path, char *fname,struct stat *psb, int is_compdir); static TAGHANDLER *scan_gethandler(char *type); @@ -227,7 +227,7 @@ void scan_process_playlistlist(void) { if(strrchr(pnext->path,PATHSEP)) { file = strrchr(pnext->path,PATHSEP) + 1; } - + if(strcasecmp(file,"iTunes Music Library.xml") == 0) { if(conf_get_int("scanning","process_xml",1)) { DPRINTF(E_INF,L_SCAN,"Scanning %s\n",pnext->path); @@ -262,7 +262,7 @@ void scan_process_playlistlist(void) { int scan_init(char **patharray) { int err=0; int index=0; - char resolved_path[MAX_PATH]; + char resolved_path[PATH_MAX]; DPRINTF(E_DBG,L_SCAN,"Starting scan_init\n"); @@ -387,7 +387,7 @@ int scan_path(char *path) { DPRINTF(E_INF,L_SCAN,"Error statting %s: %s\n",mp3_path,strerror(errno)); } else { if(S_ISDIR(sb.st_mode)) { /* follow dir */ - if(conf_get_int("scanning","ignore_appledouble",1) && + if(conf_get_int("scanning","ignore_appledouble",1) && ((strcasecmp(pde->d_name,".AppleDouble") == 0) || (strcasecmp(pde->d_name,".AppleDesktop") == 0))) { DPRINTF(E_DBG,L_SCAN,"Skipping appledouble folder\n"); @@ -476,11 +476,11 @@ int scan_static_playlist(char *path) { strcpy(base_path,path); ptr = base_path; while(*ptr) { - if((*ptr == '/') || (*ptr == '\\')) + if((*ptr == '/') || (*ptr == '\\')) *ptr = PATHSEP; ptr++; } - + if((current=strrchr(base_path,PATHSEP))){ *(current+1) = '\x0'; } /* else something is fubar */ @@ -500,7 +500,7 @@ int scan_static_playlist(char *path) { ptr = linebuffer; while(*ptr) { - if((*ptr == '/') || (*ptr == '\\')) + if((*ptr == '/') || (*ptr == '\\')) *ptr = PATHSEP; ptr++; } @@ -539,7 +539,7 @@ int scan_static_playlist(char *path) { /** * here, we want to scan a file and add it (if necessary) - * to the database. + * to the database. * * @param path path of file to scan * @param compdir whether or not this is a compdir: diff --git a/src/os-win32.c b/src/os-win32.c index 1f2e9878..f14684d9 100644 --- a/src/os-win32.c +++ b/src/os-win32.c @@ -61,7 +61,7 @@ typedef struct tag_osfileinfo { /* Globals */ OSFILEINFO file_info[MAXDESC]; -char os_config_file[_MAX_PATH]; +char os_config_file[PATH_MAX]; char *os_w32_socket_states[] = { "Closed/Unused", "Open/Listening", @@ -83,14 +83,14 @@ int os_init(int foreground, char *runas) { int err; char *inifile; char drive_buffer[4]; - char drive_map[MAX_PATH]; + char drive_map[PATH_MAX]; int drive_letter; inifile=_os_filepath("mapping.ini"); - DPRINTF(E_LOG,L_MISC,"Building drive mapping table from %s\n",inifile); + DPRINTF(E_LOG,L_MISC,"Building drive mapping table from %s\n",inifile); for(drive_letter = 'a'; drive_letter <= 'z'; drive_letter++) { sprintf(drive_buffer,"%c",drive_letter); - GetPrivateProfileString("mapping",drive_buffer,"",drive_map,MAX_PATH,inifile); + GetPrivateProfileString("mapping",drive_buffer,"",drive_map,PATH_MAX,inifile); if(strlen(drive_map)) { os_drive_maps[drive_letter - 'a'] = strdup(drive_map); DPRINTF(E_LOG,L_MISC,"Mapped %c to %s\n",drive_letter,drive_map); @@ -100,9 +100,9 @@ int os_init(int foreground, char *runas) { } os_maps_init=1; free(inifile); - + _os_socket_startup(); - + if(!os_initialized) { _os_lock(); if(!os_initialized) { @@ -272,13 +272,13 @@ int os_acceptsocket(int fd, struct in_addr *hostaddr) { while (((retval = accept(REALSOCK,(struct sockaddr *)(&netclient), &len)) == SOCKET_ERROR) && - (WSAGetLastError() == WSAEINTR)); + (WSAGetLastError() == WSAEINTR)); if (retval == INVALID_SOCKET) { DPRINTF(E_LOG,L_MISC,"Error accepting...\n"); return _os_sock_to_fd(retval); } - + *hostaddr = netclient.sin_addr; return _os_sock_to_fd(retval); } @@ -294,12 +294,12 @@ int os_waitfdtimed(int fd, struct timeval end) { return -1; sock = REALSOCK; - + /* if ((fd < 0) || (fd >= FD_SETSIZE)) { errno = EINVAL; return -1; - } + } */ FD_ZERO(&readset); @@ -364,7 +364,7 @@ char *os_strsep(char **stringp, const char *delim) { } int os_opensocket(unsigned short port) { - int error; + int error; struct sockaddr_in server; SOCKET sock; int true = 1; @@ -387,18 +387,18 @@ int os_opensocket(unsigned short port) { if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&true, sizeof(true)) == SOCKET_ERROR) { error = WSAGetLastError(); - while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR)); + while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR)); errno = EINVAL; /* windows errnos suck */ return -1; } - + server.sin_family = AF_INET; server.sin_addr.s_addr = htonl(INADDR_ANY); server.sin_port = htons((short)port); if ((bind(sock, (struct sockaddr *)&server, sizeof(server)) == -1) || (listen(sock, MAXBACKLOG) == -1)) { error = errno; - while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR)); + while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR)); errno = WSAGetLastError(); return -1; } @@ -410,7 +410,7 @@ int os_opensocket(unsigned short port) { int os_write(int fd, void *buffer, unsigned int count) { int retval; - + if(NOTSOCK) { retval = _write(fd,buffer,count); } else { @@ -463,7 +463,7 @@ int os_close(int fd) { closesocket(REALSOCK); SOCKSTATE = 0; } - } + } return 0; } @@ -492,18 +492,18 @@ int os_gettimeofday (struct timeval *tv, struct timezone* tz) { tz->tz_minuteswest = _timezone; } return (0); -} +} /** - * initialize winsock + * initialize winsock */ void _os_socket_startup(void) { WORD minver; int err; - + minver = MAKEWORD( 2, 2 ); - + err = WSAStartup( minver, &w32_wsadata ); if ( err != 0 ) { DPRINTF(E_FATAL,L_MISC,"Could not initialize winsock\n"); @@ -565,9 +565,9 @@ char *os_configpath(void) { char *_os_filepath(char *file) { char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; - char path[_MAX_PATH]; + char path[PATH_MAX]; - GetModuleFileName(NULL,path,_MAX_PATH); + GetModuleFileName(NULL,path,PATH_MAX); _splitpath(path,drive,dir,NULL,NULL); _makepath(path,drive,dir,NULL,NULL); strcat(path,file); @@ -580,9 +580,9 @@ char *_os_filepath(char *file) { * */ char *os_apppath(char *junk) { - char app_path[_MAX_PATH]; + char app_path[PATH_MAX]; - GetModuleFileName(NULL,app_path,_MAX_PATH); + GetModuleFileName(NULL,app_path,PATH_MAX); return strdup(app_path); } @@ -616,7 +616,7 @@ int os_islocaladdr(char *hostaddr) { } index++; } - + DPRINTF(E_DBG,L_MISC,"Nope!\n"); return FALSE; } @@ -687,7 +687,7 @@ DIR *os_opendir(char *filename) { if (!(dirp = (DIR *) malloc (sizeof (DIR)))) return NULL; - + dirp->dir_find_handle = INVALID_HANDLE_VALUE; dirp->dd_fd = 0; dirp->dd_loc = 0; diff --git a/src/w32-eventlog.c b/src/w32-eventlog.c index d6794f9e..a7b3d921 100644 --- a/src/w32-eventlog.c +++ b/src/w32-eventlog.c @@ -39,14 +39,14 @@ static HANDLE elog_handle = NULL; int elog_register(void) { HKEY reg_key = NULL; DWORD err = 0; - char path[_MAX_PATH]; + char path[PATH_MAX]; DWORD event_types; wsprintf(path,"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s", PACKAGE); if((err=RegCreateKey(HKEY_LOCAL_MACHINE, path, ®_key)) != ERROR_SUCCESS) return FALSE; - GetModuleFileName(NULL, path, _MAX_PATH ); + GetModuleFileName(NULL, path, PATH_MAX); err=RegSetValueEx(reg_key, "EventMessageFile",0,REG_EXPAND_SZ,path,(DWORD)strlen(path) + 1); if(err != ERROR_SUCCESS) { @@ -87,9 +87,9 @@ int elog_init(void) { } -/** +/** * uninitialize the eventlog - * + * * @returns TRUE */ int elog_deinit(void) { diff --git a/src/w32-service.c b/src/w32-service.c index 857d207f..6af55eab 100644 --- a/src/w32-service.c +++ b/src/w32-service.c @@ -225,9 +225,9 @@ void *service_startup(void *arg) { void service_register(void) { SC_HANDLE scm; SC_HANDLE svc; - char path[MAX_PATH]; + char path[PATH_MAX]; - GetModuleFileName(NULL, path, MAX_PATH ); + GetModuleFileName(NULL, path, PATH_MAX ); if(!(scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE))) { DPRINTF(E_FATAL,L_MISC,"Cannot open service control manager\n");