LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: phc

Linux/Unix下多线程代理验证工具Phc1.1正式版放出

[复制链接]
发表于 2005-10-18 23:22:23 | 显示全部楼层
红色的代码用意何在?
要是我就这样写

  1.     void
  2. xfree (void **p)
  3. {
  4.     assert(p != NULL);
  5.     if(*p != NULL){
  6.         free(*p);
  7.         *p = NULL;
  8.     }
  9. };
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-18 23:30:02 | 显示全部楼层
Post by dorice
呵呵,我自己写了一个类似于windows下的花刺代理验证的东西自己用,已经足够了,采用kylix开发,有windows和linux两个版本

你的工具是不是支持复杂匹配的?下面窗口的"{"是?

呵呵,kylix没学过,希望将来有机会学,:-).
回复 支持 反对

使用道具 举报

发表于 2005-10-18 23:36:16 | 显示全部楼层
就是支持正则表达式而已
我是用正则表达式在网页上找到代理的地址和端口的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-18 23:38:47 | 显示全部楼层
Post by 小锁
红色的代码用意何在?
要是我就这样写

  1.     void
  2. xfree (void **p)
  3. {
  4.     assert(p != NULL);
  5.     if(*p != NULL){
  6.         free(*p);
  7.         *p = NULL;
  8.     }
  9. };
复制代码


assert(*p != NULL)?
避免free(0)的发生. p!=NULL不能保证*p!=NULL.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-18 23:43:22 | 显示全部楼层
Post by dorice
就是支持正则表达式而已
我是用正则表达式在网页上找到代理的地址和端口的

我写了一个抓取bbs上的代理的简单脚本,不同的网站要用不同的脚本了,
还没有想过把抓取规则写入代码,:-).
回复 支持 反对

使用道具 举报

发表于 2005-10-18 23:49:22 | 显示全部楼层
Post by phc
assert(*p != NULL)?
避免free(0)的发生. p!=NULL不能保证*p!=NULL.

free(null)不会发生任何事情,但是p == NULL时,肯定发生段错误,这个输入函数用错,所以用
assert来断言,并且我对*p == NULL的情况有所考虑。
你没看到你if()后面的";"?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-19 00:04:50 | 显示全部楼层
Post by 小锁
free(null)不会发生任何事情,但是p == NULL时,肯定发生段错误,这个输入函数用错,所以用
assert来断言,并且我对*p == NULL的情况有所考虑。
你没看到你if()后面的";"?


非常感谢,那个";"错的太恶了!我这里的字体设置的看不清楚,
同意,作为一个完整的xfree函数,p = NULL的特殊情况也需要考虑,

回看了一下源程序,原来想实现的也是这个效果,但是多处这种错误...
当时一定在daydream,呵呵.
free(NULL)在标准的free实现下的确不会发生事情,写在这里只是为了buggy的free实现,或许多虑了,:-).
Btw,期待有更多的错误发现!
回复 支持 反对

使用道具 举报

