summary refs log blame commit diff stats
path: root/plugins/hextray/callbacks.h
blob: 99cbae741f7db01c179c110ff2582ea5b1543987 (plain) (tree)




































                                                                                                                  
/* X-Tray
 * Copyright (C) 2005 Michael Hotaling <Mike.Hotaling@SinisterDevelopments.com>
 *
 * X-Tray is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * X-Tray is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with X-Tray; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _H_CALLBACKS_H
#define _H_CALLBACKS_H

int					event_cb		(char *word[], void *userdata);
int					command_cb		(char *word[], char *word_eol[], void *userdata);

LRESULT CALLBACK	WindowProc		(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
BOOL	CALLBACK	EnumWindowsProc	(HWND hWnd, LPARAM lParam);
LRESULT CALLBACK	sdTrayProc		(HWND hwnd, int msg);

LRESULT CALLBACK	AlertProc		(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK	HotKeyProc		(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK	EventsProc		(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK	AboutProc		(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK	AlertsProc		(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
LRESULT CALLBACK	SettingsProc	(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
int		CALLBACK	PrefProc		(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);

#endif
* used independently. * * May 28 1998, Toni Ronkko * First version. *****************************************************************************/ #include "dirent.h" /* Use the new safe string functions introduced in Visual Studio 2005 */ #if defined(_MSC_VER) && _MSC_VER >= 1400 # define STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE) #else # define STRNCPY(dest,src,size) strncpy((dest),(src),(size)) #endif /***************************************************************************** * Open directory stream DIRNAME for read and return a pointer to the * internal working area that is used to retrieve individual directory * entries. */ DIR *opendir(const char *dirname) { DIR *dirp; assert (dirname != NULL); assert (strlen (dirname) < MAX_PATH); /* construct new DIR structure */ dirp = (DIR*) malloc (sizeof (struct DIR)); if (dirp != NULL) { char *p; /* take directory name... */ STRNCPY (dirp->patt, dirname, sizeof(dirp->patt)); dirp->patt[MAX_PATH] = '\0'; /* ... and append search pattern to it */ p = strchr (dirp->patt, '\0'); if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') { *p++ = '\\'; } *p++ = '*'; *p = '\0'; /* open stream and retrieve first file */ dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data); if (dirp->search_handle == INVALID_HANDLE_VALUE) { /* invalid search pattern? */ free (dirp); return NULL; } /* there is an un-processed directory entry in memory now */ dirp->cached = 1; } return dirp; } /***************************************************************************** * Read a directory entry, and return a pointer to a dirent structure * containing the name of the entry in d_name field. Individual directory * entries returned by this very function include regular files, * sub-directories, pseudo-directories "." and "..", but also volume labels, * hidden files and system files may be returned. */ struct dirent *readdir(DIR *dirp) { assert (dirp != NULL); if (dirp->search_handle == INVALID_HANDLE_VALUE) { /* directory stream was opened/rewound incorrectly or ended normally */ return NULL; } /* get next directory entry */ if (dirp->cached != 0) { /* a valid directory entry already in memory */ dirp->cached = 0; } else { /* read next directory entry from disk */ if (FindNextFileA (dirp->search_handle, &dirp->current.data) == FALSE) { /* the very last file has been processed or an error occured */ FindClose (dirp->search_handle); dirp->search_handle = INVALID_HANDLE_VALUE; return NULL; } } /* copy as a multibyte character string */ STRNCPY ( dirp->current.d_name, dirp->current.data.cFileName, sizeof(dirp->current.d_name) ); dirp->current.d_name[MAX_PATH] = '\0'; return &dirp->current; } /***************************************************************************** * Close directory stream opened by opendir() function. Close of the * directory stream invalidates the DIR structure as well as any previously * read directory entry. */ int closedir(DIR *dirp) { assert (dirp != NULL); /* release search handle */ if (dirp->search_handle != INVALID_HANDLE_VALUE) { FindClose (dirp->search_handle); dirp->search_handle = INVALID_HANDLE_VALUE; } /* release directory handle */ free (dirp); return 0; } /***************************************************************************** * Resets the position of the directory stream to which dirp refers to the * beginning of the directory. It also causes the directory stream to refer * to the current state of the corresponding directory, as a call to opendir() * would have done. If dirp does not refer to a directory stream, the effect * is undefined. */ void rewinddir(DIR* dirp) { /* release search handle */ if (dirp->search_handle != INVALID_HANDLE_VALUE) { FindClose (dirp->search_handle); dirp->search_handle = INVALID_HANDLE_VALUE; } /* open new search handle and retrieve first file */ dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data); if (dirp->search_handle == INVALID_HANDLE_VALUE) { /* invalid search pattern? */ free (dirp); return; } /* there is an un-processed directory entry in memory now */ dirp->cached = 1; }