2006年05月18日

一个大体得概念很重要,尤其是对于我这个从来没编过web程序,但是需要快速完成得人来说。看了很多文档,感觉无从入手。

推荐writing Apache Modules with C and Perl

http://www.kuzbass.ru/docs/apache_c_mod_perl/1.htm

2006年05月15日

1.安装Apache For Windows   2.0.55

Issue: No installed service named apache2

Resolution: apache -k install

http://127.0.0.1/     测试成功

2.安装Perl For Windows 

3 mod_perl for windows  2.0

机器上没有nmake,所以不去编译mod_perl.so,直接用ppm

ppm install http://theoryx5.uwinnipeg.ca/ppms/mod_perl.ppd

参考http://theory.uwinnipeg.ca/modperl/docs/2.0/os/win32/install.html

http://theory.uwinnipeg.ca/modperl/docs/2.0/os/win32/config.html  

要strictly follow这个config文件就会自然成功。^_^

换了台机器,不小心装了apach2.2,当时没看到,后来发现不兼容的,重新装了2.0.58。

停掉IIS,apache启动成功。

装mod_perl却不顺利,不能用ppm,按照指示,手动下载了mod_perl.so放在modules下面,没有作用,可能版本有问题吧,我下的是2.2应该不能用吧。

按照上述文档,编译了2.0版本并安装,启动不了,察看一下extra.pl,半分法注释查找哪里出错,发现use CGI,到cpan上装一下就好了

2006年03月19日

1, In either case, we will always indent the statements controlled by the while by one tab stop (which we have shown as four spaces) so you can see at a glance which statements are inside the loop. The indentation emphasizes the logical structure of the program. Although C compilers do not care about how a program looks, proper indentation and spacing are critical in making programs easy for people to read. We recommend writing only one statement per line, and using blanks around operators to clarify grouping.

2,If an arithmetic operator has integer operands, an integer operation is performed. If an arithmetic operator has one floating-point operand and one integer operand, however, the integer will be converted to floating point before the operation is done. If we had written (fahr-32), the 32 would be automatically converted to floating point. Nevertheless, writing floating-point constants with explicit decimal points even when they have integral values emphasizes their floating-point nature for human readers.

3,It’s bad practice to bury “magic numbers” like 300 and 20 in a program; they convey little information to someone who might have to read the program later, and they are hard to change in a systematic way. One way to deal with magic numbers is to give them meaningful names. A #define line defines a symbolic name or symbolic constant to be a particular string of characters

4, Symbolic constant names are conventionally written in upper case so they can ber readily distinguished from lower case variable names. Notice that there is no semicolon at the end of a #define line.

5, By the way, printf is not part of the C language; there is no input or output defined in C itself. printf is just a useful function from the standard library of functions that are normally accessible to C programs. The behaviour of printf is defined in the ANSI standard, however, so its properties should be the same with any compiler and library that conforms to the standard.

6,   #include <stdio.h>

   /* copy input to output; 2nd version  */
   main()
   {
       int c;

       while ((c = getchar()) != EOF)
           putchar(c);
   }

We used int for a subtle but important reason.

The problem is distinguishing the end of input from valid data. The solution is that getchar returns a distinctive value when there is no more input, a value that cannot be confused with any real character. This value is called EOF, for “end of file”. We must declare c to be a type big enough to hold any value that getchar returns. We can’t use char since c must be big enough to hold EOF in addition to any possible char. Therefore we use int.

EOF is an integer defined in <stdio.h>, but the specific numeric value doesn’t matter as long as it is not the same as any char value. By using the symbolic constant, we are assured that nothing in the program depends on the specific numeric value.

7,for (nc = 0; gechar() != EOF; ++nc)
           ;
The body of this for loop is empty, because all the work is done in the test and increment parts. But the grammatical rules of C require that a for statement have a body. The isolated semicolon, called a null statement, is there to satisfy that requirement. We put it on a separate line to make it visible.

8,You may have noticed that there is a return statement at the end of main. Since main is a function like any other, it may return a value to its caller, which is in effect the environment in which the program was executed. Typically, a return value of zero implies normal termination; non-zero values signal unusual or erroneous termination conditions. In the interests of simplicity, we have omitted return statements from our main functions up to this point, but we will include them hereafter, as a reminder that programs should return status to their environment.


确实应该是初学的时候应该十分注意的东西啊,不过大学时候学的和后来重新看大学C课本,似乎都没有这么明显的发现这些问题。是教材不太好么?如果是的话,那中国的大学老师们似乎应该反思了吧。

2005年07月07日

use CreateObject to access to COM,so to obtain some functions that are not provided in VBscript or Jscript

if COM Objects start with the same name, they are in the same physical file.All the Scripting Objects live inside SCRRUN.DLL, and all the WScript Objects
are stored inside WSHOM.OCX. You can view both files in the Windows system
folder.

Any object name you supply to CreateObject—like Scripting.
FileSystemObject or WScript.Shell—is really a ProgID, or program
identifier. You will always find a Registry key in HKEY_CLASSES_ROOT\ with
the same name. This is the central store telling CreateObject how to
access the object. If the Registry key is missing, you will no longer be able
to access the object.

It has two subkey:CLSID and CurVer. CLSID shows the classID.The compiler that produced the run-time object generates the Class-ID.you can’t manually
change the Class-ID by changing Registry values. If you did, you could no
longer access the object because the Registry Class-ID needs to match the
Class-ID stored inside the object. The same is true if you update an object file.
Because the new version has a new Class-ID, you need to register the new
object. Just replacing the file would disable the object.

