• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pcs_free函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: pcs_http_build_url

static PcsFileInfo *pcs_upload_form(Pcs handle, const char *path, PcsBool overwrite, PcsHttpForm form)
{
	struct pcs *pcs = (struct pcs *)handle;
	char *url, *html,
		*dir = pcs_utils_basedir(path),
		*filename = pcs_utils_filename(path);
	cJSON *json, *item;
	PcsFileInfo *meta;

	url = pcs_http_build_url(pcs->http, URL_PCS_REST,
		"method", "upload",
		"app_id", "250528",
		"ondup", overwrite ? "overwrite" : "newcopy",
		"dir", dir,
		"filename", filename,
		"BDUSS", pcs->bduss, 
		NULL);
	pcs_free(dir);
	pcs_free(filename);
	if (!url) {
		pcs_set_errmsg(handle, "Can't build the url.");
		return NULL;
	}
	html = pcs_post_httpform(pcs->http, url, form, PcsTrue);
	pcs_free(url);
	if (!html) {
		pcs_set_errmsg(handle, "Can't get response from the server.");
		return NULL;
	}
	json = cJSON_Parse(html);
	if (!json) {
		pcs_set_errmsg(handle, "Can't parse the response as json: %s", html);
		return NULL;
	}
	//"{\"error_code\":31062,\"error_msg\":\"file name is invalid\",\"request_id\":3071564675}
	item = cJSON_GetObjectItem(json, "error_code");
	if (item) {
		int error_code = item->valueint;
		const char *error_msg = NULL;
		item = cJSON_GetObjectItem(json, "error_msg");
		if (item)
			error_msg = item->valuestring;
		pcs_set_errmsg(handle, "Can't upload file. error_code: %d. error_msg: %s. raw response: %s", error_code, error_msg, html);
		cJSON_Delete(json);
		return NULL;
	}

	meta = pcs_parse_fileinfo(json);
	cJSON_Delete(json);
	if (!meta) {
		pcs_set_errmsg(handle, "Can't parse the response as meta");
		return NULL;
	}
	return meta;
}
开发者ID:imzjy,项目名称:baidupcs,代码行数:55,代码来源:pcs.c


示例2: pcs_slist_destroy

PCS_API void pcs_slist_destroy(PcsSList *slist)
{
	PcsSList *p = slist, *p2;
	while(p) {
		p2 = p;
		p = p->next;
		if (p2->string)
			pcs_free(p2->string);
		pcs_free(p2);
	}
}
开发者ID:hepking,项目名称:BaiduPCS,代码行数:11,代码来源:pcs_slist.c


示例3: my_dirent_destroy

void my_dirent_destroy(my_dirent *link)
{
	my_dirent *cusor, *ent;
	cusor = link;
	while(cusor) {
		ent = cusor;
		cusor = cusor->next;
		if (ent->path)
			pcs_free(ent->path);
		pcs_free(ent);
	}
}
开发者ID:yaoey,项目名称:baidupcs,代码行数:12,代码来源:dir.c


示例4: pcs_http_write

size_t pcs_http_write(char *ptr, size_t size, size_t nmemb, void *userdata)
{
	struct pcs_http *http = (struct pcs_http *)userdata;
	size_t sz;
	char *p;

	if (size == 0 || nmemb == 0) {
		return 0;
	}
	sz = size * nmemb;
	if (!pcs_http_parse_http_head(http, &ptr, &sz, PcsTrue)) {
		if (http->strerror) pcs_free(http->strerror);
		http->strerror = pcs_utils_strdup("Cannot parse the http head. ");
		return 0;
	}
	if (sz > 0) {
		if (http->res_type == PCS_HTTP_RES_TYPE_NORMAL + 1) {
			http->res_body = pcs_http_append_bytes(http->res_body, http->res_body_size, ptr, sz);
			http->res_body_size += sz;
		}
		else if (http->res_type == PCS_HTTP_RES_TYPE_VALIDATE_TEXT + 1) {
			//验证内容正确性
			p = &ptr[sz - 1];
			while(p > ptr) {
				if (*p == 0) {
					if (http->strerror) pcs_free(http->strerror);
					http->strerror = pcs_utils_strdup("The response is not the validate text. ");
					return 0;
				}
				p--;
			}
			http->res_body = pcs_http_append_bytes(http->res_body, http->res_body_size, ptr, sz);
			http->res_body_size += sz;
		}
		else if (http->res_type == PCS_HTTP_RES_TYPE_RAW + 1) {
			http->res_body = pcs_http_append_bytes(http->res_body, http->res_body_size, ptr, sz);
			http->res_body_size += sz;
		}
		else if (http->res_type == PCS_HTTP_RES_TYPE_DOWNLOAD + 1) {
			if (!http->write_func) {
				if (http->strerror) pcs_free(http->strerror);
				http->strerror = pcs_utils_strdup("Have no write function. ");
				return 0;
			}
			return (*http->write_func)(ptr, sz, http->res_content_length, http->write_data);
		}
		else
			return 0;
	}

	return size * nmemb;
}
开发者ID:786259135,项目名称:BaiduPCS,代码行数:52,代码来源:pcs_http.c


