- 博客(12)
- 收藏
- 关注
原创 Call tzset() before chroot()
在看lighttpd源码的时候,发现在chroot()之前调用了tzset()。由于之前都没怎么 考虑过时区的问题,所以觉得比较莫名奇妙,时区和chroot()有什么关系呢? man tzset发现了问题所在: If the TZ variable does not appear in the environment, the tzname vari‐
2012-09-01 16:48:31
791
原创 Use OpenSSL API to connect to Lighttpd Server
0. 前提条件 关于SSL和OpenSSL的工作原理比较复杂,我只是了解一二, 所以这里并不会讲解SSL和OpenSSL到底是如何工作的,下面 仅给出一些相关参考资料: SSL的工作原理:RFC6101OpenSSL官网:http://www.openssl.org使用OpenSSL API进行安全编程:http://www.ibm.com/developerworks/cn/linu
2012-08-22 16:57:22
928
原创 Write CGI with Python (Lighttpd Server)
1. Add the following configurations to your lighttpd.conf: server.modules = ( "mod_cgi" ) cgi.assign = ( ".py" => "/usr/bin/python2" )2. Write a simple website as an interface to add two integers:
2012-08-21 16:59:37
1469
原创 My first Python Program -- Command line Address Book
花了几个小时把A Byte of Python看完以后,我觉得Python确实是简洁易用。 A Byte of Python最后面让大家写一个Command line address book练一下手, 于是就有了我的第一个Python程序了,直接上代码,没什么好解释的。 #!/usr/bin/python2 # Filename: address_book.py import o
2012-08-21 10:05:02
1245
原创 Linux - 创建与使用动态链接库
1.创建动态链接库hello.so: #include void hello(void) { printf("Hello, this is hello.so\n"); }$gcc -fpic -shared -o hello.so hello_so.c 2.使用动态链接库hello.so: #include #include #include int main(i
2012-08-16 10:05:56
1431
原创 Lighttpd - Configuration
配置文件应该是lighttpd源代码里面比较难的一部分,其中涉及了大量的结构体、变量、函数, parser部分还涉及了一些编译原理的知识。这一部分我看了好几天,每天看之前都要复习一下 几个重要的结构体的组成和它们之间的关系。 我打算在对lighttpd的整个框架都理解透了以后再写分析,因为单独去分析某个部分的话会让人 不理解这个部分在整个项目中的作用,而且有些细节只有在理解整体之后才能
2012-08-15 12:29:37
1278
原创 Lemon Parser Generator
lighttpd的配置文件需要用到lemon来分析,lemon是一个LALR(1)的语法分析生成器。 本来以为要用到LALR(1)的知识,刚好上个学期学了编译原理这门课,但是由于课时 不够,Bottom-Up Parsing只讲了LR(0)和SLR(1),LR(1)和LALR(1)没讲到,所以在 尝试使用lemon之前特意花了一个小时去看了LR(1)和LALR(1)的知识。好在基础的 知识
2012-08-12 15:20:33
4231
转载 DJB hash function for strings
/* the famous DJB Hash Function for strings */ unsigned int DJBHash(char *str) { unsigned int hash = 5381; while (*str){ hash = ((hash << 5) + hash) + (*str++); /* times 33 */ } hash &= ~(1 <<
2012-08-10 22:48:21
6711
转载 Valgrind
The Valgrind tool suite provides a number of debugging and profiling tools that help you make your programs faster and more correct. The most popular of these tools is called Memcheck. It can detect
2012-08-10 16:05:00
531
原创 PCRE - Perl-compatible regular expressions
lighttpd的源码中,keyvalue这个数据结构用到了pcre库。之前没见过, google之后发现是一个正则表达式的库,顺便简单了解了一下使用方法。 关于PCRE库的介绍和使用方法可以看手册PCRE(3),PCRE的源码里 附带了一个pcredemo.c,里面注释很详细了,看完应该就会用了。 其实最简单的使用只需要知道两个函数(man pcreapi):
2012-08-09 23:09:30
939
转载 do...while(0)的妙用
转载自:http://www.cnblogs.com/baiyanhuang/archive/2009/09/16/1730736.html 在C++中,有三种类型的循环语句:for, while, 和do...while, 但是在一般应用中作循环时, 我们可能用for和while要多一些,do...while相对不受重视。 但是,最近在读我们项目的代码时,却发现了do..
2012-08-08 18:17:54
396
转载 Lighttpd - HTTPStates
第一次接触graphviz,看起来挺简单方便的,以后画状态图之类的可以考虑一下。 把下面代码保存为HTTPStates.dot #!graphviz digraph state { edge [color=green]; connect -> reqstart -> read -> reqend -> handlereq -> respstart -> write
2012-08-08 17:17:31
618
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