2008年5月30日 星期五

compile the shared libraries

# ./configure --help | grep share
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--enable-elf-shlibs select ELF shared libraries
--enable-bsd-shlibs select BSD shared libraries

show the uuid_generate/uuid_unparse symbols in the static libraries
# nm -o /usr/lib/libuuid.a |grep uuid_generate
/usr/lib/libuuid.a:gen_uuid.o:00000c70 T uuid_generate
/usr/lib/libuuid.a:gen_uuid.o:000002f0 T uuid_generate_random
/usr/lib/libuuid.a:gen_uuid.o:00000960 T uuid_generate_time
# nm -o /usr/lib/libuuid.a |grep uuid_unparse
/usr/lib/libuuid.a:unparse.o:00000090 T uuid_unparse
/usr/lib/libuuid.a:unparse.o:000000d0 T uuid_unparse_lower
/usr/lib/libuuid.a:unparse.o:000000b0 T uuid_unparse_upper
/usr/lib/libuuid.a:unparse.o:00000000 t uuid_unparse_x

Compile the uuid library as shared library
# ./configure --enable-elf-shlibs --prefix=/usr
# make all
# make check
# make install


for the static/shared library related knowledge, please refer the following link
http://www.adp-gmbh.ch/cpp/gcc/create_lib.html
Creating a shared and static library with the gnu compiler [gcc]

Here's a summary on how to create a shared and a static library with gcc. The goal is to show the basic steps. I do not want to go into the hairy details. It should be possible to use this page as a reference.
These examples were tested and run on cygwin/Windows.
The code for the library
This is the code that goes into the library. It exhibits one single function that takes two doubles and calculates their mean value and returns it.
calc_mean.c

//#include

##N(mean)
double mean(double a, double b) {
return (a+b) / 2;
}

The header file
Of course, we need a header file.
calc_mean.h

double mean(double, double);

Creating the static library
A static library is basically a set of object files that were copied into a single file. This single file is the static library. The static file is created with the archiver (ar).
First, calc_mean.c is turned into an object file:

gcc -c calc_mean.c -o calc_mean.o

Then, the archiver (ar) is invoked to produce a static library (named libmean.a) out of the object file calc_mean.o.

ar rcs libmean.a calc_mean.o

Note: the library must start with the three letters lib and have the suffix .a.
Creating the shared library
As with static libraries, an object file is created. The -fPIC option tells gcc to create position independant code which is necessary for shared libraries. Note also, that the object file created for the static library will be overwritten. That's not bad, however, because we have a static library that already contains the needed object file.

gcc -c -fPIC calc_mean.c -o calc_mean.o

For some reason, gcc says:

cc1: warning: -fPIC ignored for target (all code is position independent)

It looks like -fPIC is not necessary on x86, but all manuals say, it's needed, so I use it too.
Now, the shared library is created

gcc -shared -Wl,-soname,libmean.so.1 -o libmean.so.1.0.1 calc_mean.o

Note: the library must start with the three letter lib.
The programm using the library
This is the program that uses the calc_mean library. Once, we will link it against the static library and once against the shared library.
main.c

#include
#include "calc_mean.h"

int main(int argc, char* argv[]) {

double v1, v2, m;
v1 = 5.2;
v2 = 7.9;

m = mean(v1, v2);

printf("The mean of %3.2f and %3.2f is %3.2f\n", v1, v2, m);

return 0;
}

Linking against static library

gcc -static main.c -L. -lmean -o statically_linked

Note: the first three letters (the lib) must not be specified, as well as the suffix (.a)
Linking against shared library

gcc main.c -o dynamically_linked -L. -lmean

Note: the first three letters (the lib) must not be specified, as well as the suffix (.so)
Executing the dynamically linked programm

LD_LIBRARY_PATH=.
./dynamically_linked

Thanks
Thanks to Donn Morrison who helped me improve this page.

2008年5月29日 星期四

Linux Command - install

/usr/bin/install -c -m 644 libuuid.a /usr/lib/libuuid.a
ranlib /usr/lib/libuuid.a
/bin/chmod 444 /usr/lib/libuuid.a

>> Whie install libpcap library. The Makefile forget to create the "/usr/local/libpcap/bin/" directory. So the procedures will fail and exit as following screen.

