第二基地

September 17, 2006

blogger’s feed

Filed under: linux

http://fvwmer.blogspot.com/atom.xml

这边不更新了

Filed under: linux

觉得新的blogger更好一点,搬过去了,而且这边速度比较慢,所以就停止更新了,有需要请访问http://fvwmer.blogspot.com,或者点击右边链接里的“新家”

August 12, 2006

到目前为止的进展

Filed under: linux, program

在写一个google talk的客户端,目前为止核心还没有完成,打算先实现xmpp规定的功能特性的一个基本子集
我发现google的talk服务器也并不是严格地实现了所有xmpp的服务器端功能特性,比如说客户端发送的流里存在某些错误的时候talk.google.com并不会返回错误的类型,而是直接发送</stream>然后关闭所有已建立的连接,比较暴力,呵呵
现在存在的问题的:因为xml解析器用的是expat,基于回调函数,限制非常大,因为我不可能把什么东西都通过expat传递给回调函数,那样就破坏了各个模块的独立性。所以打算第一个版本就expat了,但是完成之后第一件事就是自己实现一个针对xmpp的解析器,不会很复杂,差不多应该相当于一个词法分析器的复杂度?
这两天停下来了,因为要实习,累得开不了工,还有一个原因是我还没想好要怎么处理<message></message>,因为这里会涉及到后面的gui和cli要用到的接口,不考虑全面一点以后免不了要重写
收获还是很大的

August 7, 2006

atoi?itoa?

Filed under: linux, program, C

atoi ()是库函数,用于把字符串转换成整数,实现起来相当容易,于是我傻乎乎地开始去找itoa,找了一圈,终于发现了,没有itoa啊
然后转念一想,要itoa做什么!真要的话自己写一个,几分钟的事情,但是现成的sprintf放这儿不用就真的傻了
而且sprintf显然更方便,因为它有转义字符可以控制输出的格式,于是结论:C语言哪里需要什么itoa嘛!

July 28, 2006

解压一大堆文件的脚本

Filed under: linux, program, bash

#!/bin/bash
do_dir ()
{
cd $1
for i in *
do
if [[ -f $i ]]
then
decompress $i
elif [[ $i == "." ]] || [[ $i == ".." ]]
then
continue
elif [[ -d $i ]]
then
[[ $recue == 1 ]] && do_dir $i
fi
done
}

decompress ()
{
case $1 in

*.tar.bz2)
tar jxvf $1
;;
*.tar.gz)
tar zxvf $1
;;
*.rar)
rar x $1
;;
*.gz)
gzip -d $1
;;
*.bz2)
bzip2 -d $1
;;
*)
echo "$1:not a compressed file,do nothing"
return
;;
esac
[[ $del == 1 ]] && rm $1
}

get_help ()
{
echo "this bash script is written to get all the compressed files under a directory to be uncompressed."
echo "Usage:tarball.sh [OPTION] [DIR]"
echo "OPTION:"
echo -e "\t-r\trecursively"
echo -e "\t-d\tremove the file after decompress it"
}

if [[ $# == 0 ]]
then
echo "no arguments detected,do you want to continue or just get help?[c/H]:"
read help
fi

[[ $help != "c" ]] && get_help && exit 0

for arg in $@
do
case $arg in
-r)
recue=1
;;
-d)
del=1
;;
-h)
get_help
exit 0
;;
-*)
echo "unknown arg:$arg"
echo "type tarball.sh -h to get help"
get_help
exit 1
;;
*)
[[ $arg != $0 ]] && [ -d $arg ] && name=$arg
;;
esac
done

if [[ -n $name ]]
then
do_dir $name
else
do_dir "."
fi






















Get free blog up and running in minutes with Blogsome | Theme designs available here