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


C++ Conversion::free方法代码示例

本文整理汇总了C++中Conversion::free方法的典型用法代码示例。如果您正苦于以下问题:C++ Conversion::free方法的具体用法?C++ Conversion::free怎么用?C++ Conversion::free使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Conversion的用法示例。


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

示例1:

/*
 * Converts the specified registry file.  The specified file is
 * removed if the conversion is successful.  If conversion_count
 * is not NULL, the total number of Articles converted will be
 * passed back.
 */
int
wsreg_convert_registry(const char *filename, int *conversion_count,
    Progress_function progress_callback)
{
	File_util *futil = _wsreg_fileutil_initialize();

	if (initialized == WSREG_NOT_INITIALIZED) {
		return (WSREG_NOT_INITIALIZED);
	}

	if (!futil->exists(filename)) {
		/*
		 * Bad filename.
		 */
		return (WSREG_FILE_NOT_FOUND);
	}
	if (futil->can_read(filename) && futil->can_write(filename)) {
		/*
		 * The registry file can be read and removed.
		 */
		if (wsreg_can_access_registry(O_RDWR)) {
			/*
			 * The conversion permissions are appropriate.
			 * Perform the conversion.
			 */
			int result;
			int article_count = 0;
			Progress *progress =
			    _wsreg_progress_create(
				    (Progress_callback)*progress_callback);
			int count = 0;
			Unz_article_input_stream *ain = NULL;
			Conversion *c = NULL;

			/*
			 * The first progress section represents the
			 * unzipping of the data file.
			 */
			progress->set_section_bounds(progress, 5, 1);
			ain = _wsreg_uzais_open(filename, &result);
			progress->finish_section(progress);
			if (result != WSREG_SUCCESS) {
				/*
				 * The open failed.  Clean up and
				 * return the error code.
				 */
				if (ain != NULL) {
					ain->close(ain);
				}
				progress->free(progress);
				return (result);
			}

			c = _wsreg_conversion_create(progress);

			/*
			 * The second progress section represents
			 * the reading of articles.
			 */
			article_count = ain->get_article_count(ain);
			progress->set_section_bounds(progress, 8,
			    article_count);
			while (ain->has_more_articles(ain)) {
				Article *a = ain->get_next_article(ain);
				if (a != NULL) {
					c->add_article(c, a);
				}
				progress->increment(progress);
			}
			progress->finish_section(progress);
			ain->close(ain);

			/*
			 * The third progress section represents
			 * the conversion and registration of the
			 * resulting components.
			 */
			progress->set_section_bounds(progress, 100,
			    article_count);
			count = c->register_components(c, NULL, FALSE);
			progress->finish_section(progress);

			/*
			 * Pass the count back to the caller.
			 */
			if (conversion_count != NULL) {
				*conversion_count = count;
			}

			/*
			 * Remove the old registry file.
			 */
			futil->remove(filename);

//.........这里部分代码省略.........
开发者ID:belenix,项目名称:belenixold,代码行数:101,代码来源:wsreg.c

示例2: fopen


//.........这里部分代码省略.........
{
	/*
	 * The default datasheet file is stdin.
	 */
	FILE *in = stdin;
	char *result = NULL;
	char *location = NULL;
	char *parent_mnemonic = NULL;
	char *parent_id = NULL;
	Wsreg_component *parent_component = NULL;
	List *matches = NULL;
	List *article_list = NULL;
	Conversion *conversion;

	if (arg_list->size(arg_list) > 0) {
		/*
		 * Install location, datasheet filename.
		 */
		char *path;
		location = (char *)arg_list->element_at(arg_list, 0);
		if (strcmp(location, "-") == 0) {
			location = NULL;
		}
		path = (char *)arg_list->element_at(arg_list, 1);
		in = NULL;
		if (path != NULL) {
			in = fopen(path, "r");
		}
		if (in == NULL) {
			(void) fprintf(stderr, PRODREG_CANT_READ_FILE,
			    path);
			(void) fprintf(stderr, "\n");
			return ("");
		}

		if (arg_list->size(arg_list) > 2) {
			/*
			 * Parent mnemonic, parent id.
			 */
			parent_mnemonic =
			    (char *)arg_list->element_at(arg_list, 2);
			parent_id = (char *)arg_list->element_at(arg_list, 3);
			if (parent_mnemonic != NULL &&
			    parent_id != NULL) {
				matches =
				    get_matching_components(parent_mnemonic,
					parent_id);
				if (matches != NULL &&
				    matches->size(matches) == 1) {
					parent_component =
					    (Wsreg_component *)
					    matches->element_at(matches, 0);
				} else {
					(void) fprintf(stderr,
					    PRODREG_NO_SUCH_COMPONENT,
					    parent_mnemonic, parent_id);
					(void) fprintf(stderr, "\n");

				}
			}
		}
	}

	article_list = read_articles(in);
	conversion = _wsreg_conversion_create(NULL);

	/*
	 * Creates associations between parent Article and
	 * child Article.
	 */
	conversion->create_associations(article_list);

	/*
	 * Convert the articles to Wsreg_component structures
	 * and register.
	 */
	article_list->reset_iterator(article_list);
	while (article_list->has_more_elements(article_list)) {
		Article *a =
		    (Article *)article_list->next_element(article_list);
		/*
		 * The install location passed in overrides that in the
		 * datasheet.  I am not sure where this would be applicable.
		 * Is it really that the datasheet is incorrect and the
		 * user knows best here?
		 */
		if (location != NULL) {
			a->set_property(a, "installlocation", location);
		}
		conversion->add_article(conversion, a);
		result = a->get_id(a);
	}
	conversion->register_components(conversion, parent_component, TRUE);
	conversion->free(conversion);

	if (matches != NULL) {
		matches->free(matches, (Free)wsreg_free_component);
	}
	return (result);
}
开发者ID:belenix,项目名称:belenixold,代码行数:101,代码来源:Prodreg.c


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