2013年8月31日星期六

Ubutun install qemu software problems

 This post last edited by the qhmilanista on 2012-03-01 00:56:58
I downloaded one to qh @ qh-VirtualBox: ~ / Downloads $ qemu.tar.gz package
then qh @ qh-VirtualBox: ~ / Downloads $ tar-zxvf qemu.tar.gz
appear qemu-1.0.1 folder
then continue into the conduct configure:

qh @ qh-VirtualBox: ~ / download / qemu-1.0.1 $. / configure

Error: zlib check failed
Make sure to have the zlib libs and headers installed.

why it went wrong ah, the solution should be how to install?
------ Solution ---------------------------------------- ----
sudo apt-get install libglib2.0-dev, that's it!
------ Solution ---------------------------------------- ----
apt-get the easy way
apt-get install qemu qemu-kvm
------ For reference only --------------------- ------------------
installed zlib ah ..
------ For reference only ------------ ---------------------------


I have zlib installed, and then make or wrong eh

qh @ qh-VirtualBox: ~ / download / qemu-1.0.1 $. / configure
glib-2.0 required to compile QEMU
qh @ qh-VirtualBox: ~ / download / qemu-1.0.1 $ make
Please call configure before running make!
make: *** [config-host.mak] Error 1



is also download glib-2.0 Why? Thank
------ For reference only ------------------------------------- -
no master Well
------ For reference only ------------------------------ ---------

see. / configure the result of what is missing pretend to have been a re-make
------ For reference only ----- ----------------------------------
Why not go to the Software Center installed it?
------ For reference only -------------------------------------- -
the same problem, try can live without
------ For reference only ------------------------- --------------
short answer:

sudo apt-get install zlib1g
sudo apt-get install libglib2.0-dev


Comments:
[Resolved] Ubuntu install QEMU in the configuration error: ERROR: zlib check failed

[Resolved] Ubuntu configure QEMU error: ERROR: glib-2.12 required to compile QEMU


emacs installed yasnippet failed

 This post last edited by the kingyaying on 2013-03-27 21:16:28
I yasnippet-bundle.el into ~ / .emacs.d / plugins and then add the file ~ /. emacs

contents inside :

