2012-02-27

C++ Structure and Class size

C++中,同样数据成员的struct和class的大小(sizeof)是相同的。带有成员函数的class并不增加大小,但是带有virtual函数的class会增加4 bytes。

===== Test Pprogram ===

#include <iostream>

using namespace std;

struct S {
        int     a;
        int     b;
};

class C {
public:
        int     a;
        int             b;
};

class CF {
public:
        int             a;
        int             b;

        void f1() {};
        void f2() {};
        void f3() {};
};


class CVF {
public:
        int             a;
        int             b;

        virtual void f1() {};
        virtual void f2() {};
        virtual void f3() {};
};

int main(int argc, char** argv)
{
        cout << "Size of struct S " << sizeof(struct S) << endl;
        cout << "Size of class C " << sizeof(C) << endl;
        cout << "Size of class CF " << sizeof(CF) << endl;
        cout << "Size of class CVF " << sizeof(CVF) << endl;

        return 0;
}

==== Result ====

Size of struct S 8
Size of class C 8
Size of class CF 8
Size of class CVF 12




2012-01-13

Python / Twisted / WebSocket / Protobuf on Windows 7 (64bit)





Python Basic
============


- Install 32-bit Python 2.7.2


- Install setuptool-0.6c11.win32-py2.7.exe (easy_install)


Twisted Framework and SSL support
=================================


- Install Twisted-11.1.0 from source code ( it installs zope interface automatically from internet)


    unzip Twisted-11.1.0.tar.bz2
    cd Twisted-11.1.0
    setup.py install


- Install Win32OpenSSL 32bit 1.0.0e 


- Install pyOpenSSL (Twisted SSL support needs this)


    cd c:\python2.7\scripts
    easy_install pyopenssl


WebSocket Autobahn
==================


- Install Autobahn from source code


    unzip autobahn
    cd autobahn\lib\python 
    setup.py install


  Test the Autobahn installation


    cd autobahn\demo\echo
    echo_server.py


    In another DOS window


    cd autobahn\demo\echo
    echo_client.py


  Test the SSL support of WebSocket and Twisted


    cd autobahn\demo\echo_tls
    echo_tls_server.py


    In another DOS window
    
    cd autobahn\demo\echo_tls
    echo_tls_client.py -u wss://localhost:9000
  
Protobuf and Protobuf.socketrpc
===============================


- Install protobuf Python library from source code


    unzip protobuf-2.4.1-win32.zip
    cd protobuf-2.4.1\python
    setup.py install
    
- Install protobuf compiler Windows binary


    create d:\temp\protoc
    add d:\temp\protoc to PATH
    put protoc.exe into d:\temp\protoc


- Install protobuf.socketrpc from source code


    unzip protobuf.socketrpc-1.3.2.tar.gz
    cd protobuf.socketrpc-1.3.2
    setup.py install


  Test the protobuf.socketrpc


    cd protobuf.socketrpc-1.3.2\src\protobuf\socketrpc\examples\helloworld
    run_server.py


    In another DOS windows


    cd protobuf.socketrpc-1.3.2\src\protobuf\socketrpc\examples\helloworld
    run_client.py




  
  

IIS 7.5 HTTPS Configuration and Certificate Installation





How to Generate a Server Certificate for the IIS server 7.5?
============================================================


Background
----------


There're different ways to generate server certificate for IIS server 7.5. Here's 
a way to use a private CA to sign the server certificate. 


The private CA here is a openssl based CA. To set up the CA, you have to run a Linux
with openssl installed. There're couple of shell scripts to help create the CA and 
sign certificate request. 


For this testing, the private CA is running on Aric's Ubuntu Linux. The certificate
of the CA is included below.


