当前位置: 首页>>代码示例>>C++>>正文


C++ os_strncpy函数代码示例

本文整理汇总了C++中os_strncpy函数的典型用法代码示例。如果您正苦于以下问题:C++ os_strncpy函数的具体用法?C++ os_strncpy怎么用?C++ os_strncpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了os_strncpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cgiWiFiConnect

// This cgi uses the routines above to connect to a specific access point with the
// given ESSID using the given password.
int ICACHE_FLASH_ATTR cgiWiFiConnect(HttpdConnData *connData) {
  char essid[128];
  char passwd[128];

  if (connData->conn==NULL) return HTTPD_CGI_DONE;

  int el = httpdFindArg(connData->getArgs, "essid", essid, sizeof(essid));
  int pl = httpdFindArg(connData->getArgs, "passwd", passwd, sizeof(passwd));

  if (el > 0 && pl >= 0) {
    //Set to 0 if you want to disable the actual reconnecting bit
    os_strncpy((char*)stconf.ssid, essid, 32);
    os_strncpy((char*)stconf.password, passwd, 64);
    DBG("Wifi try to connect to AP %s pw %s\n", essid, passwd);

    //Schedule disconnect/connect
    os_timer_disarm(&reassTimer);
    os_timer_setfn(&reassTimer, reassTimerCb, NULL);
    os_timer_arm(&reassTimer, 1000, 0); // 1 second for the response of this request to make it
    jsonHeader(connData, 200);
  } else {
    jsonHeader(connData, 400);
    httpdSend(connData, "Cannot parse ssid or password", -1);
  }
  return HTTPD_CGI_DONE;
}
开发者ID:seco,项目名称:esp-link,代码行数:28,代码来源:cgiwifi.c

示例2: otb_conf_store_sta_conf

uint8 ICACHE_FLASH_ATTR otb_conf_store_sta_conf(char *ssid, char *password, bool commit)
{
  uint8 rc = OTB_CONF_RC_NOT_CHANGED;
  otb_conf_struct *conf = &otb_conf_private;
  bool update_rc;

  DEBUG("CONF: otb_conf_store_sta_conf entry");
  
  if (os_strncmp(conf->ssid, ssid, OTB_CONF_WIFI_SSID_MAX_LEN) ||
      os_strncmp(conf->password, password, OTB_CONF_WIFI_PASSWORD_MAX_LEN))
  {
    INFO("CONF: New config: ssid, password");
    rc = OTB_CONF_RC_CHANGED;
    os_strncpy(conf->ssid, ssid, OTB_CONF_WIFI_SSID_MAX_LEN);
    os_strncpy(conf->password, password, OTB_CONF_WIFI_PASSWORD_MAX_LEN);
    if (commit)
    {
      INFO("CONF: Committing new config: ssid, password");
      update_rc = otb_conf_update(conf);
      if (!update_rc)
      {
        ERROR("CONF: Failed to update config");
        rc = OTB_CONF_RC_ERROR;
      }
    }
  }
  
  DEBUG("CONF: otb_conf_store_sta_conf exit");
  
  return rc;
}
开发者ID:piersfinlayson,项目名称:otb-iot,代码行数:31,代码来源:otb_conf.c

示例3: restoreFactorySettings

void restoreFactorySettings() {
	wifi_station_disconnect();
	wifi_set_opmode(0x3); //reset to STA+AP mode

	struct softap_config apConfig;
	wifi_softap_get_config(&apConfig);
	os_strncpy((char*)apConfig.ssid, "smartswitch", 18);
	apConfig.authmode = 0; //Disable security
	wifi_softap_set_config(&apConfig);

	struct station_config stconf;
	os_strncpy((char*)stconf.ssid, "", 2);
	os_strncpy((char*)stconf.password, "", 2);
	wifi_station_set_config(&stconf);

	OLED_CLS();
	OLED_Print(2, 0, "RESET", 1);
	os_printf("Reset completed. Restarting system...\n");

	ioOutput(0, GPIO_OUTPUT1);
	ioOutput(0, GPIO_OUTPUT2);

	while (!GPIO_INPUT_GET(GPIO_BUTTON1)) { os_printf("."); };
	while (!GPIO_INPUT_GET(GPIO_BUTTON2)) { os_printf("."); };

	system_restart();
}
开发者ID:MbedTinkerer,项目名称:ESP8266-relay-board-firmware,代码行数:27,代码来源:io.c

