📄 af.c
字号:
/* af.c * linqianghe@163.com * 2006-10-20 */#include "net-support.h"#include <stdio.h>#include <string.h>static short sVafinit = 0;extern struct aftype unspec_aftype;extern struct aftype myinet_aftype;struct aftype *aftypes[] ={ &myinet_aftype, &unspec_aftype, NULL};void afinit(){ unspec_aftype.title = "UNSPEC"; myinet_aftype.title = "DARPA Internet"; sVafinit = 1;}struct aftype *get_afntype(int af){ struct aftype **afp; if( !sVafinit ) afinit(); afp = aftypes; while( *afp != NULL ){ if( (*afp)->af == af ) return (*afp); afp++; } return ( NULL );}int get_socket_for_af(int af){ struct aftype **afp; if (!sVafinit) afinit(); afp = aftypes; while( *afp != NULL ){ if ((*afp)->af == af) return (*afp)->fd; afp++; } return -1;}void print_aflist(int type) { int count = 0; char * txt; struct aftype **afp; if (!sVafinit) afinit(); afp = aftypes; while( *afp != NULL ){ if( (type == 1 && ((*afp)->rprint == NULL)) || ((*afp)->af == 0) ){ afp++; continue; } if( (count % 3) == 0 ) fprintf(stderr,count?"\n ":" "); txt = (*afp)->name; if (!txt) txt = ".."; fprintf(stderr,"%s (%s) ",txt,(*afp)->title); count++; afp++; } fprintf(stderr,"\n");}struct aftype *get_aftype(const char *name){ struct aftype **afp; if (!sVafinit) afinit(); afp = aftypes; while (*afp != NULL) { if( !strcmp((*afp)->name, name) ) return (*afp); afp++; } if (index(name, ',')) fprintf(stderr, "Please don't supply more than one address family.\n"); return (NULL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -