⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1043.html

📁 著名的linux英雄站点的文档打包
💻 HTML
📖 第 1 页 / 共 4 页
字号:
#include   <br>
#include   <br>
<br>
void main(int argc,char **argv)  <br>
{  <br>
  fd_set readset;  <br>
  Gpm_Event event;  <br>
  Gpm_Connect conn;  <br>
<br>
  conn.eventMask   = ~0;  <br>
  conn.defaultMask = ~GPM_HARD;  <br>
  conn.maxMod      = 0;  <br>
  conn.minMod      = 0;  <br>
<br>
  if (Gpm_Open(&conn,0)==-1) {  <br>
    printf("Can not open mouse connection");  <br>
    exit(1);  <br>
  }  <br>
<br>
  while (1) {  <br>
<br>
    FD_ZERO(&readset);  <br>
    FD_SET(gpm_fd,&readset);  <br>
    select(gpm_fd+1,&readset,0,0,0);  <br>
<br>
    if (FD_ISSET(gpm_fd,&readset)) {  <br>
      if (Gpm_GetEvent(&event)&gt;0) {  <br>
        printf("mouse: event 0x%02X, at %2i %2i (delta %2i %2i),"  <br>
               "button %i, modifiers 0x%02X
",  <br>
               event.type,  <br>
               event.x,event.y,  <br>
               event.dx,event.dy,  <br>
               event.buttons,  <br>
               event.modifiers  <br>
              );  <br>
      }  <br>
    }  <br>
  }  <br>
<br>
  while (Gpm_Close());  <br>
<br>
}  <br>
<br>
编译 <br>
gcc -o gpm_mouse gpm_mouse.c -lgpm  <br>
检验结果 <br>
mouse: event 0x01, at 15  1 (delta -2 -1),button 0, modifiers 0x00  <br>
mouse: event 0x01, at 14  1 (delta -1  0),button 0, modifiers 0x00  <br>
mouse: event 0x01, at 13  1 (delta -1  0),button 0, modifiers 0x00  <br>
<br>
-------------------------------------------------------------------------------- <br>
<br>
资料结构 <br>
typedef struct Gpm_Connect {  <br>
  unsigned short eventMask, defaultMask;  <br>
  unsigned short minMod, maxMod;  <br>
  int pid;  <br>
  int vc;  <br>
}              Gpm_Connect;  <br>
enum Gpm_Etype {  <br>
  GPM_MOVE=1,  <br>
  GPM_DRAG=2,   /* exactly one of the bare ones is active at a time */  <br>
  GPM_DOWN=4,  <br>
  GPM_UP=  8,  <br>
<br>
  GPM_SINGLE=16,            /* at most one in three is set */  <br>
  GPM_DOUBLE=32,  <br>
  GPM_TRIPLE=64,            /* WARNING: I depend on the values */  <br>
<br>
  GPM_MFLAG=128,            /* motion during click? */  <br>
  GPM_HARD=256,             /* if set in the defaultMask, force an already  used event to pass over to another handler */  <br>
<br>
  GPM_ENTER=512,            /* enter event, user in Roi's */  <br>
  GPM_LEAVE=1024            /* leave event, used in Roi's */  <br>
};  <br>
<br>
typedef struct Gpm_Event {  <br>
  unsigned char buttons, modifiers;  /* try to be a multiple of 4 */  <br>
  unsigned short vc;  <br>
  short dx, dy, x, y;  <br>
  enum Gpm_Etype type;  <br>
  int clicks;  <br>
  enum Gpm_Margin margin;  <br>
}              Gpm_Event;  <br>
<br>
typedef int Gpm_Handler(Gpm_Event *event, void *clientdata);  <br>
<br>
函数宣告 <br>
int Gpm_Open(Gpm_Connect * CONN, int FLAGS);  <br>
int Gpm_Close(void);  <br>
int Gpm_GetEvent(Gpm_Event * EVENT);  <br>
int Gpm_Getc(FILE * fp);  <br>
#define    Gpm_Getchar() Gpm_Getc(stdin)  <br>
int Gpm_Wgetch();  <br>
#define Gpm_Getch() (Gpm_Wgetch(NULL))  <br>
int Gpm_Repeat (int millisecs);  <br>
int Gpm_DrawPointer (int X, int Y, int FD);  <br>
int GPM_DRAWPOINTER (Gpm_Event *EPTR;)  <br>
int Gpm_FitValuesM (int *X, int *Y, int MARGIN);  <br>
int Gpm_FitValues (X,Y);  <br>
Gpm_FitEvent (EPTR);  <br>
char *Gpm_GetLibVersion (int *where);  <br>
char *Gpm_GetServerVersion (int *where);  <br>
int Gpm_GetSnapshot (Gpm_Event *ePtr);  <br>
<br>
 Linux程式设计-20.getopt <br>