示例4: cgiWiFiConnect

//This cgi uses the routines above to connect to a specific access point with the
//given ESSID using the given password.
int ICACHE_FLASH_ATTR cgiWiFiConnect(HttpdConnData *connData) {
	char essid[128];
	char passwd[128];
	static ETSTimer reassTimer;
	
	if (connData->conn==NULL) {
		//Connection aborted. Clean up.
		return HTTPD_CGI_DONE;
	}
	
	httpdFindArg(connData->postBuff, "essid", essid, sizeof(essid));
	httpdFindArg(connData->postBuff, "passwd", passwd, sizeof(passwd));

	os_strncpy((char*)stconf.ssid, essid, 32);
	os_strncpy((char*)stconf.password, passwd, 64);

	//Schedule disconnect/connect
	os_timer_disarm(&reassTimer);
	os_timer_setfn(&reassTimer, reassTimerCb, NULL);
#if 0
	os_timer_arm(&reassTimer, 1000, 0);

	httpdRedirect(connData, "connecting.html");
#else
	httpdRedirect(connData, "/wifi");
#endif
	return HTTPD_CGI_DONE;
}
开发者ID:Informatic,项目名称:esphttpd,代码行数:30,代码来源:cgiwifi.c

示例5: cgiWiFiConnect

//This cgi uses the routines above to connect to a specific access point with the
//given ESSID using the given password.
int ICACHE_FLASH_ATTR cgiWiFiConnect(HttpdConnData *connData) {
	char essid[128];
	char passwd[128];
	static ETSTimer reassTimer;
	
	if (connData->conn==NULL) {
		//Connection aborted. Clean up.
		return HTTPD_CGI_DONE;
	}
	
	httpdFindArg(connData->post->buff, "essid", essid, sizeof(essid));
	httpdFindArg(connData->post->buff, "passwd", passwd, sizeof(passwd));

	os_strncpy((char*)stconf.ssid, essid, 32);
	os_strncpy((char*)stconf.password, passwd, 64);
	os_printf("Try to connect to AP %s pw %s\n", essid, passwd);

	//Schedule disconnect/connect
	os_timer_disarm(&reassTimer);
	os_timer_setfn(&reassTimer, reassTimerCb, NULL);
//Set to 0 if you want to disable the actual reconnecting bit
#ifdef DEMO_MODE
	httpdRedirect(connData, "/wifi");
#else
	os_timer_arm(&reassTimer, 500, 0);
	httpdRedirect(connData, "connecting.html");
#endif
	return HTTPD_CGI_DONE;
}
开发者ID:ESP32DE,项目名称:esp_enc28j60,代码行数:31,代码来源:cgiwifi.c

示例6: user_init

void user_init(void) {
	char * ap = "SKUNKWILLEM";
	char * pass = "00000000";
	uart_init(BIT_RATE_115200, uart_receive, false);
	system_set_os_print(1);
	os_printf("\nUart init done... \n");


	wifi_softap_get_config(&apconf);
	memset(apconf.ssid, 0, 32);
	memset(apconf.password, 0, 64);

	os_strncpy((char*)apconf.ssid, ap, 32);
	os_strncpy((char*)apconf.password, pass, 64);
	apconf.authmode = AUTH_WPA_WPA2_PSK;
	apconf.max_connection = 5;
	apconf.ssid_hidden = 0;
	wifi_softap_set_config(&apconf);


	IP4_ADDR(&IpInfo.gw, 192, 168, 10, 1);
	IP4_ADDR(&IpInfo.ip, 192, 168, 10, 1);
	IP4_ADDR(&IpInfo.netmask, 255, 255, 255, 0);
	wifi_softap_dhcps_stop();
	dhcps_start(&IpInfo);
	wifi_set_ip_info(0x01, &IpInfo);


	os_timer_disarm(&waitTimer);
	os_timer_setfn(&waitTimer, init_udp, NULL);
	os_timer_arm(&waitTimer, 2000, 0);

}
开发者ID:houzhenggang,项目名称:esp8266-firmwares,代码行数:33,代码来源:user_main.c

