void print_buffer (void) { FILE *File; gint CurrentPage; char *TempName, *PrintCmd; if (!OpenedFilesCnt) return; CurrentPage = gtk_notebook_get_current_page (GTK_NOTEBOOK(MainNotebook)); if (!gtk_text_get_length (GTK_TEXT(FPROPS(CurrentPage, Text)))) { print_msg ("Nothing to print !"); return; } if (!FPROPS(CurrentPage, Changed[0])) { PrintCmd = g_strconcat (get_string_conf ("General/Misc/PrintCommand"), " \"", FPROPS(CurrentPage, Name), "\"", NULL); print_msg (g_strconcat ("File \"", FPROPS(CurrentPage, Name), "\" is being printed...", NULL)); } else { gchar *Buffer; TempName = g_strconcat (TEMP_DIR, TEMP_PREFIX, FPROPS(CurrentPage, BaseName), NULL); if (!(File = fopen (TempName, "w"))) { print_msg (g_strconcat ("Buffer \"", FPROPS(CurrentPage, BaseName), "\" cannot be printed", NULL)); g_free (TempName); return; } Buffer = gtk_editable_get_chars (GTK_EDITABLE(FPROPS(CurrentPage, Text)), 0, -1); fwrite (Buffer, gtk_text_get_length (GTK_TEXT(FPROPS(CurrentPage, Text))), 1, File); g_free (Buffer); fclose (File); PrintCmd = g_strconcat(get_string_conf ("General/Misc/PrintCommand"), " \"", TempName,"\"", NULL); print_msg (g_strconcat ("Buffer \"", FPROPS(CurrentPage, BaseName), "\" is being printed...", NULL)); g_free (TempName); } if (system (PrintCmd)) print_msg (g_strconcat ("Problem encountered while trying to print", NULL)); g_free (PrintCmd); }
int parse_configuration_file(FILE *configuration_fd) { unsigned int filelines = 0; char buf[MAX_CONFIGURATION_LINE_LEN]; char *index; fseek(configuration_fd, 0, SEEK_SET); memset(&buf, 0x0, sizeof(buf)); while((fgets(buf, sizeof(buf)-1, configuration_fd)) != NULL) { index = buf; /* The following characters mean ignore the line #;\n */ if((*index != '#') && (*index != 0x0a) && (*index != ';') && (!index != '\n') && (index != NULL)) { filelines++; if(filelines >= MAX_CONFIGURATION_LINES) { return filelines; } else { ADD_NULL_BYTE(buf); } if(strlen(buf) > MAX_CONFIGURATION_LINE_LEN) { continue; } if(options.plugin_dir == NULL) options.plugin_dir = get_string_conf("plugin_dir", buf); get_yn_conf("write_packets", buf, options.write_packets); get_yn_conf("write_packet_hdrs", buf, options.write_packet_hdrs); get_int_conf("ip_version", buf, options.ip_version); if(options.ip_version != IPV4 || options.ip_version != IPV6) { options.ip_version = IPV4; } } memset(buf, 0x0, sizeof(buf)); } return filelines; }