??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲AV无码精品色午夜果冻不卡 ,亚洲av无码成人精品区,亚洲va在线va天堂va手机http://www.tkk7.com/wenhl5656/zh-cnSun, 11 May 2025 14:01:31 GMTSun, 11 May 2025 14:01:31 GMT60pImpl Idiomhttp://www.tkk7.com/wenhl5656/archive/2010/08/07/328217.htmlDestDestSat, 07 Aug 2010 14:58:00 GMThttp://www.tkk7.com/wenhl5656/archive/2010/08/07/328217.html降低文g间的~译依赖关系Q通过把一个Class分成两个ClassQ一个只提供接口Q另一个负责实现该接口Q实现接口与实现的分R这个分ȝ关键在于“以声明的依赖性”替换“定义的依赖性”,而编译依赖性最化的本质是:让头文g可能的自我满Q万一做不刎ͼ则让它与其他文g内的声明式(而非定义式)怾?br />
引用q里的一些描qͼ
The Pimpl idiom, also known as the compilation firewall or Cheshire Cat technique, is a "private implementation" technique useful only in CeePlusPlus and statically compiled languages like it...

Benefits:
  1. Changing private member variables of a class does not require recompiling classes that depend on it, thus make times are faster, and the FragileBinaryInterfaceProblem is reduced.
  2. The header file does not need to #include classes that are used 'by value' in private member variables, thus compile times are faster.
  3. This is sorta like the way SmallTalk automatically handles classes... more pure encapsulation.
Drawbacks:
  1. More work for the implementor.
  2. Doesn't work for 'protected' members where access by subclasses is required.
  3. Somewhat harder to read code, since some information is no longer in the header file.
  4. Run-time performance is slightly compromised due to the pointer indirection, especially if function calls are virtual (branch prediction for indirect branches is generally poor).
How to do it:
  1. Put all the private member variables into a struct.
  2. Put the struct definition in the .cpp file.
  3. In the header file, put only the ForwardDeclaration of the struct.
  4. In the class definition, declare a (smart) pointer to the struct as the only private member variable.
  5. The constructors for the class need to create the struct.
  6. The destructor of the class needs to destroy the struct (possibly implicitly due to use of a smart pointer).
  7. The assignment operator and CopyConstructor need to copy the struct appropriately or else be disabled.
CodeQ?/font>
1   struct AImp;
2   class A {
3   public:
4     // Same public interface as A, but all delegated to concrete implementation.
5   private:
6     AImp * pimpl;
7   };
8 


If you use a SmartPointer and you only have one implementation, there is no need to make any of the member functions virtual, except possibly the destructor. The run-time cost of non-virtual member function calls is much lower, and a compiler that does whole-program optimization can inline them even though they're in a separate translation unit. Here's an example:
 1  // foo.h
 2 
 3   class foo_impl;
 4 
 5   class foo {
 6     // Boilerplate
 7     friend class foo_impl;
 8     foo() {} // so only foo_impl can derive from foo
 9     const foo_impl * impl() const;
10     foo_impl * impl();
11   public:
12     virtual ~foo() {}
13     // Factories
14     static std::auto_ptr<foo> create(int value);
15     // Interface
16     int value() const;
17   };
18 
19   // foo.cpp
20 
21   class foo_impl : public foo {
22     friend class foo;
23     // Constructors mirroring the factory functions in foo
24     explicit foo_impl(int value) : value_(value) {}
25     // Member data
26     int value_;
27   };
28 
29   inline const foo_impl * foo::impl() const {
30     return static_cast<const foo_impl *>(this);
31   }
32   inline foo_impl * foo::impl() {
33     return static_cast<foo_impl *>(this);
34   }
35 
36   std::auto_ptr<foo> foo::create(int value) {
37     return std::auto_ptr<foo>(new foo_impl(value));
38   }
39 
40   int foo::value() const { return impl()->value_; }
41 
42 

Here, the destructor needs to be declared virtual foo so that std::auto_ptr<foo> calls foo_impl's destructor. If you use boost::shared_ptr<foo> instead, even that doesn't need to be virtual, because shared_ptr remembers how to call the correct destructor. (This doesn't improve performance or memory use, because shared_ptr is larger and slower than auto_ptr, but if you need to use shared_ptr anyway you may as well eliminate the virtual destructor.) -- BenHutchings


参考阅读:

Effective C++
http://c2.com/cgi/wiki?PimplIdiom
http://en.wikipedia.org/wiki/Opaque_pointer


Dest 2010-08-07 22:58 发表评论
]]>
Effective C++ - 09.l对不要在构造和析构q程中调用虚函数http://www.tkk7.com/wenhl5656/archive/2010/07/28/327365.htmlDestDestWed, 28 Jul 2010 13:37:00 GMThttp://www.tkk7.com/wenhl5656/archive/2010/07/28/327365.html要点Q绝对不应该在构造函数和析构函数中调用虚函数?br />
Derived Class对象内的Base Class成分会在Derived Class自n成分被构造之前构造完成。如果Base Class构造函C有虚函数Qvirtual functionQ,该virtual functionl对不会下降到Derived Class层中Q而是直接调用Base Class中该函数Q通俗的说Q即——在Base Class构造时Qvirtual function不再被当成virtual function?br />
q是因ؓQ在Base Class构造期_对象的类型是Base Class而不是Derived Class。不只是虚函C被编译器解析至Base Class中,若用运行期cM息(runtime type informationQ例如dynamic_cast和typeidQ,也会把对象视为Base Classcd。同栯也适合于析构函数。一旦由Derived Class的析构函数进入到BaseClass的析构函数后Q对象就成ؓ一个BaseClass的对象了?br />


Dest 2010-07-28 21:37 发表评论
]]>
扑և数组中最大的K个数http://www.tkk7.com/wenhl5656/archive/2010/01/20/310228.htmlDestDestWed, 20 Jan 2010 06:05:00 GMThttp://www.tkk7.com/wenhl5656/archive/2010/01/20/310228.htmlC代码Q?br />
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 int new_random(int min, int max)
 4 {
 5     return (min + (int)(((float)rand()/RAND_MAX)*(max - min)));
 6 }
 7 void swap(int *a, int *b)
 8 {
 9     int c = *a;
10     *= *b;
11     *= c;
12 }
13 
14 int partition(int A[], int p, int r)
15 {
16     int i = p - 1, j;
17     for(j = p; j < r; j++)
18     {
19         if(A[j] <= A[r])
20         {
21             i++;
22             swap(&A[i], &A[j]);
23         }
24     }
25     swap(&A[i + 1], &A[r]);
26     return i + 1;
27 }
28 
29 int randomize_partition(int A[], int p, int r)
30 {
31     int i = new_random(p, r);
32     swap(&A[i], &A[r]);
33     return partition(A, p, r);
34 }
35 
36 //W一U算?/span>
37 int randomized_select(int data[], int p, int r, int k)
38 {
39     if(k > (r - p + 1)) return 0;
40     if(p == r) return data[p];
41     int i = randomize_partition(data, p, r);
42     //int i = partition(data, p, r);
43 
44     int count = i - p + 1;
45     if(k <= count)
46         return randomized_select(data, p, i, k);
47     else
48         return randomized_select(data, i + 1, r, k - count);
49 

Java代码Q?br />
 1 package algorithm;
 2 
 3 import java.util.ArrayList;
 4 import java.util.Collections;
 5 import java.util.List;
 6 import java.util.Random;
 7 
 8 public class FindKth {
 9 
10     public static Random rand = new Random();
11 
12     /**
13      * Find the K-th smallest number in a list using random algorithm
14      * 
15      * @return the k-th smallest number
16      */
17     public static int selectKth(int[] arr, int k) {
18         int low = 0;
19         int high = arr.length - 1;
20         int m;
21         k = k - 1;
22         while (low < high) {
23             int r = low + rand.nextInt(high - low + 1);
24             swap(arr, low, r);
25             m = low;
26             for (int i = low + 1; i <= high; i++)
27                 if (arr[i] < arr[low])
28                     swap(arr, ++m, i);
29             swap(arr, low, m);
30             if (m == k)
31                 return arr[k];
32             else if (m < k)
33                 low = m + 1;
34             else
35                 high = m - 1;
36         }
37 
38         return arr[k];
39     }
40 
41     public static int selectKth(Integer[] arr, int k) {
42         int[] array = new int[arr.length];
43         for (int i = 0; i < arr.length; i++)
44             array[i] = arr[i];
45         return selectKth(array, k);
46     }
47 
48     private static void swap(int[] arr, int low, int r) {
49         int tmp = arr[low];
50         arr[low] = arr[r];
51         arr[r] = tmp;
52     }
53 
54     /**
55      * @param args
56      */
57     public static void main(String[] args) {
58         List<Integer> list = new ArrayList<Integer>();
59         for (int i = 0; i < 10; i++)
60             list.add(new Integer(i + 1));
61         Integer[] arr = new Integer[list.size()];
62         for (int loop = 0; loop < 1000; loop++) {
63             Collections.shuffle(list);
64             list.toArray(arr);
65             int res = selectKth(arr, 5);
66             if (res != 5)
67                 System.out.println(loop + " " + res);
68         }
69 
70     }
71 
72 }
73 

Python代码Q?br />
 1 #!/usr/bin/env python
 2 from random import randint
 3 
 4 # finding the kth smallest number in a list
 5 def select(list, k):
 6     low = 0
 7     up = len(list) - 1
 8     k = k - 1
 9     while(low < up):
10         rand = randint(low, up)
11         list[low], list[rand] = list[rand], list[low] #swap
12         m = low
13         tmp = list[low]
14         for i in xrange(low + 1, up + 1):
15             if list[i] < tmp:
16                 m += 1
17                 list[m], list[i] = list[i], list[m] # swap
18         list[m], list[low] = list[low], list[m]
19         if m == k:
20             return list[k]
21         elif m < k:
22             low = m + 1
23         elif m > k:
24             up = m - 1  
25     return list[k]
26     
27     
28 = range(111)
29 from random import shuffle
30 for i in range(100):
31     shuffle(x)
32     print select(x, 5)





Dest 2010-01-20 14:05 发表评论
]]>
Linux中进E如何成为守护进E?/title><link>http://www.tkk7.com/wenhl5656/archive/2009/12/11/305533.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Fri, 11 Dec 2009 03:33:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2009/12/11/305533.html</guid><description><![CDATA[<div>    守护q程q行在后?不与M控制l端相关?守护q程以root用户q行或者其他特D的用户,q处理一些系l的Q? 习惯上守护进E的名字以dl尾,但不是必ȝ.</div> <div>    对守护进E的两个基本要求: 它必Linitq程的子q程; 不与M控制l端相关?</div> <div>    一般来? q程可以通过以下步骤成ؓ守护q程:</div> <blockquote> <div>1. 调用fork(), 创徏新的q程, 它会是将来的守护q程.</div> <div>2. 在守护进E的父进E中调用exit(). q保证祖父进E?守护q程的祖父进E?认父进E已l结? q保证父q程不再l箋q行, 守护q程不是l长q程. 最后一Ҏ(gu)利完成一下步骤的前提.</div> <div>3. 调用setsid(), 使得守护q程有一个新的进E组和新的会? 两者都把它作ؓ首进E? q也保证它不会与控制l端相关?</div> <div>4. 用chdir()当前工作目录改为根目录. 因ؓ前面调用fork()创徏了新q程, 它所l承来的当前工作目录可能在文件系l的M地方. 而守护进E通常在系l启动时q行, 同时不希望一些随机目录保持打开状? 也就L了管理员卸蝲守护q程工作目录所在的那个文gpȝ.</div> <div>5. 关闭所有的文g描述W? 不需要承Q何打开的文件描q符, 对于无法认的文件描q符, 让它们l处于打开状?</div> <div>6. 打开0, 1?h件描q符(标准输入, 标准输出和标准错?, 把它们重定向?dev/null.</div> </blockquote> <div>Ҏ(gu)q些规则, 下面E序可以成ؓ守护q程:</div> <div> <div style="padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; border-left-color: rgb(204, 204, 204); width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">sys</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">types.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">sys</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">stat.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">stdlib.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">stdio.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">fcntl.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">unistd.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">linux</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">fs.h</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> main(</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">)<br /> </span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">{<br /> </span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);"> pid_t pid;<br /> </span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i;<br /> </span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> create new process </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);"> pid </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> fork();<br /> </span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(pid </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(pid </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">) exit(EXIT_SUCCESS);<br /> </span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> create new session and process group </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(setsid() </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> set the working directory to the root directory</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(chdir(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> close all open files -- NR_OPEN is overkill, but works </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; i </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> NR_OPEN; i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) close(i);<br /> </span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> redirect fd's 0, 1, 2 to /dev/null </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);"> open(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/dev/null</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, O_RDWR); </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> stdin </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);"> dup(</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> stdout </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);"> dup(</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> stderr </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"> do it daemon thing<img src="http://www.tkk7.com/Images/dot.gif" alt="" />.</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);"> <br /> </span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 0, 0);">}</span></div> </div> <div><br /> </div> <div>许多Unixpȝ在它们的C函数库中提供了daemon()函数来完成这些工?</div> <div><span id="xzaiobf" class="Apple-tab-span" style="white-space: pre;"> </span>#include <unistd.h></div> <div><span id="pbileur" class="Apple-tab-span" style="white-space: pre;"> </span>int daemon(int nochdir, int noclose);</div> <div><br /> </div> <img src ="http://www.tkk7.com/wenhl5656/aggbug/305533.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2009-12-11 11:33 <a href="http://www.tkk7.com/wenhl5656/archive/2009/12/11/305533.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>两个已排序链表的合ƈhttp://www.tkk7.com/wenhl5656/archive/2009/06/21/283442.htmlDestDestSun, 21 Jun 2009 04:02:00 GMThttp://www.tkk7.com/wenhl5656/archive/2009/06/21/283442.html 1 typedef struct Node{
 2     int data;
 3     struct Node* next;
 4 }Node, *LinkList;
 5 void Merge(LinkList la, LinkList lb, LinkList &lc)
 6 {
 7     // NULL?/span>
 8     if(!la) {lc = pb; return;}
 9     if(!lb) {lc = pa; return;}
10     Node* p;
11     
12     // 定最大值在la? q是lb?/span>
13     if(la.data > lb.data) { lc = p = la; la = la->next; }
14     else { lc = p = lb; lb = lb->next; }
15     
16     while(la &&lb)
17     {
18         if(la.data > lb.data)
19         {
20             p->next = la;
21             la = la->next;
22         }else if(la.data < lb.data)
23         {
24             p->next = lb;
25             lb = lb->next;
26         }else// la ?nbsp;lb中值相{的情况
27             p->next = la;
28             la = la->next;
29             Node* tmp = lb;
30             lb = lb->next;
31             free(tmp);
32         }
33         p = p->next;
34     }
35     // 剩余部分链表的挂?/span>
36     p->next = (la ? la:lb);
37 }