示例7: wpa_driver_broadcom_init

static void * wpa_driver_broadcom_init(void *ctx, const char *ifname)
{
	int s;
	struct sockaddr_ll ll;
	struct wpa_driver_broadcom_data *drv;
	struct ifreq ifr;

	/* open socket to kernel */
	if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
		perror("socket");
		return NULL;
	}
	/* do it */
	os_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
		perror(ifr.ifr_name);
		return NULL;
	}


	drv = os_zalloc(sizeof(*drv));
	if (drv == NULL)
		return NULL;
	drv->ctx = ctx;
	os_strncpy(drv->ifname, ifname, sizeof(drv->ifname));
	drv->ioctl_sock = s;

	s = socket(PF_PACKET, SOCK_RAW, ntohs(ETH_P_802_2));
	if (s < 0) {
		perror("socket(PF_PACKET, SOCK_RAW, ntohs(ETH_P_802_2))");
		close(drv->ioctl_sock);
		os_free(drv);
		return NULL;
	}

	os_memset(&ll, 0, sizeof(ll));
	ll.sll_family = AF_PACKET;
	ll.sll_protocol = ntohs(ETH_P_802_2);
	ll.sll_ifindex = ifr.ifr_ifindex;
	ll.sll_hatype = 0;
	ll.sll_pkttype = PACKET_HOST;
	ll.sll_halen = 0;

	if (bind(s, (struct sockaddr *) &ll, sizeof(ll)) < 0) {
		perror("bind(netlink)");
		close(s);
		close(drv->ioctl_sock);
		os_free(drv);
		return NULL;
	}

	eloop_register_read_sock(s, wpa_driver_broadcom_event_receive, ctx,
				 NULL);
	drv->event_sock = s;

	return drv;
}
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:57,代码来源:driver_broadcom.c

示例8: myPassFn

// Password authentication for admin interface
int myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pass, int passLen)
 {
  if(no==0)
   {
    os_strncpy(user, configGet()->admin_user, userLen);
    os_strncpy(pass, configGet()->admin_pass, passLen);
    return 1;
   }
  return 0;
 }
开发者ID:MalteP,项目名称:espweather,代码行数:11,代码来源:user_main.c

示例9: os_strncpy

	IROM void Flash::get(char* value, int length, const char* key, const char* dflt) {
		int idx=findKey(key);
		uint16_t len=4;
		if ( idx>=0 ) {
			if ( !loadItem(idx+1,(uint8_t*)value,len) ) {
				os_strncpy(value,dflt,length);
			} else {
				value[len]='\0';
			}
		}
		else os_strncpy(value,dflt,length);
	}
开发者ID:vortex314,项目名称:esp_cbor,代码行数:12,代码来源:Flash.cpp

示例10: otb_conf_update_loc

bool ICACHE_FLASH_ATTR otb_conf_update_loc(int loc, char *val)
{
  int len;
  bool rc = FALSE;
  otb_conf_struct *conf;

  DEBUG("CONF: otb_conf_update entry");
  
  conf = &otb_conf_private;
  
  OTB_ASSERT((loc >= 1) && (loc <= 3));
  
  len = os_strlen(val);
  if (len > (OTB_CONF_LOCATION_MAX_LEN))
  {
    otb_cmd_rsp_append("location string too long", val);
    goto EXIT_LABEL;
  }
  
  switch (loc)
  {
    case 1:
      os_strncpy(conf->loc.loc1, val, OTB_CONF_LOCATION_MAX_LEN);
      break;
  
    case 2:
      os_strncpy(conf->loc.loc2, val, OTB_CONF_LOCATION_MAX_LEN);
      break;
  
    case 3:
      os_strncpy(conf->loc.loc3, val, OTB_CONF_LOCATION_MAX_LEN);
      break;
  
    default:
      OTB_ASSERT(FALSE);
      goto EXIT_LABEL;
      break;
  }

  rc = otb_conf_update(conf);
  if (!rc)
  {
    ERROR("CONF: Failed to update config");
    otb_cmd_rsp_append("internal error");
  }
  
EXIT_LABEL:

  DEBUG("CONF: otb_conf_update exit");
 
  return rc; 
}
开发者ID:piersfinlayson,项目名称:otb-iot,代码行数:52,代码来源:otb_conf.c

