8/31/2006

06年九月的第一天

   转眼夏天就过去了,8月已过去,现在快1点半了,但却没有睡意,在一边下载着文档,一边看着geekbone的资料。自从转投linux和c以来,发现自己需要提高的地方很多,当然也学到了不少东西。对AIX比较熟,照着网上的文档安装过一遍:),另外,Oracle也比较熟,安装基本没问题,基本配置也会,再就是tuxedo,这块以前接触最多的了,安装配置以及写service就不说了,我还写WTC(WebLogic Tuxedo Connector)相关程序,原本那个系统的WTC很简单,后端(这里主要指中间件)数据经过WTC,它啥事也不做,把数据tpforward给前置服务器Weblogic,但后来需要考虑数据安全的问题,于是后端传过来的数据需要加密后再发到前置。这时就需要改用tpacall了。
   后来接触到了MQ,消息中间件。感觉MQ配置、开发并不复杂,关键要真正理解MQ的设计思想、框架。两台主机通过MQ发送文件,一般有两种方式:1)建远程队列;2)群集(cluster)。
   以前只听说过HA切换,有幸见识到了它的真面目,记得HACMP的版本是5.3,IBM High Availability Cluster Multiprocessing for AIX 5L V5.3 (HACMP V5.3)。HA安装到没什么,关键是在此之前的规划,包括网络划分、备份方案(比如raid 0+1)等等,这个挺复杂的,最后就是切换脚本。
   目前主要做Linux桌面应用开发,算是做产品吧,以前做工程(项目开发)挺累的,不过能学到不少东西,现在挺怀念的:)既然我选择了Linux开源方向,就要坚持走下去吧,要继续提高编程能力,以及Linux内核的学习,另外,争取参加几个开源项目,加油!

8/30/2006

在Linux下对一个二进制文件的分析过程

拿到这个文件,首先应该分静态分析和动态分析。

对未明2进制文件分析工具简单总结:
静态考查:file、nm、strings、objdump
动态跟踪:strace、lstrace
动态调试: gdb、insight
反汇编 :ida

对未明2进制文件分析方法简单总结:

1. 外部观察,了解文件类型、行为和外部接口。

2. 静态分析,看看程序用了那些外部函数:
nm xxx -- 列出二进制文件中符号表
objdump -R xxx -- 列出文件中入口函数的名称

3. 静态考查更多的外部接口
静态分析可以通过strings来简单了解。

4. 用ida反汇编,静态考查我们以上发现的兴趣点

8/25/2006

svn的bug?

最近使用svn时遇到一个问题:如果上传到svn服务器上的文件为link文件,则可能出问题,svn checkout出来该link文件变为一个普通文件,不知道是不是svn的bug或者svn服务器配置的问题?

关于VIM插件介绍

http://learn.tsinghua.edu.cn:8080/2005212716/html/vimplugins.html

先贴个网页,待有空补充

8/24/2006

贴一下我的.vimrc

在linux下面写c/c++程序,我习惯使用vim,下面是我喜欢的配置,具体含义可以 :help

~/.vimrc:

" vim:shiftwidth=4:tabstop=4:expandtab
set background=dark
set nobackup
set nowritebackup
set autoindent
set showcmd
set showmatch
set formatoptions+=mM
set noincsearch
set hlsearch
set wrap
set wrapscan
set ruler
set shiftwidth=4
set tabstop=4
set showmode
set novisualbell
set nonumber
syntax on
" Key mapping to stop the search highlight
nmap :nohlsearch
imap :nohlsearch
"Ctrl+p 添加注释信息
map ^P o/*Comment by hzy


" 编辑当前文件所在目录下的另一个文件
" 使用表达式来从当前文件路径中解析出路径
if has("unix")
map ,e :e =expand("%:p:h") . "/"
else
map ,e :e =expand("%:p:h") . "\\"
endif

"setup cscope automaticly
if has("cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif

Linux下firefox插件开发

最近在这方面的工作,抽时间总结一下。

终于有点时间了 :)
机器环境:Linux 2.6.12-1.1456.cocreate.3
Firefox版本:firefox-1.5.0.3
编译Firefox:
1)安装mozilla开发包;
2)从 ftp://ftp.mozilla.org/pub/mozilla.org/mozilla/ 下载Firefox源码firefox-1.5.0.3-source.tar.bz2,下载中文语言包firefox-langpacks-cn-1.5.0.3.tar.bz2;
3)以上两个文件下载完毕后放到/usr/src/redhat/SOURCES/,然后在/usr/src/redhat/SPECS/编写编译打包用的spec文件firefox-1.5.x,关于RPM、SPEC等可参考
http://www.redhat.com/docs/manuals/linux/RHL-7-Manual/ref-guide/index.html;
其中语言安装脚本部分可以这么写:
# Install langpacks
%{__mkdir_p} $RPM_BUILD_ROOT%{_libdir}/firefox/extensions
%{__tar} xjf %{SOURCE23}
for langpack in `ls firefox-langpacks/*.xpi`; do
language=`basename $langpack .xpi`
extensiondir=$RPM_BUILD_ROOT%{_libdir}/firefox/extensions/langpack-$language@firefox.mozilla.org
%{__mkdir_p} $extensiondir
unzip $langpack -d $extensiondir
find $extensiondir -type f | xargs chmod 644

langtmp=%{_tmpdir}/%{name}/langpack-$language
%{__mkdir_p} $langtmp
jarfile=$extensiondir/chrome/$language.jar
unzip $jarfile -d $langtmp
find $langtmp -type f | xargs chmod 644
%{__rm} -rf $jarfile
cd $langtmp
zip -r -D $jarfile locale
%{__rm} -rf locale
cd -
done
%{__rm} -rf firefox-langpacks

4)运行rpmbuild -bl firefox-1.5.x 确认%files的路径等正确,然后编译:rpmbuild -ba firefox-1.5.x,经过大约40几分钟(如果机器配置差的话需要更长的时间),如果没有出错则编译成功,生成的文件在/usr/src/redhat/RPMS/i386/和/usr/src/redhat/SRPMS/;

下面进入主题,编写插件:
为简单起见可以将firefox源码包中的插件simple目录拷贝一份出来,然后直接修改相应文件,编写代码。完成后需要生成生成头文件和xpt文件,命令如下:
(1)生成头文件
/usr/lib/mozilla-1.7.12/xpidl -m header -I/usr/share/idl/mozilla-1.7.12
testplug.idl
(2)生成xpt文件
/usr/lib/mozilla-1.7.12/xpidl -m typelib -I/usr/share/idl/mozilla-1.7.12
testplug.idl

写spec文件,如下:
。。。
%prep
rm -rf %{buildroot}

%setup -n %{name} -q

%build
./configure
%{__make}

%install
%{__mkdir} -p %{buildroot}%{_libdir}/firefox/{plugins,components}
install -m755 src/.libs/libtestplug.so %{buildroot}%{_libdir}/firefox/plugins
install -m755 src/testplug.xpt %{buildroot}%{_libdir}/firefox/components
install -m644 demo.html %{buildroot}%{_libdir}/firefox/

%clean
rm -rf %{buildroot}

%files
%defattr (-,root,root)
%{_libdir}/firefox/plugins/libtestplug.so
%{_libdir}/firefox/components/testplug.xpt
%{_libdir}/firefox/demo.html

%changelog
。。。

编译成功后启动firefox就可以看到测试了。


<参考>
mozilla/modules/plugin/tools/sdk/samples(firefox插件sample文件)
http://www.mozilla.org/projects/plugins/npruntime.html
http://kb.mozillazine.org/Extension_development

运行时改变Linux的交换文件(来自网上资料)

内存不够用,而且用光交换分区空间的情况,导致无法正确安装、升级软件包。解决办法:
1、使用dd命令建立一个文件,作为交换文件;
2、使用mkswap命令初始化上一步中建立的文件;
3、使用swapon命令激活交换文件,这样交换空间就是原有交换分区的容量加上新建的交换文件的容量;
4、进行耗费内存的操作;
5、根据需要可以使用swapoff关闭交换文件,并删除文件节省磁盘空间。

下面是操作的例子:

# dd if=/dev/zero of=/tmp/swapfile bs=1024 count=65536# mkswap /tmp/swapfile# swapon /tmp/swapfile# ...# swapoff /tmp/swapfile# rm /tmp/swapfile

KOffice相关开发资料

#google:
site:developer.kde.org xxx

#irc:
irc.kde.org

#koffice others:
http://commit-digest.org/ http://developer.kde.org/documentation/tutorials/kiosk/index.html http://developer.kde.org/documentation/library/3.4api/kdeui/html/classKMainWindow.html

更新系统库

os: Linux CCOSS_882447307 2.6.12-1.1456.cocreate.3
gcc: 3.3.3 20040412
qte: qt-embedded-free-3.3.6
kde-lib: kdelibs-3.5.3
koffice: koffice-1.5.1

自己写的测试程序(main.cpp,见附录),编译通过,然后运行 qvfb -width 640 -height 480 & ,接着运行测试程序./main -qws 出现以下错误:
./main: error while loading shared libraries: libkdecore.so.4: cannot open shared object file: No such file or directory

估计是因为在系统库中找不到libkdecore.so,于是ldconfig -p | grep libkdecore ,果然没找到,于是手动添加一下,vi /etc/ld.so.conf,增加/usr/local/kde/lib目录,再运行ldconfig更新一下就OK了。


#main.cpp for test
#include
#include
#include

int
main (int argc, char **argv)
{
KApplication *a;
a = new KApplication (argc, argv, "p2");

QPushButton *hello = new QPushButton (i18n ("Hello World !"), 0);

a->setMainWidget (hello);
hello->show ();

return a->exec ();
}

8/08/2006

终于可以访问了

今天通过http://www.pkblogs.com/primerlife这种方式,可以访问了