示例5: pcs_http_destroy

PCS_API void pcs_http_destroy(PcsHttp handle)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	if (http->curl)
		curl_easy_cleanup(http->curl);
	if (http->res_header)
		pcs_free(http->res_header);
	if (http->res_body)
		pcs_free(http->res_body);
	if (http->res_encode)
		pcs_free(http->res_encode);
	pcs_free(http);
}
开发者ID:imzjy,项目名称:baidupcs,代码行数:13,代码来源:pcs_http.c


示例6: node_destroy

static void node_destroy(HashtableNode *node, void(*free_value)(void *))
{
	HashtableNode *tmp, *cusor;
	cusor = node;
	while(cusor) {
		tmp = cusor;
		cusor = cusor->next;
		if (tmp->key)
			pcs_free(tmp->key);
		if (free_value && tmp->value)
			(*free_value)(tmp->value);
		pcs_free(tmp);
	}
}
开发者ID:AsakuraFuuko,项目名称:baidupcs,代码行数:14,代码来源:hashtable.c


示例7: pcs_setopt

PCS_API PcsRes pcs_setopt(Pcs handle, PcsOption opt, void *value)
{
	PcsRes res = PCS_OK;
	struct pcs *pcs = (struct pcs *)handle;
	switch (opt)
	{
	case PCS_OPTION_USERNAME:
		if (pcs->username) pcs_free(pcs->username);
		pcs->username = pcs_utils_strdup((char *)value);
		break;
	case PCS_OPTION_PASSWORD:
		if (pcs->password) pcs_free(pcs->password);
		pcs->password = pcs_utils_strdup((char *)value);
		break;
	case PCS_OPTION_CAPTCHA_FUNCTION:
		pcs->captcha_func = (PcsGetCaptchaFunction)value;
		break;
	case PCS_OPTION_CAPTCHA_FUNCTION_DATA:
		pcs->captcha_data = value;
		break;
	case PCS_OPTION_DOWNLOAD_WRITE_FUNCTION:
		pcs_http_setopt(pcs->http, PCS_HTTP_OPTION_HTTP_WRITE_FUNCTION, value);
		break;
	case PCS_OPTION_DOWNLOAD_WRITE_FUNCTION_DATA:
		pcs_http_setopt(pcs->http, PCS_HTTP_OPTION_HTTP_WRITE_FUNCTION_DATE, value);
		break;
	case PCS_OPTION_HTTP_RESPONSE_FUNCTION:
		pcs_http_setopt(pcs->http, PCS_HTTP_OPTION_HTTP_RESPONSE_FUNCTION, value);
		break;
	case PCS_OPTION_HTTP_RESPONSE_FUNCTION_DATE:
		pcs_http_setopt(pcs->http, PCS_HTTP_OPTION_HTTP_RESPONSE_FUNCTION_DATE, value);
		break;
	case PCS_OPTION_PROGRESS_FUNCTION:
		pcs_http_setopt(pcs->http, PCS_HTTP_OPTION_PROGRESS_FUNCTION, value);
		break;
	case PCS_OPTION_PROGRESS_FUNCTION_DATE:
		pcs_http_setopt(pcs->http, PCS_HTTP_OPTION_PROGRESS_FUNCTION_DATE, value);
		break;
	case PCS_OPTION_PROGRESS:
		pcs_http_setopt(pcs->http, PCS_HTTP_OPTION_PROGRESS, value);
		break;
	default:
		pcs_set_errmsg(handle, "Unknown option");
		res = PCS_UNKNOWN_OPT;
		break;
	}
	return res;
}
开发者ID:imzjy,项目名称:baidupcs,代码行数:48,代码来源:pcs.c