/usr/bin/install -c pcap-config /usr/local/libpcap/bin/pcap-config
/usr/bin/install: cannot create regular file `/usr/local/libpcap/bin/pcap-config': No such file or directory
make: *** [install] Error 1

>> We can just create the directory directly. And rerun the "make install". The procedures will success finally.
# mkdir /usr/local/libpcap/bin/
# /usr/bin/install -c pcap-config /usr/local/libpcap/bin/pcap-config
# make install ==> Successful complete the installation this time

2008年5月27日 星期二

Enable the ortp debug mode

If you want to show the message output by the ortp_debug function, you must configure the options as following
./configure --prefix=/usr --enable-debug=yes

Some question
It seems we don't call the "rtp_session_recv_with_ts" function, but the ortp internally will run this function and output the following messages.
ortp-debug-Queue is empty.
ortp-debug-[rtpsession.c:993] No mp for timestamp 0 queried
ortp-debug-rtp_session_recvm_with_ts: packet_time=10, time=10
ortp-debug-someone is calling me, ts=160
ortp-debug-Queue is empty.
ortp-debug-[rtpsession.c:993] No mp for timestamp 160 queried
ortp-debug-rtp_session_recvm_with_ts: packet_time=30, time=10
ortp-debug-someone is calling me, ts=320
ortp-debug-Queue is empty.
ortp-debug-[rtpsession.c:993] No mp for timestamp 320 queried
ortp-debug-rtp_session_recvm_with_ts: packet_time=50, time=30

2008年5月26日 星期一

ortp layer structure

Receive the rtp packets
rtp_session_recv_with_ts
-->rtp_session_recvm_with_ts
-->rtp_session_rtp_recv
-->
recv(sockfd,mp->b_wptr,bufsz,0); or
(session->rtp.tr->t_recvfrom)(session->rtp.tr, mp->b_wptr,
bufsz, 0,
(struct sockaddr *) &remaddr,
&addrlen); or
recvfrom(sockfd, mp->b_wptr,
bufsz, 0,
(struct sockaddr *) &remaddr,
&addrlen);
After received the packet, the ortp will use rtp_session_rtp_parse to parse the incoming packet to determine if the received packet was fit the RTP format or not?

The ortp library internally uses the data structure "mblk_t" to store the received packets.

2008年5月22日 星期四

Linux Debug - gdb

set argument parameter
(gdb) set args -f config -c callee

set breaking point
(gdb) break a.c:100

print variable hex values
(gdb) p/x abc

show the memory of variable "buf" 5 string lines
(gdb) x/5s buf

Show the current information
(gdb) info program

Show the breakpoints info
(gdb) info br

(gdb) info br
Num Type Disp Enb Address What
1 breakpoint keep y 0x0805244f in fun1 at file.c:1419
breakpoint already hit 1 time
2 breakpoint keep y 0x001370ff in fun2 at file.c:297


Disable breakpoint
(gdb) disable 1
Num Type Disp Enb Address What
1 breakpoint keep n 0x0805244f in fun1 at file.c:1419
breakpoint already hit 1 time
2 breakpoint keep y 0x001370ff in fun2 at file.c:297

disable breakpoint num 4
(gdb) disable br 4

We can use "bt" (backtrace) command to find out How does the program reach current function stack. Like following example. The function is following the function stack sequence as main->dfun->cfun->bfun->afun and the current program counter is paused in the aaaa.c:590 position
(gdb) bt
#0 afun (sr=0x8df9008, je=0xb7d02808) at aaaa.c:590
#1 0x0013e748 in bfun (pVoid=0xbf97ce94) at bbbb.c:323
#2 0x0013d4b3 in cfun (pVoid=0xbf97ce94) at cccc.c:53
#3 0x0804b3cc in dfun (pVoid=0xbf97ce94) at dddd.c:471
#4 0x0804ad42 in main (argc=5, argv=0xbf97e0b4) at sip8d.c:396



How do I examine memory?
Use the x/FMT ADDRESS format (see the detailed description after the section)
Ex. see the 100 bytes after address 0xbff6eec8
x/100x 0xbff6eec8

Use the x command to examine memory. The syntax for the x command is x/FMT ADDRESS. The FMT field is a count followed by a format letter and a size letter. There are many options here, use the help command 'help x' to see them all. The ADDRESS argument can either be a symbol name, such as a variable, or a memory address.

If we have char *s = "Hello World\n", some uses of the x command could be:

Examine the variable as a string:

(gdb) x/s s
0x8048434 <_io_stdin_used+4>: "Hello World\n"

Examine the variable as a character:

(gdb) x/c s
0x8048434 <_io_stdin_used+4>: 72 'H'

Examine the variable as 4 characters:

(gdb) x/4c s
0x8048434 <_io_stdin_used+4>: 72 'H' 101 'e' 108 'l' 108 'l'

Examine the first 32 bits of the variable:

(gdb) x/t s
0x8048434 <_io_stdin_used+4>: 01101100011011000110010101001000

Examine the first 24 bytes of the variable in hex:

(gdb) x/3x s
0x8048434 <_io_stdin_used+4>: 0x6c6c6548 0x6f57206f 0x0a646c72


# Automatic print specified variables every step (e.g. set the tmp, string variables as automatic variables)
(gdb) display string
(gdb) display tmp
(gdb) info display
Auto-display expressions now in effect:
Num Enb Expression
2: y tmp
1: y string

online English directory

Yahoo directory
http://tw.dictionary.yahoo.com/

線上英漢字典/中文拼音/地址英譯、地圖查詢/計算機
http://cdict.giga.net.tw/

Dr. eye
http://www.dreye.com:8080/axis/ddict.jsp?
http://www.dreye.com.tw/index_b5.html

2008年5月20日 星期二

Linux Service - cvs pserver & ssh

Two method to access the CVS server - ssh vs pserver
* Setup cvs server via ssh (port 22) -- client use ext method to connect
* Setup cvs server via cvs connection (port 2401) -- client use pserver to connect

How to Setup a CVS pserver
http://comsci.liu.edu/~murali/cvs/pserver.htm
Assumptions:

*

RedHat 6.1 Installed
*

Repository will reside in /usr/local/cvsroot. You can change this.

Needed:

*

CVS v1.10.6-2 is installed (RPM is on RedHat CD if not already installed)

Repository Installation:

1.

Login as root on repository machine
2.

Create a user (& group) called: cvs
3.

Create repository:

cvs -d /usr/local/cvsroot init

(Repeat this process if you want to create multiple repositories e.g., /usr/local/cvsroot2, /usr/local/cvspublic etc). Each repository can have different sets of authorized users.
4.

Change owner and group of repository and all files to cvs:

chown -R cvs.cvs /usr/local/cvsroot

5.

Create tcp service by editing /etc/services - add line (NOTE: May already be present):

cvspserver 2401/tcp #CVS PServer

6.

Create inetd entry for service by editing /etc/inetd.conf - add following lines:

#
# CVS PServer
#
cvspserver stream tcp nowait cvs /usr/bin/cvs cvs --allow-root=/usr/local/cvsroot pserver

NOTE: The above line "cvspserver stream ..." must appear on a single line. If you created multiple repositories in step 3, add an additional --allow-root=[repository path] argument for each repository.
7.

Restart inetd. NOTE: Because you will be restarting inetd from root's session, it will inherit the environment, most notably HOME=/root. This causes the following error when you try to check anything out of the repository:

cvs server: cannot open /root/.cvsignore: Permission denied
cvs [server aborted]: can't chdir(/root): Permission denied

To remedy this, use one of two methods.
1) The first method is to restart the server (the problem does not occur when inetd is started during system startup.
2) The second method is a manual restart while logged in as root. For this to work you need to restart inetd without the HOME pointing to root's home directory. Start a terminal session and enter the following:

unset HOME
/etc/rc.d/init.d/inet restart

8.

Now login as the user cvs. We will now setup the password file for cvs users.
9.

You will need a utility to create encrypted passwords. You can use the below perl script for that purpose:

#!/usr/bin/perl

srand (time());
my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))";
my $salt = sprintf ("%c%c", eval $randletter, eval $randletter);
my $plaintext = shift;
my $crypttext = crypt ($plaintext, $salt);

print "${crypttext}\n";

10.

Create a text file in /usr/local/cvsroot/CVSROOT called passwd and enter the users as shown below (format is: userid:encrypted-password:cvs ):

username1:x$5itFdsw123:cvs
username2:3fgRH4p3443:cvs

NOTE: Use the crypt.pl utilty from above to generate the encrypted passwords for the above entries. The passwords for the users should NOT be the same as their unix password (if they have a unix account). The cvs users you enter above do NOT need a unix account.
11.

Set restrictive permissions on the file:

chmod 400 /usr/local/cvsroot/CVSROOT/passwd

12.

(optional) Repeat step 10 and 11 for each additional repository you created in step 3.

Repository Testing

1.

Set the default repository in the environment (will save entering it on every cvs command):

export CVSROOT=:pserver:username1@your_server_name:/usr/local/cvsroot

(substitute real values for username1, your_server_name and repository path if needed)
2.

Test the basic login:

cvs login

Enter the username1's password. There should not be any error messages.
3.

Create a tiny test project:

cd
mkdir testproj
echo "//Main Class">testproj/Main.java

4.

Import the project to the repository.

cd testproj
cvs import -m "My initial project message" testproj mycompany start

5.

Check to make sure the project was created in the repository. You should see the file Main.java in /usr/local/cvsroot/testproj
6.

Remove the test project from the repository:

rm --R /usr/local/cvsroot/testproj

Linux Command - find

Find out the files that file length greater than 100M bytes
# find ./* -size +100M
./proc/kcore
[omit]

Some experience
# find . -type f ! -name 'Root' ! -name 'Repository' ! -name 'Entries' -print

// 將目錄下的所有Root 檔案換成新的檔案 (Root.user), 並且將過程log 下來丟到a.log 檔案
# find ./* -name Root -fls a.log -exec cp -f Root.user {} \;

// find 預設所有的condition 都是and, 除非你指定用or 來做logic adjudgement
# find . -type f | egrep 'data|temp' > exclude

// Find all the files and folders below the specified directory and print the specified data of column
# find ./* -name CVS -exec "rm -rf {}" \; 2>&1 | gawk -F"[ ]" '{print $2" "$3" "$4}'

# find ./* -name Makefile -exec grep -R -H "export" {} \;

# find the files below the current working directory that is modified not greater than 1 min.
find ./* -mtime -1 -exec ls -la {} \;

# find the desired file only in the current directory (no any underly directory is needed, sub-directory is 0)
find ./* -maxdepth 0 -size +100M -exec ls -l -h {} \;

EX. 1
Example:
Find all files with the txt extension in your home directory:
find ~ -name"*.txt" -print

Find all files with at least one upper casecharacter in your current directory:
find . -name "[A-Z]*"-print

Find all files that begin with two lower case characters, followed by.txt:
find . -name "[a-z][a-z][0--9][0--9].txt" -print

EX. 2
Description:
Lets say your system had 200GB of empty hard drive space yesterday, and suddenly you have none. Someone has uploaded created a very large file, and we need to find it!
Example:


find / -mtime -1 -size +150000000 -print

This finds all files created in the last day that are larger than 150GB.


EX. 3
Description:
suid allows programs to run as other users (usually root). Knowing what files have suid is very important to locking down your system. The file /root/suid.txt is created with the the findings.
Example:


ls -alF `find / -perm -4000` > /root/suid.txt


EX. 4
Description:
Simplify the output of find by sending the \"permission denied\" messages to /dev/null.
Example:

find / -name libib* 2>/dev/null


find can use "operators" include following sign

OPERATORS
Listed in order of decreasing precedence:

( expr )
Force precedence.

! expr True if expr is false.

-not expr
Same as ! expr, but not POSIX compliant.

expr1 expr2
Two expressions in a row are taken to be joined with an implied "and"; expr2 is not
evaluated if expr1 is false.

expr1 -a expr2
Same as expr1 expr2.

expr1 -and expr2
Same as expr1 expr2, but not POSIX compliant.

expr1 -o expr2
Or; expr2 is not evaluated if expr1 is true.

expr1 -or expr2
Same as expr1 -o expr2, but not POSIX compliant.

expr1 , expr2
List; both expr1 and expr2 are always evaluated. The value of expr1 is discarded; the
value of the list is the value of expr2. The comma operator can be useful for
searching for several different types of thing, but traversing the filesystem hierarchy
only once. The -fprintf action can be used to list the various matched items into sev-
eral different output files.

e.g.
// List all the files postfix '*.[ao]' or '*.so'
# find . -name '*.[ao]' -o -name '*.so'

// if you use "operators" in the find command. And you want to process ("-exec") the output of find command, you must add "-print " to redirect the output data to the -exec as "{}" present the output data. Like the following examples
# find ./subFolder -name *.h -print -o -name *.sh -print -o -name *.c -print -exec dos2unix {} \;


很棒的find 說明文件
http://www.linux-mag.com/2002-09/power_01.html

enable CVS client debug

print the debug message of the cvs client

# cvs -t co sip8d/audiow.pcm

2008年5月19日 星期一

SSH Without a Password, it is work for me :)

Copy from the following link
http://www.csua.berkeley.edu/~ranga/notes/ssh_nopass.html

The following steps can be used to ssh from one system to another without specifying a password.
Notes:

* The system from which the ssh session is started via the ssh command is the client.
* The system that the ssh session connects to is the server.
* These steps seem to work on systems running OpenSSH.
* The steps assume that a DSA key is being used. To use a RSA key substitute 'rsa' for 'dsa'.
* The steps assume that you are using a Bourne-like shell (sh, ksh or bash)
* Some of this information came from:
http://www.der-keiler.de/Mailing-Lists/securityfocus/Secure_Shell/2002-12/0083.html

Steps:

1. On the client run the following commands:

$ mkdir -p $HOME/.ssh
$ chmod 0700 $HOME/.ssh
$ ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P ''

This should result in two files, $HOME/.ssh/id_dsa (private key) and $HOME/.ssh/id_dsa.pub (public key).

Note:
The possible key type include the following choices (refer to the man page of ssh-keygen)
-t type
Specifies the type of key to create. The possible values are “rsa1” for protocol version
1 and “rsa” or “dsa” for protocol version 2.

DESCRIPTION of the ssh-keygen
ssh-keygen generates, manages and converts authentication keys for ssh(1). ssh-keygen can create
RSA keys for use by SSH protocol version 1 and RSA or DSA keys for use by SSH protocol version 2.
The type of key to be generated is specified with the -t option. If invoked without any arguments, ssh-keygen will generate an RSA key for use in SSH protocol 2 connections.

2. Copy $HOME/.ssh/id_dsa.pub to the server.
3. On the server run the following commands:

$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys2 (Or you can just copy the file id_dsa.pub as the name "authorized_keys", # cp $HOME/.ssh/id_dsa.pub $HOME/.ssh/authorized_keys)

$ chmod 0600 $HOME/.ssh/authorized_keys2

Depending on the version of OpenSSH the following commands may also be required:

$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys
$ chmod 0600 $HOME/.ssh/authorized_keys

An alternative is to create a link from authorized_keys2 to authorized_keys:

$ cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys

4. On the client test the results by ssh'ing to the server:
$ ssh -i $HOME/.ssh/id_dsa server

5. (Optional) Add the following $HOME/.ssh/config on the client:

Host server
IdentityFile ~/.ssh/id_dsa

This allows ssh access to the server without having to specify the path to the id_dsa file as an argument to ssh each time.

Helpful manpages:

* ssh(1)
* ssh-keygen(1)
* ssh_config(5)

2008年5月16日 星期五

Debug progress of xinetd

#ps axjf | head -1
PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
# ps axjf | grep xinetd
3122 10550 10550 3122 pts/3 10550 S+ 0 0:00 | | \_ /bin/sh /sbin/service xinetd restart
10550 10557 10550 3122 pts/3 10550 S+ 0 0:00 | | \_ /bin/bash /etc/init.d/xinetd restart
10557 10568 10550 3122 pts/3 10550 S+ 0 0:00 | | \_ /bin/bash -c ulimit -S -c 0 >/dev/null 2>&1 ; xinetd -d -stayalive -reuse -pidfile /var/run/xinetd.pid
10568 10569 10550 3122 pts/3 10550 S+ 0 0:00 | | \_ xinetd -d -stayalive -reuse -pidfile /var/run/xinetd.pid

[root@localhost(3:48:34pm):~/etc/xinetd.d]cat /var/run/xinetd.pid
10569

run the xinetd manually as following command
/usr/sbin/xinetd -filelog /var/adm/xinetd.log -f /etc/xinetd.conf -d -stayalive -reuse -pidfile /var/run/xinetd.pid

Some observations
1. While we restart the service, it forks another shell to run the practical daemon (in the case, it is the /etc/init.d/xinetd)
2. ulimit is a bash buildin command. We can use it to control the resources available to a process started by the shell (here is bash).

2008年5月15日 星期四

Microsoft Visio usage

If you want to use a line with arrow that need the text descriptions inside the middle of line, the best candidate is the following object.
File -> Shapes -> Block Diagram -> Basic Shapes(US units) -> Dynamic connector

The Internet Cloud pattern is located in the (This is more clearly than the one located in the "Network Locations")
File -> Shapes -> Web Digram -> Conceptual Web Site Shapes(US units) -> Cloud

Visio icons collection website
http://www.visiocafe.com/index.htm

the registration test tool of eXosip2 -- sip_regi

I had ever using the following command to test the sip server, and the result is ok
./sip_reg -r sip:sip-serverip:5060 -u sip:user@192.168.2.101 -d -U admin -P openserrw

2008年5月13日 星期二

use gcc -E to debug the header file inclusion

#include
#ifndef _WIN32_WCE
#include
#endif

#ifdef _WIN32_WCE
#include
#include
#include
#include
#include
#define close(s) closesocket(s)
#elif WIN32
#include
#include
#include
#include
#define close(s) closesocket(s)
#else
#include
#include
#include
#include
#include
#endif

#include

#include
#include

// Generate the file that only processed by the cpp (C Preprocessor)
# gcc -E eXregister_api.c -o eXregister_api.c.preprocessor
The following file is generated by the above command
------------------------------------------------------------
# 1 "eXosip2.h" 1
# 28 "eXosip2.h" ==> the 28th row of eXosip2.h
# 1 "/usr/include/stdio.h" 1 3 4

# 29 "eXosip2.h" 2 ==> the 29th row of eXosip2.h

# 1 "/usr/include/errno.h" 1 3 4
# 32 "/usr/include/errno.h" 3 4

# 31 "eXosip2.h" 2 ==> the 31th row of eXosip2.h
# 47 "eXosip2.h" ==> the 47th row of eXosip2.h
# 1 "/usr/include/sys/types.h" 1 3 4
# 29 "/usr/include/sys/types.h" 3 4

# 48 "eXosip2.h" 2 ==> the 48th row of eXosip2.h
# 1 "/usr/include/sys/socket.h" 1 3 4
# 26 "/usr/include/sys/socket.h" 3 4

# 49 "eXosip2.h" 2 ==> the 49th row of eXosip2.h
# 1 "/usr/include/netinet/in.h" 1 3 4
# 24 "/usr/include/netinet/in.h" 3 4
# 1 "/usr/include/stdint.h" 1 3 4
# 27 "/usr/include/stdint.h" 3 4
# 1 "/usr/include/bits/wchar.h" 1 3 4
# 28 "/usr/include/stdint.h" 2 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 29 "/usr/include/stdint.h" 2 3 4
# 49 "/usr/include/stdint.h" 3 4

# 50 "eXosip2.h" 2 ==> the 50th row of eXosip2.h
# 1 "/usr/include/arpa/inet.h" 1 3 4
# 31 "/usr/include/arpa/inet.h" 3 4

# 51 "eXosip2.h" 2 ==> the 51th row of eXosip2.h
# 1 "/usr/include/netdb.h" 1 3 4
# 33 "/usr/include/netdb.h" 3 4
# 1 "/usr/include/rpc/netdb.h" 1 3 4
# 42 "/usr/include/rpc/netdb.h" 3 4
# 1 "/usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h" 1 3 4
# 43 "/usr/include/rpc/netdb.h" 2 3 4

# 52 "eXosip2.h" 2

gcc consist 4 stages in the pverall processing

When you invoke GCC, it normally does
preprocessing,
compilation,
assembly and
linking.
The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler.

-c Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.
By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with .o.
Unrecognized input files, not requiring compilation or assembly, are ignored.

-S Stop after the stage of compilation proper; do not assemble. The output is in the form of an assembler code file for each non-assembler input file specified.
By default, the assembler file name for a source file is made by replacing the suffix .c, .i, etc., with .s. Input files that don’t require compilation are ignored.

-E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.

2008年5月12日 星期一

Linux Development - Make

.SECONDEXPANSION:
AVAR = top
onefile: $(AVAR)
echo "make onefile";
twofile: $$(AVAR)
echo "make twofile";
AVAR = bottom

# make onefile
make: *** No rule to make target `top', needed by `onefile'. Stop.
==> $(AVAR) is expanded to "top"
# make twofile
make: *** No rule to make target `bottom', needed by `twofile'. Stop.
==> because of second expansion, the $$(AVAR) is expanded to "bottom"

