易截截图软件、单文件、免安装、纯绿色、仅160KB

在linux下 获取,修改网关GateWay的两个函数

//获去GateWay
QString GetGateWay()
{
FILE *fp;
char buf[512];
char cmd[128];
char gateway[30];
char *tmp;
strcpy(cmd, "ip route");
fp = popen(cmd, "r");
if(NULL == fp)
{
perror("popen error");
return "";
}
while(fgets(buf, sizeof(buf), fp) != NULL)
{
tmp =buf;
while(*tmp && isspace(*tmp))
++ tmp;
if(strncmp(tmp, "default", strlen("default")) == 0)
break;
}
sscanf(buf, "%*s%*s%s", gateway);
printf("default gateway:%s\n", gateway);
pclose(fp);

return QString(gateway);
}
//设置网关
int SetGateWay(const char *szGateWay)
{
int ret = 0;
char cmd[128];
QString DefGW = GetGateWay();
const char *strGW = DefGW.latin1();

strcpy(cmd, "route del default gw ");
strcat(cmd, strGW);
ret = system(cmd);
if(ret < 0)
{
perror("route error");
return -1;
}
strcpy(cmd, "route add default gw ");
strcat(cmd, szGateWay);

ret = system(cmd);
if(ret < 0)
{
perror("route error");
return -1;
}
return ret;
}


相关文档:

实战Linux Bluetooth编程(六) L2CAP编程实例

例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
 如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......

实战Linux Bluetooth编程 (七) SDP协议

Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......

下载linux系统到开发板

利用dnw及串口终端下载安装linux到开发板时,要先设成Nor Flash 启动,步骤如下:
1) 对Nand Flash进行分区
2) 安装bootloader
3) 安装内核文件
4) 安装文件系统
下载完毕要先拔下usb接线,若不取下来有可能导致在系统复位时,电脑会死机。 ......

[linux] vim编码

Vim和所有的流行文本编辑器一样,可以很好的编辑各种字符编码的文件,这当然包括 UCS-2、UTF-8 等流行的 Unicode 编码方式。而且和很多来自 Linux 世界的软件一样,这需要你自己动手设置。
Vim 有四个跟字符编码方式有关的选项,encoding 、fileencoding 、fileencodings 、termencoding (这些选项可能的取值请参考 Vim 在 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号