-----BEGIN CERTIFICATE-----
MIIDcjCCAtugAwIBAgIJAI1vSteGwmBkMA0GCSqGSIb3DQEBBQUAMIGDMQswCQYD
VQQGEwJBVTEMMAoGA1UECBMDTlNXMQ8wDQYDVQQHEwZTeWRuZXkxEDAOBgNVBAoT
B1NpZW1lbnMxCzAJBgNVBAsTAlNQMRAwDgYDVQQDEwdPcGVuU1NMMSQwIgYJKoZI
hvcNAQkBFhVhcmljLndhbmdAc2llbWVucy5jb20wHhcNMTExMjAyMDMwNzMzWhcN
MTQxMjAxMDMwNzMzWjCBgzELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA05TVzEPMA0G
A1UEBxMGU3lkbmV5MRAwDgYDVQQKEwdTaWVtZW5zMQswCQYDVQQLEwJTUDEQMA4G
A1UEAxMHT3BlblNTTDEkMCIGCSqGSIb3DQEJARYVYXJpYy53YW5nQHNpZW1lbnMu
Y29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnacafZQPmnyVhtP+LLaxY
WM3sSJJ0msivxcyPCfD9nLNK3P34aQyeNlUgqZc5mAp0Je/zURXAsi+t2WjUA8pF
wFsxxKC10TE/qobhXsT+RwfkkvDUh5poCN9jdWgzg1Zs3uKNbCuj/AgT/dWr+cry
yYZTryMuX4jIyAA4ca3ggQIDAQABo4HrMIHoMB0GA1UdDgQWBBQjct00RwGzBIR1
WXEPTdH1DHHRETCBuAYDVR0jBIGwMIGtgBQjct00RwGzBIR1WXEPTdH1DHHREaGB
iaSBhjCBgzELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA05TVzEPMA0GA1UEBxMGU3lk
bmV5MRAwDgYDVQQKEwdTaWVtZW5zMQswCQYDVQQLEwJTUDEQMA4GA1UEAxMHT3Bl
blNTTDEkMCIGCSqGSIb3DQEJARYVYXJpYy53YW5nQHNpZW1lbnMuY29tggkAjW9K
14bCYGQwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCS8DsJnkgFHPBt
Q+dhFLDvnu3ZwgU0iSaZVmEzyclDAbgnrde3rzofHoFX/c/4MZJf2NYg992REiOO
TNp9wuN/yxlRcCxZQYRzLoqkBoYGQwFj705Um83DX7jOGVwdFF2o7GVN0QnvXHBY
2JsGjKthN6VDWi2jZjzaLPBot9hilA==
-----END CERTIFICATE-----


The CA certificate might be needed on the client side in order to verify the certificates
signed by this CA. If needed, just copy above CA contents (including begin and end lines)
to a text file, and import it into the client system. It might be different about how to 
import the CA certificate on different systems.


Steps to Create Server Certificate for IIS 7.5
----------------------------------------------


1. Create certificate request on IIS 7.5




   a. Open IIS Manager;


   b. Select the server you are going to create certificate;


   c. In the 'Features View', double click 'Server Certificates'. It shows a list of the 
      certificates installed for this server;


   d. In the 'Actions' panel, click 'Create Certificate Request...';


   e. In the new dialog box, enter the information required. Could use the server name as the
      'Common Name'. Click 'Next';


   f. Choose 'Microsoft RSA SChannel Cryptographic Provider' and '1024' bit length. Click
      'Next';


   g. Click the browse button to select a folder and file name to save the certificate request.
      Click 'Finish'.


2. Send the certificate request to the CA to sign it


   Just copy the file you saved above and send to Aric.


3. The CA signs the certificate


   Aric will sign this certificate request and send back the certificate.