make debug tips
we can use the following parameters added after make to verbose the debugging messages
-w Option: How the ‘-w’ or ‘--print-directory’ option helps debug use of recursive make commands.

simple recursive Makefile example

./Makefile

SUBDIR=sub

.PHONY: clean clean-am
clean:
list="$(SUBDIR) ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$list; do \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target); \
done
clean-am:
-rm -rf .libs
-rm -f .o

sub/Makefile

.PHONY: clean
clean:
-rm -rf .libs


****************************************************************************
Some curious question
* what is the different between the $variable-name and $$variable-name
ans:
The GNU make works in two distinct phases: a read-in phase and a target-update phase, so we must use double $ to expand the variable value

Refer the GNU make processing logic (a snapshot from the GNU make manual)
3.9 How make Reads a Makefile

GNU make does its work in two distinct phases. During the first phase it reads all the makefiles, included makefiles, etc. and internalizes all the variables and their values, implicit and explicit rules, and constructs a dependency graph of all the targets and their prerequisites. During the second phase, make uses these internal structures to determine what targets will need to be rebuilt and to invoke the rules necessary to do so.

* You can use $(variable-name), but you can not use $$(variable-name) or will due to error because the gnu make doesn't know how to immediately expansion in the first read-in phase

libeXosip2-3.0.2 recursive definition skill in the header definition (debug for the osip_proxy_authorization_free)