http://www.openchess.org/noitatsko/programming/ (2001-05-27 13:04:00) <br>
<br>
<br>
getopt在UNIX下的命令列程式特别好用,特别是在你有许多参数要加入时。一般来说,你可以透过「man 3 getopt」来获得其说明。  <br>
<br>
-------------------------------------------------------------------------------- <br>
<br>
int getopt(int argc, char * const argv[],const char *optstring);  <br>
extern char *optarg;  <br>
extern int optind, opterr, optopt;  <br>
<br>
-------------------------------------------------------------------------------- <br>
<br>
例:这个例是从manpage抄出来的,蛮不清处的。我会再找时间写一系列例。  <br>
#include   <br>
<br>
       int  <br>
       main (argc, argv)  <br>
            int argc;  <br>
            char **argv;  <br>
       {  <br>
         int c;  <br>
         int digit_optind = 0;  <br>
<br>
         while (1)  <br>
           {  <br>
             int this_option_optind = optind ? optind : 1;  <br>
             int option_index = 0;  <br>
             static struct option long_options[] =  <br>
             {  <br>
               {"add", 1, 0, 0},  <br>
               {"append", 0, 0, 0},  <br>
               {"delete", 1, 0, 0},  <br>
               {"verbose", 0, 0, 0},  <br>
               {"create", 1, 0, 'c'},  <br>
               {"file", 1, 0, 0},  <br>
               {0, 0, 0, 0}  <br>
             };  <br>
<br>
             c = getopt_long (argc, argv, "abc:d:012",  <br>
                        long_options, &option_index);  <br>
             if (c == -1)  <br>
            break;  <br>
<br>
             switch (c)  <br>
               {  <br>
               case 0:  <br>
                 printf ("option %s", long_options[option_index].name);  <br>
                 if (optarg)  <br>
                   printf (" with arg %s", optarg);  <br>
                 printf ("");  <br>
                 break;  <br>
<br>
               case '0':  <br>
               case '1':  <br>
               case '2':  <br>
                 if (digit_optind != 0 && digit_optind != this_option_optind)  <br>
                   printf ("digits occur in two different argv-elements.");  <br>
                 digit_optind = this_option_optind;  <br>
                 printf ("option %c", c);  <br>
                 break;  <br>
<br>
               case 'a':  <br>
                 printf ("option a");  <br>
                 break;  <br>
<br>
               case 'b':  <br>
                 printf ("option b");  <br>
                 break;  <br>
<br>
               case 'c':  <br>
                 printf ("option c with value `%s'", optarg);  <br>
                 break;  <br>
<br>
               case 'd':  <br>
                 printf ("option d with value `%s'", optarg);  <br>
                 break;  <br>
<br>
               case '?':  <br>
                 break;  <br>
<br>
               default:  <br>
                 printf ("?? getopt returned character code 0%o ??", c);  <br>
               }  <br>
           }  <br>
<br>
         if (optind &lt; argc)  <br>
           {  <br>
             printf ("non-option ARGV-elements: ");  <br>
             while (optind &lt; argc)  <br>
             printf ("%s ", argv[optind++]);  <br>
             printf ("");  <br>
           }  <br>
<br>
         exit (0);  <br>
       }  <br>
 <br>
 <br>
<br>
 <br>
 
</FONT><br>
                                      </TD>
                                    </TR>
                                <TR>
                                <TD colSpan=2><FONT 
                                class=middlefont></FONT><BR>
                                        <FONT 
                                class=normalfont>全文结束</FONT> </TD>
                                    </TR>
                                <TR>
                                <TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2 
                                height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
                        <TD vAlign=top width="20%" 
                      background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2> 
                          <DIV align=center> 
                            <table class=tableoutline cellspacing=1 cellpadding=4 
                        width="100%" align=center border=0>
                              <tr class=firstalt> 
                                <td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
                                <font class=normalfont><b>所有分类</b></font></td>
                              </tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td>    </tr>  </table></td></tr>                            </table>
                          </DIV></TD></TR>
                    <TR vAlign=top>
                        <TD width="80%"> 
                          <DIV align=center><BR>
                          </DIV>
                        </TD></TR></TBODY></TABLE></TD></TR>
                </TABLE></TD></TR>
          </TABLE>
      <TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee 
        border=0><TBODY>
        <TR>
          <TD width="50%">
              <P><FONT class=middlefont>版权所有 &copy; 2004 <A 
            href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
                违者必究. </FONT></P>
            </TD>
          <TD width="50%">
              <DIV align=right><FONT class=middlefont>Powered by: <A 
            href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
            </TD></TR></TBODY></TABLE>
      <CENTER></CENTER></TD></TR>
    </TABLE></CENTER></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -