PATH_MAX vs MAX_PATH fixes. Stupid windows.

This commit is contained in:
Ron Pedde 2006-11-14 01:40:22 +00:00
parent 16b323f024
commit 654d0fe685
4 changed files with 40 additions and 40 deletions

View File

@ -82,7 +82,7 @@ typedef struct {
static int scan_path(char *path); static int scan_path(char *path);
static int scan_get_info(char *file, MP3FILE *pmp3); static int scan_get_info(char *file, MP3FILE *pmp3);
static int scan_freetags(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); static TAGHANDLER *scan_gethandler(char *type);
@ -227,7 +227,7 @@ void scan_process_playlistlist(void) {
if(strrchr(pnext->path,PATHSEP)) { if(strrchr(pnext->path,PATHSEP)) {
file = strrchr(pnext->path,PATHSEP) + 1; file = strrchr(pnext->path,PATHSEP) + 1;
} }
if(strcasecmp(file,"iTunes Music Library.xml") == 0) { if(strcasecmp(file,"iTunes Music Library.xml") == 0) {
if(conf_get_int("scanning","process_xml",1)) { if(conf_get_int("scanning","process_xml",1)) {
DPRINTF(E_INF,L_SCAN,"Scanning %s\n",pnext->path); 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 scan_init(char **patharray) {
int err=0; int err=0;
int index=0; int index=0;
char resolved_path[MAX_PATH]; char resolved_path[PATH_MAX];
DPRINTF(E_DBG,L_SCAN,"Starting scan_init\n"); 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)); DPRINTF(E_INF,L_SCAN,"Error statting %s: %s\n",mp3_path,strerror(errno));
} else { } else {
if(S_ISDIR(sb.st_mode)) { /* follow dir */ 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,".AppleDouble") == 0) ||
(strcasecmp(pde->d_name,".AppleDesktop") == 0))) { (strcasecmp(pde->d_name,".AppleDesktop") == 0))) {
DPRINTF(E_DBG,L_SCAN,"Skipping appledouble folder\n"); DPRINTF(E_DBG,L_SCAN,"Skipping appledouble folder\n");
@ -476,11 +476,11 @@ int scan_static_playlist(char *path) {
strcpy(base_path,path); strcpy(base_path,path);
ptr = base_path; ptr = base_path;
while(*ptr) { while(*ptr) {
if((*ptr == '/') || (*ptr == '\\')) if((*ptr == '/') || (*ptr == '\\'))
*ptr = PATHSEP; *ptr = PATHSEP;
ptr++; ptr++;
} }
if((current=strrchr(base_path,PATHSEP))){ if((current=strrchr(base_path,PATHSEP))){
*(current+1) = '\x0'; *(current+1) = '\x0';
} /* else something is fubar */ } /* else something is fubar */
@ -500,7 +500,7 @@ int scan_static_playlist(char *path) {
ptr = linebuffer; ptr = linebuffer;
while(*ptr) { while(*ptr) {
if((*ptr == '/') || (*ptr == '\\')) if((*ptr == '/') || (*ptr == '\\'))
*ptr = PATHSEP; *ptr = PATHSEP;
ptr++; ptr++;
} }
@ -539,7 +539,7 @@ int scan_static_playlist(char *path) {
/** /**
* here, we want to scan a file and add it (if necessary) * 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 path path of file to scan
* @param compdir whether or not this is a compdir: * @param compdir whether or not this is a compdir:

View File

@ -61,7 +61,7 @@ typedef struct tag_osfileinfo {
/* Globals */ /* Globals */
OSFILEINFO file_info[MAXDESC]; OSFILEINFO file_info[MAXDESC];
char os_config_file[_MAX_PATH]; char os_config_file[PATH_MAX];
char *os_w32_socket_states[] = { char *os_w32_socket_states[] = {
"Closed/Unused", "Closed/Unused",
"Open/Listening", "Open/Listening",
@ -83,14 +83,14 @@ int os_init(int foreground, char *runas) {
int err; int err;
char *inifile; char *inifile;
char drive_buffer[4]; char drive_buffer[4];
char drive_map[MAX_PATH]; char drive_map[PATH_MAX];
int drive_letter; int drive_letter;
inifile=_os_filepath("mapping.ini"); 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++) { for(drive_letter = 'a'; drive_letter <= 'z'; drive_letter++) {
sprintf(drive_buffer,"%c",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)) { if(strlen(drive_map)) {
os_drive_maps[drive_letter - 'a'] = strdup(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); 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; os_maps_init=1;
free(inifile); free(inifile);
_os_socket_startup(); _os_socket_startup();
if(!os_initialized) { if(!os_initialized) {
_os_lock(); _os_lock();
if(!os_initialized) { if(!os_initialized) {
@ -272,13 +272,13 @@ int os_acceptsocket(int fd, struct in_addr *hostaddr) {
while (((retval = while (((retval =
accept(REALSOCK,(struct sockaddr *)(&netclient), &len)) == SOCKET_ERROR) && accept(REALSOCK,(struct sockaddr *)(&netclient), &len)) == SOCKET_ERROR) &&
(WSAGetLastError() == WSAEINTR)); (WSAGetLastError() == WSAEINTR));
if (retval == INVALID_SOCKET) { if (retval == INVALID_SOCKET) {
DPRINTF(E_LOG,L_MISC,"Error accepting...\n"); DPRINTF(E_LOG,L_MISC,"Error accepting...\n");
return _os_sock_to_fd(retval); return _os_sock_to_fd(retval);
} }
*hostaddr = netclient.sin_addr; *hostaddr = netclient.sin_addr;
return _os_sock_to_fd(retval); return _os_sock_to_fd(retval);
} }
@ -294,12 +294,12 @@ int os_waitfdtimed(int fd, struct timeval end) {
return -1; return -1;
sock = REALSOCK; sock = REALSOCK;
/* /*
if ((fd < 0) || (fd >= FD_SETSIZE)) { if ((fd < 0) || (fd >= FD_SETSIZE)) {
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
*/ */
FD_ZERO(&readset); FD_ZERO(&readset);
@ -364,7 +364,7 @@ char *os_strsep(char **stringp, const char *delim) {
} }
int os_opensocket(unsigned short port) { int os_opensocket(unsigned short port) {
int error; int error;
struct sockaddr_in server; struct sockaddr_in server;
SOCKET sock; SOCKET sock;
int true = 1; int true = 1;
@ -387,18 +387,18 @@ int os_opensocket(unsigned short port) {
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&true, if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&true,
sizeof(true)) == SOCKET_ERROR) { sizeof(true)) == SOCKET_ERROR) {
error = WSAGetLastError(); error = WSAGetLastError();
while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR)); while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR));
errno = EINVAL; /* windows errnos suck */ errno = EINVAL; /* windows errnos suck */
return -1; return -1;
} }
server.sin_family = AF_INET; server.sin_family = AF_INET;
server.sin_addr.s_addr = htonl(INADDR_ANY); server.sin_addr.s_addr = htonl(INADDR_ANY);
server.sin_port = htons((short)port); server.sin_port = htons((short)port);
if ((bind(sock, (struct sockaddr *)&server, sizeof(server)) == -1) || if ((bind(sock, (struct sockaddr *)&server, sizeof(server)) == -1) ||
(listen(sock, MAXBACKLOG) == -1)) { (listen(sock, MAXBACKLOG) == -1)) {
error = errno; error = errno;
while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR)); while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR));
errno = WSAGetLastError(); errno = WSAGetLastError();
return -1; return -1;
} }
@ -410,7 +410,7 @@ int os_opensocket(unsigned short port) {
int os_write(int fd, void *buffer, unsigned int count) { int os_write(int fd, void *buffer, unsigned int count) {
int retval; int retval;
if(NOTSOCK) { if(NOTSOCK) {
retval = _write(fd,buffer,count); retval = _write(fd,buffer,count);
} else { } else {
@ -463,7 +463,7 @@ int os_close(int fd) {
closesocket(REALSOCK); closesocket(REALSOCK);
SOCKSTATE = 0; SOCKSTATE = 0;
} }
} }
return 0; return 0;
} }
@ -492,18 +492,18 @@ int os_gettimeofday (struct timeval *tv, struct timezone* tz) {
tz->tz_minuteswest = _timezone; tz->tz_minuteswest = _timezone;
} }
return (0); return (0);
} }
/** /**
* initialize winsock * initialize winsock
*/ */
void _os_socket_startup(void) { void _os_socket_startup(void) {
WORD minver; WORD minver;
int err; int err;
minver = MAKEWORD( 2, 2 ); minver = MAKEWORD( 2, 2 );
err = WSAStartup( minver, &w32_wsadata ); err = WSAStartup( minver, &w32_wsadata );
if ( err != 0 ) { if ( err != 0 ) {
DPRINTF(E_FATAL,L_MISC,"Could not initialize winsock\n"); DPRINTF(E_FATAL,L_MISC,"Could not initialize winsock\n");
@ -565,9 +565,9 @@ char *os_configpath(void) {
char *_os_filepath(char *file) { char *_os_filepath(char *file) {
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
char dir[_MAX_DIR]; 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); _splitpath(path,drive,dir,NULL,NULL);
_makepath(path,drive,dir,NULL,NULL); _makepath(path,drive,dir,NULL,NULL);
strcat(path,file); strcat(path,file);
@ -580,9 +580,9 @@ char *_os_filepath(char *file) {
* *
*/ */
char *os_apppath(char *junk) { 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); return strdup(app_path);
} }
@ -616,7 +616,7 @@ int os_islocaladdr(char *hostaddr) {
} }
index++; index++;
} }
DPRINTF(E_DBG,L_MISC,"Nope!\n"); DPRINTF(E_DBG,L_MISC,"Nope!\n");
return FALSE; return FALSE;
} }
@ -687,7 +687,7 @@ DIR *os_opendir(char *filename) {
if (!(dirp = (DIR *) malloc (sizeof (DIR)))) if (!(dirp = (DIR *) malloc (sizeof (DIR))))
return NULL; return NULL;
dirp->dir_find_handle = INVALID_HANDLE_VALUE; dirp->dir_find_handle = INVALID_HANDLE_VALUE;
dirp->dd_fd = 0; dirp->dd_fd = 0;
dirp->dd_loc = 0; dirp->dd_loc = 0;

View File

@ -39,14 +39,14 @@ static HANDLE elog_handle = NULL;
int elog_register(void) { int elog_register(void) {
HKEY reg_key = NULL; HKEY reg_key = NULL;
DWORD err = 0; DWORD err = 0;
char path[_MAX_PATH]; char path[PATH_MAX];
DWORD event_types; DWORD event_types;
wsprintf(path,"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s", PACKAGE); wsprintf(path,"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s", PACKAGE);
if((err=RegCreateKey(HKEY_LOCAL_MACHINE, path, &reg_key)) != ERROR_SUCCESS) if((err=RegCreateKey(HKEY_LOCAL_MACHINE, path, &reg_key)) != ERROR_SUCCESS)
return FALSE; 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); err=RegSetValueEx(reg_key, "EventMessageFile",0,REG_EXPAND_SZ,path,(DWORD)strlen(path) + 1);
if(err != ERROR_SUCCESS) { if(err != ERROR_SUCCESS) {
@ -87,9 +87,9 @@ int elog_init(void) {
} }
/** /**
* uninitialize the eventlog * uninitialize the eventlog
* *
* @returns TRUE * @returns TRUE
*/ */
int elog_deinit(void) { int elog_deinit(void) {

View File

@ -225,9 +225,9 @@ void *service_startup(void *arg) {
void service_register(void) { void service_register(void) {
SC_HANDLE scm; SC_HANDLE scm;
SC_HANDLE svc; 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))) { if(!(scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE))) {
DPRINTF(E_FATAL,L_MISC,"Cannot open service control manager\n"); DPRINTF(E_FATAL,L_MISC,"Cannot open service control manager\n");