资源简介
httpsqs-1.7.tar.gz,
代码片段和文件信息
/*
HTTP Simple Queue Service - httpsqs v1.7
Author: Zhang Yan (http://blog.s135.com) E-mail: net@s135.com
This is free software and you are welcome to modify and redistribute it under the New BSD License
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “prename.h“
#define VERSION “1.7“
/* 每个队列的默认最大长度为100万条 */
#define HTTPSQS_DEFAULT_MAXQUEUE 1000000
/* 全局设置 */
TCBDB *httpsqs_db_tcbdb; /* 数据表 */
int httpsqs_settings_syncinterval; /* 同步更新内容到磁盘的间隔时间 */
char *httpsqs_settings_pidfile; /* PID文件 */
char *httpsqs_settings_auth; /* 验证密码 */
/* 创建多层目录的函数 */
void create_multilayer_dir( char *muldir )
{
int ilen;
char str[512];
strncpy( str muldir 512 );
len=strlen(str);
for( i=0; i {
if( str[i]==‘/‘ )
{
str[i] = ‘\0‘;
//判断此目录是否存在不存在则创建
if( access(str F_OK)!=0 )
{
mkdir( str 0777 );
}
str[i]=‘/‘;
}
}
if( len>0 && access(str F_OK)!=0 )
{
mkdir( str 0777 );
}
return;
}
char *urldecode(char *input_str)
{
int len = strlen(input_str);
char *str = strdup(input_str);
char *dest = str;
char *data = str;
int value;
int c;
while (len--) {
if (*data == ‘+‘) {
*dest = ‘ ‘;
}
else if (*data == ‘%‘ && len >= 2 && isxdigit((int) *(data + 1))
&& isxdigit((int) *(data + 2)))
{
c = ((unsigned char *)(data+1))[0];
if (isupper(c))
c = tolower(c);
value = (c >= ‘0‘ && c <= ‘9‘ ? c - ‘0‘ : c - ‘a‘ + 10) * 16;
c = ((unsigned char *)(data+1))[1];
if (isupper(c))
c = tolower(c);
value += c >= ‘0‘ && c <= ‘9‘ ? c - ‘0‘ : c - ‘a‘ + 10;
*dest = (char)value ;
data += 2;
len -= 2;
} else {
*dest = *data;
}
data++;
dest++;
}
*dest = ‘\0‘;
return str;
}
/* 读取队列写入点的值 */
static int httpsqs_read_putpos(const char* httpsqs_input_name)
{
int queue_value =
评论
共有 条评论