Dest 2009-06-21 12:02 发表评论
]]>
(面试?利用栈将另一个已排序栈中元素反排?/title><link>http://www.tkk7.com/wenhl5656/archive/2009/06/21/283424.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Sat, 20 Jun 2009 17:04:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2009/06/21/283424.html</guid><description><![CDATA[     摘要: 有两个相同的栈,一个里面放着自大到小排列的数Q栈的数最,另一个栈是空? <br>不允许利用其它的数据l构Q只能利用这两个栈,要求把第一个栈里的数字反过来,?<br>到大排列,l果q放在原来的那个栈里面?nbsp; <a href='http://www.tkk7.com/wenhl5656/archive/2009/06/21/283424.html'>阅读全文</a><img src ="http://www.tkk7.com/wenhl5656/aggbug/283424.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2009-06-21 01:04 <a href="http://www.tkk7.com/wenhl5656/archive/2009/06/21/283424.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>单元试(转摘)http://www.tkk7.com/wenhl5656/archive/2009/06/17/282924.htmlDestDestWed, 17 Jun 2009 14:08:00 GMThttp://www.tkk7.com/wenhl5656/archive/2009/06/17/282924.html
单元试是由E序员自己来完成Q最l受益的也是E序员自己。可以这么说Q程序员有责ȝ写功能代码,同时也就有责Mؓ自己的代码编写单元测试。执行单元测试,是Z证明q段代码的行为和我们期望的一致?

要进行充分的单元试Q应专门~写试代码Qƈ与品代码隔R个为,比较单的办法是ؓ产品工程建立对应的测试工E,为每个类建立对应的测试类Qؓ每个函数Q很单的除外Q徏立测试函数?nbsp; 阅读全文

Dest 2009-06-17 22:08 发表评论
]]>
试用例设计http://www.tkk7.com/wenhl5656/archive/2009/06/17/282918.htmlDestDestWed, 17 Jun 2009 13:48:00 GMThttp://www.tkk7.com/wenhl5656/archive/2009/06/17/282918.html    试用例是试数据及与之相关的功能的一个特定集合,它是为验证被试E序Qؓ试E序路径或验证是否符合特定功能等斚w?span href="tag.php?name=%D0%E8%C7%F3" onclick="tagshow(event)" class="t_tag" style="border-bottom: 1px solid #ff0000; line-height: normal; cursor: pointer; white-space: nowrap;">需?/span>Q?span href="tag.php?name=%C9%E8%BC%C6" onclick="tagshow(event)" class="t_tag" style="border-bottom: 1px solid #ff0000; line-height: normal; cursor: pointer; white-space: nowrap;">设计的。在单元试q程中,试用例的设计应与复审工作相l合Q根据设计的试用例选取不同的测试数据,增加发现各c错误的可能性;另外Q根?span href="tag.php?name=%CF%EE%C4%BF" onclick="tagshow(event)" class="t_tag" style="border-bottom: 1px solid #ff0000; line-height: normal; cursor: pointer; white-space: nowrap;">目的具体情늡定测试用例项。如Q测试用例编受用例输入、用例预期输出、被单元的版本受实际输出等。单元测试用例的设计既可以?span href="tag.php?name=%B0%D7%BA%D0" onclick="tagshow(event)" class="t_tag" style="border-bottom: 1px solid #ff0000; line-height: normal; cursor: pointer; white-space: nowrap;">白盒试也可以用黑盒测试,但以白盒试ZQ黑盒测试侧重于功能Q白盒测试侧重于逻辑?/font>

    白盒试q入的前提条件是试人员已经对被试对象有了一定的了解Q基本上明确了被试软g的逻辑l构。具体过E就是针对程序逻辑l构设计和加载测试用例,驱动E序执行Q?span href="tag.php?name=%BC%EC%B2%E9" onclick="tagshow(event)" class="t_tag" style="border-bottom: 1px solid #ff0000; line-height: normal; cursor: pointer; white-space: nowrap;">?/span>在不同点E序的状态,以确定实际的状态是否与预期的状态一致?/font>

    一般来_Z度量试的完整性,试工作中通常要求辑ֈ一定的覆盖率要求。因为通过覆盖率的l计可以知道试是否充分Q对软g的哪个部分所做的试不够Q指导我们如何设计增加覆盖率的测试用例。这样就能够提高试质量Q尽量避免设计无效的用例?/font>

    在白盒测试的范畴内通常使用下面几种试覆盖率来度量试Q如Q语句覆盖、判定覆盖、条件覆盖、判定条件覆盖、条件组合覆盖、\径覆盖等。白盒测试最低应该达到的覆盖率目标是Q语句覆盖率辑ֈ100Q,分支覆盖率达?/font>100Q,覆盖E序中主要的路径Q主要\径是指完成模块正常功能的路径和功能等其他异常处理执行的\径?/font>

       试人员在实际工作中要根据不同的覆盖要求来设计面?span href="tag.php?name=%B4%FA%C2%EB" onclick="tagshow(event)" class="t_tag" style="border-bottom: 1px solid #ff0000; line-height: normal; cursor: pointer; white-space: nowrap;">代码的单元测试用例,q行试用例后至应该实现如下几个覆盖需求:
  • 对程序模块的所有独立的执行路径臛_覆盖一ơ?/font>
  • Ҏ(gu)有的逻辑判定Q真假两U情况都臛_覆盖一ơ?/font>
  • 在@环的边界和运行界限内执行循环体,即用边界值的Ҏ(gu)来测试@环体?/font>
  • 试内部数据l构的有效性等?/font>

      黑盒试是要首先了解软g产品具备的功能和性能{需求,再根据需求设计一l测试用例以验证E序内部zd是否W合需求分?/a>和设计要求的zd。在黑盒试范畴内通常使用功能覆盖率来度量试的完整性。而功能覆盖率中最常见的就是需求覆盖,目的是通过设计一定的试用例Q得每个需求点都被试到。其ơ,q包括接口覆?/font>(又叫入口点覆?/font>)Q其目的是通过设计一定的试用例?span href="tag.php?name=%CF%B5%CD%B3" onclick="tagshow(event)" class="t_tag" style="border-bottom: 1px solid #ff0000; line-height: normal; cursor: pointer; white-space: nowrap;">pȝ
的每个接口都被测试到。黑盒测试应辑ֈ的覆盖率目标是:E序单元正确地实C需求分析和设计上要求的所有功能,满性能要求Q同时程序单元要?strong style="text-align: left; font-style: normal; line-height: normal; font-weight: bold;">可靠?/a>和安全性?/font>
      试人员在实际工作中臛_应该设计能够覆盖如下需求的Z功能的单元测试用例:
(1)试E序单元的功能是否实现?/font>
(2)试E序单元性能是否满要求Q可选)?/font>
(3)是否有可选的其他试Ҏ(gu),如边界、余量、安全性、可靠性、强度(压力Q测试、hZ互界面测试等?/font>
    无论是白盒测试还是黑盒测试,每个试用例都应该包含下?/font>4个关键元素:
(1)被测单元模块初始状态声明,x试用例的开始状态(仅适用于被单元维持了调用中间状态的情况Q?/font>
(2)被测单元的输入,包含p单元读入的M外部数据倹{?/font>
(3)该测试用例实际测试的代码Q用被测单元的功能和试用例设计中用的分析来说明,如:单元中哪一个决{条件被试?/font>
(4)试用例的期望输?span href="tag.php?name=%BD%E1%B9%FB" onclick="tagshow(event)" class="t_tag" style="border-bottom: 1px solid #ff0000; line-height: normal; cursor: pointer; white-space: nowrap;">l果Q在试q行之前的测试说明中定义)?/font>


Dest 2009-06-17 21:48 发表评论
]]>
带通配W的字符匚whttp://www.tkk7.com/wenhl5656/archive/2009/06/16/282490.htmlDestDestMon, 15 Jun 2009 17:02:00 GMThttp://www.tkk7.com/wenhl5656/archive/2009/06/16/282490.html 首先?Q根?的功能,?表示L字符Q也是说在匚wq程中,?永远匚w成功。本质上Q?q没有修改算法,而仅仅修改了匚w规则——遇?则一定匹配?
然?与此不同Q?的作用是匚wL多个字符Q显然我们不能简单的修改匚wq程而满求。如果我们重新思?的作用,我们会发?的另一个作用就是分割PԌ卛_果P=P1*P2Q那么与其说*代表匚wL多个字符Q不如说P的匹配条件是在匹配P1子串后再匚wP2子串?
因此Q可以写出带通配W的字符串匹配算?nbsp; 阅读全文

Dest 2009-06-16 01:02 发表评论
]]>
理解数据库范式——通俗易懂 [转]http://www.tkk7.com/wenhl5656/archive/2009/06/15/282432.htmlDestDestMon, 15 Jun 2009 12:01:00 GMThttp://www.tkk7.com/wenhl5656/archive/2009/06/15/282432.html阅读全文

Dest 2009-06-15 20:01 发表评论
]]>
数据库设计范式深入浅??http://www.tkk7.com/wenhl5656/archive/2009/06/15/282431.htmlDestDestMon, 15 Jun 2009 12:00:00 GMThttp://www.tkk7.com/wenhl5656/archive/2009/06/15/282431.html关系数据库设计之时是要遵守一定的规则的。尤其是数据库设计范?现简单介l?NFQ第一范式Q,2NFQ第二范式)Q?NFQ第三范式)和BCNFQ另有第四范式和W五范式留到以后再介l?在你设计数据库之Ӟ若能W合q几个范式,你就是数据库设计的高手。j  阅读全文

Dest 2009-06-15 20:00 发表评论
]]>
|络爬虫的一些功能要求整理(转)http://www.tkk7.com/wenhl5656/archive/2009/06/04/280075.htmlDestDestThu, 04 Jun 2009 13:07:00 GMThttp://www.tkk7.com/wenhl5656/archive/2009/06/04/280075.html阅读全文

