当前位置: 首页>>代码示例>>C++>>正文


C++ ws_fopen函数代码示例

本文整理汇总了C++中ws_fopen函数的典型用法代码示例。如果您正苦于以下问题:C++ ws_fopen函数的具体用法?C++ ws_fopen怎么用?C++ ws_fopen使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ws_fopen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: prefs_find_preference

void 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,代码来源:sctp_chunk_statistics_dialog.cpp

示例2: color_filters_read_globals

/* read filters from the filter file */
gboolean
color_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,代码来源:color_filters.c

示例3: read_users_filters

/* read filters from the user's filter file */
static gboolean
read_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,代码来源:color_filters.c

示例4: color_filters_read_globals

/* read filters from the filter file */
gboolean
color_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,代码来源:color_filters.c

示例5: color_filters_write

/* save filters in users filter file */
gboolean
color_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,代码来源:color_filters.c

示例6: read_users_filters

/* read filters from the user's filter file */
static gboolean
read_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,代码来源:color_filters.c

示例7: wtap_dump_file_open

static 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,代码来源:file_access.c

示例8: color_filters_export

/* save filters in some other filter file (export) */
gboolean
color_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,代码来源:color_filters.c

示例9: dfilter_macro_save

void 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,代码来源:dfilter-macro.c

示例10: color_filters_export

/* save filters in some other filter file (export) */
gboolean
color_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,代码来源:color_filters.c

示例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,代码来源:rtp_stream.c

示例12: color_filters_import

/* read filters from some other filter file (import) */
gboolean
color_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,代码来源:color_filters.c

示例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,代码来源:text_page_utils.c

示例14: add_symbols_of_file

/*
 * add all etch symbols from file to our symbol cache
 */
static void
add_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,代码来源:packet-etch.c

示例15: color_filters_import

/* read filters from some other filter file (import) */
gboolean
color_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,代码来源:color_filters.c


注:本文中的ws_fopen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。