0

3649

初试swig编写php扩展

先写一段C代码:

#include <stdio.h>
#include <string.h>

char *hello(char *s)
{
    int num = strlen(s);
    //printf("string len is %i",num);
    char ns[num];
    int i;
    for(i=0; i<num; i++)
    {
        ns[(num-1)-i] = s[i];
    }
    char *result = ns;
    return result;
}

代码意思很简单喔,就是一个hello函数,该函数的作用是接收一个字符串参数,把字符串进行反转,然后返回。

现在,针对这个c函数,把它加入php的扩展(动态库方式),步骤如下:

1、将c的源文件编译成目标文件

cc -fpic -c hello.c

2、编写swig翻译文件hello.i ……

乐果   发表于   2015 年 05 月 13 日 标签:swigPHP 继续阅读

0

2321

c语言的那些坑---数组

1、arr[0]与0[arr]等价。

2、int *choise = contestants;int *choise = &contestants[0];等价。

#include <stdio.h>

int main(){

    int  contestants[] = {1,2,3};
    int *choise = contestants;
    contestants[0]  = 4;
    contestants[1] = contestants[2];
    contestants[2] = *choise;
    printf("%i,%i,%i",0[contestants],1[contestants],2[contestants]);
    //4,3,4
    printf("%i,%i,%i",contestants[0],contestants[1],contestants[2]);
    //4,3,4
    return 0;

}

乐果   发表于   2015 年 05 月 12 日 标签:c 继续阅读

0

2544

memcached编译安装

然后下载 libevent 然后上传centos,进行给予权限,然后解压

tar xzvf libevent-2.0.21-stable.tar.gz ##解压 
cd libevent-2.0.21-stable 
./configure --prefix=/usr 
make 
make install 

安装完后可以查看下/usr/lib是否有libevent等文件(ls -al /usr/lib | grep libevent)

然后下载 memcached

tar xzvf memcached-1.4.15.tar.gz 
cd memcached-1.4.15 
./configure --with-libevent=/usr 
make 
make install 

关于memcache启动的一些参数说明:

memcached命令参数解释: 
-p <num>          监听的端口 
-l <ip_addr>      连接的IP地址, 默认是本机 
......

乐果   发表于   2015 年 04 月 18 日 标签:memcached 继续阅读

0

1715

使用openssl制作证书

1、服务器单向验证 创建并进入sslkey存放目录

mkdir /opt/nginx/sslkey
cd /opt/nginx/sslkey

①、生成RSA密钥:

openssl genrsa -out key.pem 2048

②、生成一个证书请求

openssl req -new -key key.pem -out cert.csr
......

乐果   发表于   2015 年 04 月 18 日 标签:nginx 继续阅读

1

8422

mac编译安装nginx的那些坑

去官网下载nginx压缩包解压后,进入根目录,执行:

./configure \
--prefix=/data/service/nginx \
--sbin-path=/data/service/nginx/sbin/nginx \
--conf-path=/data/service/nginx/conf/nginx.conf \
--pid-path=/data/service/nginx/logs/nginx.pid \
--lock-path=/data/service/nginx/lock/nginx.lock \
--error-log-path=/data/service/nginx/logs/error.log \
--http-log-path=/data/service/nginx/logs/access.log \
--http-scgi-temp-path=/data/service/nginx/scgi \
--http-uwsgi-temp-path=/data/service/nginx/uwsgi \
--http-proxy-temp-path=/data/service/nginx/proxy \
--http-fastcgi-temp-path=/data/service/nginx/fastcig \
--http-client-body-temp-path=/data/service/nginx/body \
--user=nobody \
--group=nogroup \
--with-ipv6 \
......

乐果   发表于   2015 年 04 月 13 日 标签:mac 继续阅读

较旧的文章 较新的文章
热评文章