Dest 2009-06-04 21:07 发表评论
]]>
Q{QTBU别的网容器实现方法参?/title><link>http://www.tkk7.com/wenhl5656/archive/2009/06/04/280073.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Thu, 04 Jun 2009 13:04:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2009/06/04/280073.html</guid><description><![CDATA[     摘要: 转自javaeye。一个高性能的Web爬虫Q必L一个合适的|页容器。该定w最大的特点是要能够通过URL直接存取|页内容Qƈ且要求有很高的性能Q在一个千万别的容器中存取一万次的时间应?分钟左右(普通PC?。采用拆L办法Q在文gpȝ的基上徏立一l大文g和一l辅助文Ӟ辅助文g实现通过URL定位该URL代表的网在大文件中的位|,从页实现不随文g数量增长而性能变化的快速存取。以下将描述一个简z的实现?   <a href='http://www.tkk7.com/wenhl5656/archive/2009/06/04/280073.html'>阅读全文</a><img src ="http://www.tkk7.com/wenhl5656/aggbug/280073.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2009-06-04 21:04 <a href="http://www.tkk7.com/wenhl5656/archive/2009/06/04/280073.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>常用中文分词- 整理攉http://www.tkk7.com/wenhl5656/archive/2009/06/04/280071.htmlDestDestThu, 04 Jun 2009 13:01:00 GMThttp://www.tkk7.com/wenhl5656/archive/2009/06/04/280071.html阅读全文

Dest 2009-06-04 21:01 发表评论
]]>
字符集编码和~码字符集(转摘Q?/title><link>http://www.tkk7.com/wenhl5656/archive/2009/02/20/255893.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Fri, 20 Feb 2009 13:58:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2009/02/20/255893.html</guid><description><![CDATA[    字符集,指的是被分配了整数编L<span style="color: #0817ff;">字符集合</span>Q?br />     但是Q编码字W集中字W被分配的整数编P不一定就是该字符在计机中存储时所使用的|<br />     计算Z存储的字W到底用什么二q制整数值来表示Q是?span style="color: #388fff;">字符集编?/span>军_的?br /> <br />     字符集编码决定了如何一个字W的整数~号对应C个二q制的整数倹{?br />     有的~码Ҏ(gu)单的该整数值直接作为其在计机中的表示而存储,例如英文字符?br />     几乎所有的字符集编码方案中Q英文字母的整数~号与其在计机内部存储的二q制形式都一致?br />     但有的编码方案,例如适用于Unicode字符集的UTF-8~码形式Q就很大一部分字符的整数编号作了变换后存储在计机中?br />     ?#8220;?#8221;字ؓ例,“?#8221;的Unicodegؓ0x6C49Q但其编码ؓUTF-8格式后的gؓ0xE6B189Q注意到变成了三个字节)?br /> <br />     GB2312最初指的是一个编码字W集Q其中包含了ASCII所包含的英文字W,同时加入?763个简体汉字以及其他一些ASCII之外的符受GB2312也有自己的编码方案,但这个方案直接用一个字W在GB2312中的~号作ؓ存储|与UTF-32的做法类|?br />     我们日常说vGB2312的时候,<strong>常常xq个字符集,也指q种~码Ҏ(gu)</strong>?br /> <br />     GBK是GB2312的后l标准,d了更多的汉字和特D符PcM的是QGBK也是同时指他的字W集和他的编码?br />     GBKq是现如今中文Windows操作pȝ的系l默认编码(q正是几乎所有网上的,文g里的q问题的根源)?br /> <br />     在Java中,字符只以一U编码Ş式存在,那就是UTF-16?br />     ?#8220;在Java?#8221;到底是指在哪里呢Q就是指在JVM中,在内存中Q代码里声明的每一个charQStringcd的变量中?br /> <br />     Python中既可以按Ascii~码Q也可以按unicode~码?br />   <br /> <img src ="http://www.tkk7.com/wenhl5656/aggbug/255893.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2009-02-20 21:58 <a href="http://www.tkk7.com/wenhl5656/archive/2009/02/20/255893.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Base64~码学习和java源程序实?/title><link>http://www.tkk7.com/wenhl5656/archive/2008/12/23/247948.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Tue, 23 Dec 2008 09:36:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2008/12/23/247948.html</guid><description><![CDATA[<a title="Google" >Google </a>Base64可以搜到相关原理和许多实现?br /> 下面是我的实玎ͼ和SUN公司提供的参考实现?br /> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: rgb(0, 128, 128);">  1</span> <span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> Base64 {<br /> </span><span style="color: rgb(0, 128, 128);">  2</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> String base64_alphabet </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);">  3</span> <span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">  4</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /> </span><span style="color: rgb(0, 128, 128);">  5</span> <span style="color: rgb(0, 128, 0);">     * ~码原理:?个字节{换成4个字? (3 X 8) = 24 = (4 X 6) )<br /> </span><span style="color: rgb(0, 128, 128);">  6</span> <span style="color: rgb(0, 128, 0);">     * 先读?个字?每读一个字?左移8?再右Ud?每次6?q样有4个字节了<br /> </span><span style="color: rgb(0, 128, 128);">  7</span> <span style="color: rgb(0, 128, 0);">     * <br /> </span><span style="color: rgb(0, 128, 128);">  8</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> data<br /> </span><span style="color: rgb(0, 128, 128);">  9</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"> ~码后的Base64字符?br /> </span><span style="color: rgb(0, 128, 128);"> 10</span> <span style="color: rgb(0, 128, 0);">     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 11</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> String Base64Encode(</span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[] data) {<br /> </span><span style="color: rgb(0, 128, 128);"> 12</span> <span style="color: rgb(0, 0, 0);">        StringBuilder builder </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> StringBuilder();<br /> </span><span style="color: rgb(0, 128, 128);"> 13</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">[] temp </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">];<br /> </span><span style="color: rgb(0, 128, 128);"> 14</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> len </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> data.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> data.length </span><span style="color: rgb(0, 0, 0);">%</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 15</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; i </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> len; i </span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">) {<br /> </span><span style="color: rgb(0, 128, 128);"> 16</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> goal </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 17</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> j </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; j </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">; j</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) {<br /> </span><span style="color: rgb(0, 128, 128);"> 18</span> <span style="color: rgb(0, 0, 0);">                goal </span><span style="color: rgb(0, 0, 0);"><<=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 19</span> <span style="color: rgb(0, 0, 0);">                goal </span><span style="color: rgb(0, 0, 0);">|=</span><span style="color: rgb(0, 0, 0);"> (data[i </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> j] </span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0xff</span><span style="color: rgb(0, 0, 0);">);<br /> </span><span style="color: rgb(0, 128, 128);"> 20</span> <span style="color: rgb(0, 0, 0);">            }<br /> </span><span style="color: rgb(0, 128, 128);"> 21</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> k </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; k </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">; k</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) {<br /> </span><span style="color: rgb(0, 128, 128);"> 22</span> <span style="color: rgb(0, 0, 0);">                temp[k] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> goal </span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0x3f</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 23</span> <span style="color: rgb(0, 0, 0);">                goal </span><span style="color: rgb(0, 0, 0);">>>=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 24</span> <span style="color: rgb(0, 0, 0);">            }<br /> </span><span style="color: rgb(0, 128, 128);"> 25</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> k </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">; k </span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; k</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">) {<br /> </span><span style="color: rgb(0, 128, 128);"> 26</span> <span style="color: rgb(0, 0, 0);">                builder.append(base64_alphabet.charAt(temp[k]));<br /> </span><span style="color: rgb(0, 128, 128);"> 27</span> <span style="color: rgb(0, 0, 0);">            }<br /> </span><span style="color: rgb(0, 128, 128);"> 28</span> <span style="color: rgb(0, 0, 0);">        }<br /> </span><span style="color: rgb(0, 128, 128);"> 29</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> index;<br /> </span><span style="color: rgb(0, 128, 128);"> 30</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">switch</span><span style="color: rgb(0, 0, 0);"> (data.length </span><span style="color: rgb(0, 0, 0);">%</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">) {<br /> </span><span style="color: rgb(0, 128, 128);"> 31</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">case</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">:<br /> </span><span style="color: rgb(0, 128, 128);"> 32</span> <span style="color: rgb(0, 0, 0);">            index </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> data[data.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">>></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 33</span> <span style="color: rgb(0, 0, 0);">            builder.append(base64_alphabet.charAt(index));<br /> </span><span style="color: rgb(0, 128, 128);"> 34</span> <span style="color: rgb(0, 0, 0);">            index </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (data[data.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0x03</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);"><<</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 35</span> <span style="color: rgb(0, 0, 0);">            builder.append(base64_alphabet.charAt(index));<br /> </span><span style="color: rgb(0, 128, 128);"> 36</span> <span style="color: rgb(0, 0, 0);">            builder.append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /> </span><span style="color: rgb(0, 128, 128);"> 37</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">break</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 38</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">case</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">:<br /> </span><span style="color: rgb(0, 128, 128);"> 39</span> <span style="color: rgb(0, 0, 0);">            index </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> data[data.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">>></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 40</span> <span style="color: rgb(0, 0, 0);">            builder.append(base64_alphabet.charAt(index));<br /> </span><span style="color: rgb(0, 128, 128);"> 41</span> <span style="color: rgb(0, 0, 0);">            index </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (data[data.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0x03</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);"><<</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 42</span> <span style="color: rgb(0, 0, 0);">                    </span><span style="color: rgb(0, 0, 0);">|</span><span style="color: rgb(0, 0, 0);"> data[data.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">>></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 43</span> <span style="color: rgb(0, 0, 0);">            builder.append(base64_alphabet.charAt(index));<br /> </span><span style="color: rgb(0, 128, 128);"> 44</span> <span style="color: rgb(0, 0, 0);">            index </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (data[data.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0x0f</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(0, 0, 0);"><<</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 45</span> <span style="color: rgb(0, 0, 0);">            builder.append(base64_alphabet.charAt(index));<br /> </span><span style="color: rgb(0, 128, 128);"> 46</span> <span style="color: rgb(0, 0, 0);">            builder.append(</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">);<br /> </span><span style="color: rgb(0, 128, 128);"> 47</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">break</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 48</span> <span style="color: rgb(0, 0, 0);">        }<br /> </span><span style="color: rgb(0, 128, 128);"> 49</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> builder.toString();<br /> </span><span style="color: rgb(0, 128, 128);"> 50</span> <span style="color: rgb(0, 0, 0);">    }<br /> </span><span style="color: rgb(0, 128, 128);"> 51</span> <span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 52</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 53</span> <span style="color: rgb(0, 128, 0);">     * 解码原理:?个字节{换成3个字? 先读???用或q算),每次左移6?再右U??每次8?<br /> </span><span style="color: rgb(0, 128, 128);"> 54</span> <span style="color: rgb(0, 128, 0);">     * <br /> </span><span style="color: rgb(0, 128, 128);"> 55</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> data<br /> </span><span style="color: rgb(0, 128, 128);"> 56</span> <span style="color: rgb(0, 128, 0);">     *            需解码的Base64字符丌Ӏ?br /> </span><span style="color: rgb(0, 128, 128);"> 57</span> <span style="color: rgb(0, 128, 0);">     * </span><span style="color: rgb(128, 128, 128);">@return</span><span style="color: rgb(0, 128, 0);"> byte[]Q解码出的字节数l?br /> </span><span style="color: rgb(0, 128, 128);"> 58</span> <span style="color: rgb(0, 128, 0);">     </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 59</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[] Base64Decode(String data) {<br /> </span><span style="color: rgb(0, 128, 128);"> 60</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">[] chArray </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> data.toCharArray();<br /> </span><span style="color: rgb(0, 128, 128);"> 61</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> len </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> chArray.length;<br /> </span><span style="color: rgb(0, 128, 128);"> 62</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[] result </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[len </span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">];<br /> </span><span style="color: rgb(0, 128, 128);"> 63</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">, res_i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; i </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> len; i </span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">, res_i </span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">) {<br /> </span><span style="color: rgb(0, 128, 128);"> 64</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> goal </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 65</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> index </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 66</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> k </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; k </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">; k</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) {<br /> </span><span style="color: rgb(0, 128, 128);"> 67</span> <span style="color: rgb(0, 0, 0);">                index </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> base64_alphabet.indexOf(chArray[i </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> k]);<br /> </span><span style="color: rgb(0, 128, 128);"> 68</span> <span style="color: rgb(0, 0, 0);">                goal </span><span style="color: rgb(0, 0, 0);"><<=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">6</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 69</span> <span style="color: rgb(0, 0, 0);">                goal </span><span style="color: rgb(0, 0, 0);">|=</span><span style="color: rgb(0, 0, 0);"> index;<br /> </span><span style="color: rgb(0, 128, 128);"> 70</span> <span style="color: rgb(0, 0, 0);">            }<br /> </span><span style="color: rgb(0, 128, 128);"> 71</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> j </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">; j </span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; j</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">) {<br /> </span><span style="color: rgb(0, 128, 128);"> 72</span> <span style="color: rgb(0, 0, 0);">                result[res_i </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> j] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">) goal;<br /> </span><span style="color: rgb(0, 128, 128);"> 73</span> <span style="color: rgb(0, 0, 0);">                goal </span><span style="color: rgb(0, 0, 0);">>>=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 74</span> <span style="color: rgb(0, 0, 0);">            }<br /> </span><span style="color: rgb(0, 128, 128);"> 75</span> <span style="color: rgb(0, 0, 0);">        }<br /> </span><span style="color: rgb(0, 128, 128);"> 76</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> {号=的处?/span><span style="color: rgb(0, 128, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 77</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (chArray[len </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">)<br /> </span><span style="color: rgb(0, 128, 128);"> 78</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> result;<br /> </span><span style="color: rgb(0, 128, 128);"> 79</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (chArray[len </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">)<br /> </span><span style="color: rgb(0, 128, 128);"> 80</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> Arrays.copyOf(result, result.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">);<br /> </span><span style="color: rgb(0, 128, 128);"> 81</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 82</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> Arrays.copyOf(result, result.length </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br /> </span><span style="color: rgb(0, 128, 128);"> 83</span> <span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 84</span> <span style="color: rgb(0, 0, 0);">    }<br /> </span><span style="color: rgb(0, 128, 128);"> 85</span> <span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> ?nbsp;s q行 BASE64 ~码</span><span style="color: rgb(0, 128, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 86</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> String getBASE64(String s) {<br /> </span><span style="color: rgb(0, 128, 128);"> 87</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (s </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br /> </span><span style="color: rgb(0, 128, 128);"> 88</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 89</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> sun.misc.BASE64Encoder()).encode(s.getBytes());<br /> </span><span style="color: rgb(0, 128, 128);"> 90</span> <span style="color: rgb(0, 0, 0);">    }<br /> </span><span style="color: rgb(0, 128, 128);"> 91</span> <span style="color: rgb(0, 0, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 92</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> ?nbsp;BASE64 ~码的字W串 s q行解码</span><span style="color: rgb(0, 128, 0);"><br /> </span><span style="color: rgb(0, 128, 128);"> 93</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> String getFromBASE64(String s) {<br /> </span><span style="color: rgb(0, 128, 128);"> 94</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (s </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br /> </span><span style="color: rgb(0, 128, 128);"> 95</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);"> 96</span> <span style="color: rgb(0, 0, 0);">        BASE64Decoder decoder </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> BASE64Decoder();<br /> </span><span style="color: rgb(0, 128, 128);"> 97</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br /> </span><span style="color: rgb(0, 128, 128);"> 98</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[] b </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> decoder.decodeBuffer(s);<br /> </span><span style="color: rgb(0, 128, 128);"> 99</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> String(b);<br /> </span><span style="color: rgb(0, 128, 128);">100</span> <span style="color: rgb(0, 0, 0);">        } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (Exception e) {<br /> </span><span style="color: rgb(0, 128, 128);">101</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /> </span><span style="color: rgb(0, 128, 128);">102</span> <span style="color: rgb(0, 0, 0);">        }<br /> </span><span style="color: rgb(0, 128, 128);">103</span> <span style="color: rgb(0, 0, 0);">    }<br /> </span><span style="color: rgb(0, 128, 128);">104</span> <span style="color: rgb(0, 0, 0);">}</span></div> <br /> <br /> <img src ="http://www.tkk7.com/wenhl5656/aggbug/247948.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2008-12-23 17:36 <a href="http://www.tkk7.com/wenhl5656/archive/2008/12/23/247948.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java 生成随机序列http://www.tkk7.com/wenhl5656/archive/2008/12/23/247947.htmlDestDestTue, 23 Dec 2008 09:32:00 GMThttp://www.tkk7.com/wenhl5656/archive/2008/12/23/247947.html阅读全文

Dest 2008-12-23 17:32 发表评论
]]>
在VC中链接动态链接库的方?/title><link>http://www.tkk7.com/wenhl5656/archive/2008/10/04/232325.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Sat, 04 Oct 2008 06:47:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2008/10/04/232325.html</guid><description><![CDATA[     摘要: 在做VC目Ӟ用到的关于动态链接库的一些知识?<br>链接动态链接库的一些方?nbsp; <a href='http://www.tkk7.com/wenhl5656/archive/2008/10/04/232325.html'>阅读全文</a><img src ="http://www.tkk7.com/wenhl5656/aggbug/232325.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2008-10-04 14:47 <a href="http://www.tkk7.com/wenhl5656/archive/2008/10/04/232325.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>/subsystem:windows ?/subsystem:console(转蝲)http://www.tkk7.com/wenhl5656/archive/2008/10/02/232136.htmlDestDestThu, 02 Oct 2008 15:15:00 GMThttp://www.tkk7.com/wenhl5656/archive/2008/10/02/232136.htmlQ?a >/subsystem:windows ?/subsystem:console 

       操作pȝ装蝲应用E序后,做完初始化工作就转到E序的入口点执行。程序的默认入口点实际上是由q接E序讄的,不同的连接器选择的入口函C不尽相同。在VC++下,q接器对控制台程序设|的入口函数?mainCRTStartupQmainCRTStartup 再调用你自己~写?main 函数Q对囑Ş用户界面QGUIQ程序设|的入口函数?WinMainCRTStartupQWinMainCRTStartup 调用你自己写?WinMain 函数。而具体设|哪个入口点是由q接器的“/subsystem:”选项参数定的,它告诉操作系l如何运行编译生成的.EXE文g。可以指定四U方式:“CONSOLE|WINDOWS|NATIVE|POSIX”如果q个选项参数的gؓ“WINDOWS”Q则表示该应用程序运行时不需要控制台Q有兌接器参数选项的详l说明请参?MSDN 库?nbsp;

以下四种l合Q可以实现console和windows模式的؜合,可以辑ֈ不弹出DOSH口的效果,也可以达到在WindowsE序中向控制台输出printf信息了?br /> #pragma comment( linker, "/subsystem:windows /entry:WinMainCRTStartup" )
#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )

#pragma comment( linker, "/subsystem:console /entry:mainCRTStartup" )
#pragma comment( linker, "/subsystem:console /entry:WinMainCRTStartup" )


int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR     lpCmdLine,
int       nCmdShow)
{
     // ... ...
}

int main(void)
{
     // ... ...
}




