2011年9月27日

[ -a FILE ] 如果 FILE 存在则为真。
[ -b FILE ] 如果 FILE 存在且是一个块特殊文件则为真。
[ -c FILE ] 如果 FILE 存在且是一个字特殊文件则为真。
[ -d FILE ] 如果 FILE 存在且是一个目录则为真。
[ -e FILE ] 如果 FILE 存在则为真。
[ -f FILE ] 如果 FILE 存在且是一个普通文件则为真。
[ -g FILE ] 如果 FILE 存在且已经设置了SGID则为真。
[ -h FILE ] 如果 FILE 存在且是一个符号连接则为真。
[ -k FILE ] 如果 FILE 存在且已经设置了粘制位则为真。
[ -p FILE ] 如果 FILE 存在且是一个名字管道(F如果O)则为真。
[ -r FILE ] 如果 FILE 存在且是可读的则为真。
[ -s FILE ] 如果 FILE 存在且大小不为0则为真。
[ -t FD ] 如果文件描述符 FD 打开且指向一个终端则为真。
[ -u FILE ] 如果 FILE 存在且设置了SUID (set user ID)则为真。
[ -w FILE ] 如果 FILE 如果 FILE 存在且是可写的则为真。
[ -x FILE ] 如果 FILE 存在且是可执行的则为真。
[ -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 指向相同的设备和节点号则为真。
[ -o OPTIONNAME ] 如果 shell选项 “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 阅读(1287) | 评论 (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 阅读(329) | 评论 (0)编辑 收藏

2011年9月16日

#include <stdio.h>

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

    
/**
     * sizeof  关键字
     
*/
    
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 阅读(206) | 评论 (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 阅读(1337) | 评论 (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 阅读(206) | 评论 (0)编辑 收藏

2011年7月4日

posted @ 2011-07-04 15:44 xsong 阅读(275) | 评论 (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 


"括号补全功能,

: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 阅读(721) | 评论 (0)编辑 收藏

2011年5月30日

    c 提供了 atoi atof 等函数实现了字符串转化数值的函数。使用方法简单。
但是如果转化 "123ss"等字符串里包含非数值的字符串时,则会自动转化为 123,不会抛出异常。
想要验证 字符串是否是数值格式  可使用
strtol (__const char *__restrict __nptr, char **__restrict __endptr, int __base)
 nptr指向的字符串, 
strtol()函数检测到第一个非法字符时,立即停止检测,其后的所有字符都会被当作非法字符处理。合法字符串会被转换为long int, 作为函数的返回值。非法字符串,即从第一个非法字符的地址,被赋给*endptr**endptr是个双重指针,即指针的指针。strtol()函数就是通过它改变*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 阅读(577) | 评论 (0)编辑 收藏

2011年5月26日

系统中的浏览器都是由在/usr/bin中的与浏览器同名的脚本文件启动的.你可以对其进行编辑加入环境变量进行连接库文件进行预载.对firefox浏览器,用sudo权限编辑/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 阅读(464) | 评论 (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 阅读(249) | 评论 (0)编辑 收藏

仅列出标题  下一页