示例11: u_dataViewQosNew

/**************************************************************
 * constructor/destructor
 **************************************************************/
v_dataViewQos
u_dataViewQosNew(
    v_dataViewQos tmpl)
{
    v_dataViewQos q;
    u_result result;
    int len;

    q = os_malloc(sizeof(C_STRUCT(v_dataViewQos)));
    if (q != NULL) {
        if (tmpl != NULL) {
            /* Copy non-reference fields */
            *q = *tmpl;
            /* Copy reference fields */
            
            if (tmpl->userKey.enable){
                if (tmpl->userKey.expression != NULL) {
                    len = strlen(tmpl->userKey.expression);
                    q->userKey.expression = os_malloc(len+1);
                    os_strncpy(q->userKey.expression, tmpl->userKey.expression, len);
                    q->userKey.expression[len] = 0;
                } else {
                    q->userKey.expression = NULL;
                }
            }
        } else {
            result = u_dataViewQosInit(q);
            if (result != U_RESULT_OK) {
                u_dataViewQosFree(q);
                q = NULL;
            }
        }
    }
    return q;
}
开发者ID:S73417H,项目名称:opensplice,代码行数:38,代码来源:u_dataViewQos.c

示例12: broadcom_ioctl

static int broadcom_ioctl(struct wpa_driver_broadcom_data *drv, int cmd,
			  void *buf, int len)
{
	struct ifreq ifr;
	wl_ioctl_t ioc;
	int ret = 0;

	wpa_printf(MSG_MSGDUMP, "BROADCOM: wlioctl(%s,%d,len=%d,val=%p)",
		   drv->ifname, cmd, len, buf);
	/* wpa_hexdump(MSG_MSGDUMP, "BROADCOM: wlioctl buf", buf, len); */

	ioc.cmd = cmd;
	ioc.buf = buf;
	ioc.len = len;
	os_strncpy(ifr.ifr_name, drv->ifname, IFNAMSIZ);
	ifr.ifr_data = (caddr_t) &ioc;
	if ((ret = ioctl(drv->ioctl_sock, SIOCDEVPRIVATE, &ifr)) < 0) {
		if (cmd != WLC_GET_MAGIC)
			perror(ifr.ifr_name);
		wpa_printf(MSG_MSGDUMP, "BROADCOM: wlioctl cmd=%d res=%d",
			   cmd, ret);
	}

	return ret;
}
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:25,代码来源:driver_broadcom.c

示例13: wpa_driver_nl80211_driver_cmd