Dest 2008-10-02 23:15 发表评论
]]>
C语言q算优先U?/title><link>http://www.tkk7.com/wenhl5656/archive/2008/09/23/230693.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Tue, 23 Sep 2008 08:04:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2008/09/23/230693.html</guid><description><![CDATA[<img height="441" alt="" src="http://www.tkk7.com/images/blogjava_net/wenhl5656/1.JPG" width="339" border="0" /> <img src ="http://www.tkk7.com/wenhl5656/aggbug/230693.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2008-09-23 16:04 <a href="http://www.tkk7.com/wenhl5656/archive/2008/09/23/230693.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C语言宏定义技?/title><link>http://www.tkk7.com/wenhl5656/archive/2008/09/23/230554.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Tue, 23 Sep 2008 01:11:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2008/09/23/230554.html</guid><description><![CDATA[C语言宏定义技巧(常用宏定义)  <br />   <br /> 写好C语言Q漂亮的宏定义很重要Q用宏定义可以防止出错Q提高可UL性,可读性,方便?nbsp;{等。下面列举一些成熟Y件中常用得宏定义。。。。。?<br /> <br />   <br /> <br /> 1Q防止一个头文g被重复包?<br /> <br /> #ifndef COMDEF_H <br /> <br /> #define COMDEF_H <br /> <br />   //头文件内?<br /> <br /> #endif <br /> <br /> 2Q重新定义一些类型,防止׃各种q_和编译器的不同,而生的cd字节数差异,方便UL?<br /> <br /> typedef  unsigned char      boolean;     /* Boolean value type. */ <br /> <br />   <br /> <br /> typedef  unsigned long int  uint32;      /* Unsigned 32 bit value */ <br /> <br /> typedef  unsigned short     uint16;      /* Unsigned 16 bit value */ <br /> <br /> typedef  unsigned char      uint8;       /* Unsigned 8  bit value */ <br /> <br />   <br /> <br /> typedef  signed long int    int32;       /* Signed 32 bit value */ <br /> <br /> typedef  signed short       int16;       /* Signed 16 bit value */ <br /> <br /> typedef  signed char        int8;        /* Signed 8  bit value */ <br /> <br />   <br /> <br />   <br /> <br /> //下面的不使用 <br /> <br /> typedef  unsigned char     byte;         /* Unsigned 8  bit value type. */ <br /> <br /> typedef  unsigned short    word;         /* Unsinged 16 bit value type. */ <br /> <br /> typedef  unsigned long     dword;        /* Unsigned 32 bit value type. */ <br /> <br />   <br /> <br /> typedef  unsigned char     uint1;        /* Unsigned 8  bit value type. */ <br /> <br /> typedef  unsigned short    uint2;        /* Unsigned 16 bit value type. */ <br /> <br /> typedef  unsigned long     uint4;        /* Unsigned 32 bit value type. */ <br /> <br />   <br /> <br /> typedef  signed char       int1;         /* Signed 8  bit value type. */ <br /> <br /> typedef  signed short      int2;         /* Signed 16 bit value type. */ <br /> <br /> typedef  long int          int4;         /* Signed 32 bit value type. */ <br /> <br />   <br /> <br /> typedef  signed long       sint31;       /* Signed 32 bit value */ <br /> <br /> typedef  signed short      sint15;       /* Signed 16 bit value */ <br /> <br /> typedef  signed char       sint7;        /* Signed 8  bit value */ <br /> <br />   <br /> <br /> 3Q得到指定地址上的一个字节或?<br /> <br /> #define  MEM_B( x )  ( *( (byte *) (x) ) ) <br /> <br /> #define  MEM_W( x )  ( *( (word *) (x) ) ) <br /> <br /> 4Q求最大值和最?<br /> <br />    #define  MAX( x, y ) ( ((x) > (y)) ? (x) : (y) ) <br /> <br />    #define  MIN( x, y ) ( ((x) < (y)) ? (x) : (y) ) <br /> <br /> 5Q得C个field在结构体(struct)中的偏移?<br /> <br /> #define FPOS( type, field ) \ <br /> <br /> /*lint -e545 */ ( (dword) &(( type *) 0)-> field ) /*lint +e545 */ <br /> <br /> 6,得到一个结构体中field所占用的字节数 <br /> <br /> #define FSIZ( type, field ) sizeof( ((type *) 0)->field ) <br /> <br /> 7Q按照LSB格式把两个字节{化ؓ一个Word <br /> <br /> #define  FLIPW( ray ) ( (((word) (ray)[0]) * 256) + (ray)[1] ) <br /> <br /> 8Q按照LSB格式把一个Word转化Z个字?<br /> <br /> #define  FLOPW( ray, val ) \ <br /> <br />   (ray)[0] = ((val) / 256); \ <br /> <br />   (ray)[1] = ((val) & 0xFF) <br /> <br /> 9Q得C个变量的地址Qword宽度Q?<br /> <br /> #define  B_PTR( var )  ( (byte *) (void *) &(var) ) <br /> <br /> #define  W_PTR( var )  ( (word *) (void *) &(var) ) <br /> <br /> 10Q得C个字的高位和低位字节 <br /> <br /> #define  WORD_LO(xxx)  ((byte) ((word)(xxx) & 255)) <br /> <br /> #define  WORD_HI(xxx)  ((byte) ((word)(xxx) >> 8)) <br /> <br /> 11Q返回一个比X大的最接近?的倍数 <br /> <br /> #define RND8( x )       ((((x) + 7) / 8 ) * 8 ) <br /> <br /> 12Q将一个字母{换ؓ大写 <br /> <br /> #define  UPCASE( c ) ( ((c) >= 'a' && (c) <= 'z') ? ((c) - 0x20) : (c) ) <br /> <br /> 13Q判断字W是不是10q值的数字 <br /> <br /> #define  DECCHK( c ) ((c) >= '0' && (c) <= '9') <br /> <br /> 14Q判断字W是不是16q值的数字 <br /> <br /> #define  HEXCHK( c ) ( ((c) >= '0' && (c) <= '9') ||\ <br /> <br />                        ((c) >= 'A' && (c) <= 'F') ||\ <br /> <br /> ((c) >= 'a' && (c) <= 'f') ) <br /> <br /> 15Q防止溢出的一个方?<br /> <br /> #define  INC_SAT( val )  (val = ((val)+1 > (val)) ? (val)+1 : (val)) <br /> <br /> 16Q返回数l元素的个数 <br /> <br /> #define  ARR_SIZE( a )  ( sizeof( (a) ) / sizeof( (a[0]) ) ) <br /> <br /> 17Q返回一个无W号数n值MOD_BY_POWER_OF_TWO(X,n)=X%(2^n) <br /> <br /> #define MOD_BY_POWER_OF_TWO( val, mod_by ) \ <br /> <br />            ( (dword)(val) & (dword)((mod_by)-1) ) <br /> <br /> 18Q对于IOI间映射在存储空间的l构Q输入输出处?<br /> <br />   #define inp(port)         (*((volatile byte *) (port))) <br /> <br />   #define inpw(port)        (*((volatile word *) (port))) <br /> <br />   #define inpdw(port)       (*((volatile dword *)(port))) <br /> <br />    <br /> <br />   #define outp(port, val)   (*((volatile byte *) (port)) = ((byte) (val))) <br /> <br />   #define outpw(port, val)  (*((volatile word *) (port)) = ((word) (val))) <br /> <br />   #define outpdw(port, val) (*((volatile dword *) (port)) = ((dword) (val))) <br /> <br /> [2005-9-9d]  <br /> <br /> 19,使用一些宏跟踪调试 <br /> <br /> A N S I标准说明了五个预定义的宏名。它们是Q?<br /> <br /> _ L I N E _ <br /> <br /> _ F I L E _ <br /> <br /> _ D A T E _ <br /> <br /> _ T I M E _ <br /> <br /> _ S T D C _ <br /> <br /> 如果~译不是标准的,则可能仅支持以上宏名中的几个Q或Ҏ(gu)不支持。记住编译程?<br /> <br /> 也许q提供其它预定义的宏名?<br /> <br /> _ L I N E _及_ F I L E _宏指令在有关# l i n e的部分中已讨论,q里讨论其余的宏名?<br /> <br /> _ D AT E _宏指令含有Ş式ؓ??q的Ԍ表示源文件被译C码时的日期?<br /> <br /> 源代码翻译到目标代码的时间作Z包含在_ T I M E _中。串形式为时Q分Q秒?<br /> <br /> 如果实现是标准的Q则宏_ S T D C _含有十进制常?。如果它含有M其它敎ͼ则实现是 <br /> <br /> 非标准的?<br /> <br /> 可以定义宏,例如: <br /> <br /> 当定义了_DEBUGQ输出数据信息和所在文件所在行 <br /> <br /> #ifdef _DEBUG <br /> <br /> #define DEBUGMSG(msg,date) printf(msg);printf(“%d%d%d”,date,_LINE_,_FILE_) <br /> <br /> #else <br /> <br />       #define DEBUGMSG(msg,date)  <br /> <br /> #endif <br /> <br />   <br /> <br /> 20Q宏定义防止使用是错?<br /> <br /> 用小括号包含?<br /> <br /> 例如Q?define ADD(a,b) Qa+bQ?<br /> <br /> 用do{}while(0)语句包含多语句防止错?<br /> <br /> 例如Q?difne DO(a,b) a+b;\ <br /> <br />                    a++; <br /> <br /> 应用Ӟif(….) <br /> <br />           DO(a,b); //产生错误 <br /> <br />         else <br /> <br />          <br /> <br /> 解决Ҏ(gu): #difne DO(a,b) do{a+b;\ <br /> <br />                    a++;}while(0) <br /> <br />   <br /> 宏中"#"?##"的用?<br /> 一、一般用?<br /> 我们使用#把宏参数变ؓ一个字W串,?#把两个宏参数贴合在一? <br /> 用法: <br /> Qi nclude<cstdio> <br /> Qi nclude<climits> <br /> using namespace std; <br /> <br /> #define STR(s)     #s <br /> #define CONS(a,b)  int(a##e##b) <br /> <br /> int main() <br /> { <br />     printf(STR(vck));           // 输出字符?vck" <br />     printf("%d\n", CONS(2,3));  // 2e3 输出:2000 <br />     return 0; <br /> } <br /> <br /> 二、当宏参数是另一个宏的时?<br /> 需要注意的是凡宏定义里有用'#'?##'的地方宏参数是不会再展开. <br /> <br /> 1, ?#'?##'的情?<br /> #define TOW      (2) <br /> #define MUL(a,b) (a*b) <br /> <br /> printf("%d*%d=%d\n", TOW, TOW, MUL(TOW,TOW)); <br /> q行的宏会被展开为: <br /> printf("%d*%d=%d\n", (2), (2), ((2)*(2))); <br /> MUL里的参数TOW会被展开?2). <br /> <br /> 2, 当有'#'?##'的时?<br /> #define A          (2) <br /> #define STR(s)     #s <br /> #define CONS(a,b)  int(a##e##b) <br /> <br /> printf("int max: %s\n",  STR(INT_MAX));    // INT_MAX Qi nclude<climits> <br /> q行会被展开为: <br /> printf("int max: %s\n", "INT_MAX"); <br /> <br /> printf("%s\n", CONS(A, A));               // compile error  <br /> q一行则是: <br /> printf("%s\n", int(AeA)); <br /> <br /> INT_MAX和A都不会再被展开, 然而解册个问题的Ҏ(gu)很简? 加多一层中间{换宏. <br /> 加这层宏的用意是把所有宏的参数在q层里全部展开, 那么在{换宏里的那一个宏(_STR)p得到正确的宏参数. <br /> <br /> #define A           (2) <br /> #define _STR(s)     #s <br /> #define STR(s)      _STR(s)          // 转换?<br /> #define _CONS(a,b)  int(a##e##b) <br /> #define CONS(a,b)   _CONS(a,b)       // 转换?<br /> <br /> printf("int max: %s\n", STR(INT_MAX));          // INT_MAX,int型的最大|Z个变?nbsp;Qi nclude<climits> <br /> 输出? int max: 0x7fffffff <br /> STR(INT_MAX) -->  _STR(0x7fffffff) 然后再{换成字符Ԍ <br /> <br /> printf("%d\n", CONS(A, A)); <br /> 输出为:200 <br /> CONS(A, A)  -->  _CONS((2), (2))  --> int((2)e(2)) <br /> <br /> 三?#'?##'的一些应用特?<br /> 1、合q匿名变量名 <br /> #define  ___ANONYMOUS1(type, var, line)  type  var##line <br /> #define  __ANONYMOUS0(type, line)  ___ANONYMOUS1(type, _anonymous, line) <br /> #define  ANONYMOUS(type)  __ANONYMOUS0(type, __LINE__) <br /> 例:ANONYMOUS(static int);  ? static int _anonymous70;  70表示该行行号Q?<br /> W一层:ANONYMOUS(static int);  -->  __ANONYMOUS0(static int, __LINE__); <br /> W二层:                        -->  ___ANONYMOUS1(static int, _anonymous, 70); <br /> W三层:                        -->  static int  _anonymous70; <br /> xơ只能解开当前层的宏,所以__LINE__在第二层才能被解开Q?<br /> <br /> 2、填充结?<br /> #define  FILL(a)   {a, #a} <br /> <br /> enum IDD{OPEN, CLOSE}; <br /> typedef struct MSG{ <br />   IDD id; <br />   const char * msg; <br /> }MSG; <br /> <br /> MSG _msg[] = {FILL(OPEN), FILL(CLOSE)}; <br /> 相当于: <br /> MSG _msg[] = {{OPEN, "OPEN"}, <br />               {CLOSE, "CLOSE"}}; <br /> <br /> 3、记录文件名 <br /> #define  _GET_FILE_NAME(f)   #f <br /> #define  GET_FILE_NAME(f)    _GET_FILE_NAME(f) <br /> static char  FILE_NAME[] = GET_FILE_NAME(__FILE__); <br /> <br /> 4、得C个数值类型所对应的字W串~冲大小 <br /> #define  _TYPE_BUF_SIZE(type)  sizeof #type <br /> #define  TYPE_BUF_SIZE(type)   _TYPE_BUF_SIZE(type) <br /> char  buf[TYPE_BUF_SIZE(INT_MAX)]; <br />      -->  char  buf[_TYPE_BUF_SIZE(0x7fffffff)]; <br />      -->  char  buf[sizeof "0x7fffffff"]; <br /> q里相当于: <br /> <img src ="http://www.tkk7.com/wenhl5656/aggbug/230554.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2008-09-23 09:11 <a href="http://www.tkk7.com/wenhl5656/archive/2008/09/23/230554.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Google牛h?/title><link>http://www.tkk7.com/wenhl5656/archive/2008/06/04/205791.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Wed, 04 Jun 2008 06:05:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2008/06/04/205791.html</guid><description><![CDATA[1 Vinton Cerf Q号UC联网之父QTCIP/IP协议和互联网架构的合作设计者。他05q?0?日开始正式ؓgoogle工作Q职位ؓ“首席互联|传布官”?br /> <br /> 2 Joshua Bloch Q号Ujava教父Q《Effective Java》的作者,JSR175标准的leaderQJ2SE 1.5的主要开发h员之一?br /> <br /> 3 Guido Van RossumQ?Python之父。Google把python用的炉火U青Q有了python之父的加盟,肯定如虎ȝ了?br /> <br /> 4 Andrew MortonQ?linux的二号h物。其在google的工作仍是l维护linux2.6内核<br /> <br /> 5 Mark LucovskyQ?Windows核心设计师。不晓得到了Morton会不会吵hQ?Q?br /> <br /> 6 Bram MoolenaarQVim的作?br /> <br /> 7 Darin Fisher QMozilla目d开发?br /> <br /> 8 Sean EganQ?Gaim开发团队的leader<br /> <br /> 9 Greg SteinQ?Apache目主要开发者,Apache基金会主?br /> <br /> 10 Udi ManberQ?Amazon的A9搜烦团队ȝ<br /> <br /> 11 Rob PikeQPlan 9 OSd开发?br /> <br /> 12 Adam BosworthQ?BEA的首席架构师<br /> <br /> 13 Larry BrilliantQ?|络先驱大慈善家Q负责google.org<br /> <br /> 14 Andy HertzfeldQ曾l是Macintosh研发团队核心成员<br /> <br /> 15 Louis MonierQInternet搜烦的发明者,eBay的前开发ȝ<br /> <br /> 16 Adndrew W Moore Q卡内基隆大学资讯与机器h工程学的教授Q他负责Google在匹兹堡新创立的实验?br /> <br /> 17 Alan DavidsonQCentre for Democracy & Technology的协理,他负责处理处理google与美国政府的关系<br /> <br /> 18 Ben GoodgerQFirefox的主要设计?br /> <br /> Google高层理团队<br /> <br /> Eric Schmidt 博士Q董事长兼首席执行官 <br /> 在就职于 Novell 公司之前QEric 曾Q Sun Microsystems, Inc.的首席技术官和公司行政主。在此期_他负责开发了 Sun 独立于^台的~程技?JavaQƈ立?Sun 的互联网软g战略。在 1983 q加?Sun 之前QEric 是施乐帕z阿囄I中?(Xerox Palo Alto Research Center, PARC) 计算机科学实验室的研I员Qƈ曑֜贝尔实验室和 Zilog 任职。Eric 在普林斯大学获甉|工程专业的理学学士学位,q在加州大学伯克莱分校获计算Z业硕士和博士学位?006 q_Eric 因推动全球最成功的互联网搜烦引擎公司的战略发展而获得认可,入选国家工E学院?<br /> <br /> Larry PageQ创始hg品总裁 <br /> Sergey BrinQ创始h兼技术总裁 <br /> Shona BrownQ业务运营高U副总裁 <br /> W. M. Coughran, Jr.Q工E事务副总裁 <br /> ?20 余年的计机职业生中,Bill 曾从事过|络pȝ内置软g、安全系l品以及计机U学和工E等斚w的工作。在加入 Google 之前Q?Bill 在硅谷创Z Entrisphere 公司Qƈ担Q首席执行官和其他一些行政职务。此前,他是贝尔实验室成员,是计科学研I中?(Computing Sciences Research Center) 的领ghQ开发了 C、C++、Unix、Plan 9 以及 Inferno。他在计机U学和分布式pȝ斚wQ做Z卓越贡献?br /> <br /> David C. DrummondQ公司发展事务高U副总裁 <br /> Alan EustaceQ工E与研究高副总裁 <br /> Alan Eustace ?Google 公司工程部副总裁Q全面负责公品研I和发展事务。Alan ?2002 q夏加入 Google 公司。此前,他在 Digital/Compaq/HP 的西方研I实验室 (Western Research Laboratory, WRL) 工作?5q_q行了多U芯片设计和l构目的研IӞ 包括 MicroTitan Floating Point 单元、BIPS –Q?当时速度最快的微处理器。Alan q与 Amitabh Srivastava 一起从?ATOM 斚w的工作,即二q制~码仪器pȝQؓ多种E序分析以及计算机结构分析工具奠定了基础。这些工具对?EV5?EV6?EV7 芯片设计来说Q具有极其深q的影响?999 q_Alan 升Q西方研究实验?(Western Research Laboratory, WRL) 董事。WRL U极q行袖珍式计机Q芯片多元化处理器,功率和能量管理,互联|性能以及频率和电压羃放比例等目的研I?br /> <br /> Urs HölzleQ运营高U副总裁?Google Fellow <br /> 作ؓ动态编译(也称?#8220;x~译”Q的先导之一QUrs 发明了今天大多数先进 Java ~译器仍在用的基础技术。在加入 Google 前,Urs ?Animorphic Systems 的创始h之一Q该公司开发了 Smalltalk ?Java 的编译器。Sun Microsystems ?1997 q收?Animorphic Systems 后,他协助开发了 Javasoft 的高性能 Hotspot Java ~译器?br /> <br /> Jeff HuberQ工E事务副总裁 <br /> 加入 Google 之前QJeff ?eBay 公司的结构与pȝ开发事务副总裁。在此期_他成功完成了产品搜烦基础l构的开发和q_ API E序的扩展。就职于 eBay 公司之前QJeff ?Excite@Home 公司的高U工E副总裁Q主ؓ最大的宽带服务提供商开发消费者品以及基设施?br /> <br /> Omid KordestaniQ全球销售及业务拓展高副总裁 <br /> George ReyesQ高U副总裁兼首席胦务官 <br /> Jonathan RosenbergQ品管理事务高U副总裁 <br /> Elliot SchrageQ全球通联及公׃务副总裁 <br /> <br /> Google 理团队<br /> <br /> Tim Armstrong, q告销售事务副总裁 <br /> Nikesh AroraQ欧z运营副总裁?<br /> Sukhinder Singh CassidyQ亚太和拉丁洲地区q营副总裁 <br /> Vinton G. CerfQ副总裁兼首席互联网N <br /> Vinton G. Cerf ?Google 的副总裁兼首席互联网N他负责ؓ公司在互联网及其他^C定新的可行技术和应用E序?br /> <br /> 作ؓd遐迩?#8220;互联|之?#8221;QVint ?Robert Kahn 合作设计?TCP/IP 协议及互联网的基体系l构。ؓ了表C对其工作的认可Q克林顿ȝ?1997 q向他们授予国国家U技奖章?005 q_Vint ?Bob 荣获国非军人最高荣誉勋??ȝ自由勋章。这证明Q他们在用于互联|内数据传输的Y件代码方面的工作已将他们推上“改变了全球商务、通信和娱乐状늚数字革命的最前沿”?br /> <br /> ?1994 q到 2005 q_Vint 一直在 MCI 担Q高副总裁Q此前,他担ȝ国国家研I推q机?(CNRI, Corporation for National Research Initiatives) 的副总裁Q在 1982 q至 1986 q间Q他担Q MCI 副总裁Q从 1976 q到 1982 q_在Q职美国国防部高研究目机构 (DARPA, U.S. Department of Defense's Advanced Research Projects Agency) 期间QVint 领导了互联网及与互联|相关的数据包技术和安全技术的开发工作,在其中发挥了关键作用?br /> <br /> ?2000 q开始,Vint 担Q了互联网名称与数字地址分配机构 (ICANN, Internet Corporation for Assigned Names and Numbers) 董事长,q于 1998 q成为喷气推q技术实验室 (Jet Propulsion Laboratory) 的访问学者?992 q至 1995 q_作ؓ机构的创始hQ他担Q互联|协?(ISOC, Internet Society) 总裁Qƈ?2000 q之前一直Q ISOC 理事会成员。Vint 同时也是 IEEE、ACM、AAAS、美国文理科学院 (American Academy of Arts and Sciences)、国际工E联合会 (International Engineering Consortium)、美国计机历史博物?(Computer History Museum) 和美国国家工E院 (National Academy of Engineering) 成员?br /> <br /> <br /> Vint 获得q无数同互联|工作相关的奖项和荣誉,包括马可奖 (Marconi Fellowship)、美国国家工E院颁发?Charles Stark Draper 奖、科学技?Prince of Asturias 奖、Alexander Graham Bell Association for the Deaf 颁发?Alexander Graham Bell 奖、美国计机机械协会 (Association for Computer Machinery) 颁发的图灵奖 (A.M. Turing Award)、国际电信联?(International Telecommunications Union) 银奖?IEEE Alexander Graham Bell 奖章{等?br /> <br /> Vint 拥有国加州大学z杉矶分?(UCLA) 计算机科学博士学位及十余个名誉学位?br /> <br /> Salar KamangarQ品管理副总裁 <br /> Marissa MayerQ搜索品与用户体验副总裁 <br /> Norio MurakamiQGoogle 日本副总裁兼ȝ?<br /> Miriam RiveraQ副总裁g理L律顾?<br /> Sheryl SandbergQ全球在UK售和q营副总裁 <br /> Susan WojcickiQ品管理副总裁 <br /> 董事?br /> <br /> Eric Schmidt 博士QGoogle Inc. <br /> Sergey BrinQGoogle Inc. <br /> Larry PageQGoogle Inc. <br /> John DoerrQKleiner Perkins Caufield & Byers 公司 <br /> Michael MoritzQSequoia Capital 公司 <br /> Ram ShriramQSherpalo 公司 <br /> John HennessyQ斯坦福大学 <br /> Arthur LevinsonQGenentech <br /> Paul OtelliniQIntel <br /> Shirley M. TilghmanQ普林斯大?<br /> Ann Mather <br /> <br /> 王怀?nbsp; Google中文名谷歌创造h  亚太市场ȝ  已离?br /> <img src ="http://www.tkk7.com/wenhl5656/aggbug/205791.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2008-06-04 14:05 <a href="http://www.tkk7.com/wenhl5656/archive/2008/06/04/205791.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle埃里的演讲——历史上最牛的演讲QZZQ?/title><link>http://www.tkk7.com/wenhl5656/archive/2008/06/04/205781.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Wed, 04 Jun 2008 05:54:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2008/06/04/205781.html</guid><description><![CDATA[     摘要: q是甲骨文公司总裁Larry Ellison (Oracle CEO) 在耉大学Yale University l?000U毕业生the graduating class of 2000所作的演讲全文Q由于他句句惊hQ很P最后被耉大学保安请下讲台。该演讲L历史最牛之演讲Q但是否classic则不得而知Q美国出版的一本大学经典演讲集未将其收入其中? <br> <br>历史上最牛的演讲———甲骨文总裁拉里埃里在耉大学的演?<br> <br>耉的毕业生们,我很抱歉---如果你们不喜Ƣ这L开场白。我惌你们为我做一?事。请?--好好看一看周_看一看站在你左边的同学,看一看站在你双的同学?请你设想q样的情况:从现在v5q之后,10q之后,?0q之后,今天站在你左边的 q个Z是一个失败者;双的这个hQ同P也是个失败者。而你Q站在中间的家伙Q?你以Z怎样Q?一hp|者。失败的l历。失败的优等生?nbsp; <a href='http://www.tkk7.com/wenhl5656/archive/2008/06/04/205781.html'>阅读全文</a><img src ="http://www.tkk7.com/wenhl5656/aggbug/205781.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2008-06-04 13:54 <a href="http://www.tkk7.com/wenhl5656/archive/2008/06/04/205781.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>传奇~程高手(zz?http://www.tkk7.com/wenhl5656/archive/2008/06/04/205780.htmlDestDestWed, 04 Jun 2008 05:52:00 GMThttp://www.tkk7.com/wenhl5656/archive/2008/06/04/205780.html
传奇~程高手Q?
Bill Joy
John Carmack
David Cutler
Donald E. Knuth
Ken Thompson
Rob Pike
Dennis M. Ritchie
Edsger Wybe Dijkstra
Anders Hejlsberg
  阅读全文

