2008/01/25

configure.in for libiconv ( iconv ) checking.




As the title states, use this with your autoconf and automake under
both Linux ( where iconv_open() is a libc built-in function )
and Solaris ( where iconv_open() is a part of GNU libiconv ).

#
# Checks for iconv
#
AC_MSG_CHECKING([for a usable iconv])
ICONV_LIBS=""
AC_TRY_LINK([#include ],
[iconv_open ("from", "to");],
[use_iconv=1],
[use_iconv=0])
if test x$use_iconv = x1; then
AC_MSG_RESULT([libc])
else
# try using libiconv
fontconfig_save_libs="$LIBS"
LIBS="$LIBS -liconv"

AC_TRY_LINK([#include ],
[iconv_open ("from", "to");],
[use_iconv=1],
[use_iconv=0])

if test x$use_iconv = x1; then
ICONV_LIBS="-liconv"
AC_MSG_RESULT([libiconv])
else
AC_MSG_RESULT([no])
fi

LIBS="$fontconfig_save_libs"
fi
AC_SUBST(ICONV_LIBS)
AC_DEFINE_UNQUOTED(USE_ICONV,$use_iconv,[Use iconv.])

2008/01/22

Solaris Vim multibyte( Japanese, Chinese, Korean ) support

This also includes Linux and other platforms if you needmultibyte( Japanese, Chinese, Korean ) support for vim.

wget vim-7.1.tar.gz
tar xvzf vim-7.1.tar.gz
cd vim71
--prefix=$HOME \
--enable-multibyte \
--enable-cscope \
--with-features=huge

2008/01/16

Add a text to a PNG file


#if 0
png_text text_ptr[1];
text_ptr[0].key = "userInfo";
char png_userInfo[100];
sprintf(png_userInfo, "%d", m_userInfo);
text_ptr[0].text = png_userInfo;
text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;
png_set_text(png_ptr, info_ptr, text_ptr, 1);
#endif

2008/01/13

FutureNet CR-110 Pro Router configuration

show config

nat 2 192.168.254.016 192.168.254.016 * * 000.000.000.000
nat 127 * * * * 000.000.000.000
main 0 ip 222.151.076.136
main 0 mask 255.255.255.224
main 0 gateway 222.151.076.129
main 0 dhcp off
main 0 autodns on
main 0 secdns 210.224.177.140
main 0 pppoe on
admin password ********
dhcp client 0 0002b35d1040 192.168.254.001
dhcp client 1 0002b38d1dbd 192.168.254.002
dhcp client 2 0002b35d101b 192.168.254.003
dhcp client 3 0000e2864dc9 192.168.254.004
dhcp client 4 0002b38d1dc0 192.168.254.005
dhcp client 5 0003936953e0 192.168.254.006
dhcp client 6 000cf1a4b1b9 192.168.254.007
dhcp client 7 00094157c00f 192.168.254.008
dhcp client 8 0015609910d3 192.168.254.009
dhcp client 9 000a4810de69 192.168.254.010
dhcp client 10 00164111e07d 192.168.254.011
dhcp client 11 00029e053f09 192.168.254.012
dhcp client 12 0050da89d4f4 192.168.254.013
dhcp client 13 00065b37e7a3 192.168.254.014
dhcp client 14 00c09fd9b526 192.168.254.015
dhcp client 15 000d60e8d839 192.168.254.016
dhcp client 16 00096b5267bf 192.168.254.017
dhcp client 17 0013a9087c6c 192.168.254.018
pppoe 1 use on
pppoe 1 id aad92338@BIG
pppoe 1 password ********
pppoe 1 connectondemand off
pppoe 1 idletimeout 0
pppoe 1 maxtimeout 0

----------------

show routetable

Dynamic Routing
Destination Gateway Interface Met
---------------- --------------- --------- ---
192.168.254.000/24 Ether 1 1
default Ether 0 1
000.000.000.000/0 Ether 0 1

Static Routing
Destination Gateway Interface Met

CR 100 Pro Router.

2008/01/07

Endianess conversion

Endianness maybe a pain in the ass if you don't know it, and you have to work on multi platforms like Linux x86 and Solaris Sparc.

And here is a tip ( quick hack, quit easy ) to convert the endianness .


[vuhung@soltest01 perl]$od -x useable.dat |head
0000000 7561 6d69 2800 0b00 0100 0000 0100 0100
0000020 6400 6700 6197 7155 90a4 c065 3e49 0000
0000040 dd6d 0000 0404 3501 0000 0040 0103 0100
0000060 0200 0000 0100 0100 6400 6800 6197 7155
0000100 90a4 c065 3e49 0000 dd6d 0000 0404 3401
0000120 0000 0040 0103 0100 0300 0000 0100 0100
0000140 6400 6900 d925 5d15 2429 7019 f824 0100
0000160 74b7 0100 0404 3401 0000 0000 0103 0100
0000200 0400 0000 0100 0100 6400 6a00 7709 5805
0000220 4a0a 5d06 e093 0400 d0dd 0600 0404 3501
[vuhung@soltest01 perl]$od -x useable.dat.big | head
0000000 6175 696d 0028 000b 0001 0000 0001 0001
0000020 0064 0067 9761 5571 a490 65c0 493e 0000
0000040 6ddd 0000 0404 0135 0000 4000 0301 0001
0000060 0002 0000 0001 0001 0064 0068 9761 5571
0000100 a490 65c0 493e 0000 6ddd 0000 0404 0134
0000120 0000 4000 0301 0001 0003 0000 0001 0001
0000140 0064 0069 25d9 155d 2924 1970 24f8 0001
0000160 b774 0001 0404 0134 0000 0000 0301 0001
0000200 0004 0000 0001 0001 0064 006a 0977 0558
0000220 0a4a 065d 93e0 0004 ddd0 0006 0404 0135
[vuhung@soltest01 perl]$cat endian-convert.pl
#!/usr/local/bin/perl

($ifile, $ofile) = @ARGV;

open(IN, "$ifile");
open(OUT,">$ofile");
while(read(IN,$buf,2)){
$buf = unpack("n",$buf);
$buf = pack("v",$buf);
print OUT $buf;
}
[vuhung@soltest01 perl]$

gdb on ( Open ) Solaris 10

If you try to install gdb 6.6 as what is described gdb's README file, you will get compilation error when you "make", in tui module.

The tip: disable tui and compile gdb only!


wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/gdb-6.6.tar.gz
tar xvzf gdb-6.6.tar.gz
cd gdb-6.6/gdb
./configure --prefix=$HOME --disable-tui
make
make install