static void perl_auto_load_from_path (const char *path) { WIN32_FIND_DATA find_data; HANDLE find_handle; char *search_path; int path_len = strlen (path); /* +6 for \*.pl and \0 */ search_path = malloc(path_len + 6); sprintf (search_path, "%s\\*.pl", path); find_handle = FindFirstFile (search_path, &find_data); if (find_handle != INVALID_HANDLE_VALUE) { do { if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ||find_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)) { char *full_path = malloc (path_len + strlen (find_data.cFileName) + 2); sprintf (full_path, "%s\\%s", path, find_data.cFileName); perl_load_file (full_path); free (full_path); } } while (FindNextFile (find_handle, &find_data) != 0); FindClose (find_handle); } free (search_path); }
static int perl_command_load (char *word[], char *word_eol[], void *userdata) { char *file = get_filename (word, word_eol); if (file != NULL ) { perl_load_file (file); return XCHAT_EAT_XCHAT; } return XCHAT_EAT_NONE; }
static void perl_auto_load_from_path (const char *path) { DIR *dir; struct dirent *ent; dir = opendir (path); if (dir) { while ((ent = readdir (dir))) { int len = strlen (ent->d_name); if (len > 3 && strcasecmp (".pl", ent->d_name + len - 3) == 0) { char *file = malloc (len + strlen (path) + 2); sprintf (file, "%s/%s", path, ent->d_name); perl_load_file (file); free (file); } } closedir (dir); } }