Dest 2008-06-04 13:52 发表评论
]]>
Windows XP的启动过E?/title><link>http://www.tkk7.com/wenhl5656/archive/2008/06/01/205198.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Sun, 01 Jun 2008 12:20:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2008/06/01/205198.html</guid><description><![CDATA[<p>从按下计机开兛_动计机Q到d到桌面完成启动,一qq了以下几个阶段Q?/p> <p>  1. 预引|Pre-BootQ阶D;<br />   2. 引导阶段Q?/p> <p>  3. 加蝲内核阶段Q?br />   4. 初始化内栔RD;<br />   5. 登陆?/p> <p>  每个启动阶段的详l介l?/p> <p>  aQ?预引导阶D?/p> <p>  在按下计机甉|使计机启动Qƈ且在Windows XP专业版操作系l启动之前这D|<br /> _我们UC为预引导QPre-BootQ阶D,在这个阶D里Q计机首先q行Power On Sel<br /> f TestQPOSTQ,POST系l的d存以及其他硬件设备的现状。如果计机pȝ的BI<br /> OSQ基输入/输出pȝQ是x即用的,那么计算机硬件设备将l过验以及完成配|?br /> 计算机的基础输入/输出pȝQBIOSQ定位计机的引D备,然后MBRQMaster Boot Re<br /> cordQ被加蝲q运行。在预引导阶D,计算加蝲Windows XP的NTLDR文g?/p> <p>  bQ?引导阶段</p> <p>  Windows XP Professional引导阶段包含4个小的阶Dc?/p> <p>  首先Q计机要经q初始引导加载器阶段QInitial Boot LoaderQ,在这个阶D里Q?br /> NTLDR计机微处理器从实模式转换?2位^面内存模式。在实模式中Q系lؓMS-DOS?br /> ?40kb内存Q其余内存视为扩展内存,而在32位^面内存模式中Q系l(Windows XP Pr<br /> ofessionalQ视所有内存ؓ可用内存。接着QNTLDR启动内徏的mini-file system driver<br /> sQ通过q个步骤QNTLDR可以识别每一个用NTFS或者FAT文gpȝ格式化的分区Q以便发<br /> C及加载Windows XP ProfessionalQ到q里Q初始引导加载器阶段q束了?/p> <p>  接着pȝ来到了操作系l选择阶段Q如果计机安装了不止一个操作系l(也就是多<br /> pȝQ,而且正确讄了boot.ini使系l提供操作系l选择的条件下Q计机昄器会?br /> CZ个操作系l选单Q这是NTLDRdboot.ini的结果。(至于操作pȝ选单Q由于暂时条<br /> 件不够,没办法截图,但是W者模拟了一个)</p> <p>  在boot.ini中,主要包含以下内容Q?/p> <p>  [boot loader]<br />   timeout=30<br />   default=multiQ?QdiskQ?QrdiskQ?QpartitionQ?Q\WINDOWS</p> <p>  [operating systems]</p> <p>  multiQ?QdiskQ?QrdiskQ?QpartitionQ?Q\WINDOWS="Microsoft Windows XP <br /> Professional" /fastdetect</p> <p>  multiQ?QdiskQ?QrdiskQ?QpartitionQ?Q\WINNT="Windows Windows 2000 Pr<br /> ofessional"</p> <p>  其中QmultiQ?Q表C磁盘控制器QdiskQ?QrdiskQ?Q表C磁盘,partitionQxQ?br /> 表示分区。NTLDR是从这里查找Windows XP Professional的系l文件的位置的。(*本文<br /> 不会更详l地讲解boot.ini的组成结构,因ؓ其与本主题关pM大,如果想了解,可以?br /> 一些专门的|站处查询相关信息。)如果在boot.ini中只有一个操作系l选项Q或者把ti<br /> meoutD?Q则pȝ不出现操作系l选择菜单Q直接引导到那个唯一的系l或者默认的<br /> pȝ。在选择启动Windows XP Professional后,操作pȝ选择阶段l束Q硬件检阶D开<br /> 始?/p> <p>  在硬件检阶D中Qntdetect.com收集计机g信息列表q将列表q回到NTLDRQ?br /> q样做的目的是便于以后将q些g信息加入到注册表HKEY_LOCAL_MACHINE下的hardware<br /> 中?br />   g完成后Q进入配|选择阶段。如果计机含有多个g配置文g列表Q可?br /> 通过按上下按钮来选择。如果只有一个硬仉|文Ӟ计算Z昄此屏q而直接用默<br /> 认的配置文g加蝲Windows XP专业版?/p> <p>  引导阶段l束。在引导阶段Q系l要用到的文件一共有QNTLDRQBoot.iniQntdetec<br /> t.comQntokrnl.exeQNtbootdd.sysQbootsect.dosQ可选的Q?/p> <p>  cQ?加蝲内核阶段</p> <p>  在加载内栔RD,ntldr加蝲UCؓWindows XP内核的ntokrnl.exe。系l加载了Window<br /> s XP内核但是没有它初始化。接着ntldr加蝲g抽象层(HALQhal.dllQ,然后Q系l?br /> l箋加蝲HKEY_LOCAL_MACHINE\system键,NTLDRdselect键来军_哪一个Control Set?br /> 被加载。控刉中包含设备的驱动E序以及需要加载的服务。NTLDR加蝲HKEY_LOCAL_MACH<br /> INE\system\service\…下start键gؓ0的最底层讑֤驱动。当作ؓControl Set的镜像的<br /> Current Control Set被加载时Qntldr传递控制给内核Q初始化内核阶段开始了?</p> <p>  dQ?初始化内栔RD?/p> <p>  在初始化内核阶段开始的时候,彩色的Windows XP的logo以及q度条显C在屏幕中央<br /> Q在q个阶段Q系l完成了启动?Q务:</p> <p>  内核使用在硬件检时攉到的数据来创ZHKEY_LOCAL_MACHINE\HARDWARE键?br />   内核通过引用HKEY_LOCAL_MACHINE\system\Current的默认值复制Control Set来创?br /> 了Clone Control Set。Clone Control Set配置是计机数据的备份,不包括启动中的改<br /> 变,也不会被修改?/p> <p>  pȝ完成初始化以及加载设备驱动程序,内核初始化那些在加蝲内核阶段被加载的?br /> 层驱动程序,然后内核扫描HKEY_LOCAL_MACHINE\system\CurrentControlSet\service\…<br /> 下start键gؓ1的设备驱动程序。这些设备驱动程序在加蝲的时候便完成初始化,如果?br /> 错误发生Q内怋用ErrorControl键值来军_如何处理Qgؓ3Ӟ错误标志为危?关键<br /> Q系l初ơ遇到错误会以LastKnownGood Control Set重新启动Q如果用LastKnownGood<br />  Control Set启动仍然产生错误Q系l报告启动失败,错误信息被昄Q系l停止启?br /> Qgؓ2旉误情况ؓ严重Q系l启动失败ƈ且以LastKnownGood Control Set重新启动Q?br /> 如果pȝ启动已经在用LastKnownGood|它会忽略错误q且l箋启动Q当值是1的时?br /> 错误为普通,pȝ会生一个错误信息,但是仍然会忽略这个错误ƈ且l启动;当值是<br /> 0的时候忽略,pȝ不会昄M错误信息而l运?/p> <p>  Session Manager启动了Windows XP高子系l以及服务,Session Manager启动控制<br /> 所有输入、输备以及访问显C器屏幕的Win32子系l以及Winlogonq程Q初始化内核?br /> 毕?/p> <p> Zx86 pȝ?Windows XP Professional 的启动文?/p> <p>文g?nbsp;      文g所处位|?nbsp;   描述 <br /> Ntldr        pȝ分区根目?nbsp; 操作pȝ装蝲?</p> <p>Boot.ini     pȝ分区根目?nbsp; 该文件指?Windows XP Professional 的安装\径。对<br /> 于多引导pȝ Boot.ini 包含一个显C在启动菜单上的操作pȝ选择菜单?/p> <p>Bootsect.dos (仅适用于多引导pȝ) pȝ分区根目?nbsp; Ntldr 会装蝲此文Ӟ以读?br /> 可能包含 MS-DOS, Windows 95, Windows 98, or Windows Me {OS的Windows Xrofessio<br /> nal 多引导系l设定?Bootsect.dos 包含q些操作pȝ的引导扇区,文g属性ؓpȝ?br /> 隐藏?</p> <p>Ntdetect.com   pȝ分区根目?nbsp; 此文件将扫描g讄信息Qƈ传递给 Ntldr </p> <p>Ntbootdd.sys   pȝ分区根目?(SCSI 或者ATA {固件本w禁用或者不支持 INT-13 ?br /> 断扩展调用的讑֤需要此文g).  该驱动程序用于访问不使用 BIOSQ而连接到 SCSI 或?br />  ATA 的硬盘驱动器Q?The contents of this file depend on the startup controller<br />  used. </p> <p>Ntoskrnl.exe systemroot\System32  Windows XP Professional操作pȝ的核?(也被?br /> ?kernel) 。作?kernel的一部分Q运行在处理器特权模式下的代码,允许直接讉Kp?br /> l数据和g?<br />  在安装Windows XP Professional 操作pȝ期间Q如果是单处理器pȝQsetupE序从操<br /> 作系l光盘上复制 Ntoskrnl.exe 文gQ如果是多处理器pȝQSetup 从安装光盘上复制<br />  Ntoskrnlmp.exe q将它重命名为Ntoskrnl.exe. </p> <p>Hal.dll systemroot\System32  g抽象层动?HAL)链接库文件。HAL abstracts 从操<br /> 作系l提取底层硬件信息,q给相同cd的设备,提供公用~程接口?<br />  Microsoft&reg; Windows&reg; XP Professional 操作pȝ光盘包含若干 Hal 文gQSe<br /> tup 适合(zhn)系l硬件设|的文g复制到?zhn)的计机Qƈ重命名ؓ Hal.dll. </p> <p>System registry file systemroot\System32\Config\System  此注册表文g包含创徏HK<br /> EY_LOCAL_MACHINE\SYSTEM 注册表键值所需要的数据。该键值包含了操作pȝ启动讑֤?br /> pȝ服务所需要的信息?</p> <p>Device drivers systemroot\System32\Drivers  一些硬件设备的驱动E序文gQ比如键<br /> 盘、鼠标、显卡?</p> <p>   systemroot是众多环境变量之一Q用于将象文件和文g路径q样的字W串兌到变量,<br /> 以便 Windows XP Professional应用E序和服务用。例如,通过使用环境变量Q?br /> 脚本不同修改可以运行在不同环境讄的计机上。?zhn)可以通过在命令行执行 <br />  set 命o查看环境变量列表</p> <p>硬件和g配置文g<br />     q入此阶D,Ntldr 启动Ntdetect.com, 后者将执行基础g扫描。随?Ntldr 扫描<br />  Boot.ini 信息Q以及保存在注册表中的硬件和软g信息Q传送给 Ntoskrnl.exe。Ntdet<br /> ect.com 硬仉|信?(比如 便携计算Z接驳或未接驳讄) 和保存在 Advanced<br />  Configuration and Power Interface (ACPI) 表中的信息?ACPI 兼容Zg允许Window<br /> s XP Professional 设备电源管理功能和讑֤资源需求?/p> <p>    、设|硬仉D在d Boot.ini q完成其d后, Ntldr 启动 Ntdetect.com<br /> 。在 x86 pȝ?Ntdetect.com 调用pȝ例行E序攉已经安装的硬件信息,q将攉?br /> 信息q回lNtldrQNtldr 这些信息收集后存入内部数据?Q然后启?Ntoskrnl.exe <br /> q将信息传递给它?/p> <p>Ntdetect.com 所攉的硬件设备的信息如下Q?/p> <p>信息Zg信息Q比如日期和旉 <br /> ȝ和板卡类?<br /> 昑֍ <br /> 键盘 <br /> 通讯端口 <br /> 盘 <br /> 软盘 <br /> 输入讑֤ (比如鼠标) <br /> q行端口 <br /> 安装在Industry Standard Architecture (ISA) ȝ上的讑֤<br />    Ntdetect.com 在非ACPI兼容计算机的讑֤扫描中扮演了重要的角艌Ӏ因为在q些cd<br /> 的计机上,Zg而不是操作系l决定了分配l设备的资源Q对于用ACPIZg的计机<br /> QWindows XP Professional 对硬件设备分配资源。在q个阶段QNtdetect.com 攉g<br /> 信息Q?Windows XP Professional 为桌面计机创徏一个单独的默认g配置文gQ而ؓ<br /> 便携计算机创Z个缺省的配置文g。对于便机Q操作系l基于当前计机上硬?br /> 状态选择适当的配|文件?/p> <p>桌面型计机. Profile 1 <br /> 便携式计机. <br /> Docked Profile <br /> Undocked Profile<br /> g配置文g对于便携式计机是非常有用的Q因些计机的硬件状态通常都不是静<br /> 态的Q启动的时候,没有列表在特定的g配置文g中的讑֤驱动是不会被加蝲的?br />    关于创徏和用硬仉|文件的信息Q请参考Windows XP Professional 帮助和支持中<br /> 心,也可以参考知识库文 225810, "How to Create Hardware Profiles on Windows 2<br /> 000?Based Mobile Computers," 查找此文,h询Web Resources 面 http://www.m<br /> icrosoft.com/windows/reskits/webresources 上的知识库链接,同时(zhn)也可以查看"Man<br /> aging Devices" ?"Supporting Mobile Users" <br />    核心装蝲阶段Ntldr 负责?Windows 核心?(Ntoskrnl.exe) 和硬件抽象层 (HAL) ?br /> 载到内存。?zhn)的系l所使用?Hal.dll 文g是可以发生变化的。在安装期间QWindows X<br /> P Professional 安装E序从若q?HAL 文g中选择一个复制到pȝQ?请参看表28.2 关于<br /> q些文g的列? q名ؓHal.dll?/p> <p>在设备管理器中查看计机描述 </p> <p>在运行对话框Q输?devmgmt.mscQ点ȝ定?<br /> 在设备管理器展开计算机察看?zhn)计算机的描述?<br /> 通过比较讑֤理器中的描q和下面?28.2中的描述, (zhn)可以确定从 Windows XP Profe<br /> ssional 操作pȝ光盘复制到?zhn)pȝ中的HAL文g</p> <p>Table 28.2   关于不同 Hal.dll 文g的描q?/p> <p>讑֤理器中计算机的描述  复制的HAL文g <br /> ACPI 多处理器 PC Halmacpi.dll <br /> ACPI 单处理器 PC Halaacpi.dll <br /> Advanced Configuration and Power Interface (ACPI) PC Halacpi.dll <br /> MPS 多处理器 PC Halmps.dll <br /> MPS 单处理器 PC Halapic.dll <br /> 标准 PC Hal.dll <br /> Compaq SystemPro 多处理器或者完全兼?Halsp.dll </p> <p><br /> 核心层kernel 和硬件抽象层HAL 初始化一lY件组Ӟ他们l称为windows 执行体。Win<br /> dows 执行体扫描储存在注册表control sets中的信息Qƈ启动服务和驱动程序?</p> <p>关于Windows executive services, h?"Common Stop Messages for Troubleshooti<br /> ng" </p> <p>控制集Control Sets<br /> Ntldr ?HKEY_LOCAL_MACHINE\SYSTEM 注册表子键中d相关信息Q该子健中的数据创徏<br /> 于\System32\Config\ System 文g,故?Ntldr 能够军_哪些讑֤驱动在系l启动时装蝲<br /> ?通常Q注册表中存在几个control sets, 其后面的序号取决于系l设定多长时间变更一<br /> ơ。?/p> <p>提示Q?/p> <p>如非必要不要直接~辑注册表。注册表~辑器绕开了系l保护机Ӟ(zhn)的修改有可能会?br /> 坏系l,严重者甚至需要重新安?Windows。如果你必须~辑注册表,请事先作备䆾Qƈ<br /> 详细阅读 Microsoft&reg; Windows&reg; 2000 Server Resource Kit 中关?Registry <br /> Reference 的章节http://www.microsoft.com/windows/reskits/webresources.<br /> 典型的注册表控制?control set 子键如下Q?/p> <p>\CurrentControlSet, 一个注册在\Select\Current 中Q指?ControlSetxxx 子键的指<br /> ?(xxx 代表一?control set ~号, 比如 001)  <br /> \Clone, 一?\CurrentControlSet的拷贝,当?zhn)每次启动计算机的时候创建。(gnaw072<br /> 5注:此处原文如此Q有待考证Q?<br /> \Select, 包含如下键| <br /> Default, 指针指向pȝ指定用户下次登陆所使用的控刉~号 (比如 001=ControlSet00<br /> 1)?如果没有错误发生Q或者ƈ非由 LastKnownGood 启动Ҏ(gu)讄Q此 control set ~?br /> 号将?Default, Current?LastKnownGood 注册Ҏ(gu)影响 (假定当前用户可以成功d<br /> )<br /> Current, 指向此次用于启动pȝ的控刉  <br /> Failed, 指向没有成功启动 Windows XP Professional 的控刉。当使用 LastKnownGoo<br /> d 选项启动pȝӞ此项被更?Qgnaw0725注:表示 Windows XP 在其中保存失败启动<br /> 生的数据的控件组?此控件组在用L一ơ调?#8220;最q一ơ的正确配置”选项之前q不?br /> 际存在。)  <br /> LastKnownGood, 指向上次用户会话所使用的控刉 。当用户d的时候,LastKnownGoo<br /> d 控制集被前一ơ用户会话用的讄信息所更新?br /> 除非(zhn)从Windows Advanced Options菜单中选择Last Known Good ConfigurationQNtldr<br />  用Default 键值所标示的控刉?/p> <p>核心层用Ntldr 提供的内部数据结构创?HKEY_LOCAL_MACHINE\HARDWARE 子键Q其中包<br /> 含在pȝ启动阶段攉的硬件信息。这些数据包含信息包括各U硬件组件和分配l每个设<br /> 备的pȝ资源。?zhn)可以通过查看在启动过E中昄的进度指C器来监控核心层加蝲q程 ?br /> ?Last Known Good Configuration的相关信息,(zhn)可以查?"Tools for Troubleshoot<br /> ing" </p> <p>Windows XP Professional 支持讑֤扩展。新的或者更新的驱动E序q不存在?Windows<br />  XP Professional 操作pȝ光盘上,而是׃g厂商提供。驱动程序是核心模式lgQ?br /> 需要Drivers are kernel-mode components required by devices to function within <br /> an operating system. 服务是支持操作系l功能和应用E序的组件。与用户应用E序相比<br /> Q服务可以运行在一个不同的上下文,通常不会提供用户可以讄的选项。服务,比如?br /> 机打?Print SpoolerQ不需要用L录即可运行,而且与登陆到pȝ的用h兟뀂Wind<br /> ows XP Professional 驱动E序和服务系l文仉常被存攑֜ systemroot\System32 ?<br /> systemroot\System32\Drivers 目录下,?.exe, .sys, or .dll {扩展名保存?/p> <p>驱动E序也是服务Q因此在核心层初始化期间QNtldr ?Ntoskrnl.exe 按照存储在HKEY<br /> _LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\servicename 注册表子键中的数?br /> 来确定装载的驱动E序和服务次序。例如,Ntldr 首先搜烦Services 子键?Start gؓ<br />  0的服务,比如盘控制器。当 Ntldr 启动 Ntoskrnl.exe后,一个Ntoskrnl.exe lg?br /> 索ƈ启动驱动E序Q比如网l协议,q些启动?Start gؓ 1.</p> <p>Table 28.3 Q列Z Start 的|十进Ӟ。Boot cd的驱?(Start gؓ0的项) <br /> 文gpȝ驱动E序的Start值始lؓ0Q因为启?Windows XP Professional 需要它们的?br /> 持?/p> <p>?28.3 <服务?gt; Start的赋?<br /> ?Startcd 关于 Start 赋值的描述 <br /> 0 Boot Zx86pȝ Ntldr 或者Itanium IA64ldr上的Zg调用模式指定装蝲的驱动,?br /> 果没有错误发生,核心层Kernel启动该驱动E序 <br /> 1 System 指定在系l核心层 Kernel 初始化期间被 Windows XP Professional boot dri<br /> vers 所调用的驱动程?<br /> 2 Auto load 指定在系l启动时被会话管理器 (Smss.exe)或者服务控制器 (Services.ex<br /> e)所加蝲的驱动程序或者服务?<br /> 3 Load on demand 指定一个通过用户、进E或者其他服务手动启动的驱动E序或者服?</p> <p>4 Disabled 指定一个禁止(不启动)的驱动程序或者服务?</p> <p><br /> ?28.4 列出了Type 的一些|十进Ӟ </p> <p>?28.4   <服务?gt; Type 的赋?/p> <p>?nbsp; Type 赋值描q?<br /> 1 指定一个核心设备驱动程?<br /> 2 指定一个文件系l驱动程?(也是一个核心设备驱动程? <br /> 4 指定参数传递给讑֤驱动E序 <br /> 16 指定一个遵循服务控制协议的服务Q该服务可以独立q行在一个进E中Q且可以为服?br /> 控制器所启动 <br /> 32 指定一个可以和其他服务׃nq程的服?</p> <p><br /> 一些驱动程序和服务需要在启动之前定之间的相互依赖关pR通过查看HKEY_LOCAL_MAC<br /> HINE\SYSTEM\CurrentControlSet\Services\servicename下DependOnGroup?DependOnSe<br /> rvice  ?Q?zhn)可以扑ֈq个依存关系的列表。关于用依赖关p阻止或者gq驱动程?br /> 或者服务启动的信息Q请查看 "Temporarily Disabling Services" 。该服务子键也包?br /> 了媄响驱动程序和服务如何加蝲的信息,?28.5 中描qC其中的一部分?/p> <p>?28.5   注册表其?<服务?gt; ?/p> <p>?描述 <br /> DependOnGroup 此组中所描述的项目,臛_有一个在当前服务装蝲前必被加蝲。子?S<br /> YSTEM\CurrentControlSet\Control\ServiceGroupOrder 包含服务l装载次?<br /> DependOnService 此列表中描述的服务,必须在当前服务之前加载?<br /> Description lg描述 <br /> DisplayName 指定lg的显C名U?<br /> ErrorControl 控制一个驱动程序错误是需要系l?LastKnownGood 控制集还是提CZ<br /> 个错误停止信息?<br /> 如果gؓ 0x0 (忽略Q没有错误报?, 不会昄警告信息Ql执行启动?<br /> 如果gؓ 0x1 (普通,报告错误), 错误记录到pȝ日志q提C告信息,但l启动过<br /> E?<br /> 如果gؓ 0x2 (严重), 事件记录到pȝ日志Q?LastKnownGood 讄Q重新启动系<br /> l,执行启动q程?<br /> 如果gؓ 0x3 (关键), 事件记录到pȝ日志Q?LastKnownGood 讄Q重新启动系<br /> l。如果当前启动已l?LastKnownGood 讑֮Q则昄错误停止信息?<br /> Group 指定驱动E序或者服务隶属的l。此设定允讔R动程序或者服务同步启动(比入<br /> Q文件系l驱动程序)注册表子?HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Con<br /> trol\ServiceGroupOrder 中的 List Ҏ(gu)定了l项启动序?<br /> ImagePath 如果存在ImagePath,该项用于标示驱动E序或者服务的路径和文件名?(zhn)?br /> 可以使用Windows Explorer 核实q些路径和文件名?<br /> ObjectName 指定一个对象名。如?Type Ҏ(gu)定一?Windows XP Professional 服务Q?br /> 那么它就代表服务q行时用于登陆的帐户名?<br /> Tag 指定一个驱动程序在驱动E序l中的启动顺序?</p> <p><br /> 会话理?br /> 当所有标志ؓ Boot ?Startup 数据cd的注册表子键执行完成后, kernel 开始加载会<br /> 话管理器 Session ManagerQ由?(Smss.exe) 执行后箋重要的初始化工作Q比如:</p> <p>创徏pȝ环境变量 <br /> 启动Windows 子系l核心保护模?(通过 systemroot\System32\Win32k.sys 实现), q将<br />  Windows XP Professional 从文本模式切换至囑Ş模式。基于Windows的应用程序都q行<br /> ?Windows 子系l上Q这个环境下允许应用E序讉K操作pȝ功能函数Q比如在屏幕上显<br /> CZ息?<br /> 启动 Windows 子系l用h式部?(通过 systemroot\System32\Csrss.exe 实现). <br /> 启动登陆理?(通过  systemroot\System32\Winlogon.exe 实现). <br /> 创徏辅助虚拟内存|?<br /> 为存攑֜下列子键中的文g列表Q执行gq的重命名操作?HKEY_LOCAL_MACHINE\SYSTEM<br /> \CurrentControlSet\Control\Session Manager\PendingFileRenameOperations. 比如Q?br /> 当?zhn)安装了一个新的驱动程序或者应用程序后Q系l可能会提示(zhn)重新启动,以便 Windo<br /> ws XP Professional 能够替换当前正在使用的文件?br /> Windows 子系l和Z它执行的应用E序是用h式进E,它们不能直接讉Kg和设?br /> 驱动。用h式进E执行优先低于核心q程Q当操作pȝ需要更多内存的时候,它可?br /> 被用户模式下进E用的内存~存到虚拟页面文件。关于用h式和核心模式lg的信<br /> 息,请参?Common Stop Messages for Troubleshooting" ?/p> <p>会话理器Session Manager 搜索注册表Q以获得服务信息Q注册表键值如下:</p> <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager 包含一个在<br /> 服务装蝲之前q行的命令列?nbsp; Autochk.exe 工具?BootExecute 的值和存储?Memo<br /> ry Management 子键中的虚拟内存 (面文g) 讄所指定。Autochk, ?Chkdsk 工具?br /> 一个版本,如果操作pȝ到一个文件系l错误,需要在完成启动q程之前q行修复Q?br /> 那么׃在启动的时候运行它。关?Autochk ?Chkdsk, "Troubleshooting Disks and<br />  File Systems" ?<br /> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems<br />  包含一个有效子pȝ的列表。比?Csrss.exe 包含Windows 子系l中的一部分Q用h<br /> 式?nbsp; <br /> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\servicename. 服务控制理<br /> 器(Service Control ManagerQ?初始化那些设|ؓ启动自动加蝲的服务?br /> d阶段在此阶段Windows 子系l启?Winlogon.exeQ此模块为系l服务,以完成用L<br /> d或者登出的动作?Winlogon.exe 所完成的功能如下:</p> <p>启动服务子系l?(Services.exe), 也称为服务控制管理器 (SCM). <br /> 启动本地安全性授权进E?Local Security Authority (LSA) (Lsass.exe). <br /> 在出现开始登陆提C时Q侦?CTRL+ALT+DEL l合键?<br /> 囑Ş化识别和验证 Graphical Identification and Authentication (GINA) lg获取?br /> 户名和密码,q将q些信息传送给 LSA q行安全验证。如果用h供有效验证,那么通过<br /> 使用Kerberos V 5 验证协议或?NTLM 可以或者访问权限。关于安全组件的信息Q比?<br /> LSA, Kerberos V5 协议或?NTLM, Distributed Systems Guide of the Microsoft&reg<br /> ; Windows&reg; 2000 Server Resource Kit.</p> <p>当服务控制管理器Service Control Manager 初始化自动装载服务项和驱动时QWinlogon<br />  开始初始化安全和认证组Ӟ当用L录后Q系l进行如下动作:</p> <p>更新控制集Control sets ?控制集ؓ LastKnownGood 注册Ҏ(gu)影响Qƈ?Clone 中<br /> 的内容一同更新。Clone, 是CurrentControlSet 的一份拷? 当?zhn)每次启动计算机时?br /> 创徏。当用户d的时候,LastKnownGood 控制集被前一ơ用户会话用的讄信息所?br /> 新?<br /> 实施{略。组{略{略讑֮开始实施于用户和计机帐户。关于组{略的相关信息,h<br /> ?Planning Deployments," "Managing Desktops," ?"Authorization and Access Co<br /> ntrol" Q以及Windows 2000 Server Resource Kit中分布式pȝ指南中关?"Group Pol<br /> icy" 的章节,同时(zhn)也可以参考其|站资源站点 http://www.microsoft.com/windows/r<br /> eskits/webresources 上关?Change and Configuration Management Deployment Guid<br /> e 的链接?<br /> q行启动E序?Windows XP Professional 启动登陆脚本Q启动程序组Qƈ且启动在如下<br /> 注册表子键和启动目录所兌的服务项: <br /> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce <br /> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer<br /> \Run <br /> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run <br /> HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Run <br /> HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run <br /> HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce <br /> systemdrive\Documents and Settings\All Users\Start Menu\Programs\Startup <br /> systemdrive\Documents and Settings\username\Start Menu\Programs\Startup <br /> windir\Profiles\All Users\Start Menu\Programs\Startup <br /> windir\Profiles\username\Start Menu\Programs\Startup <br /> windir\Profiles 目录文g夹仅存在于从Windows NT 4.0升的系l上?/p> <p>直到用户成功登陆到计机后,Windows XP Professional 启动q程最l完成?/p> <p>x即用即插即用检不与登陆过E同步运作,它依赖于pȝZgQ硬Ӟ讑֤驱动<br /> E序以及操作pȝ功能Q从而能够检和枚D新的讑֤?Windows XP Professional Z<br /> 用ACPIZg的设备优化即插即用支持,q且允许增强功能Q比如硬件资源共享?/p> <p>当即插即用能够很好协调工作时QWindows XP Professional 能够在最用户参与的前提<br /> 下,到新的讑֤Q分配系l资源,安装或者请求驱动程序。ACPI Ҏ(gu)对于移动用h<br /> 非常有用的,q些Ҏ(gu)可以很好的支持待机、休眠、冷热插拔等功能?/p> <p> </p> <img src ="http://www.tkk7.com/wenhl5656/aggbug/205198.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2008-06-01 20:20 <a href="http://www.tkk7.com/wenhl5656/archive/2008/06/01/205198.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>(zz)理工U大学排?/title><link>http://www.tkk7.com/wenhl5656/archive/2008/06/01/205197.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Sun, 01 Jun 2008 12:18:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/archive/2008/06/01/205197.html</guid><description><![CDATA[       1 北京大学 ★★★★?理科W一Q中国科学院院士数量全国W一Q科学家的摇。数<br /> 学、物理、化学、生物四个基U学的实力均居全国高校之首。北京大学医学部的分数线<br /> 仅次于北京大学校本部和清华大学?br />   2 哈尔滨工业大?★★★★?工科W一Q哈天研I全国第一Q工E师的摇。近q?br /> 来逐渐加强理科的徏设,加上强大的工U背景,理科实力大有上升?br />   3 复旦大学 ★★★★?在这里读书是许多南方人的梦想Q地处上P是文理基l?br /> 合性大学,历史(zhn)?<br />   4 江大学 ★★★★?理号U?#8220;清?#8221;Q合q了杭州大学、浙江医U大学和江<br /> 农业大学后更是实力大增,成ؓ全国惟一一所兼具理工农医的大学?<br />   5 南京大学 ★★★★?虽然有些理科专业有点冷门Q比如天文学Q,但绝Ҏ(gu)一?br /> 的?br />   6 中国U学技术大?★★★☆?虽然地处合肥Q掩不住其大家本Ԍ毕竟是科技?br /> 直办高校?br />   7 上v交通大?★★★☆?地处上v宝地Q势头完全压倒交通大学家族的老大哥西<br /> 安交通大学。ƈ且工U实力非帔R厚?<br />   8 北京航空航天大学 ★★★☆?它的崛vQ相当原因是׃地处天子脚下吧。不q?br /> 自n的理工科实力实很强Q尤其是自动化之cȝ工科?<br />   9 国防U学技术大?★★☆☆?计算机类专业Q其中计机U学技术超q清?br /> 大学居全国第一Q由于是军校Q不用支持高额的学杂贏V?<br />   10 华中U技大学 ★★☆☆?华中地区理工cd学的老大Q有一些其他著名的工科?br /> 学没有的工科专业? <img src ="http://www.tkk7.com/wenhl5656/aggbug/205197.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2008-06-01 20:18 <a href="http://www.tkk7.com/wenhl5656/archive/2008/06/01/205197.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>断点l传的原?/title><link>http://www.tkk7.com/wenhl5656/articles/205193.html</link><dc:creator>Dest</dc:creator><author>Dest</author><pubDate>Sun, 01 Jun 2008 12:11:00 GMT</pubDate><guid>http://www.tkk7.com/wenhl5656/articles/205193.html</guid><description><![CDATA[      其实断点l传的原理很单,是在Http的请求上和一般的下蝲有所不同而已。打个比方,览器请求服务器上的一个文Ӟ所发出的请求如下:<br /> <br />    假设服务器域名ؓ<a >www.sjtu.edu.cn</a>Q文件名为down.zip?br /> <br /> GET /down.zip HTTP/1.1<br /> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, plication/vnd.ms-powerpoint, */*<br /> Accept-Language: zh-cn<br /> Accept-Encoding: gzip, deflate<br /> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)<br /> Connection: Keep-Alive<br /> <br /> 服务器收到请求后Q按要求Lh的文Ӟ提取文g的信息,然后q回l浏览器Q返回信息如下:<br /> <br /> 200<br /> Content-Length=106786028<br /> Accept-Ranges=bytes<br /> Date=Mon, 30 Apr 2001 12:56:11 GMT<br /> ETag=W/"02ca57e173c11:95b"<br /> Content-Type=application/octet-stream<br /> Server=Microsoft-IIS/5.0<br /> Last-Modified=Mon, 30 Apr 2001 12:56:11 GMT<br /> <br /> 所谓断点箋传,也就是要从文件已l下载的地方开始l下载。所以在客户端浏览器传给Web服务器的时候要多加一条信息——从哪里开始?br /> <br /> 下面是用自己~的一?览?来传递请求信息给Web服务器,要求?000070字节开始?br /> <br /> GET /down.zip HTTP/1.0<br /> User-Agent: Firefox<br /> RANGE: bytes=2000070-<br /> Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2<br /> <br /> 仔细看一下就会发现多了一行RANGE: bytes=2000070-Q这一行的意思就是告诉服务器down.zipq个文g?000070字节开始传Q前面的字节不用传了?br /> 服务器收到这个请求以后,q回的信息如下:<br /> <br /> 206<br /> Content-Length=106786028<br /> Content-Range=bytes 2000070-106786027/106786028<br /> Date=Mon, 30 Apr 2001 12:55:20 GMT<br /> ETag=W/"02ca57e173c11:95b"<br /> Content-Type=application/octet-stream<br /> Server=Microsoft-IIS/5.0<br /> Last-Modified=Mon, 30 Apr 2001 12:55:20 GMT<br /> <br /> 和前面服务器q回的信息比较一下,׃发现增加了一行:<br /> <br /> Content-Range=bytes 2000070-106786027/106786028<br /> <br /> q回的代码也改ؓ206了,而不再是200了?br /> 知道了以上原理,可以进行断点箋传的~程了?br /> <img src ="http://www.tkk7.com/wenhl5656/aggbug/205193.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wenhl5656/" target="_blank">Dest</a> 2008-06-01 20:11 <a href="http://www.tkk7.com/wenhl5656/articles/205193.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>javadoc~javah~HtmlConverter~http://www.tkk7.com/wenhl5656/articles/205191.htmlDestDestSun, 01 Jun 2008 12:02:00 GMThttp://www.tkk7.com/wenhl5656/articles/205191.htmljavadoc.exe