示例8: cb_get_verify_code_byurlc_curl_write

static size_t cb_get_verify_code_byurlc_curl_write(char *ptr, size_t size, size_t nmemb, void *userdata)
{
	char **html = (char **) userdata;
	char *p;
	size_t sz, ptrsz;

	ptrsz = size * nmemb;
	if (ptrsz == 0)
		return ptrsz;

	if (*html)
		sz = strlen(*html);
	else
		sz = 0;
	size = sz + ptrsz;
	p = (char *) pcs_malloc(size + 1);
	if (!p)
		return 0;
	if (*html) {
		memcpy(p, *html, sz);
		pcs_free(*html);
	}
	memcpy(&p[sz], ptr, ptrsz);
	p[size] = '\0';
	*html = p;
	return ptrsz;
}
开发者ID:abitduck,项目名称:baidupcs,代码行数:27,代码来源:shell.c


示例9: strlen

PCS_API char *pcs_utils_strcat(char *dst, const char *src, int src_len, int free_dst)
{
	char *res = 0;
	int dst_len;

	if (!src)
		return dst;
	if (src_len == -1)
		src_len = strlen(src);
	if (src_len == 0)
		return dst;

	if (dst)
		dst_len = strlen(dst);
	else
		dst_len = 0;

	res = (char *)pcs_malloc(dst_len + src_len + 1);
	if (!res)
		return 0;
	memcpy(res, dst, dst_len);
	memcpy(res + dst_len, src, src_len);
	res[dst_len + src_len] = '\0';
	if (dst && free_dst)
		pcs_free(dst);
	return res;
}
开发者ID:786259135,项目名称:BaiduPCS,代码行数:27,代码来源:pcs_utils.c


示例10: strcpy

/*
* 获取路径的父路径,如果没有父路径则返回NULL。
*   path  - 当前路径
*   len   - path的字节长度,如果传入-1,则内部使用strlen()获取其长度
* 返回值需要调用pcs_free()
*/
char *base_dir(const char *path, int len)
{
	char *dir, *p;
	if (!path) return NULL;
	if (len == -1) len = strlen(path);
	if (len == 0) return NULL;
	dir = (char *)pcs_malloc(len + 1);
	strcpy(dir, path);
	p = dir + len - 1;
	while (p > dir && *p != '/' && *p != '\\') p--;
	if (p == dir) {
		if (*p != '/' && *p != '\\') {
			pcs_free(dir);
			return NULL;
		}
		p[1] = '\0';
	}
	else {
#ifdef _WIN32
		if (*(p - 1) == ':' && ((p - dir) == 2))
			*(p + 1) = '\0';
		else
			*p = '\0';
#else
		*p = '\0';
#endif
	}
	return dir;
}
开发者ID:hepking,项目名称:BaiduPCS,代码行数:35,代码来源:utils.c


示例11: pcs_http_get_content_length_from_header

static inline int pcs_http_get_content_length_from_header(const char *header, int size)
{
	int res = -1;
	char *val = NULL;
	const char *p = header, *key = "Content-Length",
		*end = NULL,
		*tmp;
	int i = 14;//strlen(key) = 14;
	while (*p) {
		if (*p == key[0] && pcs_utils_streq(p, key, i)) {
			tmp = p + i;
			PCS_SKIP_SPACE(tmp);
			if (*tmp != ':') continue; tmp++;
			PCS_SKIP_SPACE(tmp);
			end = tmp;
			while (*end && *end >= '0' && *end <= '9') end++;
			if (end > tmp) {
				val = (char *)pcs_malloc(end - tmp + 1);
				memcpy(val, tmp, end - tmp);
				val[end - tmp] = '\0';
				res = atoi(val);
				pcs_free(val);
				break;
			}
		}
		p++;
	}
	return res;
}
开发者ID:786259135,项目名称:BaiduPCS,代码行数:29,代码来源:pcs_http.c


示例12: exec_cat