4. Install the certificate on IIS 7.5


   a. Save the signed certificate into a folder on the server;


   b. Open IIS Manager, select the server you are going to create certificate;


   c. In the 'Features View', double click 'Server Certificates'. It shows a list of the 
      certificates installed for this server;


   d. In the 'Actions' panel, click 'Complete Certificate Request...';


   e. In the new dialog box, click the browse button to find the certificate file just saved;
      Note you may need to set the filter to '*.*' rather than '*.cer' if the certificate is 
      saved with a different suffix from '.cer'.


   f. In 'Friendly name' field, enter something, i.e. Aric signed certificate. Click 'OK'.


   g. If everything is ok, now you have installed the certificate on IIS 7.5;


5. Enable HTTPS for the web site


   a. Open IIS Manager;


   b. Select the server you are going to create certificate;


   c. Navigate to the web site you want to enable HTTPS;


   d. In 'Features View', under 'Actions' panel, click 'Bindings...';


   e. If there's no https binding enabled, you click 'Add...' to add it. If it already exists, 
      click 'Edit...' to modify it;


   f. In the new dialog box, choose the 'https' Type, enter your port number in 'Port'. Under
      'SSL certificate:', select the certificate you just installed in step 4. Click 'OK' to 
      finish. There might come up with some warnings, just click OK to finish it.


   g. Now back to 'Site Bindings' dialog, click 'Close';


   h. Restart the web site by clicking 'Restart' under the 'Actions' panel.


6. Now your web site should work with HTTPS. You can open a browser to test it.



Makefile example 2

#
# Introduction
#
# This is a Makefile example which can be used to build library or program from
# given directories. These directories could be at the same folder of the Makefile
# itself, or they could exist in other levels of the Makefile, sub-folders or
# parent-folders. 
#
# The Makefile searches all the .cpp files in the given folders and compile them
# into object files and link them into library or program. It generates dependency
# files automatically so that it can catch any change or the source files or 
# related header files.
#
# All the output of the make process is put in $(ODIR) folder. The default value
# is 'Build', but can be overriden with 'ODIR=xxx' when executing 'make'.   
#
# This makefile example contains a example to search folders and sub-folders for
# source file, and then collect all the folders.
#


PWD := $(abspath $(shell pwd))
TOP_DIR := $(abspath ../../..)
ODIR ?= Build


#
# The final targat. Should define only one of them: PROG or LIB
#
PROG := 
LIB := libapclient.a


#
# Find all the directories containing any generated CPP file.
#
GENERATED_TOP_DIR := $(TOP_DIR)/Dingo/Client/AccessPoint/GeneratedServices
GENERATED_CPP_FILES := $(shell find $(GENERATED_TOP_DIR) -name *.cpp)
GENERATED_CPP_DIRS := $(sort $(dir $(GENERATED_CPP_FILES)))


#
# The modules (directories) that need to be built. All the .cpp files in these
# directories will be built automatically.
#
MODULES   := \
  $(TOP_DIR)/Dingo/Client/AccessPoint/TinyXML \
    $(TOP_DIR)/Dingo/Gateway/Siemens.Gateway.Linux.Client \
    $(TOP_DIR)/Dingo/Gateway/PlatformSpecific/Linux \
  $(GENERATED_CPP_DIRS)

# CFLAGS for compiling
CFLAGS := -MD -MP -g \
-I. \
-I$(TOP_DIR)/Dingo/Client/AccessPoint/GatewayClient \
-I$(TOP_DIR)/Dingo/Client/AccessPoint/GatewayProxy \
-I$(TOP_DIR)/Dingo/Client/AccessPoint/GatewayProxy/gSoap \
-I$(TOP_DIR)/Dingo/Client/AccessPoint/TinyXML \
-I$(TOP_DIR)/Dingo/Gateway \
-I$(TOP_DIR)/Dingo/Gateway/PlatformSpecific/Linux \
-I$(TOP_DIR)/Dingo/Client/AccessPoint/GeneratedServices \


#
# -DDEBUG to enable logging of gSoap library
#
ifeq ($(DEBUG),yes)
CFLAGS += -DDEBUG
endif


ifeq ($(OPENSSL),yes)
CFLAGS += -DWITH_OPENSSL
endif