int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf,
				  size_t buf_len )
{
	struct i802_bss *bss = priv;
	struct wpa_driver_nl80211_data *drv = bss->drv;
	struct ifreq ifr;
	android_wifi_priv_cmd priv_cmd;
	int ret = 0;

	if (os_strcasecmp(cmd, "STOP") == 0) {
		linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 0);
		wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STOPPED");
	} else if (os_strcasecmp(cmd, "START") == 0) {
		linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1);
		wpa_msg(drv->ctx, MSG_INFO, WPA_EVENT_DRIVER_STATE "STARTED");
	} else if (os_strcasecmp(cmd, "MACADDR") == 0) {
		u8 macaddr[ETH_ALEN] = {};

		ret = linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname, macaddr);
		if (!ret)
			ret = os_snprintf(buf, buf_len,
					  "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
	} else { /* Use private command */
		memset(&ifr, 0, sizeof(ifr));
		memset(&priv_cmd, 0, sizeof(priv_cmd));
		os_memcpy(buf, cmd, strlen(cmd) + 1);
		os_strncpy(ifr.ifr_name, bss->ifname, IFNAMSIZ);

		priv_cmd.buf = buf;
		priv_cmd.used_len = buf_len;
		priv_cmd.total_len = buf_len;
		ifr.ifr_data = &priv_cmd;

		if ((ret = ioctl(drv->global->ioctl_sock, SIOCDEVPRIVATE + 1, &ifr)) < 0) {
			wpa_printf(MSG_ERROR, "%s: failed to issue private commands\n", __func__);
		} else {
			drv_errors = 0;
			ret = 0;
			if ((os_strcasecmp(cmd, "LINKSPEED") == 0) ||
			    (os_strcasecmp(cmd, "RSSI") == 0) ||
			    (os_strcasecmp(cmd, "GETBAND") == 0) )
				ret = strlen(buf);
			else if (os_strcasecmp(cmd, "COUNTRY") == 0)
				wpa_supplicant_event(drv->ctx,
					EVENT_CHANNEL_LIST_CHANGED, NULL);
			else if (os_strncasecmp(cmd, "SETBAND", 7) == 0)
				wpa_printf(MSG_DEBUG, "%s: %s ", __func__, cmd);
			else if (os_strcasecmp(cmd, "P2P_DEV_ADDR") == 0)
				wpa_printf(MSG_DEBUG, "%s: P2P: Device address ("MACSTR")",
					__func__, MAC2STR(buf));
			else if (os_strcasecmp(cmd, "P2P_SET_PS") == 0)
				wpa_printf(MSG_DEBUG, "%s: P2P: %s ", __func__, buf);
			else if (os_strcasecmp(cmd, "P2P_SET_NOA") == 0)
				wpa_printf(MSG_DEBUG, "%s: P2P: %s ", __func__, buf);
			else
				wpa_printf(MSG_DEBUG, "%s %s len = %d, %d", __func__, buf, ret, strlen(buf));
		}
	}
	return ret;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_hardware_qcom_wlan,代码行数:60,代码来源:driver_cmd_nl80211.c

示例14: c_splitString

c_iter
c_splitString(
    const c_char *str,
    const c_char *delimiters)
{
    const c_char *head, *tail;
    c_char *nibble;
    c_iter iter = NULL;
    c_long length;

    if (str == NULL) return NULL;

    tail = str;
    while (*tail != '\0') {
        head = c_skipUntil(tail,delimiters);
        length = abs((c_address)head - (c_address)tail);
        if (length != 0) {
            length++;
            nibble = (c_string)os_malloc(length);
            os_strncpy(nibble,tail,length);
            nibble[length-1]=0;
            iter = c_iterAppend(iter,nibble);
        }
        tail = head;
        if (c_isOneOf(*tail,delimiters)) tail++;
    }
    return iter;
}
开发者ID:xrl,项目名称:opensplice,代码行数:28,代码来源:c_stringSupport.c

示例15: v_partitionPolicyRemove

v_partitionPolicyI
v_partitionPolicyRemove(
    v_partitionPolicyI p,
    const c_char *expr,
    c_base base)
{
    v_partitionPolicyI newPolicy;
    c_char *str;
    c_char *start; /* start of expr in p */
    os_size_t len;

    newPolicy.v = NULL;
    if (p.v != NULL) {
        if (strcmp(p.v, expr) != 0) {
            len = strlen(p.v);
            str = os_malloc(len + 1);
            start = strstr(p.v, expr);
            assert(start != NULL);
            assert((c_address)start >= (c_address)p.v);
            os_strncpy(str, p.v, (c_address)start - (c_address)p.v); /* includes ',' */
            str[(c_address)start - (c_address)p.v] = 0; /* make '\0' terminated */
            if (strcmp(start, expr) != 0) { /* not at the end */
                os_strcat(str, (c_char *)((c_address)start + strlen(expr) + 1 /* , */));
            }
            newPolicy.v = c_stringNew(base, str);
            os_free(str);
        }
    }

    return newPolicy;
}
开发者ID:osrf,项目名称:opensplice,代码行数:31,代码来源:v_policy.c


注:本文中的os_strncpy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。