本文整理汇总了C++中doSystem函数的典型用法代码示例。如果您正苦于以下问题:C++ doSystem函数的具体用法?C++ doSystem怎么用?C++ doSystem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了doSystem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: disconnect_ndis
int
disconnect_ndis(int devnum)
{
int valid_node, qmi_mode = 0;
char control_node[16] = {0};
// check wdm device
valid_node = find_modem_node("cdc-wdm", 0, 0, -1, NULL); // todo (need devnode for cdc-wdm)
if (valid_node >= 0) {
qmi_mode = 1;
sprintf(control_node, "cdc-wdm%d", valid_node);
}
else {
// check serial device
valid_node = get_modem_node("ttyUSB", devnum, NULL);
if (valid_node >= 0)
sprintf(control_node, "ttyUSB%d", valid_node);
}
if (strlen(control_node) > 0) {
if (!qmi_mode) {
int vid = 0, pid = 0;
get_modem_vid_pid(control_node, &vid, &pid);
if ( (vid == 0x1199 || vid == 0x0f3d) && (pid == 0x68a3 || pid == 0x68aa) )
return doSystem("/bin/comgt -d /dev/%s -s %s/ppp/3g/%s", control_node, MODEM_SCRIPTS_DIR, "Sierra_disconn.scr");
else
return doSystem("/bin/comgt -d /dev/%s -s %s/ppp/3g/%s", control_node, MODEM_SCRIPTS_DIR, "NDIS_disconn.scr");
}
else
return qmi_stop_network(control_node);
}
return 1;
}
示例2: safe_remove_usb_modem
void
safe_remove_usb_modem(void)
{
doSystem("killall %s %s", "-q", "usb_modeswitch");
doSystem("killall %s %s", "-q", "eject");
if (nvram_get_int("modem_type") == 3)
{
char* svcs[] = { "udhcpc", NULL };
if (pids(svcs[0]))
{
doSystem("killall %s %s", "-SIGUSR2", svcs[0]);
usleep(300000);
kill_services(svcs, 3, 1);
}
stop_wan_usbnet();
// unlink_modem_ndis();
}
else
{
char* svcs_ppp[] = { "pppd", NULL };
kill_services(svcs_ppp, 10, 1);
// unlink_modem_ras();
}
set_usb_modem_dev_wan(0, 0);
}
示例3: stop_modem_ndis
void
stop_modem_ndis(void)
{
int i, modem_devnum = 0;
char node_fname[64];
char ndis_ifname[16] = {0};
doSystem("killall %s %s", "-q", "usb_modeswitch");
doSystem("killall %s %s", "-q", "eject");
if (get_modem_ndis_ifname(ndis_ifname, &modem_devnum)) {
disconnect_ndis(modem_devnum);
if (is_interface_exist(ndis_ifname))
ifconfig(ndis_ifname, 0, "0.0.0.0", NULL);
}
for (i=0; i<MAX_USB_NODE; i++)
{
sprintf(node_fname, "%s/ttyUSB%d", MODEM_NODE_DIR, i);
unlink(node_fname);
sprintf(node_fname, "%s/cdc-wdm%d", MODEM_NODE_DIR, i);
unlink(node_fname);
sprintf(node_fname, "%s/weth%d", MODEM_NODE_DIR, i);
unlink(node_fname);
sprintf(node_fname, "%s/wwan%d", MODEM_NODE_DIR, i);
unlink(node_fname);
}
}
示例4: storageDiskPart
static void storageDiskPart(webs_t wp, char_t *path, char_t *query)
{
char_t *part1_vol, *part2_vol, *part3_vol;
int max_part = atoi(websGetVar(wp, T("max_part"), T("")));
FILE *fp = NULL;
char part[30];
if (NULL == (fp = fopen("/proc/mounts", "r")))
{
perror(__FUNCTION__);
return;
}
while(EOF != fscanf(fp, "%s %*s %*s %*s %*s %*s\n", part))
{
if (NULL != strstr(part, "/dev/sd") || NULL != strstr(part, "/dev/mmc"))
doSystem("umount -l %s", part);
}
fclose(fp);
part1_vol = websGetVar(wp, T("part1_vol"), T(""));
part2_vol = websGetVar(wp, T("part2_vol"), T(""));
part3_vol = websGetVar(wp, T("part3_vol"), T(""));
doSystem("storage.sh reparted %s %s %s %d",
part1_vol, part2_vol, part3_vol, max_part);
sleep(50);
memset(part, 0, 30);
do {
sprintf(part, "/dev/sda%d", max_part+4);
FormatPart(part, "");
sleep(5);
} while (max_part--);
doSystem("storage.sh restart");
sleep(5);
websRedirect(wp, "usb/STORAGEdisk_admin.asp");
}
示例5: webcamra
/* goform/webcamra */
static void webcamra(webs_t wp, char_t *path, char_t *query)
{
char_t *enable, *resolution, *fps, *port;
// fetch from web input
enable = websGetVar(wp, T("enabled"), T(""));
resolution = websGetVar(wp, T("resolution"), T(""));
fps = websGetVar(wp, T("fps"), T(""));
port = websGetVar(wp, T("port"), T(""));
// set to nvram
nvram_bufset(RT2860_NVRAM, "WebCamEnabled", enable);
nvram_bufset(RT2860_NVRAM, "WebCamResolution", resolution);
nvram_bufset(RT2860_NVRAM, "WebCamFPS", fps);
nvram_bufset(RT2860_NVRAM, "WebCamPort", port);
nvram_commit(RT2860_NVRAM);
// setup device
doSystem("killall uvc_stream");
if (0 == strcmp(enable, "1"))
{
doSystem("uvc_stream -r %s -f %s -p %s -b",
resolution, fps, port);
}
// debug print
websHeader(wp);
websWrite(wp, T("<h2>Web Camera Settings</h2><br>\n"));
websWrite(wp, T("enabled: %s<br>\n"), enable);
websWrite(wp, T("resolution: %s<br>\n"), resolution);
websWrite(wp, T("fps: %s<br>\n"), fps);
websWrite(wp, T("port: %s<br>\n"), port);
websFooter(wp);
websDone(wp, 200);
}
示例6: storageAdm
/* goform/storageAdm */
static void storageAdm(webs_t wp, char_t *path, char_t *query)
{
char_t *submit;
submit = websGetVar(wp, T("hiddenButton"), T(""));
if (0 == strcmp(submit, "delete"))
{
char_t *user_select;
char feild[20];
feild[0] = '\0';
user_select = websGetVar(wp, T("storage_user_select"), T(""));
sprintf(feild, "User%s", user_select);
nvram_bufset(RT2860_NVRAM, feild, "");
doSystem("rm -rf \"%s/home/%s\"", first_part, nvram_bufget(RT2860_NVRAM, feild));
sprintf(feild, "User%sPasswd", user_select);
nvram_bufset(RT2860_NVRAM, feild, "");
sprintf(feild, "FtpUser%s", user_select);
nvram_bufset(RT2860_NVRAM, feild, "");
sprintf(feild, "SmbUser%s", user_select);
nvram_bufset(RT2860_NVRAM, feild, "");
nvram_commit(RT2860_NVRAM);
doSystem("storage.sh admin");
}
else if (0 == strcmp(submit, "apply"))
{
initUSB();
}
websRedirect(wp, "usb/STORAGEuser_admin.asp");
}
示例7: iTunesSrv
static void iTunesSrv(webs_t wp, char_t *path, char_t *query)
{
char_t *enable, *dir_path, *name;
// fetch from web input
enable = websGetVar(wp, T("enabled"), T("0"));
dir_path = websGetVar(wp, T("dir_path"), T(""));
name = websGetVar(wp, T("srv_name"), T(""));
// set to nvram
nvram_bufset(RT2860_NVRAM, "iTunesEnable", enable);
nvram_bufset(RT2860_NVRAM, "iTunesDir", dir_path);
nvram_bufset(RT2860_NVRAM, "iTunesSrvName", name);
nvram_commit(RT2860_NVRAM);
// setup device
doSystem("killall mt-daapd; killall mDNSResponder");
if (strcmp(enable, "1") == 0)
doSystem("config-iTunes.sh \"%s\" \"%s\" \"%s\"",
name,
nvram_bufget(RT2860_NVRAM, "Password"),
dir_path);
// debug print
websHeader(wp);
websWrite(wp, T("<h2>iTunes Server Settings</h2><br>\n"));
websWrite(wp, T("capability: %s<br>\n"), enable);
websWrite(wp, T("srv_name: %s<br>\n"), name);
websWrite(wp, T("media library: %s<br>\n"), dir_path);
websFooter(wp);
websDone(wp, 200);
}
示例8: openvpn_tunif_stop
static void
openvpn_tunif_stop(const char *ifname)
{
if (is_interface_exist(ifname)) {
doSystem("ifconfig %s %s", ifname, "down");
doSystem("%s %s --dev %s", OPENVPN_EXE, "--rmtun", ifname);
}
}
示例9: link_backup_run
void link_backup_run(int sign)
{
if(sign==1){
doSystem("start_linkbackup > /dev/console&");
}else{
doSystem("killall link_backup");
}
}
示例10: openvpn_tapif_start
static void
openvpn_tapif_start(const char *ifname, int insert_to_bridge)
{
if (!is_interface_exist(ifname))
doSystem("%s %s --dev %s", OPENVPN_EXE, "--mktun", ifname);
if (insert_to_bridge)
doSystem("brctl %s %s %s", "addif", IFNAME_BR, ifname);
doSystem("ifconfig %s %s %s", ifname, "0.0.0.0", "promisc up");
}
示例11: openvpn_tapif_stop
static void
openvpn_tapif_stop(const char *ifname)
{
if (is_interface_exist(ifname)) {
doSystem("ifconfig %s %s", ifname, "down");
doSystem("brctl %s %s %s 2>/dev/null", "delif", IFNAME_BR, ifname);
doSystem("%s %s --dev %s", OPENVPN_EXE, "--rmtun", ifname);
}
}
示例12: default_plc_write_to_flash
/*
* write default .nvm and .pib to flash
*/
int default_plc_write_to_flash(void)
{
FILE *fp;
int len, i;
char cmd[64], buf[64];
char mac[18], dak[48], nmk[48];
unsigned char emac[ETHER_ADDR_LEN], enmk[PLC_KEY_LEN];
doSystem("cp %s %s", DEFAULT_NVM_PATH, BOOT_NVM_PATH);
doSystem("cp %s %s", DEFAULT_PIB_PATH, BOOT_PIB_PATH);
// modify .pib
// MAC
if (!__getPLC_para(emac, OFFSET_PLC_MAC)) {
_dprintf("READ PLC MAC: Out of scope\n");
}
else {
if (emac[0] != 0xff) {
if (ether_etoa(emac, mac))
doSystem("/usr/local/bin/modpib %s -M %s", BOOT_PIB_PATH, mac);
// DAK
if (__getPLC_PWD(emac, buf)) {
sprintf(cmd, "/usr/local/bin/hpavkey -D %s", buf);
fp = popen(cmd, "r");
if (fp) {
len = fread(buf, 1, sizeof(buf), fp);
pclose(fp);
if (len > 1) {
buf[len - 1] = '\0';
for (i = 0; i < PLC_KEY_LEN; i++) {
if (i == 0)
sprintf(dak, "%c%c", buf[0], buf[1]);
else
sprintf(dak, "%s:%c%c", dak, buf[i*2], buf[i*2+1]);
}
doSystem("/usr/local/bin/modpib %s -D %s", BOOT_PIB_PATH, dak);
}
}
}
}
}
// NMK
if (!__getPLC_para(enmk, OFFSET_PLC_NMK))
_dprintf("READ PLC NMK: Out of scope\n");
else {
if (enmk[0] != 0xff && enmk[1] != 0xff && enmk[2] != 0xff) {
if (key_etoa(enmk, nmk))
doSystem("/usr/local/bin/modpib %s -N %s", BOOT_PIB_PATH, nmk);
}
}
return plc_write_to_flash(BOOT_NVM_PATH, BOOT_PIB_PATH);
}
示例13: openvpn_tapif_start
static void
openvpn_tapif_start(const char *ifname, int insert_to_bridge)
{
if (!is_interface_exist(ifname))
doSystem("%s %s --dev %s", OPENVPN_EXE, "--mktun", ifname);
if (insert_to_bridge)
br_add_del_if(IFNAME_BR, ifname, 1);
doSystem("ifconfig %s %s %s", ifname, "0.0.0.0", "promisc up");
set_vpn_balancing(ifname);
}
示例14: wan6_up
void wan6_up(char *wan_ifname)
{
int ipv6_type, start_radvd_now;
char *wan_addr6, *wan_gate6, *wan_addr4;
ipv6_type = get_ipv6_type();
if (ipv6_type == IPV6_DISABLED)
return;
stop_dhcp6c();
build_dns6_var();
control_if_ipv6_dad(IFNAME_BR, 1);
start_radvd_now = 1;
if (ipv6_type == IPV6_6IN4 || ipv6_type == IPV6_6TO4 || ipv6_type == IPV6_6RD)
{
wan_addr4 = nvram_safe_get("wan0_ipaddr");
wan_addr6 = nvram_safe_get("wan0_addr6");
start_sit_tunnel(ipv6_type, wan_addr4, wan_addr6);
}
else
{
control_if_ipv6_dad(wan_ifname, 1);
if (ipv6_type == IPV6_NATIVE_STATIC) {
wan_addr6 = nvram_safe_get("wan0_addr6");
wan_gate6 = nvram_safe_get("wan0_gate6");
control_if_ipv6_radv(wan_ifname, 0);
clear_if_addr6(wan_ifname);
if (*wan_addr6)
doSystem("ip -6 addr add %s dev %s", wan_addr6, wan_ifname);
if (*wan_gate6) {
doSystem("ip -6 route add %s dev %s", wan_gate6, wan_ifname);
doSystem("ip -6 route add default via %s metric %d", wan_gate6, 1);
}
}
else {
doSystem("ip -6 route add default dev %s metric %d", wan_ifname, 2048);
control_if_ipv6_autoconf(wan_ifname, nvram_invmatch("ip6_wan_dhcp", "1"));
control_if_ipv6_radv(wan_ifname, 1);
/* wait for interface ready */
sleep(2);
start_dhcp6c(wan_ifname);
if (nvram_match("ip6_lan_auto", "1"))
start_radvd_now = 0;
}
}
if (start_radvd_now)
reload_radvd();
}
示例15: load_wireless_modules
static void
load_wireless_modules(void)
{
#if defined (USE_RT2860V2_AP)
doSystem("modprobe %s", "rt2860v2_ap");
#endif
#if defined (USE_RT3090_AP)
doSystem("modprobe %s", "rt3090_ap");
#elif defined (USE_RT5392_AP)
doSystem("modprobe %s", "rt5392_ap");
#elif defined (USE_MT76X3_AP)
doSystem("modprobe %s", "mt76x3_ap");
#endif
#if defined (USE_MT76X2_AP)
doSystem("modprobe %s", "mt76x2_ap");
#endif
#if defined (USE_RT5592_AP)
doSystem("modprobe %s", "rt5592_ap");
#elif defined (USE_RT3593_AP)
doSystem("modprobe %s", "rt3593_ap");
#elif defined (USE_MT7610_AP)
doSystem("modprobe %s", "mt7610_ap");
#endif
}