发表于 2005-10-19 13:08:33 | 显示全部楼层
刚才下载了,可是 ./configure时出了个问题,我对这些不怎么懂,将过程贴出来吧:


  1. # ./configure
  2. checking for a BSD-compatible install... /usr/bin/install -c
  3. checking whether build environment is sane... yes
  4. checking whether make sets $(MAKE)... yes
  5. checking for working aclocal-1.4... missing
  6. checking for working autoconf... missing
  7. checking for working automake-1.4... missing
  8. checking for working autoheader... missing
  9. checking for working makeinfo... missing
  10. checking for gcc... gcc
  11. checking for C compiler default output file name... configure: error: C compiler cannot create executables
  12. See `config.log' for more details.
复制代码


下面是config.log文件内容:

  1. This file contains any messages produced by compilers while
  2. running configure, to aid debugging if configure makes a mistake.

  3. It was created by src/phc.c configure 1.1, which was
  4. generated by GNU Autoconf 2.59.  Invocation command line was

  5.   $ ./configure

  6. ## --------- ##
  7. ## Platform. ##
  8. ## --------- ##

  9. hostname = YQ.SCU
  10. uname -m = i686
  11. uname -r = 2.6.8-2-k7
  12. uname -s = Linux
  13. uname -v = #1 Thu May 19 18:03:29 JST 2005

  14. /usr/bin/uname -p = unknown
  15. /bin/uname -X     = unknown

  16. /bin/arch              = i686
  17. /usr/bin/arch -k       = unknown
  18. /usr/convex/getsysinfo = unknown
  19. hostinfo               = unknown
  20. /bin/machine           = unknown
  21. /usr/bin/oslevel       = unknown
  22. /bin/universe          = unknown

  23. PATH: /usr/local/sbin
  24. PATH: /usr/local/bin
  25. PATH: /usr/sbin
  26. PATH: /usr/bin
  27. PATH: /sbin
  28. PATH: /bin
  29. PATH: /usr/bin/X11


  30. ## ----------- ##
  31. ## Core tests. ##
  32. ## ----------- ##

  33. configure:1347: checking for a BSD-compatible install
  34. configure:1402: result: /usr/bin/install -c
  35. configure:1413: checking whether build environment is sane
  36. configure:1456: result: yes
  37. configure:1471: checking whether make sets $(MAKE)
  38. configure:1491: result: yes
  39. configure:1523: checking for working aclocal-1.4
  40. configure:1534: result: missing
  41. configure:1538: checking for working autoconf
  42. configure:1549: result: missing
  43. configure:1553: checking for working automake-1.4
  44. configure:1564: result: missing
  45. configure:1568: checking for working autoheader
  46. configure:1579: result: missing
  47. configure:1583: checking for working makeinfo
  48. configure:1594: result: missing
  49. configure:1647: checking for gcc
  50. configure:1663: found /usr/bin/gcc
  51. configure:1673: result: gcc
  52. configure:1917: checking for C compiler version
  53. configure:1920: gcc --version </dev/null >&5
  54. gcc (GCC) 4.0.2 (Debian 4.0.2-2)
  55. Copyright (C) 2005 Free Software Foundation, Inc.
  56. This is free software; see the source for copying conditions.  There is NO
  57. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  58. configure:1923: $? = 0
  59. configure:1925: gcc -v </dev/null >&5
  60. Using built-in specs.
  61. Target: i486-linux-gnu
  62. Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
  63. Thread model: posix
  64. gcc version 4.0.2 (Debian 4.0.2-2)
  65. configure:1928: $? = 0
  66. configure:1930: gcc -V </dev/null >&5
  67. gcc: '-V' option must have argument
  68. configure:1933: $? = 1
  69. configure:1956: checking for C compiler default output file name
  70. configure:1959: gcc    conftest.c  >&5
  71. /usr/bin/ld: crt1.o: No such file: No such file or directory
  72. collect2: ld returned 1 exit status
  73. configure:1962: $? = 1
  74. configure: failed program was:
  75. | /* confdefs.h.  */
  76. |
  77. | #define PACKAGE_NAME "src/phc.c"
  78. | #define PACKAGE_TARNAME "src-phc-c"
  79. | #define PACKAGE_VERSION "1.1"
  80. | #define PACKAGE_STRING "src/phc.c 1.1"
  81. | #define PACKAGE_BUGREPORT ""
  82. | #define PACKAGE "phc"
  83. | #define VERSION "1.1"
  84. | /* end confdefs.h.  */
  85. |
  86. | int
  87. | main ()
  88. | {
  89. |
  90. |   ;
  91. |   return 0;
  92. | }
  93. configure:2001: error: C compiler cannot create executables
  94. See `config.log' for more details.

  95. ## ---------------- ##
  96. ## Cache variables. ##
  97. ## ---------------- ##

  98. ac_cv_env_CC_set=
  99. ac_cv_env_CC_value=
  100. ac_cv_env_CFLAGS_set=
  101. ac_cv_env_CFLAGS_value=
  102. ac_cv_env_CPPFLAGS_set=
  103. ac_cv_env_CPPFLAGS_value=
  104. ac_cv_env_CPP_set=
  105. ac_cv_env_CPP_value=
  106. ac_cv_env_LDFLAGS_set=
  107. ac_cv_env_LDFLAGS_value=
  108. ac_cv_env_build_alias_set=
  109. ac_cv_env_build_alias_value=
  110. ac_cv_env_host_alias_set=
  111. ac_cv_env_host_alias_value=
  112. ac_cv_env_target_alias_set=
  113. ac_cv_env_target_alias_value=
  114. ac_cv_path_install='/usr/bin/install -c'
  115. ac_cv_prog_ac_ct_CC=gcc
  116. ac_cv_prog_make_make_set=yes

  117. ## ----------------- ##
  118. ## Output variables. ##
  119. ## ----------------- ##

  120. ACLOCAL='/mnt/data/ftp/software/phc-1.1/missing aclocal-1.4'
  121. AUTOCONF='/mnt/data/ftp/software/phc-1.1/missing autoconf'
  122. AUTOHEADER='/mnt/data/ftp/software/phc-1.1/missing autoheader'
  123. AUTOMAKE='/mnt/data/ftp/software/phc-1.1/missing automake-1.4'
  124. CC='gcc'
  125. CFLAGS=''
  126. CPP=''
  127. CPPFLAGS=''
  128. DEFS=''
  129. ECHO_C=''
  130. ECHO_N='-n'
  131. ECHO_T=''
  132. EGREP=''
  133. EXEEXT=''
  134. INSTALL_DATA='${INSTALL} -m 644'
  135. INSTALL_PROGRAM='${INSTALL}'
  136. INSTALL_SCRIPT='${INSTALL}'
  137. LDFLAGS=''
  138. LIBOBJS=''
  139. LIBS=''
  140. LTLIBOBJS=''
  141. MAKEINFO='/mnt/data/ftp/software/phc-1.1/missing makeinfo'
  142. OBJEXT=''
  143. PACKAGE='phc'
  144. PACKAGE_BUGREPORT=''
  145. PACKAGE_NAME='src/phc.c'
  146. PACKAGE_STRING='src/phc.c 1.1'
  147. PACKAGE_TARNAME='src-phc-c'
  148. PACKAGE_VERSION='1.1'
  149. PATH_SEPARATOR=':'
  150. PTHREAD_CC=''
  151. PTHREAD_CFLAGS=''
  152. PTHREAD_LIBS=''
  153. SET_MAKE=''
  154. SHELL='/bin/sh'
  155. VERSION='1.1'
  156. ac_ct_CC='gcc'
  157. acx_pthread_config=''
  158. bindir='${exec_prefix}/bin'
  159. build=''
  160. build_alias=''
  161. build_cpu=''
  162. build_os=''
  163. build_vendor=''
  164. datadir='${prefix}/share'
  165. exec_prefix='NONE'
  166. host=''
  167. host_alias=''
  168. host_cpu=''
  169. host_os=''
  170. host_vendor=''
  171. includedir='${prefix}/include'
  172. infodir='${prefix}/info'
  173. libdir='${exec_prefix}/lib'
  174. libexecdir='${exec_prefix}/libexec'
  175. localstatedir='${prefix}/var'
  176. mandir='${prefix}/man'
  177. oldincludedir='/usr/include'
  178. prefix='NONE'
  179. program_transform_name='s,x,x,'
  180. sbindir='${exec_prefix}/sbin'
  181. sharedstatedir='${prefix}/com'
  182. sysconfdir='${prefix}/etc'
  183. target_alias=''

  184. ## ----------- ##
  185. ## confdefs.h. ##
  186. ## ----------- ##

  187. #define PACKAGE "phc"
  188. #define PACKAGE_BUGREPORT ""
  189. #define PACKAGE_NAME "src/phc.c"
  190. #define PACKAGE_STRING "src/phc.c 1.1"
  191. #define PACKAGE_TARNAME "src-phc-c"
  192. #define PACKAGE_VERSION "1.1"
  193. #define VERSION "1.1"

  194. configure: exit 77
复制代码
回复 支持 反对

使用道具 举报

发表于 2005-10-19 13:36:26 | 显示全部楼层
....
回复 支持 反对

使用道具 举报

发表于 2005-10-19 13:39:32 | 显示全部楼层
如果是我会这样写。。
#define  xfree (p) do { \
       free (p); \
       p = NULL; \
} while (0)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表