static void identd (void *arg, int c, void *cbd) { struct sockaddr_in addr; socklen_t len = sizeof (addr); int read_sok = accept (ident_sok, (struct sockaddr *) &addr, &len); if (read_sok < 0) { //perror ("accept"); PrintText (current_sess, "Identd startup error. Restarting.\n"); identd_stop (); identd_start (); return; } char outbuf [256]; snprintf (outbuf, sizeof (outbuf), "%%\tServicing ident request from %s\n", inet_ntoa (addr.sin_addr)); PrintText (current_sess, outbuf); struct two_ints *x = (struct two_ints *)malloc(sizeof(struct two_ints)); x->sock = read_sok; x->tag = fe_input_add (read_sok, FIA_READ, (input_callback)identd_reply, x); }
xchat_hook* xchat_hook_fd(xchat_plugin *ph, int fd, int flags, xchat_fd_cb *callb, void *userdata) { xchat_hook *hook; hook = plugin_add_hook(ph, HOOK_FD, 0, 0, 0, (void*)callb, 0, userdata); hook->pri = fd; // plugin hook_fd flags correspond exactly to FIA_* flags (fe.h) hook->tag = fe_input_add(fd, flags, (void*)plugin_fd_cb, hook); return hook; }
void identd_really_start () { if (ident_sok >= 0) return; ident_sok = launch_identd_helper (); if (ident_sok < 0) PrintText (current_sess, "Unable to start identd\n"); else { ident_tag = fe_input_add (ident_sok, FIA_READ, (input_callback)identd, NULL); PrintText (current_sess, "identd started\n"); } }
void gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter, char *extensions, int flags) { struct file_req *freq; GtkWidget *dialog; GtkFileFilter *filefilter; extern char *get_xdir_fs (void); char *token; char *tokenbuffer; #if 0 /* native file dialogs */ #ifdef WIN32 if (!(flags & FRF_WRITE)) { freq = malloc (sizeof (struct file_req)); freq->th = thread_new (); freq->flags = 0; freq->multiple = (flags & FRF_MULTIPLE); freq->callback = callback; freq->userdata = userdata; freq->title = g_locale_from_utf8 (title, -1, 0, 0, 0); if (!filter) { freq->filter = "All files\0*.*\0" "Executables\0*.exe\0" "ZIP files\0*.zip\0\0"; } else { freq->filter = filter; } thread_start (freq->th, win32_thread, freq); fe_input_add (freq->th->pipe_fd[0], FIA_FD|FIA_READ, win32_read_thread, freq); return; } else { freq = malloc (sizeof (struct file_req)); freq->th = thread_new (); freq->flags = 0; freq->multiple = (flags & FRF_MULTIPLE); freq->callback = callback; freq->userdata = userdata; freq->title = g_locale_from_utf8 (title, -1, 0, 0, 0); if (!filter) { freq->filter = "All files\0*.*\0\0"; } else { freq->filter = filter; } thread_start (freq->th, win32_thread2, freq); fe_input_add (freq->th->pipe_fd[0], FIA_FD|FIA_READ, win32_read_thread, freq); return; } #endif #endif if (flags & FRF_WRITE) { dialog = gtk_file_chooser_dialog_new (title, NULL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); if (filter && filter[0]) /* filter becomes initial name when saving */ { char temp[1024]; path_part (filter, temp, sizeof (temp)); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), temp); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), file_part (filter)); } if (!(flags & FRF_NOASKOVERWRITE)) gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); } else dialog = gtk_file_chooser_dialog_new (title, NULL, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); if (flags & FRF_MULTIPLE) gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); if (last_dir[0]) gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir); if (flags & FRF_ADDFOLDER) gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), get_xdir_fs (), NULL); if (flags & FRF_CHOOSEFOLDER) { gtk_file_chooser_set_action (GTK_FILE_CHOOSER (dialog), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), filter); } else { if (filter && (flags & FRF_FILTERISINITIAL)) gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), filter); } if (flags & FRF_EXTENSIONS && extensions != NULL) { filefilter = gtk_file_filter_new (); tokenbuffer = g_strdup (extensions); token = strtok (tokenbuffer, ";"); while (token != NULL) { gtk_file_filter_add_pattern (filefilter, token); token = strtok (NULL, ";"); } g_free (tokenbuffer); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filefilter); } freq = malloc (sizeof (struct file_req)); freq->dialog = dialog; freq->flags = flags; freq->callback = callback; freq->userdata = userdata; g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gtkutil_file_req_response), freq); g_signal_connect (G_OBJECT (dialog), "destroy", G_CALLBACK (gtkutil_file_req_destroy), (gpointer) freq); gtk_widget_show (dialog); }
void gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter, char *extensions, int flags) { struct file_req *freq; GtkWidget *dialog; GtkFileFilter *filefilter; extern char *get_xdir_fs (void); char *token; char *tokenbuffer; #if 0 /* native file dialogs */ #ifdef WIN32 if (!(flags & FRF_WRITE)) { freq = malloc (sizeof (struct file_req)); freq->th = thread_new (); freq->flags = 0; freq->multiple = (flags & FRF_MULTIPLE); freq->callback = callback; freq->userdata = userdata; freq->title = g_locale_from_utf8 (title, -1, 0, 0, 0); if (!filter) { freq->filter = "All files\0*.*\0" "Executables\0*.exe\0" "ZIP files\0*.zip\0\0"; } else { freq->filter = filter; } thread_start (freq->th, win32_thread, freq); fe_input_add (freq->th->pipe_fd[0], FIA_FD|FIA_READ, win32_read_thread, freq); return; } else { freq = malloc (sizeof (struct file_req)); freq->th = thread_new (); freq->flags = 0; freq->multiple = (flags & FRF_MULTIPLE); freq->callback = callback; freq->userdata = userdata; freq->title = g_locale_from_utf8 (title, -1, 0, 0, 0); if (!filter) { freq->filter = "All files\0*.*\0\0"; } else { freq->filter = filter; } thread_start (freq->th, win32_thread2, freq); fe_input_add (freq->th->pipe_fd[0], FIA_FD|FIA_READ, win32_read_thread, freq); return; } #endif #endif if (flags & FRF_WRITE) { dialog = gtk_file_chooser_dialog_new (title, NULL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); if (filter && filter[0]) /* filter becomes initial name when saving */ { char temp[1024]; path_part (filter, temp, sizeof (temp)); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), temp); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), file_part (filter)); } if (!(flags & FRF_NOASKOVERWRITE)) gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); } else dialog = gtk_file_chooser_dialog_new (title, NULL, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); if (flags & FRF_MULTIPLE) gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); if (last_dir[0]) gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir); if (flags & FRF_ADDFOLDER) gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), get_xdir (), NULL); if (flags & FRF_CHOOSEFOLDER) { gtk_file_chooser_set_action (GTK_FILE_CHOOSER (dialog), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), filter); } else { if (filter && (flags & FRF_FILTERISINITIAL)) { gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), filter); } /* With DCC, we can't rely on filter as initial folder since filter already contains * the filename upon DCC RECV. Thus we have no better option than to check for the message * which will be the title of the window. For DCC it always contains the "offering" word. * This method is really ugly but it works so we'll stick with it for now. */ else if (strstr (title, "offering") != NULL) { gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), prefs.hex_dcc_dir); } /* by default, open the config folder */ else { gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), get_xdir ()); } } if (flags & FRF_EXTENSIONS && extensions != NULL) { filefilter = gtk_file_filter_new (); tokenbuffer = g_strdup (extensions); token = strtok (tokenbuffer, ";"); while (token != NULL) { gtk_file_filter_add_pattern (filefilter, token); token = strtok (NULL, ";"); } g_free (tokenbuffer); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filefilter); } freq = malloc (sizeof (struct file_req)); freq->dialog = dialog; freq->flags = flags; freq->callback = callback; freq->userdata = userdata; g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gtkutil_file_req_response), freq); g_signal_connect (G_OBJECT (dialog), "destroy", G_CALLBACK (gtkutil_file_req_destroy), (gpointer) freq); gtk_widget_show (dialog); }