libeXosip2-3.0.2

In src/eXregister_api.c
#include "eXosip2.h"

In src/eXosip2.h
#include
#include

In /usr/include/osip2/osip.h
#include

In /usr/include/osipparser2/osip_parser.h
#include

In /usr/include/osipparser2/osip_message.h
#include

In /usr/include/osipparser2/osip_headers.h
#include

In /usr/include/osipparser2/headers/osip_proxy_authorization.h
#define osip_proxy_authorization_free(header) osip_authorization_free(header)

2008年5月5日 星期一

unix password/shadow management

If the /etc/shadow file contains the following token in the second field
* (we can manually put this character by pre-fixing the encrypted string with an *)
! (by using the passwd –l user_name)

user1:*$1$sdiv6Jjp$FG6IYJ4ziL8KLLfo0f8oK/:13876:0:99999:7::: ==> We can put the prefix character (*) to disable the specified user.
user2:!!:14004:0:99999:7::: ==> When we create a new user without changing the default password. The user data in the shadow file will have the prefix character (!) in the second field.

http://nmc.nchu.edu.tw/linux/User_mng.htm
停用一個帳號

方式一 : With UNIX Command
passwd –l user_name
-l This option is used to lock the specified account and it is available to root only. The locking is performed by rendering the encrypted password into an invalid string (by pre-fixing the encrypted string with an !).