用法Qjavadoc [options] [packagenames] [sourcefiles] [classnames] [@files]
-overview <file> d HTML 格式的概q文?
-public 仅显C?public cd成员
-protected 昄 protected/public cd成员Q缺省)
-package 昄 package/protected/public cd成员
-private 昄所有类和成?
-help 昄命o行选项
-doclet <class> 通过候?doclet 生成输出
-docletpath <path> 指定 doclet cL件的查找位置
-sourcepath <pathlist> 指定源文件的查找位置
-classpath <pathlist> 指定用户cL件的查找位置
-exclude <pkglist> Specify a list of packages to exclude
-subpackages <subpkglist> Specify subpackages to recursively load
-breakiterator Compute 1st sentence with BreakIterator
-bootclasspath <pathlist> 覆盖自Dcd载器所加蝲的类文g的位|?
-source <release> Provide source compatibility with specified release
-extdirs <dirlist> 覆盖已安装的扩展的位|?
-verbose 有关 Javadoc 所做工作的输出信息
-locale <name> 所用的 LocaleQ例?en_US ?en_US_WIN
-encoding <name> 源文件编码名U?
-J<flag> ?<flag> 直接传给q行时系l?

由标?doclet 提供Q?
-d <directory> 输出文g的目标目?
-use 创徏cd包的用法?
-version 包含 @version D?
-author 包含 @author D?
-docfilessubdirs Recursively copy doc-file subdirectories
-splitindex 烦引分为每个字母对应一个文?
-windowtitle <text> 文的浏览器H口标题
-doctitle <html-code> 包含包烦引页Q首)的标?
-header <html-code> 包含每一늚늜文本
-footer <html-code> 包含每一늚脚文本
-bottom <html-code> 包含每一늚底文本
-link <url> Create links to javadoc output at <url>
-linkoffline <url> <url2> Link to docs at <url> using package list at <url2>
-excludedocfilessubdir <name1>:.. Exclude any doc-files subdirectories with given name.
-group <name> <p1>:<p2>.. Group specified packages together in overview page
-nocomment Supress description and tags, generate only declarations.
-nodeprecated 不包?@deprecated 信息
-noqualifier <name1>:<name2>:... Exclude the list of qualifiers from the output.
-nosince Do not include @since information
-nodeprecatedlist 不生成不鼓励使用的列?
-notree 不生成类层次
-noindex 不生成烦?
-nohelp 不生成帮助链?
-nonavbar 不生成导航栏
-quiet Do not display status messages to screen
-serialwarn Generate warning about @serial tag
-tag <name>:<locations>:<header> Specify single argument custom tags
-taglet The fully qualified name of Taglet to register
-tagletpath The path to Taglets
-charset <charset> Charset for cross-platform viewing of generated documentation.
-helpfile <file> 包含帮助链接功能链接到目标的文g
-linksource Generate source in HTML
-stylesheetfile <path> 改变所生成文的样式的文g
-docencoding <name> 输出~码名称