(add-to-list 'load-path
"~ / .emacs.d / plugins")
(require 'yasnippet-bundle)

then restart emacs, emacs window mode , but no increase in yasnippet menus, command line inside there, how to come out of window mode menu it ?
------ Solution -------------------------------------- ------
not using emacs, command line, start the line

CentOS5.5 yum install test problems

I var / www / html folder below built a test.html file , enter the address in your browser : http://127.0.0.1/test.html error , the error is as follows:
Forbidden
You don't have permission to acces / test.html on this server.
Apache/2.2.3 (CentOS) Server at 127.0.0.1 Port 80.

help, how to solve the country
------ Solution ------------------------------- -------------
test.html permissions are ?
------ For reference only -------------------------------------- -
problem solved. Thank

phpmyadmin prompt mcrypt extension is missing, check the phpconfiguration

phpmyadmin prompt mcrypt extension is missing, check the php configuration, in the Google search found that this command can be solved
yum install php-mcrypt libmcrypt libmcrypt-devel
discovered after I entered this three packages are not found
no package php-mcrypt available.
no package libmcrypt available.
no package libmcrypt-devel available.

tried to manually install on the network, the result is still a lot of problems if the installation was successful indeed, I'm not sure.
but still prompted to open phpmyadmin mcrypt extension is missing, check the php configuration
Why not humane point ah, installed software so so very tedious ah ~ what is the solution? Please expert help, thank you. ~
------ Solution --------------------------------------- -----
package Yes ah, another 163 sources try
------ For reference only -------------------- -------------------

ask how to do? I was first learning to use linux, I chose centos, how to do to modify the source into a 163? It would be great if you can somehow.
------ For reference only -------------------------------------- -

ask how to do? I was first learning to use linux, I chose centos, how to do to modify the source into a 163? It would be great if you can somehow.  

reference to this:
http://tel.mirrors.163.com/.help/centos.html
------ For reference only ---------------- -----------------------

ask how to do? I was first learning to use linux, I chose centos, how to do to modify the source into a 163? It would be great if you can somehow.    
  
  
reference to this:   
http://tel.mirrors.163.com/.help/centos.html  


, although not able to solve the problem, if there is no source 163 which several extensions Oh, but now I solved the problem, or to thank you. Points to you friends / ~

linux socket buffer full of how to do ?

Let embedded device and PC communication using UDP , Ethernet transmit data quickly , the receiver sends the processing speed can not keep up the speed , how to handle it ?

have tried to socket buffer space is set to the maximum allowed space for drop in the bucket compared to the amount of data , the result is behind the data packets are discarded.

Has anyone encountered this problem, pointing twelve , thank you.
------ Solution ---------------------------------------- ----
1, the sender do not send too fast ;
2, when the receiver receives only receives , there can be a buf, buf open thread to handle the data .
------ Solution ---------------------------------------- ----
sender uses reactor mode, you need to send the data stored in the buffer , socket when you do actually sent writable
receiving end of the business separate thread and IO thread
------ Solution --------------------------- -----------------
packet size not larger than the MTU, but also not too small . However, these seem related stuff does not matter.

1 can not be there to receive information over time to open up a new thread to handle these messages

2 over UDP , based on the channel mode should be added , when all the information received , send a letter back to the sender to send data again
( QQ news is that now looks like this mechanism )
3 allows the sender wait for a while after each send one ( like quite a waste ! )

currently thought these
------ For reference only ------------------------------ ---------
no solution, transfer multimedia ? UDP no flow control, can only proceed from the business improvement . Multimedia on degraded
------ For reference only --------------------------------- ------
UDT directly on it. . . UDP develop their own reliable transport is not necessary that the human toll .
------ For reference only -------------------------------------- -
Thank you for your enthusiastic response , knot posted

# About the program and how to find the pathcontains problems encountered

Recently came into contact with linux, because in the program to use msleep (), so adding a header file . But the program can not find this header file, then google to find an article about the program is how to find the header file of the article. http://blog.sina.com.cn/s/blog_4d3a41f40101dq82.html Then I re-engineering configuration wrote this sentence-I / usr/src/kernels/2.6.18-194.el5-x86_64/include This is my ; the directory, I use rhel5. But in the compiler that there is a
/ usr/src/kernels/2.6.18-194.el5-x86_64/include/linux/hardirq.h: 55:2: error: # error PREEMPT_ACTIVE is too low!
/ usr/src/kernels/2.6.18-194.el5-x86_64/include/linux/bitops.h: In function 'int get_bitmask_order (unsigned int)':
/ usr/src/kernels/2.6.18-194.el5-x86_64/include/linux/bitops.h: 15: error: 'fls' was not declared in this scope
other issues (not enumerate many problems). Why is there such a problem? When everyone in the included encountered such a problem?
------ Solution ---------------------------------------- ----
This is compile the application?
linux system calls and libraries are not defined msleep it c
compile the application using the kernel header files, error is inevitable
recommend using usleep or their own definition of a msleep
------ Solution ---------------------------- ----------------
others perhaps have been re-compile the kernel module or defined msleep a
------ For reference only ------ ---------------------------------
Well, I later switched usleep, multiplied by the default parameters 1000. So do not pack the kernel header files, and also is correct. But still wonder why the kernel header files can not use it? I look at the procedures are this package, and then use the inside of msleep, ah!

ordinary user privileges in ubuntu problem

Recently installed a virtual machine , ubuntu12.04, many ring true ah. Now there is a small problem is not resolved , to say we look . Do almost everything needs root privileges , ordinary users can not create a file , you can not create a folder , you can not delete files, see the cross compiler tool chain ( confirm installation ) . . . . More to go , these things must be the root authority to complete , who gave support a move it
------ Solution ----------------- ---------------------------
to ordinary users sudo privileges
------ For reference only --- ------------------------------------
just ask people figured out sudo chown username ~ / *-R
username change your user name , the perfect solution

Unix and Mac to view memory usage, disk usage , TCP, UPD and othersystem information file directory

We know that , following the Linux / proc / save the system runs the following kinds of information . Such as memory , disk , CPU, network links , and so forth .

Now my question is whether there is Unix, and Mac like / proc / folder exists , please god guide, brother grateful .
------ Solution ---------------------------------------- ----
not matter, is generated by the kernel for administrators tuning kernel parameters , do not actually exist
------ Solution ------------ --------------------------------

the same way,
http://fanqiang.chinaunix.net/a1/b5/20010512/10571821.html
Do not forget , linux but unix- oh

mac 's :
http://osxbook.com/book/bonus/ancient/procfs/
------ For reference only ------------------ ---------------------
I mean is that no matter how produced , as long as Unix, Mac there something like that can be read, I the problem is solved , it can give me an answer . Because there is no contact with fruit Unix and Mac
------ For reference only ------------------------------- --------

Yes
------ For reference only --------------------- ------------------
I asked , Mac and Unix like / proc / directory , what is it ? Find Answers
------ For reference only ---------------------------------------
Thank you to answer , Unix is almost no change . But Mac above , according to your link given fact slightly trouble. Estimated that this is no way to do it. That fraction choose to give you problems . But I do not know how to give points it ~ ! !

------ For reference only ---------------------------------- -----

have a " knot paste" button

linux C programming, how to use so file

/ Usr/lib/libfreeimage.so.3
/ usr / lib / libfreeimage.a
/ usr/lib/libfreeimage-3.15.4.so
/ usr / lib / libfreeimage.so
As shown above, a variety of so files in these folders, but the problem is this when compiling gcc freeimage.c-lfreeimage -I/usr/include /-o freeimage, appeared One problem is that error while loading shared libraries: libfreeimage.so.3: cannot open shared object file: No such file or directory, obviously already connected to / usr / lib / folder, but it still will not
------ Solution ----------------------------- ---------------
ls-la / usr / lib / libfreeimage *
results posted to look
------ Solution ------------------------------- -------------
export LD_LIBRARY_PATH = / usr / lib: $ (LD_LIBRARY_PATH)
------ For reference only --------- ------------------------------
-rwxr-xr-x 1 root root 3679528 Aug 12 10:22 / usr/lib/libfreeimage-3.15.4.so
-rw-r - r - 1 root root 6765130 Aug 12 10:22 / usr / lib / libfreeimage.a
lrwxrwxrwx 1 root root 17 Aug 12 10:22 / usr / lib / libfreeimage.so -> libfreeimage.so. 3
lrwxrwxrwx 1 root root 22 Aug 12 10:22 / usr/lib/libfreeimage.so.3 -> libfreeimage- 3.15.4.so
------ For reference only --------------------------------- ------
gcc freeimage.c-lfreeimage -I/usr/include /-o freeimage -L/usr/lib
------ For reference only ---------------------------------------

usr/lib/libfreeimage.a  //静态库
/usr/lib/libfreeimage-3.15.4.so  //动态库
/usr/lib/libfreeimage.so

编译的时候 -L 选项 引导库 然后跟上路径就好了

- ---- For reference only ---------------------------------------
4 Can building specific points, as the third floor, I have tried, or not. Compiler is passed, but when running problem.
------ For reference only -------------------------------------- -
I meant to say, before the compile time can pass, that is the problem at run time, not later compiled successfully, to the point, please, ladies and Great God
------ For reference only ---------------------------------------
really can, powerful, Thank you, grateful, but is not very clear reason, this is the environment variable bar, so write the future is not long-term.
------ For reference only -------------------------------------- -
say is on the 7th floor master
------ For reference only --------------------------- ------------

not a long-term, only on the current environment, the LD_LIBRARY_PATH written in the boot script, or modify the configuration files under the dynamic library
online search under linux dynamic library link path, a lot of information

Q: linux under ping lost 100% could not find a reason for worry!

se1012 @ ubuntu: ~ / Desktop / ping $. / myping www.sina.com
PING www.sina.com (202.108.33.60): 56 bytes of data.

------------------- PING statistics ----------------
3 packets transmitted, 0 received, 100% lost, time 0 ms
rtt min / avg / max / mdev = 0.000/-nan/0.000/-nan ms


less likely to use Linux with gdb looked at

(gdb) set args www.sina.com
(gdb) b 129
Breakpoint 1 at 0x8048b10: file ping.c, line 129.
(gdb) r
Starting program: / home/se1012/Desktop/ping/myping www.sina.com
PING www.sina.com (202.108.33.60): 56 bytes of data.
s

Breakpoint 1, recv_packet () at ping.c: 133
133 fromlen = sizeof (from);
(gdb) s
134 signal (SIGALRM, statistics);
(gdb) s
136 while (nreceived (gdb) s
138 alarm (MAX_WAIT_TIME);
(gdb) s
141 if ((n = recvfrom (sockfd, recvpacket, sizeof (recvpacket), 0, (struct sockaddr *) & ; from, & fromlen)) <0)
(gdb) s

------------------- PING statistics ----------------
3 packets transmitted, 0 received, 100% lost, time 0 ms
rtt min / avg / max / mdev = 0.000/-nan/0.000/-nan ms
[Inferior 1 (process 14069) exited with code 01]
warning: Error removing breakpoint 0
warning: Error removing breakpoint 0
warning: Error removing breakpoint 0

at the time of exit of the recvfrom do not know why but also exit1
online with other people's code than the ratio seems to be no difference ah

my code:

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netdb.h>
#include <setjmp.h>
#include <errno.h>

#define PACKET_SIZE 4096
#define MAX_WAIT_TIME 5
#define MAX_NO_PACKETS 3

char sendpacket[PACKET_SIZE];
char recvpacket[PACKET_SIZE];
int sockfd,datalen = 56;
int nsend = 0, nreceived = 0; //发送、接收包的数量
double temp_rtt[MAX_NO_PACKETS]; //记录每组收发包的往返时间
double all_time = 0,min = 0,max = 0,avg = 0,mdev = 0;

struct sockaddr_in dest_addr;
struct sockaddr_in from;
struct timeval tvrecv;
pid_t pid; //表示进程id

void statistics(int signo);
void send_packet(void);
void recv_packet(void);
void computer_rtt(void);
void tv_sub(struct timeval *out,struct timeval *in);
int pack(int pack_no);
int unpack(char *buf,int len);
unsigned short cal_chksum(unsigned short *addr, int len);

void computer_rtt() //计算rtt最小、大值,平均值,平均差
{
    double sum_avg = 0;
    int i;
    min = max = temp_rtt[0];
    avg = all_time/nreceived; //平均值
    for(i=0; i<nreceived; i++){
        if(temp_rtt[i] < min) //最小值
            min = temp_rtt[i];
        else if(temp_rtt[i] > max) //最大值
            max = temp_rtt[i];
        if((temp_rtt[i]-avg) < 0)
            sum_avg += avg - temp_rtt[i];
        else
            sum_avg += temp_rtt[i] - avg;
        }
    mdev = sum_avg/nreceived; //平均差
}

void statistics(int signo) //统计数据函数
{
    computer_rtt();
    printf("\n-------------------PING statistics----------------\n");
    printf("%d packets transmitted,%d received,%d%% lost,time %.f ms\n",nsend,nreceived,(nsend-nreceived)/nsend*100,all_time);
    printf("rtt min/avg/max/mdev = %.3f/%.3f/%.3f/%.3f ms\n",min,avg,max,mdev);
    close(sockfd);
    exit(1);
}

unsigned short cal_chksum(unsigned short *addr,int len) //检验和算法
{
    int nleft = len; //ICMP头的长度
    int sum = 0;
    unsigned short *w=addr; //指向ICMP头的指针
    unsigned short answer=0;
    while(nleft>1) //把ICMP报头二进制数据以2字节为单位累加起来
    {
        sum += *w++;
        nleft -= 2;
    }
/*若ICMP报头为奇数个字节,把最后一个字节视为一个2字节数据的高字节,这个2字节数据的低字节为0,继续累加*/
    if(nleft == 1)
    {
        *(unsigned char *)(&answer) = *(unsigned char *)w;
        sum += answer;
    }
    sum = (sum >> 16) + (sum & 0xFFFF); //把sum的高16位和低16位相加
    sum += (sum >> 16); //把进位的值也加到校验和上
    answer = ~sum;   //取反得到校验和
    return answer;
}

int pack(int pack_no) //设置ICMP报头
{
    int i,packsize;
    struct icmp *icmp;
    //struct timeval *tval;
    icmp = (struct icmp*)sendpacket; //将sendpacket强制转换成ICMP格式
    icmp->icmp_type = ICMP_ECHO; //ICMP_ECHO类型的类型号为0
    icmp->icmp_code = 0;
    icmp->icmp_cksum = 0;
    icmp->icmp_seq = pack_no; //ICMP报文的发送顺序
    icmp->icmp_id = pid;
    packsize = 8 + datalen;     //数据报大小为64字节
    //tval = (struct timeval *)icmp->icmp_data;
    //gettimeofday(tval,NULL); //记录发送时间
//校验算法
    icmp->icmp_cksum =  cal_chksum((unsigned short *)icmp,packsize);
    return packsize;
}

//发送3个ICMP报文
void send_packet()
{
    int packetsize;
    while(nsend < MAX_NO_PACKETS)////while or if?/////
    {
        nsend++;
        packetsize = pack(nsend); //设置ICMP报头
        //发送数据报
/*int sendto ( socket s , const void * msg, int len, unsigned int flags, const struct sockaddr * to , int tolen ) ;*/
        if(sendto(sockfd,sendpacket,packetsize,0,(struct sockaddr *)&dest_addr,sizeof(dest_addr)) < 0)
        {
            perror("sendto error");
    continue;
        }
    sleep(1); //每隔一秒发送一个ICMP报文
    }
}

void recv_packet() //接受所有ICMP报文
{
    int n,fromlen;
    extern int error;
    fromlen = sizeof(from);
    signal(SIGALRM,statistics);

    while(nreceived < nsend)
    {
alarm(MAX_WAIT_TIME);
        //接收数据报
/*int recvfrom( SOCKET s, char FAR* buf, int len, int flags,struct sockaddr FAR* from, int FAR* fromlen);*/
        if((n = recvfrom(sockfd,recvpacket,sizeof(recvpacket),0,(struct sockaddr *)&from,&fromlen)) < 0)
{
            perror("recvfrom error");
    continue;
}
        gettimeofday(&tvrecv,NULL);     //记录接收时间
if(unpack(recvpacket,n)==-1) //剥去ICMP报头
{
    printf("unpack() is wrong\n");
    continue;
}
nreceived++;
    }
}

int unpack(char *buf,int len) //剥去ICMP报头
{
    int i,iphdrlen; //ip头长度
    struct ip *ip;
    struct icmp *icmp;
    struct timeval *tvsend;
    double rtt; //计算往返时延

    ip = (struct ip *)buf;
/*求IP报文头长度(ip_hl标识IP头部长度以4字节为单位),即IP报头长度乘4*/
    iphdrlen = ip->ip_hl << 2;
    icmp = (struct icmp *)(buf + iphdrlen); //越过IP头,指向ICMP报头
    len -= iphdrlen;    //ICMP报头及ICMP数据报的总长度
    if(len < 8)      //ICMP报文至少8个字节
    {
        printf("ICMP packet\'s length is less than 8\n");
        return -1;
    }
/*判断ICMP报文的类型是否为ICMP_ECHOREPLY并且为本进程的PID(确保所接收的是自己所发的ICMP的回应)*/
    if((icmp->icmp_type == ICMP_ECHOREPLY) && (icmp->icmp_id == pid))
    {
        tvsend = (struct timeval *)icmp->icmp_data; //发送时间
        tv_sub(&tvrecv,tvsend); //接收和发送的时间差
        //以毫秒为单位计算rtt
        rtt = tvrecv.tv_sec*1000 + tvrecv.tv_usec/1000;
        temp_rtt[nreceived] = rtt;
        all_time += rtt;    //总时间
        //显示相关的信息
/*char *inet_ntoa (struct in_addr); 将网络地址转换成"."点隔的字符串格式*/
        printf("%d bytes from %s: icmp_seq=%u ttl=%d time=%.1f ms\n",len,inet_ntoa(from.sin_addr),icmp->icmp_seq,ip->ip_ttl,rtt);
return 0;
    }
    else{
printf("ICMP packet is not ECHOREPLY or PID is not right\n");
return -1;
    }
}

//两个timeval相减
void tv_sub(struct timeval *recvtime,struct timeval *sendtime)
{
    long sec = recvtime->tv_sec - sendtime->tv_sec;
    long usec = recvtime->tv_usec - sendtime->tv_usec;
    if(usec >= 0){
        recvtime->tv_sec = sec;
        recvtime->tv_usec = usec;
    }else{ //接受时间usec小于发送时间usec
        recvtime->tv_sec = sec - 1;
        recvtime->tv_usec =1000000+usec;
    }
}

int main(int argc,char *argv[]) //主函数
{
    struct hostent *host=NULL; //host entry,记录主机信息
    struct protoent *protocol=NULL; //
    unsigned long inaddr = 0;
    int waittime = MAX_WAIT_TIME;
    int size = 50 * 1024;

//参数小于两个
    if(argc < 2)   
    {
        printf("usage:%s hostname/IP address\n",argv[0]);
        exit(1);
    }

//不是ICMP协议
/*struct protoent * getprotobyname( const char *name ); 返回对应于给定协议名的包含名字和协议号的protoent结构指针*/
    if((protocol = getprotobyname("icmp")) == NULL)
    {
perror("getprotobyname");
        exit(1);
    }

//生成使用ICMP的原始套接字,只有root才能生成
    if((sockfd = socket(AF_INET,SOCK_RAW,protocol->p_proto)) < 0)
    {
        perror("socket error");
        exit(1);
    }
    //回收root权限,设置当前用户权限
/*uid_t  getuid(void);返回一个调用程序的真实用户ID
int setuid(uid_t uid);设置实际用户ID和有效用户ID*/
    setuid(getuid());

/*扩大套接字的接收缓存区到50K,这样做是为了减小接收缓存区溢出的可能性,若无意中ping一个广播地址或多播地址,将会引来大量的应答.
int setsockopt(SOCKET s,int level,int optname,const char* optval,int optlen);*/
    setsockopt(sockfd,SOL_SOCKET,SO_RCVBUF,&size,sizeof(size));
//初始化dest_addr
/*void *memset(void *s, int ch, size_t n);将s中前n个字节 (typedef unsigned int size_t)用 ch 替换并返回 s */
    memset(&dest_addr,0,sizeof(dest_addr));
    dest_addr.sin_family = AF_INET; //设置协议家族类型为AF_INET

//判断第二个参数是否为主机名或IP地址
/*in_addr_t inet_addr(const char *cp); 将一个点分十进制的IP转换成一个长整数型.正确执行将返回一个无符号长整数型数。如果传入的字符串不是一个合法的IP地址,将返回INADDR_NONE*/
    if(inaddr=inet_addr(argv[1]) == INADDR_NONE) //不是合法IP地址
    {
/*通过DNS取得IP地址.gethostbyname()返回对应于给定主机名的包含主机名字和地址信息的hostent结构指针.若错误返回一个空指针*/
if((host = gethostbyname(argv[1])) == NULL) //不是合法主机名
{
            perror("gethostbyname error");
            exit(1);
}
/*void *memcpy(void *dest, const void *src, size_t n);从src所指的内存地址的起始位置开始拷贝n个字节到目标dest所指的内存地址的起始位置中*/
        memcpy((char *)&dest_addr.sin_addr,host->h_addr,host->h_length);
    }
    else{ //是IP地址
        dest_addr.sin_addr.s_addr = inaddr; /*or memcpy((char *)&dest_addr.sin_addr,argv[1],strlen(argv[1])+1);*/
    }

//获取main的进程id,用于设置ICMP的标志符
    pid = getpid();
    printf("PING %s(%s):%d bytes of data.\n",argv[1],inet_ntoa(dest_addr.sin_addr),datalen);
    send_packet(); /*发送所有ICMP报文*/
    recv_packet(); /*接收所有ICMP报文*/
    statistics(SIGALRM); /*进行统计*/
    return 0;
}

------ Solution ------------------------------------- -------
main function inside if (inaddr = inet_addr (argv [1]) == INADDR_NONE)
if ((inaddr = inet_addr (argv [1])) == INADDR_NONE)
------ Solution --------------- -----------------------------
virtual machine settings that must be the problem
------ For reference only ---------------------------------------
Manga. . .
it is mainly a problem here

void recv_packet() //接受所有ICMP报文
{
    int n,fromlen;
    extern int error;
    fromlen = sizeof(from);
    signal(SIGALRM,statistics);

    while(nreceived < nsend)
    {
    alarm(MAX_WAIT_TIME);
        //接收数据报
/*int recvfrom( SOCKET s, char FAR* buf, int len, int flags,struct sockaddr FAR* from, int FAR* fromlen);*/
        if((n = recvfrom(sockfd,recvpacket,sizeof(recvpacket),0,(struct sockaddr *)&from,&fromlen)) < 0)
    {
            perror("recvfrom error");
        continue;
    }
        gettimeofday(&tvrecv,NULL);     //记录接收时间
    if(unpack(recvpacket,n)==-1) //剥去ICMP报头
    {
        printf("unpack() is wrong\n");
        continue;
    }
    nreceived++;
    }
}

------ For reference only ----------------------------------- ----
very grateful to point out my mistake but the results have not changed ah
I gdb trace is to recv_packet () in
if ((n = recvfrom (sockfd, recvpacket, sizeof (recvpacket), 0, (struct sockaddr *) & from, & fromlen)) <0)
when he withdrew not know why ah

(gdb) s
141 if ((n = recvfrom (sockfd, recvpacket, sizeof (recvpacket), 0, (struct sockaddr *) & ; from, & fromlen)) <0)
(gdb) s

------------------- PING statistics ----------------
3 packets transmitted, 0 received, 100% lost, time 0 ms
rtt min / avg / max / mdev = 0.000/-nan/0.000/-nan ms
[Inferior 1 (process 14069) exited with code 01]
warning: Error removing breakpoint 0
warning: Error removing breakpoint 0
warning: Error removing breakpoint 0

------ For reference only ---------------------------------- -----
your code line that changed the result of error, I tried it is possible ah.
ping about the system you are using, and then try to switch the root user
#. / testping www.sina.com
PING www.sina.com (61.172.201.194): 56 bytes of data.
64 bytes from 61.172.201.194: icmp_seq = 1 ttl = 244 time = 1465899937.0 ms
64 bytes from 61.172.201.194: icmp_seq = 2 ttl = 244 time = 1465899937.0 ms
64 bytes from 61.172.201.194: icmp_seq = 3 ttl = 244 time = 1465899937.0 ms

------------------- PING statistics ----------------
3 packets transmitted, 3 received, 0% lost, time 4397699811 ms
rtt min / avg / max / mdev = 1465899937.000/1465899937.000/1465899937.000/0.000 ms
------ For reference only ----------- ----------------------------
Well I system will not ping. . . I have a linux virtual machine network with a NAT Why not ping ah. . .

se1012 @ ubuntu: ~ / Desktop / ping $ ping www.sina.com.cn
PING polaris.sina.com.cn (202.108.33.60) 56 (84) bytes of data.
^ C
--- polaris.sina.com.cn ping statistics ---
13 packets transmitted, 0 received, 100% packet loss, time 12084ms



------ For reference only ---------------------------------- -----
yes. . . I Baidu half did not solve
DNS on the external network can also resolve the ping is not coming back
I set IP addresses and NAT gateways and VMnet8 are matched to solve ah depressed dead


------ For reference only ---------------------------------- -----
use bridges to try

pxe-e32: tftp open timeout

pxe server is rhel
which dhcp and tftp services are turned on, disable set to no, the firewall is also turned off
why the client get the ip newspaper, reported this wrong?

[root @ localhost ~] # cd / tftpboot
[root @ localhost tftpboot] # tree
.
| - boot.msg
| - filesystem.squashfs
| - home
| `- partimag
| - initrd.img
| - pxelinux.0
| - pxelinux.cfg
| `- default
`- vmlinuz

3 directories, 6 files
[root @ localhost tftpboot] #
------ Solution ---------------------------- ----------------
http://hi.baidu.com/% B3% E5% BD% F8% BB% A5% C1% AA% CD% F8 / blog/item/27b799de71457550cdbf1aeb.html
------ For reference only --------------------------- ------------

I have read this post, not a cable problem, where the estimate is not configured
because the other machine, and I set up a network boot, but also in post-card to get ip tftp here. . .
------ For reference only -------------------------------------- -
It has a rhel related configuration examples, see the steps where you need to check is not consistent
http://sina.fqdaili.com/baidu.com.php ? u = d9e30512054e90a0aaOi8vcGJyYXVuLm5ldGhlbmNlLmNvbS9kb2MvbmV0L3B4ZS5odG1s & b = 15
------ For reference only -------------------------- -------------
3 floor, I am here to open the link. . .

pxe-e32: tftp open timeout
someone else has solved this problem, Results posted!
------ For reference only -------------------------------------- -
landlord really, resolved to share, a statement posted on the bin
------ For reference only -------------------- -------------------
http://bbs.chinaunix.net/thread-3620659-1-1.html

landlord to resolve the post here, but I have not solved.

The use of embedded gdb

1, pc client to use gdb, embedded board using gdbserver, because the board procedures used SIGALARM, second gdbserver will be interrupted, ask gdbserver how to shield this interrupt that does not affect the normal debugging?
2, how to program embedded in the pc side set a breakpoint? pc-gdb need to load the embedded-source? Or executable programs?

3, in addition to a little puzzled, embedded arm end use gdbserver at compile time did not involve platform options (arm9, arm11, arm cortex A8, etc.), gdbserver (or gdb) is How to obtain its register? Different platforms which registers should be different ah. . .
------ Solution ---------------------------------------- ----
first question seems to be in the gdb command line:
handle SIGALARM nostop noprint
try.
------ Solution --------------------------------- -----------
2 executable file containing debug information, or disassemble seemingly only see the information (as can tune, I have not tried)
- ----- Solution --------------------------------------------
gdb not understand, nor how multithreaded used.
Recommend quote posts so people can be notified to the post (in csdn notification icon), like me now. might be able to more effectively help you solve :).
someone else worry about the little deliberate Huitie own, but missed. Anyway csdn such a "quote = notice" I was not really know the logic: P

Consult / summon greatly:





------ For reference only ---------------------------------- -----
Upstairs two, thank you, you are good




Upstairs two, thank you, you are good
------ For reference only ---------------------------------------
While debuging a remote ; multithread program by means of gdb / gdbserver, frequently I see gdb complaints like this:

Program received signal SIG32, Real-time event 32.
0x400d7e84 in?? ()
(gdb)

Then gdb is suspended to wait for new commands, and on this occasion, typing 'c' can make the debuging continue . But instruction 'info threads' can not list correct information.

In fact, this results from stripped libpthread / libthread_db, which can be easily verified by means of '/ usr / bin / file'. ; To remove the problem, simply refer the libs to unstripped versions via gdb instructions like:

set solib-absolute-prefix [dir]

set solib-search-path [dir1]; [dir2]

As indicated above, my program is multi-threaded, when you start debugging the issue on appeal; Some say the Internet directly
handle SIG32 nostop noprint pass can be solved, but wanted to know why there is this SIG32, E text description above said strriped library problems, do not understand, you have to know < br> ------ For reference only ---------------------------------------
set solib-absolute-prefix Why gdb to set the shared library? Is the gdb settings or settings for gdbserver?

closed under linux mysql service problems

I'm in linux, mysql want to close the service , however , refused to shut down now found because of permission issues
mysqladmin: shutdown failed; error access denied you need the shutdown privilege for this operation
Oh I ask how to solve ?
------ Solution ---------------------------------------- ----
su - root
------ Solution --------------------------- -----------------
sudo service mysqld stop can also
------ Solution ----------- ---------------------------------
mysqladmin shutdown-uroot-p

PJSIP under ubuntu questions Unable to find default audio device(PJMEDIA_EAUD_NODEFDEV) [stat

Executive ./pjsua-i686-pc-linux-gnu
- id sip: 100@49.140.166.71 - registrar sip: 49.140.166.71 - realm = * - username 100 - password 100 - local -port 5076 - null-audio
can operate normally registered calls, and so failed to establish sound transmission when.
execution ./pjsua-i686-pc-linux-gnu
- id sip: 100@49.140.166.71 - registrar sip: 49.140.166.71 - realm = * - username 100 - password 100 - local -port 5076
call display: pjsua_media.c Error retrieving default audio device parameters: Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV) [status = 420006]
We encountered similar problems do? Seeking help Thank
------ Solution ----------------------------------- ---------
fix the problem?
------ Solution ---------------------------------------- ----
I have encountered this problem. Who knows how it please tell me what 23909475@163.com

Thx
------ Solution ----------------------------------- ---------
What would you solve the problem? Seek solutions!
------ Solution ---------------------------------------- ----
plug in your headphones to try, to voice headset
------ Solution ------------------------ --------------------
Hello, I have encountered such problems, seek solutions! penglin913@yahoo.cn grateful! ! !
------ Solution ---------------------------------------- ----
talkback microphone should be missing it.
------ For reference only -------------------------------------- -
Their first top down!
------ For reference only -------------------------------------- -
Solution :: New Terminal, install libasound.so.2, which sound card driver related.
# sudo get-apt install libasound-dev
in the library or other software installation process, you may need a lot of dependent files in Ubuntu via sudo get-apt install XXX to install; via sudo get-apt remove XXX to unload, It is more commonly used two commands.
------ For reference only -------------------------------------- -
Thank you for your support knot paste it solved now tell everyone I'm sorry forgot Austrian
------ For reference only ------------- --------------------------
how to get, and I have a sound card driver or not ah!
------ For reference only -------------------------------------- -
plus QQ: 2252494672

libpthread.a linux multithreading library

Recent threads in apue learning has been prompted to pthread_create is undefined references , online search a bit , to at compile time to join -lpthread. But this is still undefined after tried . I use the latest version of ubuntu, to / usr / lib looked down , unable to find libpthread.a this library . Could also do not own ? ? ? If not , then I can not find where to go online to download.
help ah , , online, etc. ~ ~ ~ ~ ~ ~ ~ ~ ~
------ Solution ------------------- -------------------------
in / usr / lib / down to be a link to try
------ For reference only --------------------------------------- < br> search for the next, my machine is having this dynamic library .

/ usr/lib/i386-linux-gnu/xen/libpthread.a
/ usr/lib/i386-linux-gnu/libpthread.a

------ For reference only ---------------------------------- -----

been resolved, thank you , online answer is gcc-lpthread < filename >
gcc on my machine to use gcc < filename >-lpthread

Compile linux-2.6.30.3 problem

In ubuntu13 compiled linux problems
 CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  SYMLINK include/asm -> include/asm-x86
  CALL    scripts/checksyscalls.sh
  CHK     include/linux/compile.h
  AS      arch/x86/kernel/entry_64.o
/tmp/cc3AKMAB.s: Assembler messages:
/tmp/cc3AKMAB.s: Error: .size expression for do_hypervisor_callback does not evaluate to a constant
make[1]: *** [arch/x86/kernel/entry_64.o] Error 1
make: *** [arch/x86/kernel] Error 2

just getting started with linux, solve ah. . .
------ Solution ---------------------------------------- ----
follow the tutorial above should be no problem out , I am also a novice, Bangding
http://hi.baidu.com/690609237/item/381db1d600fe4fe055347f3a
------ Solution --------------------- -----------------------
next newest 3.10 or 3.9 to compile the kernel to try to see if there are any problems , I see you're using u13
------ For reference only ------------------------------------- -
32位loom installed 64-bit system , right ?
------ For reference only -------------------------------------- -

not ah now cpu support 64 a
------ For reference only -------------------- -------------------

is compiled so what ,
------ For reference only ---- -----------------------------------
get modified do_hypervisor_callback, do not know what reason , do not source which has an error. . .
------ For reference only -------------------------------------- -
how to modify the do_hypervisor_callback, encountered the same problem.
------ For reference only -------------------------------------- -
open entry_64.s file, find do_hypervisor_callback entrance. The entrance xen_do_hypervisor_callback to do_hypervisor_callback to compile.
I do not know why the source added xen_ head .

gcc ubuntu system problems during installation , do not havepermission to create . . .

Prompted during installation of gcc also install m4, configure and make seemingly have passed , is the last of that make install error that there is no authority to create m4, I ask how to solve ?
------ Solution ---------------------------------------- ----
is compiled with the root user do ?
------ Solution ---------------------------------------- ----
recommended to use apt-get install to install, otherwise very troublesome relationship ; remember plus sudo
------ For reference only ------------ ---------------------------
You can say that the details right, the first time with the system, and then install these days for a long time saying that the various compiler error . . . Those who do not understand you said . . . How to use apt-get install install ?
------ For reference only -------------------------------------- -
apt-get install ubuntu install software is a way , and Redhat's yum install almost truth ;

You have to ensure that your ubuntu can access, default gateway and DNS settings are correct ;

then run sudo apt-get install build-essential
------ For reference only ------------------- --------------------
er er, understand, thank you very much ~ ~ ~

buntu system codecs why the incorrect ? ? ?

root @ ubuntu :/ tmp # tar vxjf gmp-5.1.2.tar.bz2
tar (child): gmp-5.1.2.tar.bz2: can not open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
------ Solution ------------------- -------------------------
you this archive should do is hit the illustrated bz2 tar jcvf gmp-5.1. 2.tar.bz2 decompression can be
------ Solution ------------------------------ --------------
. bz2 suffix , you must first use bunzip2 first extract into gcc-4.5.1.tar, then tar extract
----- - For reference only ---------------------------------------
er er, I try, but before I can use that command to extract gcc-4.5.1.tar .. bz2, to it die, this is how the matter
------ For reference only --- ------------------------------------
but before extracting the files on the same suffix will file will not be damaged or something , because all I was downloading. . .
------ For reference only -------------------------------------- -

If you worry about damage to re-download the chant , but my impression is bz2 bunzip2 first fishes
------ For reference only ---------- -----------------------------
er er, well, thank

pthread_cond_signal frequent calls, will not miss thepthread_cond_wait signal

First, to clarify, recently made several posts, some marked wait Results posted, though have yet to find a better satisfactory answer, but can also be attached to the end, and today attempts Results posted, several times failed because CSDN out a bug, not knot, hope you forgive me, bug does not end immediately after the paste.

I intend to use a listener thread select the link, another thread to receive data, when a socket has data that can be received when pthread_cond_signal immediately notify the receiving thread receives.
I received about 15 frames per second h264 data, each frame of data size is 80K or so, the thread is certainly enough time to close, so frequent thread switching operation will affect the performance of it?

discovered some time after closing pthread_cond_signal not evoke threads pthread_cond_wait up (this time the thread has been harvested data idle), how could this happen?

multi-threaded to receive data from the client service program, generally designed to compare how good?
Thank you very much!
------ Solution ------------------------------- -------------
seemingly depends on your code implements.

pthread_cond_wait () is used to block the current thread to wait for another thread to use pthread_cond_signal () or pthread_cond_broadcast to wake it up. pthread_cond_wait () must pthread_mutex necessary use. pthread_cond_wait () function into a wait state will automatically release mutex. When the other threads through pthread_cond_signal () or pthread_cond_broadcast, to wake up the thread, so that pthread_cond_wait () through (return), the thread and automatically get the mutex.
pthread_cond_signal function is to send a signal to another state is a thread is blocked waiting to release it from the blocked state and continue execution. If no threads blocked in a wait state, pthread_cond_signal also successful return .
pthread_cond_signal generally do not use the "thundering herd phenomenon", he only gave up one thread to signal. If there are multiple threads are blocked waiting for the condition variable, then it is based on the waiting thread priority level to determine which thread receives the signal starts to proceed. If the thread priorities are the same, according to the length of time to wait to determine which thread gets the signal. But in any case a pthread_cond_signal call up letter once.
But pthread_cond_signal simultaneously on multiple processors may wake up multiple threads, when you only make one thread to handle a task, the other thread to be awakened needed to continue to wait, and regulatory requirements pthread_cond_signal least pthread_cond_wait wake a thread on, in fact, some implementations for simplicity on a single processor will wake up in multiple threads.
------ Solution ------------ --------------------------------
conditions are met not sleep, did not lose it such a said.
------ Solution -------------------------------------- ------
pthread_cond_wait () must pthread_mutex supporting the use of another, wait for the best conditions to use a while loop.
------ For reference only -------------------------------------- -
which I also understand,
------ For reference only ---------------------------- -----------


found the reason: If a thread that has been pthread_cond_signal higher CPU, idle, the thread will not process received a message?
------ For reference only -------------------------------------- -
thundering herd effect is not dealt with, have been resolved.
------ For reference only -------------------------------------- -
learning of pthread_cond_wait () passing through, looking for thundering herd

linux how to run as root terminal

With codeblocks to run c + + program, but when a login with the general user logins , the program must be run as root , do not want to log in at the same time root, with the general user login How codeblocks , directly compiled to run after the pop-up terminal is root privileges to run ?
------ Solution ---------------------------------------- ----
to perform file execute permission not add about what ?
------ Solution -------------------------------------- ------
setuid
http://blog.csdn.net/oo__yan/article/details/7076889
------ Solution ---------------------------------------- ----
su
or manually enter the sudo command .
------ For reference only -------------------------------------- -
codeblocks you can compile and link , and then open a terminal root privileges to run executable files
------ For reference only ------------ ---------------------------
there is no direct way to use codeblocks compile and run it, do not want to open another terminal
- ---- For reference only ---------------------------------------
not people know ? Seeking help
------ For reference only ------------------------------------ ---
I just want to use codeblocks compile and run the program , in order to debug , if you manually in a terminal with root can not be debugged seeking ways
------ For reference only ----- ----------------------------------
final solution yet ?

How centos linux server data backup ?

How centos linux server data backup ? Prevent data corruption or malicious attacks cause unrecoverable consequences.
------ Solution ---------------------------------------- ----
what type of data ?
If it is a backup hard drive, you can use raid technology .
If the backup a partition , you can regularly use the dd command.
If the database data , you can export the data.

2013年8月30日星期五

linux learning experience of vim / Cvim article

 

in linux next, vim is one of the most common editor on many linux distributions comes. I was CentOS 6.3.

 Vim

basically divided into three modes, namely, the general pattern, edit mode and command line mode, the role of these three models were summarized as follows:

 
      
  1. Normal mode: the default mode. Vim opens directly into the general pattern, in this mode, the operation can be performed are: move the cursor, copy, paste, delete.
  2.   
  3. Edit Mode: Edit the file contents will appear in the lower left of the interface INSERT message.
  4.   
  5. command line mode: find, read, preserve, replace characters, display line numbers, leaving vim, etc. operations.
  6.  
 

 

one: Vim under the common command:

 

j down k up l h left to right

 

: w (lowercase) to save the file

 

: wq (lowercase) to save and exit vim

 

: w filename Save the file name for the file name name

 

: ZZ (uppercase) Save the file and exit, the equivalent of: wq

 

: wq! (lowercase) owner of the file read-only file saved to force, if not for the file owner This operation can not be successfully

 

: q! exit without saving the file

 

copy (yank)
yy or Y ; copying the entire line where the cursor
y ^ Copy to cursor column header, not including the cursor position character
y $ ; copied to the cursor trekking tail, including cursor position character
yw ; copy a word, the cursor must be in the word's first
yG copied to the end of the file
y1G Copy to File First
nyy Copy the beginning of the line where the cursor n lines

 

paste
p (lowercase) pasted to the cursor after
P (uppercase) pasted to the cursor before
delete
x (lowercase) to delete a character before the cursor
X (uppercase) deleted after the cursor one character
dd (lowercase) cursor to delete the entire line
dw (lowercase) to delete a word at the cursor
dG ; to delete the entire line where the cursor to the end of file
dgg cursor to delete the entire line to the file first
D (uppercase) to delete end of the line that contains the character at the cursor
d0 Delete to beginning of the line, does not contain the character at the cursor

 

: n1, n2d edit mode, delete the line n1-n2

 

withdrawal

 

u ( lowercase) before saving unlimited withdrawal (about 500 times)

 

ctrl + r redo redo

 

Find

 

/ string is equivalent to find, from the cursor down to start at the beginning of the search string string
/ Find mode, press n (lowercase) Find Next, press N (uppercase) Find previous
? string from the cursor to start looking up at the beginning of the character from the string
? Find mode, press n (lowercase) Find the previous one, press N (uppercase) Find Next

 

: set nu (mber) Show Line Numbers

 

: n Move to the specified line n

 

multi-window function:

 

: r file reads file content, and inserted in the current line after

 

: new new column blank window

 

: split the current file in two columns show

 

in: help, met hyperlinks can press Ctrl +] Jump

 

in: help, press Ctrl + T to jump back

 

block selection : ctrl + v

 

 

two: Vim environment settings

 

in the directory / etc / below, there is a file called vimrc file, which is the system of public of vim configuration files are valid for all users. And in each user's home directory, you can build your own private configuration file is named: ". Vimrc"

 

 

 

open. vimrc, add the following statement to make syntax highlighting: syntax on

 

set auto indent : the value of each line with the previous line indent equal; using noautoindent unset:

 

set autoindent

 

set using C / C + + language, auto-indent mode: set cindent

 

filetype plugin on is the use of plug-ins statement

 

 

three: c-support.vim plugin

 

recommend c-support.vim this plug-in can be used to compile c / c + +, very good, oh! ~

 

c-support.vim Download

 

http://www.vim.org/scripts/script.php?script_id=213

 

installation is very simple

 

Copy the zip archive cvim.zip to $ HOME / .vim / (Linux / Unix) or $ HOME / vimfiles (Windows) and run unzip cvim.zip

 

installed in $ HOME / .vim /

 

can use the command $ HOME:

 

 

cd ~ /. vim
unzip cvim.zip

 

in / etc / vim / vimrc add filetype plugin on to use this plug-in.

 

 

its hotkey Description:

 

http://lug.fh-swf.de/vim/vim-c / c-hotkeys.pdf

 

\ if inserted into the general function

 

\ im into the main function

 

\ cfu insert function header, which function description

 

\ cfr insert a frame comment, can be used to write Variable Description

 

\ rc Save and compile

 

\ rr run

 

\ nr in ~ / .vim / c-support / codesnippets write some precompiled code or code block, through the use of this command

 

jQuery focus map switching effects plugin package

 

site map is a focus of the show form of web content can be simply understood as a picture or more exhibition now focus on the page is the site map. Obvious position on the site , combined with a picture in the form of play , similar to the focus of news meant just added a picture. More commonly used on the site or channel Home Forum Home Forum , because it is through the form of pictures , so there is a certain attraction , visual attractiveness . Easily lead the visitor clicks , according to foreign design agency survey, focus map site hits significantly higher than plain text, text captions conversion rate at five times . From this point on the map allows visitors to greatly enhance the enterprise 's first impression , here we give you about a project in a beautiful package uses atmospheric fullscreen focus map . As shown below :

 

can add multiple pictures, set the image links , navigation with the mouse to switch pictures, publish articles in the time to put a little picture compression distortion .

 

use this effect for jquery first need to introduce the use of plug-ins has been packaged into jquery function code is as follows :

 
  
/* 
* jQuery图片轮播(焦点图)插件
*/
(
function ($) {
$.fn.slideBox
= function (options) {
var defaults = {
direction:
'left',
duration:
0.6,
easing:
'swing',
delay:
3,
startIndex:
0,
hideClickBar:
true,
clickBarRadius:
5,
hideBottomBar:
false
};
var settings = $.extend(defaults, options || {});
var wrapper = $(this),
ul
= wrapper.children('ul.items'),
lis
= ul.find('li'),
firstPic
= lis.first().find('img');
var li_num = lis.size(),
li_height
= 0,
li_width
= 0;
var order_by = 'ASC';
var init = function () {
if (!wrapper.size()) return false;
li_height
= lis.first().height();
li_width
= lis.first().width();
wrapper.css({
width: li_width
+ 'px',
height: li_height
+ 'px'
});
lis.css({
width: li_width
+ 'px',
height: li_height
+ 'px'
});
if (settings.direction == 'left') {
ul.css(
'width', li_num * li_width + 'px')
}
else {
ul.css(
'height', li_num * li_height + 'px')
};
ul.find(
'li:eq(' + settings.startIndex + ')').addClass('active');
if (!settings.hideBottomBar) {
var tips = $('<div class="tips"></div>').css('opacity', 0.6).appendTo(wrapper);
var title = $('<div class="title"></div>').html(function () {
var active = ul.find('li.active').find('a'),
text
= active.attr('title'),
href
= active.attr('href');
return $('<a>').attr('href', href).text(text)
}).appendTo(tips);
var nums = $('<div class="nums"></div>').hide().appendTo(tips);
lis.each(
function (i, n) {
var a = $(n).find('a'),
text
= a.attr('title'),
href
= a.attr('href'),
css
= '';
i
== settings.startIndex && (css = 'active');
$(
'<a>').attr('href', href).text(text).addClass(css).css('borderRadius',
settings.clickBarRadius
+ 'px').mouseover(function () {
$(
this).addClass('active').siblings().removeClass('active');
ul.find(
'li:eq(' + $(this).index() + ')').addClass('active').siblings
().removeClass(
'active');
start();
stop()
}).appendTo(nums)
});
if (settings.hideClickBar) {
tips.hover(
function () {
nums.animate({
top:
'0px'
},
'fast')
},
function () {
nums.animate({
top: tips.height()
+ 'px'
},
'fast')
});
nums.show().delay(
2000).animate({
top: tips.height()
+ 'px'
},
'fast')
}
else {
nums.show()
}
};
lis.size()
> 1 && start()
};
var start = function () {
var active = ul.find('li.active'),
active_a
= active.find('a');
var index = active.index();
if (settings.direction == 'left') {
offset
= index * li_width * -1;
param
= {
'left': offset + 'px'
}
}
else {
offset
= index * li_height * -1;
param
= {
'top': offset + 'px'
}
};
wrapper.find(
'.nums').find('a:eq(' + index + ')').addClass('active').siblings().removeClass
(
'active');
wrapper.find(
'.title').find('a').attr('href', active_a.attr('href')).text(active_a.attr
(
'title'));
ul.stop().animate(param, settings.duration
* 1000, settings.easing,
function () {
active.removeClass(
'active');
if (order_by == 'ASC') {
if (active.next().size()) {
active.next().addClass(
'active')
}
else {
order_by
= 'DESC';
active.prev().addClass(
'active')
}
}
else if (order_by == 'DESC') {
if (active.prev().size()) {
active.prev().addClass(
'active')
}
else {
order_by
= 'ASC';
active.next().addClass(
'active')
}
}
});
wrapper.data(
'timeid', window.setTimeout(start, settings.delay * 1000))
};
var stop = function () {
window.clearTimeout(wrapper.data(
'timeid'))
};
wrapper.hover(
function () {
stop()
},
function () {
start()
});
var imgLoader = new Image();
imgLoader.onload
= function () {
imgLoader.onload
= null;
init()
};
imgLoader.src
= firstPic.attr('src')
}
})(jQuery);
 
 Below is a picture

focus map the css style ;

 
  
div.slideBox{ position:relative;height:300px; overflow:hidden; margin:0 auto;} 
div.slideBox ul.items{ position:absolute; float:left; background:none; list-style:none; padding:0px; margin:0px;}
div.slideBox ul.items li{ float:left; background:none; list-style:none; padding:0px; margin:0px;}
div.slideBox ul.items li a{ float:left; line-height:normal !important; padding:0px !important; border:none/*For IE.ADD.JENA.201206300844*/;}
div.slideBox ul.items li a img{ margin:0px !important; padding:0px !important; display:block; border:none/*For IE.ADD.JENA.201206300844*/;}
div.slideBox div.tips{ position:absolute; bottom:0px; width:100%; height:50px; background-color:#000; overflow:hidden;}
div.slideBox div.tips div.title{ position:absolute; left:0px; top:0px; }
div.slideBox div.tips div.title a{ color:#FFF; font-size:18px; line-height:50px; margin-left:10px; text-decoration:none;}
div.slideBox div.tips div.title a:hover{ text-decoration:underline !important;}
div.slideBox div.tips div.nums{ position:absolute; right:0px; top:0px; }
div.slideBox div.tips div.nums a{ display:inline-block; >float:left/*For IE.ADD.JENA.201206300844*/; width:20px; height:20px; background-color:#FFF; text-indent:-99999px; margin:15px 10px 0px 0px;}
div.slideBox div.tips div.nums a.active{ background-color:#093;}
 
 

page layout :

 
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/sliderbox.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$(".slideBox").slideBox();
})
</script>
</head>
<body>
<div class="slideBox" >
<ul class="items">
<li><a href="#" title="这里是测试标题一"><img src="/image/1.png" width="1000" height="300"></a></li>
<li><a href="#" title="这里是测试标题2"><img src="/image/2.png" width="1000" height="300"></a></li>
<li><a href="#" title="这里是测试标题3"><img src="/image/3.png" width="1000" height="300"></a></li>
<li><a href="#" title="这里是测试标题4"><img src="/image/4.png" width="1000" height="300"></a></li>
<li><a href="#" title="这里是测试标题5"><img src="/image/5.png" width="1000" height="300"></a></li>
</ul>
</div>
</body>
</html>
 
 

just with js in the page calling the $ ( selector ). slideBox (); effect as above can be achieved , but we can also sliebox ({}) inside the specified action , such as starting picture and direction .

 

This is used in the project some time ago a picture carousel plug-in can feel can be directly used .

 

SharePoint2007 using WebPart load UserControl

 

do SharePoint2010 development until recently turned to the 2007 development, I feel there is a lot of development time between the two places is not the same, I'm exposed to 2,007 development projects which use the Module to load Application Page, and in the Application Page wrote a lot of inside background code used to implement business logic, which is rarely used items UserControl and WebPart, that the use of a custom background webpart also Webpart many server controls. Developed over 2010 after seeing this development model suddenly dizzy, felt the development cycle should be relatively slow, or Microsoft in the 2010 version will not join virtual webpart it. Recent practice a little, want to borrow to develop model developed MOSS2010 MOSS2007, today introduce SharePoint2007 WebPart load UserControl. Article belong only to the entry-level, please gurus skipped. . .

 

SharePoint personally feel there should be as much as possible with UserControl to implement business logic, data presentation, and use WebPart to load these UserControl, then Application Page loaded WebPart, this is just my personal understanding.

 

Well into the topic, 2007 web part works there is no UserControl, but the web application project which can create UserControl, we can put web app engineering UserControl copy over. So you can build a good one simple framework.

 

 

I put the UserControl in ~ / _CONTROLTEMPLAGT / WPUserControls below, CONTROLTEMPLAGT folder is a specialized storage UserControl place, and WPUserControls folder is used to store the project specifically used UserControl.

 

WebPart engineering framework to build a good note after the Debug attribute modification works, the project deployed to the specified site below.

 

began to develop a simple UserControl, but in front of the UserControl ascx file should be added to the application of an assembly statement, or after deployment will be reported "Can not load type XXX" error, as shown below:

 

 

references to assemblies where the declaration is reflect or site root directory web.config file copy over SafeControl node.

 

If you want to use the UserControl SharePoint server controls need to quote

 
  
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" 
Assembly
="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 
 

copied UserControl need to modify the namespace command space I have here is: VeloxWebPart.Templates.CONTROLTEMPLATES.WPUserControls, ascx, ascx.cs and ascx.designer.cs namespace need to be modified.

 

UserControl created and set up, you need to bind to the usercontrol webpart, the binding code is as follows:

 
        
   
protected override void CreateChildControls() 
{
try
{
base.CreateChildControls();
//string strUrl = "~/webParts/WebUserControl1.ascx";
string strUrl = "~/_CONTROLTEMPLATES/WPUserControls/UCTopMenu.ascx";
Control control = this.Page.LoadControl(strUrl);
this.Controls.Add(control);
}
catch (Exception ex)
{
this.Controls.Add(new LiteralControl(ex.Message));
} }
  
   View Code  
 

then deploy the entire project will be added to the GAC dll, which added a page to create a webpart, you can see the effects.

 

course code inside a UserControl allows administrators to enter their own path, that the site administrator can customize the layout of the page. Here late supplement.

SubSonic3.0.0.4.1 source package and call Dll

 

=============================================== =================

 

Name: SubSonic
plugin version: 3.0.0.4.1
Last Update :2013-8-10
Officer ; net: http://www.subsonicproject.com/

 

BUG modified: Empty (AllEmpty)
Email: 1654937 # qq.com
study and discussion: SubSonic3.0 study group (327360708)
Related blog: http://www.cnblogs.com/EmptyFS/

 

=============================================== =================

 

release fixes the following issues:
1, Structs.tt template generation, there is no assignment to the PropertyName property caused by a null pointer exception (System.NullReferenceException Exception)
2, use SubSonic.Query. Select and SubSonic.Query.SqlQuery query, set the Top property, the resulting "unhandled InvalidOperationException exception (keyword 'TOP' Incorrect syntax near)" Bug
3, automatically generated table name plus the plural ( s) resulting "user code unhandled SqlException, object name 'xxxs' is invalid" exception
4, using SubSonic.Query.Select and SubSonic.Query.SqlQuery query, the field is tinyint column loss problem when the Bug Fix
5, queries and stored procedures for the SubSonic.Query.Select add more executive function (Return to Contents)

 

For use Json deserialization operations acquired entity updates, you can only modify the add can not be executed (edit) the operation, this operation changes the problem, I think very few people will use, so do not added to the code, if necessary, please visit my blog users against modifying it.

 


More about SubSonic3.0 information, please visit the blog: http://www.cnblogs.com/EmptyFS /

 

 

Download: http://files.cnblogs.com/EmptyFS/SubSonic3.0.0.4.1. rar

 

 

2013年8月29日星期四

ios study notes (two) of the Objective

 

two: Objective-C classes and inheritance, and protocols

 

already mentioned in the initialization of an object, where the first talking about variables.

 

2.1 Variables

 
      
  1. local variables (internal variables): local variables within the method as defined in the description, and its scope is limited to the method, the method used after leaving this variable is illegal.
  2.   
  3. global variables (external variables): its scope is the entire source code. Specifier extern. For example:

  4.  
 

extern int intX;

 If the same source file

global variables and local variables with the same name, in the scope of local variables, global variables do not work.

 

3. instance variables: In the instance variables defined in the class that can be used within each method.

 

4. static variables (static): it is a method similar to global variables defined within a scope of the current class for all objects. Save memory, a static variable in memory, shared by all objects can be updated, the updated, all object access the updated value.

 

5. auto: This is an automatic local variable declaration is a method of internal variables are declared, is the default setting, generally omit it.

 

For example: auto int intX with int intX equivalent.

 

6. const: immutable variables.

 

7. volatile: and const Instead, the variable's value will change.

 

2.2 @ property and @ synthesize

 

in the interface file (. h), use @ property to identify the attributes (instance variables); in the implementation file (. m), use the @ synthesize statement to identify the attributes of the system Set method for automatic generation methods (getter / setter).

 

declare property syntax is: @ property (parameter 1, parameter 2) type name;

 

where the parameters are divided into three categories: read-write properties: (readwrite / readonly) setter semantics: (assign / retain / copy) Atomicity: (atomicity / nonatomic)

 

meaning of each parameter is as follows:

 

readwrite: generate setter \ getter method.

 

readonly: only generate a simple getter, no setter.

 

assign: default type, setter method of direct assignment, without retain operation.

 

retain: setter method parameters release the old value, and then retain the new value.

 

copy: setter method Copy operation, and retain the same.

 

nonatomic: non-atomic access . Without this keyword, will self as a mutex, thus ensuring atomicity.

 

"." can only operate in the setters and getters.

 

For example: In the interface file: @ property int count;

 

equivalent to declare two ways:

 
  
   - (int)count;    
- (void)setCount:(int)newCount;
 
 

implementation file (. m) in: @ synthesize count;

 

equivalent to the implementation file (. m) to implement two methods - the default assign:

 
  
  - (int)count     {    
return count;
}
-(void)setCount:(int)newCount {
count
= newCount;
}
 
 

2.3 Exception Handling

 
      
  1. @ try: code that might throw an exception block uses.
  2.   
  3. @ catch: @ chunk used to capture errors thrown, you can use multiple @ catch block.
  4.   
  5. @ finish: either case a block of statements to be executed.
  6.   
  7. @ throw: their own throw an error.
  8.  
 

2.4 based framework class

 
      
  1. NSString: string type, font and size did not carry information, can not change the contents of a string NSString objects, but there can be many ways to generate another string consists of a string. If you want to change the string itself, need to use NSString subclass NSMutableString.
  2.   
  3. NSDate: represents the time and date.
  4.   
  5. NSNumber: contains a numeric value (including bool) objects. NSNumber itself is not a number, it is not used in arithmetic expressions.
  6.   
  7. NSData: sequence of bytes, and can not be modified. Would need to be modified to use NSData subclass NSMutableData. NSData is mainly used for downloading data from the Internet (to NSData object return data); the object stored in the file; reads file data (NSData object as a buffer zone will).
  8.   
  9. NSSet: unordered collection of different objects, immutable, can be added or deleted by calling the method to get a collection of new NSSet object. Its subclasses are NSMutableSet.
  10.   
  11. NSDictionary: its unordered collection of key-value pairs, keys are usually NSString, the value can be any one object, NSDictionary is a fixed length, it becomes firstborn class is NSMutableDictionary.
  12.   
  13. property list
  14.   
  15. NSObject: Each class is inherited from NSObject, which uses NSObject protocol that achieved with the NSCopying, NSMutableCopying and NSCoding agreements related methods, detailed analysis see 2.5.3 categories, part of the agreement with the 2.5.4 source NSObject.h.
  16.  
 

2.5 Inheritance and protocols

 

2.5.1object-c inherit the base

 
      
  1. object-c does not support multiple inheritance, only single inheritance, a class can have only one parent.
  2.   
  3. method overrides: If the subclass methods and a method of the parent class has the same method name, return type and parameter list, the new method overwrite the original method.
  4.   
  5. method overloading: class, you can create multiple methods, they have the same method name, but with different parameters and different definitions, the method is called by passing them different numbers and types of parameters to be used sleep which method. Necessarily the same method name; method parameter table must be different, including the number and types of parameters, in order to distinguish different method body; method's return type and modifiers may be the same or different.
  6.   
  7. self: a class with a class method calls another method is to use the self, on behalf of itself, the equivalent of this.
  8.   
  9. super: represents the parent class, you can access the parent class using the super class quilt hidden or overridden method.
  10.  
 

2.5.2 Access Control

 
      
  1. @ protected-Methods defined in the class and any subclasses can directly access the instance variables that follow.This is the default case. class and any subclass methods Such direct access to the variable, which is the default.
  2.   
  3. @ private-Methods defined in the class can directly access the instance variables that follow, but subclasses cannot. methods in this class can access such a variable, but not the methods defined subclasses direct access.
  4.   
  5. @ public-Methods defined in the class and any other classes or modules can di-rectly access the instance variables that follow. besides himself and subclass methods can also be used by other classes or methods in other modules accessed. Openness biggest, but best to avoid using this scope. Other classes should use getter / setter methods to access or set other class instance variables to ensure encapsulation.
  6.  
 

2.5.3 Category

 

types of effects: the expansion of existing classes, without affecting the original kind of situation, Object-C provides a category dynamic run-time distribution, add new methods for the class. Implementation of the class will be distributed to many different file or several different frameworks.

 

categories of characteristics: First: category Unlike subclasses can not define new instance variables. Second: the name conflict, or class methods in the same name with the existing methods. When a name conflict occurs when the class has a higher priority. For example:

 
  
@interface NSObject (NSCoderMethods) //表示类别的名称为NSCoderMethods,要扩展的对象为NSObject 
+ (NSInteger)version;
+ (void)setVersion:(NSInteger)aVersion;
- (Class)classForCoder;
- (id)replacementObjectForCoder:(NSCoder *)aCoder;
- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
@end
 
 

class standard syntax is as follows:

 
  
#import "类名.h" 
@interface 类名 (类别名)//新方法的声明
@end

#import "类名类别名.h"
@implementation 类名 (类别名) //新方法的实现
@end
 
 

 

2.5.4 Protocol

 

protocol functions similar to c + + abstract base class in multiple inheritance. Protocol is a list of multiple classes shared methods. Protocol methods listed in this class and no corresponding implementation, but by other classes to implement these methods. If a class to comply with an agreement, the class must implement all the methods of a particular protocol (except optional method).

 

defines a protocol requires the use of @ protocol directive, followed by the protocol name, and then some of the ways is to declare, before the command @ end statement of all methods are part of the agreement.

 

agreements can have a static function.

 

@ optional means that you can not choose method.

 

@ required vowed to implementation.

 

while using multiple protocols only need <> list multiple protocols within and with "." separated:

 

@ interface Car: NSObject .

 

following NSObject.h: Each class is inherited from NSObject, which uses NSObject protocol that achieved with NSCopying, NSMutableCopying NSCoding protocol and related methods.

 
  
/*  NSObject.h */   
#import <Foundation/NSObjCRuntime.h>
#import <Foundation/NSZone.h>

@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@class Protocol;

/*************** Basic protocols ***************/

@protocol NSObject //NSObject协议
//@protocol是声明协议的标志。后面的NSObject是协议的名称
//协议中的方法是每个采用者必须实现的方法,这里有19个方法
- (BOOL)isEqual:(id)object; // 用于对象比较
- (NSUInteger)hash;

- (Class)superclass;
- (Class)class;
- (id)self;
- (NSZone *)zone;

- (id)performSelector:(SEL)aSelector;
- (id)performSelector:(SEL)aSelector withObject:(id)object;
- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
/* 延迟调用参数提供的方法,参数所需参数用withObject传入(类似于ActionScript3.0中的setTimeout函数) delay单位:秒 */
- (BOOL)isProxy;

- (BOOL)isKindOfClass:(Class)aClass; /* 用于判断对象是不是参数提供的类型 */
- (BOOL)isMemberOfClass:(Class)aClass; /* 用于判断对象是不是参数提供的类型*/
- (BOOL)conformsToProtocol:(Protocol *)aProtocol; /* 用于判断对象是否遵守了参数提供的协议*/

- (BOOL)respondsToSelector:(SEL)aSelector; /* 用于判断对象是否拥有参数提供的方法*/

- (id)retain; //增加对象的计数器
- (oneway void)release; //减少对象的计数器
- (id)autorelease; //自动减少对象的计数器,但是以推迟的方式来实现
- (NSUInteger)retainCount; //返回一个对象当前的计数器

- (NSString *)description; //允许一个对象返回一个字符串来描述它的内容;这个常用于调试debugging

@end //表示结束

@protocol NSCopying //NSCopying协议
- (id)copyWithZone:(NSZone *)zone; //协议中的方法是每个采用者必须实现的方法,这里只有一个方法

@end //表示结束

@protocol NSMutableCopying//NSMutableCopying协议
- (id)mutableCopyWithZone:(NSZone *)zone;

@end //表示结束

@protocol NSCoding //NSCoding协议

- (void)encodeWithCoder:(NSCoder *)aCoder;

- (id)initWithCoder:(NSCoder *)aDecoder;

@end

/*********** Base class ***********/

@interface NSObject <NSObject> { //告诉编译器,NSObject正在遵守NSObject协议
Class isa;
}

+ (void)load;

+ (void)initialize;
- (id)init; //对象的属性初始化

+ (id)new;
+ (id)allocWithZone:(NSZone *)zone;
+ (id)alloc;
- (void)dealloc; //用于类来释放对象实例变量并释放动态内存

- (void)finalize AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;

- (id)copy;
- (id)mutableCopy;

+ (id)copyWithZone:(NSZone *)zone;
+ (id)mutableCopyWithZone:(NSZone *)zone;

+ (Class)superclass;
+ (Class)class;
+ (BOOL)instancesRespondToSelector:(SEL)aSelector;
+ (BOOL)conformsToProtocol:(Protocol *)protocol;
- (IMP)methodForSelector:(SEL)aSelector;
+ (IMP)instanceMethodForSelector:(SEL)aSelector;
- (void)doesNotRecognizeSelector:(SEL)aSelector;

- (id)forwardingTargetForSelector:(SEL)aSelector;
- (void)forwardInvocation:(NSInvocation *)anInvocation;
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;

+ (NSMethodSignature *)instanceMethodSignatureForSelector:(SEL)aSelector;

+ (NSString *)description;

+ (BOOL)isSubclassOfClass:(Class)aClass AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER;

+ (BOOL)resolveClassMethod:(SEL)sel AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+ (BOOL)resolveInstanceMethod:(SEL)sel AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;

@end

@interface NSObject (NSCoderMethods) //类别 见2.5.3

+ (NSInteger)version;
+ (void)setVersion:(NSInteger)aVersion;
- (Class)classForCoder;
- (id)replacementObjectForCoder:(NSCoder *)aCoder;
- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;

@end

#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
@interface NSObject (NSDeprecatedMethods)

+ (void)poseAsClass:(Class)aClass DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
#if __OBJC2__
UNAVAILABLE_ATTRIBUTE
#_endif
;

@end
#_endif


#if MAC_OS_X_VERSION_10_6 <= MAC_OS_X_VERSION_MAX_ALLOWED