ifeq ($(ARM),yes)
CFLAGS += -I$(TOP_DIR)/../application/include
endif


#
# LDFLAGS for linking PROG
#
LDFLAGS :=


#
# Common Part
#
ifneq ($(ARM),yes)
CROSS_COMPILE
endif


SRC_DIRS  := $(MODULES)
INC_DIRS := $(MODULES)
BUILD_DIRS:= $(addprefix $(ODIR),$(subst $(TOP_DIR),,$(MODULES)))


SRCS      := $(foreach sdir,$(SRC_DIRS),$(wildcard $(sdir)/*.cpp))
OBJS := $(patsubst %.cpp,%.o,$(addprefix $(ODIR),$(subst $(TOP_DIR),,$(SRCS))))
DEPS      := $(OBJS:.o=.d)
INCLUDES  := $(addprefix -I,$(INC_DIRS))


CFLAGS += $(INCLUDES)


CC        := $(CROSS_COMPILE)g++
LD        := $(CROSS_COMPILE)g++
AR := $(CROSS_COMPILE)ar
ECHO := echo
MKDIR := mkdir -p
RM := rm -rf
LN := ln -sf


vpath %.cpp $(SRC_DIRS)


define make-goal
$1/%.o : %.cpp
@$(ECHO) "CC   $$<"
@$(CC) $(CFLAGS) -c $$< -o $$@


endef


.PHONY: all checkdirs clean 


all: checkdirs $(ODIR)/$(LIB) $(ODIR)/$(PROG) 


ifneq ($(PROG),)
$(ODIR)/$(PROG): $(OBJS)
@$(ECHO) "LD   $@"
@$(LD) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
endif


ifneq ($(LIB),)
$(ODIR)/$(LIB): $(OBJS)
@$(ECHO) "AR   $@"
@$(AR) crs $@ $(OBJS)
endif


checkdirs: $(BUILD_DIRS)

$(BUILD_DIRS):
@$(ECHO) "MKDIR  $@"
@$(MKDIR) -p $@


clean:
@$(RM) $(BUILD_DIRS) $(ODIR) $(TOP_DIR)/Dingo/Client/AccessPoint/TinyXML


$(foreach bdir,$(BUILD_DIRS),$(eval $(call make-goal,$(bdir))))


-include $(DEPS)


test:
@echo $(GENERATED_CPP_DIRS)

Makefile example 1

#
# Introduction
#
# This is a Makefile example which can be used to build library or program from
# given directories. These directories could be at the same folder of the Makefile
# itself, or they could exist in other levels of the Makefile, sub-folders or
# parent-folders. 
#
# The Makefile searches all the .cpp files in the given folders and compile them
# into object files and link them into library or program. It generates dependency
# files automatically so that it can catch any change or the source files or 
# related header files.
#
# All the output of the make process is put in $(ODIR) folder. The default value
# is 'Build', but can be overriden with 'ODIR=xxx' when executing 'make'.   
#
#

# The folder where the Makefile exists
PWD := $(abspath $(shell pwd))

# A common folder which is parent-folder of all given folders in $(MODULES)
TOP_DIR := $(abspath ../../..)

# The default output folder, could be overriden with 'ODIR=xxx' when 'make'.
ODIR ?= Build

# The final targat. Should define only one of them: PROG or LIB
PROG := 
LIB := libapclient.a

# The modules (directories) that need to be built. All the .cpp files in these
# directories will be built automatically. They should be specified with prefix 
# of$(TOP_DIR).
MODULES   := \
  $(TOP_DIR)/Dingo/Client/AccessPoint/ServiceProxy \
  $(TOP_DIR)/Dingo/Client/AccessPoint/ServiceProxy/gSoap \
  $(TOP_DIR)/Dingo/Client/AccessPoint/Services/IncomingEventService/Source/DataObjects \
  $(TOP_DIR)/Dingo/Client/AccessPoint/Services/IncomingEventService/Source/MetadataObjects \
  $(TOP_DIR)/Dingo/Client/AccessPoint/Services/IncomingEventService/Source/Services \
$(TOP_DIR)/Dingo/Gateway/Siemens.Gateway.Linux.Client \
$(TOP_DIR)/Dingo/Client/AccessPoint/TinyXML
# The external libs need to be linked. This is used when build program.
LIBS :=

# CFLAGS for compiling. -MD -MP must be kept.
CFLAGS := -MD -MP -g -I. \
-I$(TOP_DIR)/Dingo/Gateway \
 -I$(TOP_DIR)/Dingo/Gateway/PlatformSpecific/CPP \
-I$(TOP_DIR)/Dingo/Client/AccessPoint/Services/IncomingEventService \
-I$(TOP_DIR)/Dingo/Client/AccessPoint/TinyXML

# LDFLAGS for linking. It's only used when build program.
LDFLAGS :=

# Cross compile option 
ifneq ($(ARM),yes)
CROSS_COMPILE
endif

################################################################################
# Below part should be considered as standard and normally don't need to change!
################################################################################

SRC_DIRS  := $(MODULES)
BUILD_DIRS:= $(addprefix $(ODIR),$(subst $(TOP_DIR),,$(MODULES)))

SRCS      := $(foreach sdir,$(SRC_DIRS),$(wildcard $(sdir)/*.cpp))
OBJS := $(patsubst %.cpp,%.o,$(addprefix $(ODIR),$(subst $(TOP_DIR),,$(SRCS))))
DEPS      := $(OBJS:.o=.d)

INCLUDES  := $(addprefix -I,$(SRC_DIRS))
CFLAGS += $(INCLUDES)

CC        := $(CROSS_COMPILE)g++
LD        := $(CROSS_COMPILE)g++
AR := $(CROSS_COMPILE)ar
ECHO := echo
MKDIR := mkdir -p
RM := rm -rf
LN := ln -sf

vpath %.cpp $(SRC_DIRS)

define make-goal
$1/%.o : %.cpp
@$(ECHO) "CC   $$<"
@$(CC) $(CFLAGS) -c $$< -o $$@

endef

.PHONY: all checkdirs clean 

all: checkdirs $(ODIR)/$(LIB) $(ODIR)/$(PROG)

ifneq ($(PROG),)
$(ODIR)/$(PROG): $(OBJS)
@$(ECHO) "LD   $@"
@$(LD) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
endif

ifneq ($(LIB),)
$(ODIR)/$(LIB): $(OBJS)
@$(ECHO) "AR   $@"
@$(AR) crs $@ $(OBJS)
endif

checkdirs: $(BUILD_DIRS)
$(BUILD_DIRS):
@$(ECHO) "MKDIR  $@"
@$(MKDIR) -p $@

clean:
@$(RM) $(BUILD_DIRS) $(ODIR)

$(foreach bdir,$(BUILD_DIRS),$(eval $(call make-goal,$(bdir))))

-include $(DEPS)

VMWare Player

1. Share folder

Share folder is a better option in order to share files between Windows and virtual machine Linux. It's better than  use Samba. In order to use Share folder, you don't have to have any virtual network.

2. Virtual network:

The host-only network is not necessary. You can use NATed interface to allow the virtual machine to access outside world. Give the host VMnet interface an IP address of the same segment of virtual machine, then the host can access virtual machine. For NATed interface, there's always a special IP address reserved as the gateway for the network segment.

2011-01-20

Understanding /proc (quote)

When it comes down to it, /proc is a filesystem. Although it does not represent any physical device, you can still mount it and unmount it as you please. It contains a multitude of valuable information regarding the processes you are running, as well as the hardware you have hooked up to your computer (although in recent years, /sys has been devised by the Kernel folks to represent the hardware hierarchy and export device information ). You can see which modules you have loaded, how long your system has been up, and the memory usage of processes on your system. In fact, every single process running has an entry, or directory, inside /proc. As you can see, /proc can be a very powerful asset. But before you can use it, you need to mount it.
Note: Many of the examples in this guide require root access to work correctly. If you don't have root access on your Linux box, get it. We'll wait.
{mospagebreak title=Mounting /proc}

Mounting /proc

As mentioned earlier, /proc is a filesystem. And, like all filesystems, you need to mount it. In theory, you could mount it anywhere, but the standard is to mount it in /proc.
Most systems have /proc mounted by default in /etc/fstab, but just in case, make sure that it's mounted by doing:

$ mount

Note: Throughout this guide, $ indicates a command to be run from a normal user's shell, and # indicates something that must be run from a root shell.
If the output contains a line such as:


proc on /proc type proc (rw)

then you are fine. If not, follow the instructions below.
First, make sure that you have a directory called /proc:

# if ! test -f /proc
then
mkdir /proc
fi

Then, add a line to the file /etc/fstab such as this:

proc  /proc proc  defaults  0 0

Now, mount it:

# mount proc

You're now ready to play around with /proc.
{mospagebreak title=Viewing Process Information}
Each time a new process is created, an entry in /proc is created. The name of the directory entry corresponds to the process identification number (PID) of the created process, so, for example, a process with a PID of 8695 will have a corresponding directory entry of /proc/8695/.
nside /proc/8695/ (replace 8695 with a real PID on your system), you'll see something like:

auxv  exe  mem  root  statm
cmdline fd/  mounts seccomp status
cwd  loginuid oom_adj smaps task/
environ maps  oom_score stat  wchan

Note: The entries ending in �/� are directories.
As you can see, a lot of data about each process is stored. Let's go through the basics:
cmdline - This contains information about the actual command line invoked to start this process. This is a down and dirty way to find out what this process is actually doing.
The best way to access this info is by using a tool such as 'strings' which will display any printable information from a binary file:

$ strings cmdline
/opt/OpenOffice.org/program/soffice.bin
private:factory/swriter

cwd - This is a symlink to the working directory from which the process was started. For example, I started OpenOffice.org (PID 8695) in my home directory, so cwd points to /home/akissner.
environ - This file contains the environment of the process, sorted in to key=value pairs. There is no particular order, so for a human readable output, you would want to do something like:

$ strings environ | sort | less

This will sort the output alphabetically, sorted by the key.
exe - 'exe' is another symlink, this time to the actual binary itself. So if you wanted to run another copy of the process, you could do:

$ /proc/8695/exe

fd/ - This is a tricky one. It is a subdirectory of symbolic links to open file descriptors in use by the program. /proc/XXXX/fd/ will always contain, at the very least, the links 0, 1, 2. These correspond to STDIN, STDOUT, and STDERR, respectively.
Using this, you can see what files a program is manipulating. This is one way that you can find out where a browser keeps its cache, or a text editor keeps its temporary files.
loginuid - A little background is required before I can explain this one. This isn't completely technically correct, but it's good enough for a Cliff Notes summary.
Each process is represented in the kernel as a structure of type "task". This task structure keeps track of a lot of information about a process, including the PID, the UID of the user who started it, its children, and countless other things. One such attribute is the field "loginuid". The loginuid shows which account a user gained access to the system with. The /proc/XXXX/loginuid shows this value.
maps - 'maps' is one of the most complicated things inside of the /proc filesystem. Suffice it to say that one must have a basic grounding in the inner workings of the kernel and memory management to fully appreciate the information inside of /proc/XXXX/maps.

08048000-080a1000 r-xp 00000000 08:06 35310321   /opt/OpenOffice.org/program/soffice.bin
080a1000-080a6000 rw-p 00058000 08:06 35310321   /opt/OpenOffice.org/program/soffice.bin
080a6000-084b6000 rw-p 080a6000 00:00 0          [heap]
b0e2d000-b0e3d000 rwxp b0e2d000 00:00 0 
b0e4d000-b0e81000 r--p 00000000 08:06 86555296   /opt/OpenOffice.org/help/en/picture.db
b0e81000-b0ec4000 rw-p b0e81000 00:00 0 
b0ec4000-b0f34000 rwxp b0ec4000 00:00 0 
b0f42000-b0f62000 rwxp b0f42000 00:00 0 
b0f62000-b0f7d000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b0f7d000-b0f98000 r--s 00000000 00:07 21004324   /SYSV00000000 (deleted)
b0f98000-b0fb3000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b0fb3000-b0fce000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b0fce000-b0fe9000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b0fe9000-b1004000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b1004000-b101f000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b101f000-b103a000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b103a000-b1055000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b1055000-b1070000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b1070000-b108b000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)
b108b000-b10a6000 r--s 00000000 00:07 20971555   /SYSV00000000 (deleted)

Shown above is a sample listing for my OpenOffice.org process (PID 8695). As you can see, OpenOffice.org uses a lot of memory!
The first column lists, in hexadecimal, the address range for the mapped memory. The next column lists the permissions on that section of memory. This can either be r, w, x, p, or s, which is read, write, execute, private, and shared, respectively. The third column is the offset, and the fourth column lists the device where the memory is mapped from. The device column is split into major:minor, where major is the corresponding major device number (this has to do with which driver is assigned to which device) and minor number (which has to do with the number of devices a driver is representing). Using information from /proc/devices, you can decipher the device being used. The next column is the inode number of the file from which the memory is being mapped. Last is the pathname of the file.
mem - This cannot be used directly from the command line for anything. You can call the open() and read() system calls on it to read the pages of a process's memory, but most people will go their whole life without ever needing to to this.
mounts - In most cases, this is the same thing as /proc/mounts, which displays mounted filesystem information.
oom_* - These files control the system's behavior if it meets an Out of Memory (OOM) condition. Generally, you won't need to mess with this. The oom_adj file can be used to make a process unkillable during OOM.
root - This is a symlink to the process's root directory. Normally, this will be '/'. But if, for example, a process were started inside a 'chroot jail', then /proc/XXXX/root might point to "/foo/jail".
seccomp - Changing the value in this file from '0' to '1' will send the process in to "seccomp" mode. Seccomp is a sandbox mechanism for the kernel, which restricts a certain process from executing most system calls. This is a security feature, which you will probably never use.
smaps - This file provides detailed memory consumption information for a process.
stat - Like the name suggestions, /proc/XXXX/stat contains information about a process's status. In fact, modern versions of ps (namely those coming from the 'procps' package) use /proc/XXXX/stat for their information. The output is not formatted, and looks like this:

8695 (soffice.bin) S 8666 3234 3180 1025 3224
 8396864 68 0 8 0 27 31 0 0 16 0 1 0 51495018 134680576 8844
 4294967295 134512640 134875180 3216856352 4154390430 582 0
 0 4096 2076206327 0 0 0 33 1 0 0

The best place for information on these fields is the proc(5) manpage.
statm - This file gives memory status information. This file gives information in page-sized blocks. The columns are size (total), rss (resident set size), shared pages, text (the executable code), library code, data/stack size, and dirty pages. The last column is no longer used in the 2.6 kernel series.
status - This file contains the information given in stat and statm, but in a much more human-friendly form. Each row is labeled, and the names are for the most part self-explanatory.
task - task is a directory, containing a directory (with the same name as the PID) that contains all the information inside /proc/XXXX (except for task/). It's a bit of a pointless directory, in my opinion.
wchan - The WCHAN data for a process is the kernel function where the process is currently blocking.
That covers things for this first installment in a multi-part series on understanding the /proc filesystem. Part 2 will cover using /proc to find information about the devices attached to your system.