这篇教程C++ ws_fopen函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ws_fopen函数的典型用法代码示例。如果您正苦于以下问题:C++ ws_fopen函数的具体用法?C++ ws_fopen怎么用?C++ ws_fopen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ws_fopen函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: prefs_find_preferencevoid SCTPChunkStatisticsDialog::on_pushButton_clicked(){ FILE* fp; pref_t *pref = prefs_find_preference(prefs_find_module("sctp"),"statistics_chunk_types"); if (!pref) { g_log(NULL, G_LOG_LEVEL_ERROR, "Can't find preference sctp/statistics_chunk_types"); return; } uat_t *uat = prefs_get_uat_value(pref); gchar* fname = uat_get_actual_filename(uat,TRUE); if (!fname) { return; } fp = ws_fopen(fname,"w"); if (!fp && errno == ENOENT) { gchar *pf_dir_path = NULL; if (create_persconffile_dir(&pf_dir_path) != 0) { g_free (pf_dir_path); return; } fp = ws_fopen(fname,"w"); } if (!fp) { return; } g_free (fname); fprintf(fp,"# This file is automatically generated, DO NOT MODIFY./n"); char str[40]; struct chunkTypes tempChunk; for (int i = 0; i < chunks.size(); i++) { tempChunk = chunks.value(i); g_snprintf(str, sizeof str, "/"%d/",/"%s/",/"%s/"/n", tempChunk.id, tempChunk.name, tempChunk.hide==0?"Show":"Hide"); fputs(str, fp); void *rec = g_malloc0(uat->record_size); uat_add_record(uat, rec, TRUE); if (uat->free_cb) { uat->free_cb(rec); } g_free(rec); } fclose(fp);}
开发者ID:alagoutte,项目名称:wireshark,代码行数:52,
示例2: color_filters_read_globals/* read filters from the filter file */gbooleancolor_filters_read_globals(gpointer user_data, gchar** err_msg, color_filter_add_cb_func add_cb){ gchar *path; FILE *f; int ret; /* decide what file to open (from dfilter code) */ path = get_datafile_path("colorfilters"); if ((f = ws_fopen(path, "r")) == NULL) { if (errno != ENOENT) { *err_msg = g_strdup_printf("Could not open global filter file/n/"%s/": %s.", path, g_strerror(errno)); } g_free(path); return FALSE; } ret = read_filters_file(path, f, user_data, add_cb); if (ret != 0) { *err_msg = g_strdup_printf("Error reading global filter file/n/"%s/": %s.", path, g_strerror(errno)); fclose(f); g_free(path); return FALSE; } fclose(f); g_free(path); return TRUE;}
开发者ID:crondaemon,项目名称:wireshark,代码行数:32,
示例3: read_users_filters/* read filters from the user's filter file */static gbooleanread_users_filters(GSList **cfl){ gchar *path; FILE *f; gboolean ret; /* decide what file to open (from dfilter code) */ path = get_persconffile_path("colorfilters", TRUE); if ((f = ws_fopen(path, "r")) == NULL) { if (errno != ENOENT) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open filter file/n/"%s/": %s.", path, g_strerror(errno)); } g_free(path); return FALSE; } g_free(path); path = NULL; ret = read_filters_file(f, cfl); fclose(f); return ret;}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:26,
示例4: color_filters_read_globals/* read filters from the filter file */gbooleancolor_filters_read_globals(gpointer user_data){ gchar *path; FILE *f; gboolean ret; /* decide what file to open (from dfilter code) */ path = get_datafile_path("colorfilters"); if ((f = ws_fopen(path, "r")) == NULL) { if (errno != ENOENT) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open global filter file/n/"%s/": %s.", path, g_strerror(errno)); } g_free(path); return FALSE; } g_free(path); path = NULL; ret = read_filters_file(f, user_data); fclose(f); return ret;}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:26,
示例5: color_filters_write/* save filters in users filter file */gbooleancolor_filters_write(GSList *cfl){ gchar *pf_dir_path; gchar *path; FILE *f; /* Create the directory that holds personal configuration files, if necessary. */ if (create_persconffile_dir(&pf_dir_path) == -1) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't create directory/n/"%s/"/nfor color files: %s.", pf_dir_path, g_strerror(errno)); g_free(pf_dir_path); return FALSE; } path = get_persconffile_path("colorfilters", TRUE); if ((f = ws_fopen(path, "w+")) == NULL) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open/n%s/nfor writing: %s.", path, g_strerror(errno)); g_free(path); return FALSE; } g_free(path); write_filters_file(cfl, f, FALSE); fclose(f); return TRUE;}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:31,
示例6: read_users_filters/* read filters from the user's filter file */static gbooleanread_users_filters(GSList **cfl, gchar** err_msg, color_filter_add_cb_func add_cb){ gchar *path; FILE *f; int ret; /* decide what file to open (from dfilter code) */ path = get_persconffile_path("colorfilters", TRUE); if ((f = ws_fopen(path, "r")) == NULL) { if (errno != ENOENT) { *err_msg = g_strdup_printf("Could not open filter file/n/"%s/": %s.", path, g_strerror(errno)); } g_free(path); return FALSE; } ret = read_filters_file(path, f, cfl, add_cb); if (ret != 0) { *err_msg = g_strdup_printf("Error reading filter file/n/"%s/": %s.", path, g_strerror(errno)); fclose(f); g_free(path); return FALSE; } fclose(f); g_free(path); return TRUE;}
开发者ID:crondaemon,项目名称:wireshark,代码行数:32,
示例7: wtap_dump_file_openstatic FILE_T wtap_dump_file_open(wtap_dumper *wdh, const char *filename){ if(wdh->compressed) { return gzopen(filename, "wb"); } else { return ws_fopen(filename, "wb"); }}
开发者ID:flaub,项目名称:HotFuzz,代码行数:8,
示例8: color_filters_export/* save filters in some other filter file (export) */gbooleancolor_filters_export(const gchar *path, GSList *cfl, gboolean only_marked, gchar** err_msg){ FILE *f; if ((f = ws_fopen(path, "w+")) == NULL) { *err_msg = g_strdup_printf("Could not open/n%s/nfor writing: %s.", path, g_strerror(errno)); return FALSE; } write_filters_file(cfl, f, only_marked); fclose(f); return TRUE;}
开发者ID:crondaemon,项目名称:wireshark,代码行数:15,
示例9: dfilter_macro_savevoid dfilter_macro_save(const gchar* filename, gchar** error) { FILE* f = ws_fopen(filename,"w"); if (!f) { *error = ep_strdup_printf("Could not open file: '%s', error: %s/n", filename, g_strerror(errno) ); return; } dfilter_macro_foreach(macro_fprint, f); fclose(f); return;}
开发者ID:ARK1988,项目名称:wireshark,代码行数:14,
示例10: color_filters_export/* save filters in some other filter file (export) */gbooleancolor_filters_export(const gchar *path, const GSList *cfl, gboolean only_marked){ FILE *f; if ((f = ws_fopen(path, "w+")) == NULL) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open/n%s/nfor writing: %s.", path, g_strerror(errno)); return FALSE; } write_filters_file(cfl, f, only_marked); fclose(f); return TRUE;}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:16,
示例11: rtpstream_save/* save rtp dump of stream_fwd */gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtp_stream_info_t* stream, const gchar *filename){ gboolean was_registered; if (!tapinfo) { return FALSE; } was_registered = tapinfo->is_registered; /* open file for saving */ tapinfo->save_file = ws_fopen(filename, "wb"); if (tapinfo->save_file==NULL) { open_failure_alert_box(filename, errno, TRUE); return FALSE; } rtp_write_header(stream, tapinfo->save_file); if (ferror(tapinfo->save_file)) { write_failure_alert_box(filename, errno); fclose(tapinfo->save_file); return FALSE; } if (!tapinfo->is_registered) register_tap_listener_rtp_stream(tapinfo); tapinfo->mode = TAP_SAVE; tapinfo->filter_stream_fwd = stream; cf_retap_packets(cap_file); tapinfo->mode = TAP_ANALYSE; if (!was_registered) remove_tap_listener_rtp_stream(tapinfo); if (ferror(tapinfo->save_file)) { write_failure_alert_box(filename, errno); fclose(tapinfo->save_file); return FALSE; } if (fclose(tapinfo->save_file) == EOF) { write_failure_alert_box(filename, errno); return FALSE; } return TRUE;}
开发者ID:bearxiong99,项目名称:wireshark,代码行数:48,
示例12: color_filters_import/* read filters from some other filter file (import) */gbooleancolor_filters_import(const gchar *path, const gpointer user_data){ FILE *f; gboolean ret; if ((f = ws_fopen(path, "r")) == NULL) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open/n%s/nfor reading: %s.", path, g_strerror(errno)); return FALSE; } ret = read_filters_file(f, user_data); fclose(f); return ret;}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:18,
示例13: text_page_set_text/* * Put the complete text file into a text page. */static void text_page_set_text(GtkWidget *page, const char *absolute_path){ FILE *text_file; char line[4096+1]; /* XXX - size? */ text_file = ws_fopen(absolute_path, "r"); if (text_file != NULL) { while (fgets(line, sizeof line, text_file) != NULL) { text_page_insert(page, line, (int) strlen(line)); } if(ferror(text_file)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Error reading file /"%s/": %s", absolute_path, g_strerror(errno)); } fclose(text_file); } else { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open file /"%s/": %s", absolute_path, g_strerror(errno)); }}
开发者ID:ARK1988,项目名称:wireshark,代码行数:23,
示例14: add_symbols_of_file/* * add all etch symbols from file to our symbol cache */static voidadd_symbols_of_file(const char *filename){ FILE *pFile; pFile = ws_fopen(filename, "r"); if (pFile != NULL) { char line[256]; while (fgets(line, sizeof line, pFile) != NULL) { unsigned int hash; size_t length, pos; length = strlen(line); /* Must at least have a hash, else skip line */ if (length < 10) continue; pos = length - 1; while (pos > 0 && (line[pos] == 0xD || line[pos] == 0xA)) { pos--; } line[pos + 1] = '/0'; /* Parse the Hash */ if (sscanf(&line[0], "%x", &hash) != 1) continue; /* didn't find a valid hex value at the beginning of the line */ /* And read the symbol */ pos = strcspn(line, ","); if ((line[pos] != '/0') && (line[pos+1] !='/0')) /* require at least 1 char in symbol */ gbl_symbols_array_append(hash, g_strdup_printf("%." ETCH_MAX_SYMBOL_LENGTH "s", &line[pos+1])); } fclose(pFile); }}
开发者ID:appneta,项目名称:wireshark,代码行数:41,
示例15: color_filters_import/* read filters from some other filter file (import) */gbooleancolor_filters_import(const gchar *path, gpointer user_data, gchar **err_msg, color_filter_add_cb_func add_cb){ FILE *f; int ret; if ((f = ws_fopen(path, "r")) == NULL) { *err_msg = g_strdup_printf("Could not open filter file/n%s/nfor reading: %s.", path, g_strerror(errno)); return FALSE; } ret = read_filters_file(path, f, user_data, add_cb); if (ret != 0) { *err_msg = g_strdup_printf("Error reading filter file/n/"%s/": %s.", path, g_strerror(errno)); fclose(f); return FALSE; } fclose(f); return TRUE;}
开发者ID:crondaemon,项目名称:wireshark,代码行数:24,
示例16: write_profile_recent/* Attempt to Write out profile "recent" to the user's profile recent file. If we got an error report it with a dialog box and return FALSE, otherwise return TRUE. */gbooleanwrite_profile_recent(void){ char *pf_dir_path; char *rf_path; FILE *rf; /* To do: * - Split output lines longer than MAX_VAL_LEN * - Create a function for the preference directory check/creation * so that duplication can be avoided with filter.c */ /* Create the directory that holds personal configuration files, if necessary. */ if (create_persconffile_dir(&pf_dir_path) == -1) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't create directory/n/"%s/"/nfor recent file: %s.", pf_dir_path, g_strerror(errno)); g_free(pf_dir_path); return FALSE; } rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE); if ((rf = ws_fopen(rf_path, "w")) == NULL) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't open recent file/n/"%s/": %s.", rf_path, g_strerror(errno)); g_free(rf_path); return FALSE; } g_free(rf_path); fputs("# Recent settings file for Wireshark " VERSION "./n" "#/n" "# This file is regenerated each time Wireshark is quit/n" "# and when changing configuration profile./n" "# So be careful, if you want to make manual changes here./n" "/n", rf); fprintf(rf, "/n# Main Toolbar show (hide)./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_KEY_MAIN_TOOLBAR_SHOW ": %s/n", recent.main_toolbar_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "/n# Filter Toolbar show (hide)./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_KEY_FILTER_TOOLBAR_SHOW ": %s/n", recent.filter_toolbar_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "/n# Wireless Settings Toolbar show (hide)./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_KEY_WIRELESS_TOOLBAR_SHOW ": %s/n", recent.wireless_toolbar_show == TRUE ? "TRUE" : "FALSE");#ifdef HAVE_AIRPCAP fprintf(rf, "/n# Show (hide) old AirPcap driver warning dialog box./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_KEY_DRIVER_CHECK_SHOW ": %s/n", recent.airpcap_driver_check_show == TRUE ? "TRUE" : "FALSE");#endif fprintf(rf, "/n# Packet list show (hide)./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_KEY_PACKET_LIST_SHOW ": %s/n", recent.packet_list_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "/n# Tree view show (hide)./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_KEY_TREE_VIEW_SHOW ": %s/n", recent.tree_view_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "/n# Byte view show (hide)./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_KEY_BYTE_VIEW_SHOW ": %s/n", recent.byte_view_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "/n# Statusbar show (hide)./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_KEY_STATUSBAR_SHOW ": %s/n", recent.statusbar_show == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "/n# Packet list colorize (hide)./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_KEY_PACKET_LIST_COLORIZE ": %s/n", recent.packet_list_colorize == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "/n# Timestamp display format./n"); fprintf(rf, "# One of: RELATIVE, ABSOLUTE, ABSOLUTE_WITH_DATE, DELTA, DELTA_DIS, EPOCH, UTC, UTC_WITH_DATE/n"); fprintf(rf, RECENT_GUI_TIME_FORMAT ": %s/n", ts_type_text[recent.gui_time_format]); fprintf(rf, "/n# Timestamp display precision./n"); fprintf(rf, "# One of: AUTO, SEC, DSEC, CSEC, MSEC, USEC, NSEC/n"); fprintf(rf, RECENT_GUI_TIME_PRECISION ": %s/n", ts_precision_text[recent.gui_time_precision]);//.........这里部分代码省略.........
开发者ID:hekmati,项目名称:spyshark,代码行数:101,
示例17: uat_savegboolean uat_save(uat_t* uat, char** error) { guint i; gchar* fname = uat_get_actual_filename(uat,TRUE); FILE* fp; if (! fname ) return FALSE; fp = ws_fopen(fname,"w"); if (!fp && errno == ENOENT) { /* Parent directory does not exist, try creating first */ gchar *pf_dir_path = NULL; if (create_persconffile_dir(&pf_dir_path) != 0) { *error = g_strdup_printf("uat_save: error creating '%s'", pf_dir_path); g_free (pf_dir_path); return FALSE; } fp = ws_fopen(fname,"w"); } if (!fp) { *error = g_strdup_printf("uat_save: error opening '%s': %s",fname,g_strerror(errno)); return FALSE; } *error = NULL; g_free (fname); /* Ensure raw_data is synced with user_data and all "good" entries have been accounted for */ /* Start by clearing current user_data */ for ( i = 0 ; i < uat->user_data->len ; i++ ) { if (uat->free_cb) { uat->free_cb(UAT_USER_INDEX_PTR(uat,i)); } } g_array_set_size(uat->user_data,0); *((uat)->user_ptr) = NULL; *((uat)->nrows_p) = 0; /* Now copy "good" raw_data entries to user_data */ for ( i = 0 ; i < uat->raw_data->len ; i++ ) { void *rec = UAT_INDEX_PTR(uat, i); gboolean* valid = (gboolean*)(uat->valid_data->data + sizeof(gboolean)*i); if (*valid) { g_array_append_vals(uat->user_data, rec, 1); if (uat->copy_cb) { uat->copy_cb(UAT_USER_INDEX_PTR(uat, uat->user_data->len - 1), rec, (unsigned int) uat->record_size); } UAT_UPDATE(uat); } } fprintf(fp,"# This file is automatically generated, DO NOT MODIFY./n"); for ( i = 0 ; i < uat->user_data->len ; i++ ) { void* rec = uat->user_data->data + (uat->record_size * i); uat_field_t* f; guint j; f = uat->fields; for( j=0 ; j < uat->ncols ; j++ ) { putfld(fp, rec, &(f[j])); fputs((j == uat->ncols - 1) ? "/n" : "," ,fp); } } fclose(fp); uat->changed = FALSE; return TRUE;}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:80,
示例18: save_filter_list/* * Write out a list of filters. * * On success, "*pref_path_return" is set to NULL. * On error, "*pref_path_return" is set to point to the pathname of * the file we tried to read - it should be freed by our caller - * and "*errno_return" is set to the error. */voidsave_filter_list(filter_list_type_t list_type, char **pref_path_return, int *errno_return){ const gchar *ff_name; gchar *ff_path, *ff_path_new; GList *fl; GList *flpp; filter_def *filt; FILE *ff; guchar *p, c; *pref_path_return = NULL; /* assume no error */ switch (list_type) { case CFILTER_LIST: ff_name = CFILTER_FILE_NAME; fl = capture_filters; break; case DFILTER_LIST: ff_name = DFILTER_FILE_NAME; fl = display_filters; break; default: g_assert_not_reached(); return; } ff_path = get_persconffile_path(ff_name, TRUE); /* Write to "XXX.new", and rename if that succeeds. That means we don't trash the file if we fail to write it out completely. */ ff_path_new = g_strdup_printf("%s.new", ff_path); if ((ff = ws_fopen(ff_path_new, "w")) == NULL) { *pref_path_return = ff_path; *errno_return = errno; g_free(ff_path_new); return; } flpp = g_list_first(fl); while (flpp) { filt = (filter_def *) flpp->data; /* Write out the filter name as a quoted string; escape any quotes or backslashes. */ putc('"', ff); for (p = (guchar *)filt->name; (c = *p) != '/0'; p++) { if (c == '"' || c == '//') putc('//', ff); putc(c, ff); } putc('"', ff); /* Separate the filter name and value with a space. */ putc(' ', ff); /* Write out the filter expression and a newline. */ fprintf(ff, "%s/n", filt->strval); if (ferror(ff)) { *pref_path_return = ff_path; *errno_return = errno; fclose(ff); ws_unlink(ff_path_new); g_free(ff_path_new); return; } flpp = flpp->next; } if (fclose(ff) == EOF) { *pref_path_return = ff_path; *errno_return = errno; ws_unlink(ff_path_new); g_free(ff_path_new); return; }#ifdef _WIN32 /* ANSI C doesn't say whether "rename()" removes the target if it exists; the Win32 call to rename files doesn't do so, which I infer is the reason why the MSVC++ "rename()" doesn't do so. We must therefore remove the target file first, on Windows. XXX - ws_rename() should be ws_stdio_rename() on Windows, and ws_stdio_rename() uses MoveFileEx() with MOVEFILE_REPLACE_EXISTING, so it should remove the target if it exists, so this stuff shouldn't be necessary. Perhaps it dates back to when we were calling rename(), with that being a wrapper around Microsoft's//.........这里部分代码省略.........
开发者ID:jiangxilong,项目名称:wireshark-1,代码行数:101,
示例19: read_filter_listvoidread_filter_list(filter_list_type_t list_type, char **pref_path_return, int *errno_return){ const char *ff_name; char *ff_path; FILE *ff; GList **flpp; int c; char *filt_name, *filt_expr; int filt_name_len, filt_expr_len; int filt_name_index, filt_expr_index; int line = 1; *pref_path_return = NULL; /* assume no error */ switch (list_type) { case CFILTER_LIST: ff_name = CFILTER_FILE_NAME; flpp = &capture_filters; break; case DFILTER_LIST: ff_name = DFILTER_FILE_NAME; flpp = &display_filters; break; default: g_assert_not_reached(); return; } /* try to open personal "cfilters"/"dfilters" file */ ff_path = get_persconffile_path(ff_name, TRUE); if ((ff = ws_fopen(ff_path, "r")) == NULL) { /* * Did that fail because the file didn't exist? */ if (errno != ENOENT) { /* * No. Just give up. */ *pref_path_return = ff_path; *errno_return = errno; return; } /* * Yes. See if there's an "old style" personal "filters" file; if so, read it. * This means that a user will start out with their capture and * display filter lists being identical; each list may contain * filters that don't belong in that list. The user can edit * the filter lists, and delete the ones that don't belong in * a particular list. */ g_free(ff_path); ff_path = get_persconffile_path(FILTER_FILE_NAME, FALSE); if ((ff = ws_fopen(ff_path, "r")) == NULL) { /* * Did that fail because the file didn't exist? */ if (errno != ENOENT) { /* * No. Just give up. */ *pref_path_return = ff_path; *errno_return = errno; return; } /* * Try to open the global "cfilters/dfilters" file */ g_free(ff_path); ff_path = get_datafile_path(ff_name); if ((ff = ws_fopen(ff_path, "r")) == NULL) { /* * Well, that didn't work, either. Just give up. * Return an error if the file existed but we couldn't open it. */ if (errno != ENOENT) { *pref_path_return = ff_path; *errno_return = errno; } else { g_free(ff_path); } return; } } } /* If we already have a list of filters, discard it. */ /* this should never happen - this function is called only once for each list! */ while(*flpp) { *flpp = remove_filter_entry(*flpp, g_list_first(*flpp)); } /* Allocate the filter name buffer. */ filt_name_len = INIT_BUF_SIZE;//.........这里部分代码省略.........
开发者ID:jiangxilong,项目名称:wireshark-1,代码行数:101,
示例20: k12_openwtap_open_return_val k12_open(wtap *wth, int *err, gchar **err_info) { k12_src_desc_t* rec; guint8 header_buffer[K12_FILE_HDR_LEN]; guint8* read_buffer; guint32 type; long offset; long len; guint port_type; guint32 rec_len; guint32 hwpart_len; guint32 name_len; guint32 stack_len; guint i; k12_t* file_data;#ifdef DEBUG_K12 gchar* env_level = getenv("K12_DEBUG_LEVEL"); env_file = getenv("K12_DEBUG_FILENAME"); if ( env_file ) { dbg_out = ws_fopen(env_file,"w"); if (dbg_out == NULL) { dbg_out = stderr; K12_DBG(1,("unable to open K12 DEBUG FILENAME for writing! Logging to standard error")); } } else dbg_out = stderr; if ( env_level ) debug_level = (unsigned int)strtoul(env_level,NULL,10); K12_DBG(1,("k12_open: ENTER debug_level=%u",debug_level));#endif if ( !wtap_read_bytes(wth->fh,header_buffer,K12_FILE_HDR_LEN,err,err_info) ) { K12_DBG(1,("k12_open: FILE HEADER TOO SHORT OR READ ERROR")); if (*err != WTAP_ERR_SHORT_READ) { return WTAP_OPEN_ERROR; } return WTAP_OPEN_NOT_MINE; } if ( memcmp(header_buffer,k12_file_magic,8) != 0 ) { K12_DBG(1,("k12_open: BAD MAGIC")); return WTAP_OPEN_NOT_MINE; } offset = K12_FILE_HDR_LEN; file_data = new_k12_file_data(); file_data->file_len = pntoh32( header_buffer + 0x8); if (memiszero(header_buffer + 0x10, K12_FILE_HDR_LEN - 0x10)) { /* * The rest of the file header is all zeroes. That means * this is a file written by the old Wireshark code, and * a count of records in the file is at an offset of 0x0C. */ file_data->num_of_records = pntoh32( header_buffer + 0x0C ); } else { /* * There's at least one non-zero byte in the rest of the * header. The value 8192 is at 0xC (page size?), and * what appears to be the number of records in the file * is at an offset of 0x24 and at an offset of 0x2c. * * If the two values are not the same, we fail; if that's * the case, we need to see the file to figure out which * of those two values, if any, is the count. */ file_data->num_of_records = pntoh32( header_buffer + K12_FILE_HDR_RECORD_COUNT_1 ); if ( file_data->num_of_records != pntoh32( header_buffer + K12_FILE_HDR_RECORD_COUNT_2 ) ) { *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("k12: two different record counts, %u at 0x%02x and %u at 0x%02x", file_data->num_of_records, K12_FILE_HDR_RECORD_COUNT_1, pntoh32( header_buffer + K12_FILE_HDR_RECORD_COUNT_2 ), K12_FILE_HDR_RECORD_COUNT_2 ); return WTAP_OPEN_ERROR; } } K12_DBG(5,("k12_open: FILE_HEADER OK: offset=%x file_len=%i records=%i", offset, file_data->file_len, file_data->num_of_records )); do { if ( file_data->num_of_records == 0 ) { *err = WTAP_ERR_SHORT_READ; destroy_k12_file_data(file_data); return WTAP_OPEN_ERROR; } len = get_record(file_data, wth->fh, offset, FALSE, err, err_info); if ( len < 0 ) { K12_DBG(1,("k12_open: BAD HEADER RECORD",len)); destroy_k12_file_data(file_data); return WTAP_OPEN_ERROR; } if ( len == 0 ) { K12_DBG(1,("k12_open: BAD HEADER RECORD",len));//.........这里部分代码省略.........
开发者ID:HeartFlying,项目名称:wireshark,代码行数:101,
示例21: ws_fopen/* * XXX - the routine pointed to by "print_line_fcn_p" doesn't get handed lines, * it gets handed bufferfuls. That's fine for "follow_write_raw()" * and "follow_add_to_gtk_text()", but, as "follow_print_text()" calls * the "print_line()" routine from "print.c", and as that routine might * genuinely expect to be handed a line (if, for example, it's using * some OS or desktop environment's printing API, and that API expects * to be handed lines), "follow_print_text()" should probably accumulate * lines in a buffer and hand them "print_line()". (If there's a * complete line in a buffer - i.e., there's nothing of the line in * the previous buffer or the next buffer - it can just hand that to * "print_line()" after filtering out non-printables, as an * optimization.) * * This might or might not be the reason why C arrays display * correctly but get extra blank lines very other line when printed. */frs_return_tFollowStreamDialog::readTcpStream(){ FILE *data_out_fp; tcp_stream_chunk sc; size_t bcount; size_t bytes_read; int iplen; guint8 client_addr[MAX_IPADDR_LEN]; guint16 client_port = 0; gboolean is_server; guint32 global_client_pos = 0, global_server_pos = 0; guint32 *global_pos; gboolean skip; char buffer[FLT_BUF_SIZE+1]; /* +1 to fix ws bug 1043 */ size_t nchars; frs_return_t frs_return; iplen = (follow_info_.is_ipv6) ? 16 : 4; data_out_fp = ws_fopen(data_out_filename_.toUtf8().constData(), "rb"); if (data_out_fp == NULL) { QMessageBox::critical(this, "Error", "Could not open temporary file %1: %2", data_out_filename_, g_strerror(errno)); return FRS_OPEN_ERROR; } while ((nchars=fread(&sc, 1, sizeof(sc), data_out_fp))) { if (nchars != sizeof(sc)) { QMessageBox::critical(this, "Error", QString(tr("Short read from temporary file %1: expected %2, got %3")) .arg(data_out_filename_) .arg(sizeof(sc)) .arg(nchars)); fclose(data_out_fp); data_out_fp = NULL; return FRS_READ_ERROR; } if (client_port == 0) { memcpy(client_addr, sc.src_addr, iplen); client_port = sc.src_port; } skip = FALSE; if (memcmp(client_addr, sc.src_addr, iplen) == 0 && client_port == sc.src_port) { is_server = FALSE; global_pos = &global_client_pos; if (follow_info_.show_stream == FROM_SERVER) { skip = TRUE; } } else { is_server = TRUE; global_pos = &global_server_pos; if (follow_info_.show_stream == FROM_CLIENT) { skip = TRUE; } } bytes_read = 0; while (bytes_read < sc.dlen) { bcount = ((sc.dlen-bytes_read) < FLT_BUF_SIZE) ? (sc.dlen-bytes_read) : FLT_BUF_SIZE; nchars = fread(buffer, 1, bcount, data_out_fp); if (nchars == 0) break; /* XXX - if we don't get "bcount" bytes, is that an error? */ bytes_read += nchars; if (!skip) { frs_return = showBuffer(buffer, nchars, is_server, sc.packet_num, global_pos); if(frs_return == FRS_PRINT_ERROR) { fclose(data_out_fp); data_out_fp = NULL; return frs_return; } } } } if (ferror(data_out_fp)) {//.........这里部分代码省略.........
开发者ID:Biubiubang,项目名称:wireshark,代码行数:101,
示例22: k12_openint k12_open(wtap *wth, int *err, gchar **err_info) { k12_src_desc_t* rec; guint8 header_buffer[0x200]; guint8* read_buffer; guint32 type; long offset; long len; guint32 rec_len; guint32 extra_len; guint32 name_len; guint32 stack_len; guint i; k12_t* file_data;#ifdef DEBUG_K12 gchar* env_level = getenv("K12_DEBUG_LEVEL"); env_file = getenv("K12_DEBUG_FILENAME"); if ( env_file ) { dbg_out = ws_fopen(env_file,"w"); if (dbg_out == NULL) { dbg_out = stderr; K12_DBG(1,("unable to open K12 DEBUG FILENAME for writing! Logging to standard error")); } } else dbg_out = stderr; if ( env_level ) debug_level = (unsigned int)strtoul(env_level,NULL,10); K12_DBG(1,("k12_open: ENTER debug_level=%u",debug_level));#endif if ( file_read(header_buffer,0x200,wth->fh) != 0x200 ) { K12_DBG(1,("k12_open: FILE HEADER TOO SHORT OR READ ERROR")); *err = file_error(wth->fh, err_info); if (*err != 0 && *err != WTAP_ERR_SHORT_READ) { return -1; } return 0; } else { if ( memcmp(header_buffer,k12_file_magic,8) != 0 ) { K12_DBG(1,("k12_open: BAD MAGIC")); return 0; } } offset = 0x200; file_data = new_k12_file_data(); file_data->file_len = pntoh32( header_buffer + 0x8); file_data->num_of_records = pntoh32( header_buffer + 0xC ); K12_DBG(5,("k12_open: FILE_HEADER OK: offset=%x file_len=%i records=%i", offset, file_data->file_len, file_data->num_of_records )); do { len = get_record(file_data, wth->fh, offset, FALSE, err, err_info); if ( len < 0 ) { K12_DBG(1,("k12_open: BAD HEADER RECORD",len)); destroy_k12_file_data(file_data); return -1; } if (len == 0) { K12_DBG(1,("k12_open: BAD HEADER RECORD",len)); *err = WTAP_ERR_SHORT_READ; destroy_k12_file_data(file_data); return -1; } if (len == 0) { K12_DBG(1,("k12_open: BAD HEADER RECORD",len)); *err = WTAP_ERR_SHORT_READ; destroy_k12_file_data(file_data); return -1; } read_buffer = file_data->seq_read_buff; rec_len = pntoh32( read_buffer + K12_RECORD_LEN ); if (rec_len < K12_RECORD_TYPE + 4) { /* Record isn't long enough to have a type field */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("k12_open: record length %u < %u", rec_len, K12_RECORD_TYPE + 4); return -1; } type = pntoh32( read_buffer + K12_RECORD_TYPE ); if ( (type & K12_MASK_PACKET) == K12_REC_PACKET || (type & K12_MASK_PACKET) == K12_REC_D0020) { /* * we are at the first packet record, rewind and leave. */ if (file_seek(wth->fh, offset, SEEK_SET, err) == -1) { destroy_k12_file_data(file_data); return -1; }//.........这里部分代码省略.........
开发者ID:hashbrowncipher,项目名称:wireshark,代码行数:101,
示例23: write_recent/* Attempt to Write out "recent common" to the user's recent common file. If we got an error report it with a dialog box and return FALSE, otherwise return TRUE. */gbooleanwrite_recent(void){ char *pf_dir_path; char *rf_path; FILE *rf; /* To do: * - Split output lines longer than MAX_VAL_LEN * - Create a function for the preference directory check/creation * so that duplication can be avoided with filter.c */ /* Create the directory that holds personal configuration files, if necessary. */ if (create_persconffile_dir(&pf_dir_path) == -1) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't create directory/n/"%s/"/nfor recent file: %s.", pf_dir_path, g_strerror(errno)); g_free(pf_dir_path); return FALSE; } rf_path = get_persconffile_path(RECENT_COMMON_FILE_NAME, FALSE); if ((rf = ws_fopen(rf_path, "w")) == NULL) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't open recent file/n/"%s/": %s.", rf_path, g_strerror(errno)); g_free(rf_path); return FALSE; } g_free(rf_path); fputs("# Recent settings file for Wireshark " VERSION "./n" "#/n" "# This file is regenerated each time Wireshark is quit./n" "# So be careful, if you want to make manual changes here./n" "/n" "######## Recent capture files (latest last), cannot be altered through command line ########/n" "/n", rf); menu_recent_file_write_all(rf); fputs("/n" "######## Recent capture filters (latest last), cannot be altered through command line ########/n" "/n", rf); cfilter_recent_write_all(rf); fputs("/n" "######## Recent display filters (latest last), cannot be altered through command line ########/n" "/n", rf); dfilter_recent_combo_write_all(rf);#ifdef HAVE_PCAP_REMOTE fputs("/n" "######## Recent remote hosts, cannot be altered through command line ########/n" "/n", rf); capture_remote_combo_recent_write_all(rf);#endif fprintf(rf, "/n# Main window geometry./n"); fprintf(rf, "# Decimal numbers./n"); fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_X ": %d/n", recent.gui_geometry_main_x); fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_Y ": %d/n", recent.gui_geometry_main_y); fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_WIDTH ": %d/n", recent.gui_geometry_main_width); fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_HEIGHT ": %d/n", recent.gui_geometry_main_height); fprintf(rf, "/n# Main window maximized./n"); fprintf(rf, "# TRUE or FALSE (case-insensitive)./n"); fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED ": %s/n", recent.gui_geometry_main_maximized == TRUE ? "TRUE" : "FALSE"); fprintf(rf, "/n# Statusbar left pane size./n"); fprintf(rf, "# Decimal number./n"); if (recent.gui_geometry_status_pane_left != 0) { fprintf(rf, RECENT_GUI_GEOMETRY_STATUS_PANE_LEFT ": %d/n", recent.gui_geometry_status_pane_left); } fprintf(rf, "/n# Statusbar middle pane size./n"); fprintf(rf, "# Decimal number./n"); if (recent.gui_geometry_status_pane_right != 0) { fprintf(rf, RECENT_GUI_GEOMETRY_STATUS_PANE_RIGHT ": %d/n", recent.gui_geometry_status_pane_right); } fprintf(rf, "/n# Last used Configuration Profile./n"); fprintf(rf, RECENT_LAST_USED_PROFILE ": %s/n", get_profile_name()); fprintf(rf, "/n# WLAN statistics upper pane size./n"); fprintf(rf, "# Decimal number./n"); fprintf(rf, RECENT_GUI_GEOMETRY_WLAN_STATS_PANE ": %d/n", recent.gui_geometry_wlan_stats_pane);//.........这里部分代码省略.........
开发者ID:hekmati,项目名称:spyshark,代码行数:101,
示例24: prefs_find_preferencevoid SCTPChunkStatisticsDialog::fillTable(bool all){ FILE* fp; pref_t *pref = prefs_find_preference(prefs_find_module("sctp"),"statistics_chunk_types"); uat_t *uat = pref->varp.uat; gchar* fname = uat_get_actual_filename(uat,TRUE); bool init = false; if (!fname ) { init = true; } else { fp = ws_fopen(fname,"r"); if (!fp && errno == ENOENT) { init = true; } } g_free (fname); if (init || all) { int j = 0; for (int i = 0; i < chunks.size(); i++) { if (!chunks.value(i).hide) { ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+1); ui->tableWidget->setVerticalHeaderItem(j, new QTableWidgetItem(QString("%1").arg(chunks.value(i).name))); ui->tableWidget->setItem(j,0, new QTableWidgetItem(QString("%1").arg(selected_assoc->chunk_count[chunks.value(i).id]))); ui->tableWidget->setItem(j,1, new QTableWidgetItem(QString("%1").arg(selected_assoc->ep1_chunk_count[chunks.value(i).id]))); ui->tableWidget->setItem(j,2, new QTableWidgetItem(QString("%1").arg(selected_assoc->ep2_chunk_count[chunks.value(i).id]))); j++; } } for (int i = 0; i < chunks.size(); i++) { if (chunks.value(i).hide) { ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+1); ui->tableWidget->setVerticalHeaderItem(j, new QTableWidgetItem(QString("%1").arg(chunks.value(i).name))); ui->tableWidget->setItem(j,0, new QTableWidgetItem(QString("%1").arg(selected_assoc->chunk_count[chunks.value(i).id]))); ui->tableWidget->setItem(j,1, new QTableWidgetItem(QString("%1").arg(selected_assoc->ep1_chunk_count[chunks.value(i).id]))); ui->tableWidget->setItem(j,2, new QTableWidgetItem(QString("%1").arg(selected_assoc->ep2_chunk_count[chunks.value(i).id]))); ui->tableWidget->hideRow(j); j++; } } } else { char line[100]; size_t cap = 100; char *token, id[5]; int i = 0, j = 0; struct chunkTypes temp; while (fgets(line, cap, fp)) { if (line[0] == '#') continue; token = strtok(line, ","); /* Get rid of the quotation marks */ QString ch = QString(token).mid(1, (int)strlen(token)-2); strcpy(id, qPrintable(ch)); temp.id = atoi(id); while(token != NULL) { token = strtok(NULL, ","); if (token) { if ((strstr(token, "Hide"))) { temp.hide = 1; } else if ((strstr(token, "Show"))) { temp.hide = 0; } else { QString ch = QString(token).mid(1, (int)strlen(token)-2); strcpy(temp.name, qPrintable(ch)); } } } if (!temp.hide) { ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+1); ui->tableWidget->setVerticalHeaderItem(j, new QTableWidgetItem(QString("%1").arg(temp.name))); ui->tableWidget->setItem(j,0, new QTableWidgetItem(QString("%1").arg(selected_assoc->chunk_count[temp.id]))); ui->tableWidget->setItem(j,1, new QTableWidgetItem(QString("%1").arg(selected_assoc->ep1_chunk_count[temp.id]))); ui->tableWidget->setItem(j,2, new QTableWidgetItem(QString("%1").arg(selected_assoc->ep2_chunk_count[temp.id]))); j++; } chunks.insert(i, temp); i++; } j = ui->tableWidget->rowCount(); for (int i = 0; i < chunks.size(); i++) { if (chunks.value(i).hide) { ui->tableWidget->setRowCount(ui->tableWidget->rowCount()+1); ui->tableWidget->setVerticalHeaderItem(j, new QTableWidgetItem(QString("%1").arg(chunks.value(i).name))); ui->tableWidget->setItem(j,0, new QTableWidgetItem(QString("%1").arg(selected_assoc->chunk_count[chunks.value(i).id]))); ui->tableWidget->setItem(j,1, new QTableWidgetItem(QString("%1").arg(selected_assoc->ep1_chunk_count[chunks.value(i).id]))); ui->tableWidget->setItem(j,2, new QTableWidgetItem(QString("%1").arg(selected_assoc->ep2_chunk_count[chunks.value(i).id]))); ui->tableWidget->hideRow(j); j++; } } fclose(fp); }}
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:98,
示例25: loal_from_file/** * loal_from_file: * @param filename the file containing a loals text representation. * * Given a filename it will attempt to load a loal containing a copy of * the avpls represented in the file. * * Return value: if successful a pointer to the new populated loal, else NULL. * **/extern LoAL* loal_from_file(gchar* filename) { FILE *fp = NULL; gchar c; int i = 0; guint32 linenum = 1; gchar linenum_buf[MAX_ITEM_LEN]; gchar name[MAX_ITEM_LEN]; gchar value[MAX_ITEM_LEN]; gchar op = '?'; LoAL *loal = new_loal(filename); AVPL* curr = NULL; AVP* avp; enum _load_loal_states { START, BEFORE_NAME, IN_NAME, IN_VALUE, MY_IGNORE } state;#ifndef _WIN32 if (! getuid()) { return load_loal_error(fp,loal,curr,linenum,"MATE Will not run as root"); }#endif state = START; if (( fp = ws_fopen(filename,"r") )) { while(( c = (gchar) fgetc(fp) )){ if ( feof(fp) ) { if ( ferror(fp) ) { report_read_failure(filename,errno); return load_loal_error(fp,loal,curr,linenum,"Error while reading '%f'",filename); } break; } if ( c == '/n' ) { linenum++; } if ( i >= MAX_ITEM_LEN - 1 ) { return load_loal_error(fp,loal,curr,linenum,"Maximum item length exceeded"); } switch(state) { case MY_IGNORE: switch (c) { case '/n': state = START; i = 0; continue; default: continue; } case START: switch (c) { case ' ': case '/t': /* ignore whitespace at line start */ continue; case '/n': /* ignore empty lines */ i = 0; continue; case AVP_NAME_CHAR: state = IN_NAME; i = 0; name[i++] = c; name[i] = '/0'; g_snprintf(linenum_buf,sizeof(linenum_buf),"%s:%u",filename,linenum); curr = new_avpl(linenum_buf); continue; case '#': state = MY_IGNORE; continue; default: return load_loal_error(fp,loal,curr,linenum,"expecting name got: '%c'",c); } case BEFORE_NAME: i = 0; name[0] = '/0'; switch (c) { case '//': c = (gchar) fgetc(fp); if (c != '/n') ungetc(c,fp); continue; case ' '://.........这里部分代码省略.........
开发者ID:DuLerWeil,项目名称:wireshark,代码行数:101,
注:本文中的ws_fopen函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ws_malloc函数代码示例 C++ ws2s函数代码示例 |