go to HKEY_CLASSES_ROOT\CLSID\ to find detailed object information

1, Fill the Directory Table

Directory Directory_Parent DefaultDir
TARGETDIR   SourceDir
EXEDIR TARGETDIR App
DLLDIR EXEDIR Bin
DesktopFolder TARGETDIR Desktop

if EXEDIR is defined with full path, App will be installed to EXEDIR, or else, it will be installed to TARGETDIR/App

2, Fill the Component table

Component ComponentId Directory_ Attributes Condition Keypath
Baseball {F54ABAC0-33F2-11D3-91D7-00C04FD70856} SPORTDIR 2 Baseball.txt
Concert {76FA7A80-33F6-11D3-91D8-00C04FD70856} ARTSDIR 2 Concert.txt

Component ID should be different each time and Directory is defined in directory table

3, Fill the File Table

File Component_ FileName FileSize Version Language Attributes Sequence
Baseball.txt Baseball Baseball.txt 1000 0 1
Concert.txt Concert Concert.txt 1000 0 1

4, Fill the media Table

DiskId LastSequence DiskPrompt Cabinet VolumeLabel Source
1 1

LastSequence:File sequence number for the last file for this media

5, Feature Table

Feature Feature_Parent Title Description Display Level Directory_ Attributes
Arts Arts Arts events at Red Park. 20 3 NOTEPADDIR 0
Baseball Sport Baseball Baseball Games 17 3 SPORTDIR 32
Display
The number in this field specifies the order in which the feature is to be displayed in the user interface. The value also determines if the feature is initially displayed expanded or collapsed.

If the value is null or zero, the record is not displayed. If the value is odd, the feature node is expanded initially. If the value is even, the feature node is collapsed initially.

Level
The initial installation level of this feature. Processing the Condition Table can modify the level value. For more details, see Install Level in the Remarks section.

An install level of zero disables the item and prevents it from being displayed.

6, Component and Feature relationship

7, Regitry table

2005年04月19日

For linux

1, gcc -c primitive.c -o primitive.o

2,ar -r primitive.a primitive.o

extract

ar -x primtive.a

For windows

cl primitive.c /c

lib  primitive.obj

Note, cl got /link option to pass parameters to link.exe

对于windows:

1,cl primitive.c codec.c application.c /c to generate .obj

2, link primitive.obj /DLL /DEF:primitive.def  This will generate several files. .lib is used to build dlls or exes that refer to primitive.dll.

3, link codec.obj primitive.lib /DLL /DEF:codec.def

4, link application.obj primitive.lib codec.lib

Though codec.dll refer to primitive.dll, there is no order must-bes.

5, dumpbin /exports primitive.lib             you can see that primitive lib export primitive_print function

关于linux

产生so

gcc -g -s -shared -W1,-soname,codec.so -o codec.so codec.o

 gcc -g -s -shared -W1,-soname,prim.so -o prim.so prim.o

使用so

 gcc application.c -o application.exe -L. prim.so codec.so -Wl,-rpath

There is no order must-bes.


2005年04月14日

1,如果所依赖文件比target新,或者没有target,执行后面的命令;对于label要在make命令行中,显示的指定出来执行,如clean。

2,把所有需要link的obj放在一个宏里,需要link的lib也一样

3,对于.o的target,可以省略同名的.c文件和gcc -c xxx.c 这样的命令

4,在命令之前加上"-",则忽略错误。命令要以tab开头

5,all : target1 target2 target 3…,执行make后可以一下生成多个目标。也可以指定all为phony,只需要输入make all

6,,“$<”表示所有的依赖,“$@”表示目标集

2005年04月12日

创建引用有两种方法:

1,$aref=\@a

2,匿名引用 $aref=[1,"a","b"]  {}则代表匿名散列

析值:

1,带有大括号的引用相当于数组名

@a=@{$aref}

2, ${$aref}[3]相当于$aref->[3]  指数组a的第四个元素 和$aref[3]完全不同,后者是指aref数组的第四个元素

举例:

1   my %table;
    2   while (<>) {
    3    chomp;
    4     my ($city, $country) = split /, /;
    5     $table{$country} = [] unless exists $table{$country};  //创建一个空的匿名数组的引用,存储在$table{$country} 中
    6     push @{$table{$country}}, $city;   {匿名数组引用}将恢复数组名。
    7   }
    8   foreach $country (sort keys %table) {
    9     print "$country: ";
   10     my @cities = @{$table{$country}};
   11     print join ’, ’, sort @cities;
   12     print ".\n";
   13   }

2004年10月29日

To support the different ways applications use dialog boxes, there are two types of dialog box: modal and modeless. A modal dialog box requires the user to supply information or cancel the dialog box before allowing the application to continue.

A modeless dialog box allows the user to supply information and return to the previous task without closing the dialog box.

To create either a modal or modeless dialog box, an application must supply a dialog box template to describe the dialog box style and content; the application must also supply a dialog box procedure to carry out tasks. The dialog box template is a binary description of the dialog box and the controls it contains. The developer can create this template as a resource to be loaded from the application’s executable file, or created in memory while the application runs. The dialog box procedure is an application-defined callback function that the system calls when it has input for the dialog box or tasks for the dialog box to carry out.

DialogBox creates a modal dialog box; CreateDialog creates a modeless dialog box.