2011年9月27日

          [ -a FILE ] 如果 FILE 存在則為真。
          [ -b FILE ] 如果 FILE 存在且是一個塊特殊文件則為真。
          [ -c FILE ] 如果 FILE 存在且是一個字特殊文件則為真。
          [ -d FILE ] 如果 FILE 存在且是一個目錄則為真。
          [ -e FILE ] 如果 FILE 存在則為真。
          [ -f FILE ] 如果 FILE 存在且是一個普通文件則為真。
          [ -g FILE ] 如果 FILE 存在且已經(jīng)設(shè)置了SGID則為真。
          [ -h FILE ] 如果 FILE 存在且是一個符號連接則為真。
          [ -k FILE ] 如果 FILE 存在且已經(jīng)設(shè)置了粘制位則為真。
          [ -p FILE ] 如果 FILE 存在且是一個名字管道(F如果O)則為真。
          [ -r FILE ] 如果 FILE 存在且是可讀的則為真。
          [ -s FILE ] 如果 FILE 存在且大小不為0則為真。
          [ -t FD ] 如果文件描述符 FD 打開且指向一個終端則為真。
          [ -u FILE ] 如果 FILE 存在且設(shè)置了SUID (set user ID)則為真。
          [ -w FILE ] 如果 FILE 如果 FILE 存在且是可寫的則為真。
          [ -x FILE ] 如果 FILE 存在且是可執(zhí)行的則為真。
          [ -O FILE ] 如果 FILE 存在且屬有效用戶ID則為真。
          [ -G FILE ] 如果 FILE 存在且屬有效用戶組則為真。
          [ -L FILE ] 如果 FILE 存在且是一個符號連接則為真。
          [ -N FILE ] 如果 FILE 存在 and has been mod如果ied since it was last read則為真。
          [ -S FILE ] 如果 FILE 存在且是一個套接字則為真。
          [ FILE1 -nt FILE2 ] 如果 FILE1 has been changed more recently than FILE2, or 如果 FILE1FILE2 does not則為真。 exists and
          [ FILE1 -ot FILE2 ] 如果 FILE1 比 FILE2 要老, 或者 FILE2 存在且 FILE1 不存在則為真。
          [ FILE1 -ef FILE2 ] 如果 FILE1 和 FILE2 指向相同的設(shè)備和節(jié)點(diǎn)號則為真。
          [ -o OPTIONNAME ] 如果 shell選項(xiàng) “OPTIONNAME” 開啟則為真。
          [ -z STRING ] “STRING” 的長度為零則為真。
          [ -n STRING ] or [ STRING ] “STRING” 的長度為非零 non-zero則為真。
          [ STRING1 == STRING2 ] 如果2個字符串相同。 “=” may be used instead of “==” for strict POSIX compliance則為真。
          [ STRING1 != STRING2 ] 如果字符串不相等則為真。
          [ STRING1 < STRING2 ] 如果 “STRING1” sorts before “STRING2” lexicographically in the current locale則為真。
          [ STRING1 > STRING2 ] 如果 “STRING1” sorts after “STRING2” lexicographically in the current locale則為真。
          [ ARG1 OP ARG2 ] “OP” is one of -eq, -ne, -lt, -le, -gt or -ge. These arithmetic binary operators return true if “ARG1” is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to “ARG2”, respectively. “ARG1” and “ARG2” are integers.

          posted @ 2011-09-27 16:23 xsong 閱讀(1310) | 評論 (0)編輯 收藏

          2011年9月23日

               摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//源代碼class TT{       static int tt = 5;&nb...  閱讀全文

          posted @ 2011-09-23 13:55 xsong 閱讀(344) | 評論 (0)編輯 收藏

          2011年9月16日

          #include <stdio.h>

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

              
          /**
               * sizeof  關(guān)鍵字
               
          */
              
          int i=0;
              printf(
          "sizeof int %lu \n",sizeof(i)); // 4

              
          int *p=NULL;
              printf(
          "sizeof point %lu \n" ,sizeof(p) )    ; // 8
              printf("sizeof *p %lu \n",sizeof *p); // 4

              
          int a[100];
              printf(
          "sizeof array %lu \n"sizeof(a));// 100*4
              printf("sizeof a[100] %lu \n",sizeof(a[100])); // 4
              printf("sizeof &a %lu \n"sizeof(&a)); // 8  &a 是指針

              
          return 0;
          }

          posted @ 2011-09-16 15:04 xsong 閱讀(230) | 評論 (0)編輯 收藏

          2011年8月5日

          #include <stdio.h>
          #include 
          <stdlib.h>
          #include 
          <event.h>
          #include 
          <evhttp.h>

          void generic_request_handler(struct evhttp_request *req, void *arg) {

              
          struct evbuffer *return_buffer=evbuffer_new();

              evbuffer_add_printf(return_buffer,
          "welcome");
              evhttp_send_reply(req,HTTP_OK,
          "Client",return_buffer    );
              evbuffer_free(return_buffer);
          }

          int main(int argc, char **argv) {
              
          short http_port =8082;
              
          char *http_addr="127.0.0.1";
              
          struct evhttp *http_serv=NULL;
              event_init();

              http_serv
          = evhttp_start(http_addr,http_port);
              evhttp_set_gencb(http_serv,generic_request_handler,NULL);
              event_dispatch();
              
          return 0;
          }

          posted @ 2011-08-05 14:51 xsong 閱讀(1355) | 評論 (0)編輯 收藏

          2011年8月1日

          enum Action {Start, Stop, Rewind, Forward};

          // Special type of class 
          enum Status {
            Flunk(
          50), Pass(70), Excel(90);
            
          private final int value;
            Status(
          int value) { this.value = value; }
            
          public int value() { return value; } 
          };

          Action a 
          = Action.Stop;
          if (a != Action.Start)
            System.out.println(a);               
          // Prints "Stop"

          Status s 
          = Status.Pass;
          System.out.println(s.value());      
          // Prints "70"

          posted @ 2011-08-01 16:20 xsong 閱讀(220) | 評論 (0)編輯 收藏

          2011年7月4日

          posted @ 2011-07-04 15:44 xsong 閱讀(299) | 評論 (0)編輯 收藏

          2011年6月11日

          安裝  編輯 ~/.vimrc

          syntax on
          set tabstop=4
          set softtabstop=4
          set shiftwidth=4
          set autoindent
          set cindent
          set nu

          if &term=="xterm"
            set t_Co=8
            set t_Sb=^[[4%dm
            set t_Sf=^[[3%dm
          endif

          let g:neocomplcache_enable_at_startup = 1 


          "括號補(bǔ)全功能,

          :inoremap ( ()<ESC>i
                  :inoremap ) <c-r>=ClosePair(')')<CR>
          :inoremap { {}<ESC>i
              :inoremap } <c-r>=ClosePair('}')<CR>
              :inoremap [ []<ESC>i
              :inoremap ] <c-r>=ClosePair(']')<CR>
              :inoremap < <><ESC>i
              :inoremap > <c-r>=ClosePair('>')<CR>

              function ClosePair(char)
              if getline('.')[col('.') - 1] == a:char
              return "\<Right>"
              else
              return a:char
              endif
              endf

          posted @ 2011-06-11 12:58 xsong 閱讀(741) | 評論 (0)編輯 收藏

          2011年5月30日

              c 提供了 atoi atof 等函數(shù)實(shí)現(xiàn)了字符串轉(zhuǎn)化數(shù)值的函數(shù)。使用方法簡單。
          但是如果轉(zhuǎn)化 "123ss"等字符串里包含非數(shù)值的字符串時,則會自動轉(zhuǎn)化為 123,不會拋出異常。
          想要驗(yàn)證 字符串是否是數(shù)值格式  可使用
          strtol (__const char *__restrict __nptr, char **__restrict __endptr, int __base)
           nptr指向的字符串, 
          strtol()函數(shù)檢測到第一個非法字符時,立即停止檢測,其后的所有字符都會被當(dāng)作非法字符處理。合法字符串會被轉(zhuǎn)換為long int, 作為函數(shù)的返回值。非法字符串,即從第一個非法字符的地址,被賦給*endptr**endptr是個雙重指針,即指針的指針。strtol()函數(shù)就是通過它改變*endptr的值,即把第一個非法字符的地址傳給endptr。

              char *str1="1231",*endptr1;
              
          char *str2="123sss",*endptr2;

              printf(
          "atoi str2 is %i\n",atoi(str1));
              
          int i,j;//atoi(str);
              i=strtol(str1,&endptr1,10);
              
          if(*endptr1!=NULL){
                  printf(
          "endptr1 is %s\n",endptr1);
              }
              printf(
          "str1 auto int %i\n",i);
              j
          =strtol(str2,&endptr2,10);
              
          if(*endptr2!=NULL){
                  printf(
          "endptr2 is %s\n",endptr2);
              }
              printf(
          "str2 auto long int %i\n",j);

          posted @ 2011-05-30 15:13 xsong 閱讀(596) | 評論 (0)編輯 收藏

          2011年5月26日

          系統(tǒng)中的瀏覽器都是由在/usr/bin中的與瀏覽器同名的腳本文件啟動的.你可以對其進(jìn)行編輯加入環(huán)境變量進(jìn)行連接庫文件進(jìn)行預(yù)載.對firefox瀏覽器,用sudo權(quán)限編輯/usr/bin/firefox,將
          export LD_PRELOAD=/usr/lib/libc/memcpy-preload.so(不行就改為export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libc/memcpy-preload.so)加入文件的第一行就可以了

          posted @ 2011-05-26 13:37 xsong 閱讀(481) | 評論 (0)編輯 收藏

          2011年5月18日

          /*
           ============================================================================
           Name        : test.c
           Author      : xsong
           Version     :
           Copyright   : Your copyright notice
           Description : Hello World in C, Ansi-style
           ============================================================================
           
          */

          #include 
          <stdio.h>
          #include 
          <stdlib.h>
          #include
          <string.h>

          int main(void) {

              
          char buffer[] = "buffer example";
              
          //  memset 填充字符串
              printf("buffer size %i \n"sizeof(buffer));
              printf(
          "before memsetd -> %s \n", buffer);
              
          int mpoint = memset(buffer, '*'sizeof(buffer));
              printf(
          "memset return point -> %i \n", mpoint);
              printf(
          "after memsetd -> %s \n", buffer);
              
          //strlen 取得字符串長度
              int buffer_length = strlen(buffer);
              printf(
          "buffer size -> %i \n", buffer_length);
              
          //字符串連接
              char d[10= "foo";
              
          char s[10= "bar";
              strcat(d, s);
              printf(
          "%s %s\n", d, s);

              
          //字符串分割
              char str[] = "root:x::0:root:/root:/bin/bash:";
              
          char *token;
              token 
          = strtok(str, ":");

              
          do {
                  printf(
          "%s \n", token);
              } 
          while ((token = strtok(NULL, ":")) != NULL);

              
          return EXIT_SUCCESS;
          }

          posted @ 2011-05-18 15:38 xsong 閱讀(267) | 評論 (0)編輯 收藏

          僅列出標(biāo)題  下一頁
          主站蜘蛛池模板: 兴城市| 长治市| 龙胜| 怀柔区| 利津县| 靖西县| 沈丘县| 瑞昌市| 罗甸县| 鄂温| 广饶县| 达孜县| 卢龙县| 文昌市| 岳阳市| 台江县| 易门县| 布尔津县| 五台县| 冕宁县| 兴宁市| 万安县| 黄浦区| 微博| 察雅县| 伊川县| 广灵县| 钦州市| 凤城市| 商南县| 宜阳县| 华亭县| 绿春县| 牡丹江市| 海南省| 湾仔区| 淳安县| 龙里县| 乐都县| 贵德县| 福贡县|