static void exec_cat(Pcs pcs, struct params *params)
{
	const char *res;
	size_t sz;

	printf("\nCat %s\n", params->args[0]);
	res = pcs_cat(pcs, params->args[0], &sz);
	if (res == NULL) {
		printf("Cat failed: %s\n", pcs_strerror(pcs));
		return;
	}
	if (params->is_rc4) {
		const char *rc4_key = get_rc4_key(params);
		char *text;
		RC4_CTX rc4;
		secure_rc4_setup(&rc4, rc4_key);
		text = (char *)pcs_malloc(sz + 1);
		memset(text, 0, sz + 1);
		RC4(&rc4, sz, (const unsigned char *)res, (unsigned char *)text);
		text[sz] = '\0';
		printf(">>>\n%s\n<<<\n", text);
		pcs_free(text);
	}
	else {
		printf(">>>\n%s\n<<<\n", res);
	}
}
开发者ID:abitduck,项目名称:baidupcs,代码行数:27,代码来源:shell.c


示例13: pcs_http_create

PCS_API PcsHttp pcs_http_create(const char *cookie_file)
{
	struct pcs_http *http;

	http = (struct pcs_http *) pcs_malloc(sizeof(struct pcs_http));
	if (!http)
		return NULL;
	memset(http, 0, sizeof(struct pcs_http));
	http->timeout = 0;
	http->connect_timeout = 10;
	http->curl = curl_easy_init();
	if (!http->curl) {
		pcs_free(http);
		return NULL;
	}
	curl_easy_setopt(http->curl, CURLOPT_SSL_VERIFYPEER, 0L);
	curl_easy_setopt(http->curl, CURLOPT_SSL_VERIFYHOST, 0L);
	curl_easy_setopt(http->curl, CURLOPT_LOW_SPEED_LIMIT, 1024L);
	curl_easy_setopt(http->curl, CURLOPT_LOW_SPEED_TIME, 60L);
	curl_easy_setopt(http->curl, CURLOPT_SSL_VERIFYHOST, 0L);
	curl_easy_setopt(http->curl, CURLOPT_USERAGENT, USAGE);
	curl_easy_setopt(http->curl, CURLOPT_FOLLOWLOCATION, 1L);
	if (cookie_file) {
		curl_easy_setopt(http->curl, CURLOPT_COOKIEFILE, cookie_file);
		curl_easy_setopt(http->curl, CURLOPT_COOKIEJAR, cookie_file);
	}
	else {
		curl_easy_setopt(http->curl, CURLOPT_COOKIEFILE, "");
	}
	return http;
}
开发者ID:786259135,项目名称:BaiduPCS,代码行数:31,代码来源:pcs_http.c


示例14: exec_echo_override

static void exec_echo_override(Pcs pcs, struct params *params)
{
	char *text;
	size_t sz;
	PcsFileInfo *f;

	printf("\nOverwrite text to %s\n", params->args[0]);
	sz = strlen(params->args[1]);
	if (params->is_rc4) {
		const char *rc4_key = get_rc4_key2(params);
		RC4_CTX rc4;
		secure_rc4_setup(&rc4, rc4_key);
		text = (char *)pcs_malloc(sz + 1);
		memset(text, 0, sz + 1);
		RC4(&rc4, sz, (const unsigned char *)params->args[1], (unsigned char *)text);
		text[sz] = '\0';
		f = pcs_upload_buffer(pcs, params->args[0], PcsTrue, text, sz);
		pcs_free(text);
	}
	else {
		text = params->args[1];
		f = pcs_upload_buffer(pcs, params->args[0], PcsTrue, text, sz);
	}
	if (f) {
		pcs_fileinfo_destroy(f);
		printf("Overwirte success\n", params->args[0]);
	} else {
		printf("Overwirte failed\n", params->args[0]);
	}
}
开发者ID:abitduck,项目名称:baidupcs,代码行数:30,代码来源:shell.c


示例15: va_copy