javah.exe

用法Qjavah [options] <classes>

其中 [options] 包括Q?

-help 打印该帮助信?
-classpath <path> cȝ加蝲路径
-bootclasspath <path> 自Dcȝ加蝲路径
-d <dir> 输出目录
-o <file> 输出文gQ仅能?-d ?-o 之一Q?
-jni 生成 JNI 风格的头文gQ缺省)
-old 生成 JDK1.0 风格的头文g
-stubs 生成 stubs 文g
-version 打印版本信息
-verbose 输出有关本命令所做工作的信息
-force 始终写输出文?
指定 <classes> 时必M用全名(例如 java.lang.ObjectQ?br />
HtmlConverter.exe

用法QHtmlConverter [-option1 value1 [-option2 value2 [...]]] [-simulate] [filespecs]

其中Q选项包括Q?

-source: 获取源文件的路径?~省| <userdir>
-dest: 写入已{换文件的路径?~省| <userdir>
-backup: 写备份文件的路径?~省| <dirname>_BAK
-f: 强制覆写备䆾文g?
-subdirs: 应处理子目录中的文g?
-template: 模板文g的\径?如果不确定,请用缺省倹{?
-log: 写日志的路径?如果没有提供Q则不会写入M日志?
-progress: 转换时显C度?~省| true
-simulate: 在没有进行{换时昄特定于{换的信息?
-latest: 使用最新的 JRE 支持发行?mimetype?
-gui: 昄转换E序的图形用L面?

filespecs: 用空格分开的文件说明列表?~省| "*.html *.htm" Q需要引?
 
native2ascii

功能说明Q?
含有本地编码字W(既非 Latin1 又非 Unicode 字符Q的文g转换?Unicode ~码字符的文件?
语法Q?
native2ascii [options] [inputfile [outputfile]]
补充说明Q?
Java ~译器和其它 Java 工具只能处理含有 Latin-1 ??Unicode ~码Qudddd 记号Q字W的文g。native2ascii 含有其它字W编码的文g转换成含 Latin-1 ??Unicode ~码字符的文件。若省略 outputfileQ则使用标准输出讑֤输出。此外,如果也省?inputfileQ则使用标准输入讑֤输入?
命o选项
-reverse 执行相反的操作:含 Latin-1 ??Unicode ~码字符的文件{换成含本地编码字W的文g?
-encoding[encoding_name] 指定转换q程使用的编码名U。缺省的~码从系l属?file.encoding 中得到?


Dest 2008-06-01 20:02 发表评论
]]>
javac~appletviewer~jarhttp://www.tkk7.com/wenhl5656/articles/205190.htmlDestDestSun, 01 Jun 2008 11:57:00 GMThttp://www.tkk7.com/wenhl5656/articles/205190.html javac.exe

用法Qjavac <选项> <源文?gt;
可能的选项包括Q?
-g 生成所有调试信?
-g:none 生成无调试信?
-g:{lines,vars,source} 生成只有部分调试信息
-O 优化Q可能妨调试或者增大类文g
-nowarn 生成无警?
-verbose 输出关于~译器正在做的信?
-deprecation 输出使用了不鼓励使用的API的源E序位置
-classpath <路径> 指定用户cL件的位置
-sourcepath <路径> 指定输入源文件的位置
-bootclasspath <路径> 覆盖自DcL件的位置
-extdirs <目录(多个)> 覆盖安装的扩展类的位|?
-d <目录> 指定输出cL件的位置
-encoding <~码> 指定源文件中所用的字符集编?
-target <版本> 生成指定虚拟机版本的cL?
-help Print a synopsis of standard options

appletviewer.exe

用法Qappletviewer <options> url
其中Q?lt;options> 包括Q?
-debug ?Java 调试器中启动 applet 程序查看器
-encoding <encoding> 指定?HTML 文g使用的字W编?
-J<runtime flag> ?Java 解释器传递参?
-J 选项不是标准选项Q如有更改,不另行通知?

====================
jar.exe
用法Qjar {ctxu}[vfm0M] [jar-文g] [manifest-文g] [-C 目录] 文g?...
选项Q?
-c 创徏新的存
-t 列出存内容的列?
-x 展开存中的命名的(或所有的〕文?
-u 更新已存在的存
-v 生成详细输出到标准输Z
-f 指定存文g?
-m 包含来自标明文g的标明信?
-0 只存储方式;未用ZIP压羃格式
-M 不生所有项的清单(manifest〕文?
-i 为指定的jar文g产生索引信息
-C 改变到指定的目录Qƈ且包含下列文Ӟ
如果一个文件名是一个目录,它将被递归处理?
清单Qmanifest〕文件名和存文件名都需要被指定Q按'm' ?'f'标志指定的相同顺序?
CZ1Q将两个class文g存C个名?'classes.jar' 的存文件中Q?
jar cvf classes.jar Foo.class Bar.class
CZ2Q用一个存在的清单QmanifestQ文?'mymanifest' ?foo/ 目录下的所?
文g存C个名?'classes.jar' 的存文件中Q?
jar cvfm classes.jar mymanifest -C foo/ .


Dest 2008-06-01 19:57 发表评论
]]>
JDK安装后bin文g夹下的exe文ghttp://www.tkk7.com/wenhl5656/articles/205187.htmlDestDestSun, 01 Jun 2008 11:47:00 GMThttp://www.tkk7.com/wenhl5656/articles/205187.html安装JDK后,JAVAHOME下会出现许多可执行的exe文gQ它们的用途如下:

    javacQJava~译器,Java源代码换成字节代 
    javaQJava解释器,直接从类文g执行Java应用E序代码 
    appletviewer(程序浏览器)Q一U执行HTML文g上的Java程序类的Java览?nbsp;
    javadocQ根据Java源代码及其说明语句生成的HTML文 
    jdbQJava调试器,可以逐行地执行程序、设|断点和查变?nbsp;
    javahQ生可以调用Javaq程的Cq程Q或建立能被JavaE序调用的Cq程的头文g 
    JavapQJava反汇~器Q显C编译类文g中的可访问功能和数据Q同时显C字节代码含?nbsp;
    jarQ多用途的存及压~工P是个java应用E序Q可多个文件合qؓ单个JAR归文g?nbsp;
    htmlConverter——命令{换工兗?nbsp;
    native2ascii——将含有不是Unicode或Latinl字符的的文g转换为Unicode~码字符的文件?nbsp;
    serialver——返回serialverUID。语法:serialver [show] 命o选项show是用来显CZ个简单的界面。输入完整的cd按Enter键或"昄"按钮Q可昄serialverUID?

它们具体说明见系列文章?br />


Dest 2008-06-01 19:47 发表评论
]]>
վ֩ģ壺 ۺɫ鶹| ޹ۺ| һĻߵӰ| ͵޾Ʒ| ˬִ̼һ߳| ŷպһ| ޹ƷþþþþԻ| ޾Ʒѿ| ɫػaëƬѹۿ| ѹۿ߹ۿİ| ձÿӰѿ| þþ뾫Ʒպ| ޾avĻ| ŮƵƵƵҳ | ɫݺɫۺƵ| ҵijdzӪѿ| ձվ߹ۿ| ۺϾþۺϼþ| ˾ƷƵ| ѻɫƵ| ޾ƷƬ߲| ޹˾þۺ| һëƬѿ| һֻ| ɫƷVRһ| ҹžƵ߹ۿ| ĻӰѿ| ˳ɻ߹ۿ| þù׾Ʒѿ| ޳ӰԺ߹ۿ| ۺavһ | avƷfc2| ɫaAV| պһ| ߹ۿƷ| MM1313޾Ʒþ| ŮƵaƵȫ| ޸XXXXɫ| ҹƵ| Ѱββ8x| þ޹վ|