方式二 : 手動停用
停用一個帳號非常簡單,只需將/etc/shadow該user的帳號的password欄
位用字元"*"取代之即可。例如你要停用帳號woody,只需把/etc/passwd
中woody這一行改成向下面這個樣子即可:
woody:*:501:100:woody:/home/woody:/bin/tcsh

2008年5月4日 星期日

Linux Tool - pureftpd

Pure-FTPd is a free (BSD), secure, production-quality and standard-conformant FTP server. It doesn't provide useless bells and whistles, but focuses on efficiency and ease of use. It provides simple answers to common needs, plus unique useful features for personal users as well as hosting providers.

pure-ftpd is a powerful ftp server
# -B --daemonize (only daemon)
# -E --noanonymous
/usr/local/sbin/pure-ftpd -B

How to add a user to the pureftp

1. vi /etc/pureftpd.passwd,
新增ㄧ筆user data 在pureftpd 密碼檔當中, ㄧ般標準程序是利用
pure-pw useradd 來新增user, 這裡直接去修改 pureftpd 密碼檔比較快,
直接複製既有其他的user password, 修改username, 以及login 的directory,
david:$2a$07$zSvK1qKH4q3hWAz.E3CAEussQp29Qt/tm2vnEy:10003:100:David Lee:/home/david/./::::::::::::

/home/david/. ==> login directory 之後有一點(.)表示, login 後被 change 為只能看到login directory 以下的檔案, 不能看到整個系統的檔案

2. 新增user 之後, 再去更改該 user 的 password
pure-pw passwd david

3. 最後跑 pure-pw mkdb 即可

windows command abbreviation

cmd ==> command
mstsc ==> remote desktop program
msconfig ==> MS$ system configurator

Q. Which version of the Windows operating system am I running?
A. Click the Start button Picture of the Start button, type winver in the search box, and then press Enter

2008年5月2日 星期五

hexedit

A useful binary editor under linux
hexedit - view and edit files in hexadecimal or in ASCII
http://www.chez.com/prigaux/hexedit.html