PCS_API char *pcs_utils_vsprintf(const char *fmt, va_list ap)
{
    int cnt, sz=0;
    char *buf;
	va_list ap_try;

#ifdef WIN32
	sz = 4096;
#else
	sz = 1024;
#endif
	buf = (char*)pcs_malloc(sz);
try_print:
	va_copy(ap_try, ap);
	cnt = vsnprintf(buf, sz - 1, fmt, ap_try);
	va_end(ap_try);
	if (cnt > sz) {
		pcs_free(buf);
        sz *= 2;
		buf = (char*)pcs_malloc(sz);
		goto try_print;
    }
	if (cnt < 0) return NULL;
	buf[cnt] = '\0';
	return buf;
}
开发者ID:786259135,项目名称:BaiduPCS,代码行数:26,代码来源:pcs_utils.c


示例16: curl_easy_getinfo

PCS_API char *pcs_http_cookie_data(PcsHttp handle)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	CURLcode res;
	struct curl_slist *cookies;
	struct curl_slist *nc;
	char *data = NULL,
		*p;
	int sz = 0, i = 0;

	res = curl_easy_getinfo(http->curl, CURLINFO_COOKIELIST, &cookies);
	if (res != CURLE_OK) {
		return NULL;
	}
	nc = cookies;
	while (nc) {
		i = strlen(nc->data);
		if (!data) {
			data = (char *)pcs_malloc(i + 2);
			if (!data) {
				curl_slist_free_all(cookies);
				return NULL;
			}
			memcpy(data, nc->data, i);
			memcpy(data + i, "\n\0", 2);
			sz = i + 1;
		}
		else {
			p = (char *)pcs_malloc(sz + i + 2);
			if (!p) {
				pcs_free(data);
				curl_slist_free_all(cookies);
				return NULL;
			}
			memcpy(p, data, sz);
			memcpy(p + sz, nc->data, i);
			sz += i;
			memcpy(p + sz, "\n\0", 2);
			pcs_free(data);
			data = p;
			sz++;
		}
		nc = nc->next;
	}
	curl_slist_free_all(cookies);
	return data;
}
开发者ID:786259135,项目名称:BaiduPCS,代码行数:47,代码来源:pcs_http.c


示例17: pcs_clear_errmsg

void pcs_clear_errmsg(Pcs handle)
{
	struct pcs *pcs = (struct pcs *)handle;
	if (pcs->errmsg) {
		pcs_free(pcs->errmsg);
		pcs->errmsg = NULL;
	}
}
开发者ID:imzjy,项目名称:baidupcs,代码行数:8,代码来源:pcs.c


示例18: pcs_http_form_destroy

PCS_API void pcs_http_form_destroy(PcsHttp handle, PcsHttpForm post)
{
	struct http_post *formpost = (struct http_post *)post;
	if (formpost) {
		curl_formfree(formpost->formpost);
		pcs_free(formpost);
	}
}
开发者ID:786259135,项目名称:BaiduPCS,代码行数:8,代码来源:pcs_http.c


示例19: pcs_http_reset_response

static inline void pcs_http_reset_response(struct pcs_http *http)
{
	if (http->res_body)
		pcs_free(http->res_body);
	if (http->res_header)
		pcs_free(http->res_header);
	if (http->res_encode)
		pcs_free(http->res_encode);
	http->res_type = PCS_HTTP_RES_TYPE_NORMAL;
	http->res_code = 0;
	http->res_header = NULL;
	http->res_header_size = 0;
	http->res_body = NULL;
	http->res_body_size = 0;
	http->res_content_length = 0;
	http->res_encode = 0;
	http->strerror = NULL;
}
开发者ID:imzjy,项目名称:baidupcs,代码行数:18,代码来源:pcs_http.c


示例20: shell_args_destroy_params

void shell_args_destroy_params(struct params *params)
{
	int i;
	if (params->username) pcs_free(params->username);
	if (params->password) pcs_free(params->password);
	if (params->sort) pcs_free(params->sort);
	if (params->cookie) pcs_free(params->cookie);
	if (params->rc4_key) pcs_free(params->rc4_key);
	if (params->args) {
		for (i = 0; i < params->args_count; i++) {
			pcs_free(params->args[i]);
		}
		pcs_free(params->args);
	}
	if (params->config) pcs_free(params->config);
	if (params->cache) pcs_free(params->cache);
	pcs_free(params);
}
开发者ID:abitduck,项目名称:baidupcs,代码行数:18,代码来源:shell_args.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pcsl_mem_free函数代码示例发布时间:2022-05-30
下一篇:
C++ pcre_study函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap