本文整理汇总了C++中os_strcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ os_strcpy函数的具体用法?C++ os_strcpy怎么用?C++ os_strcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了os_strcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MQTT_SetUserPwd
void ICACHE_FLASH_ATTR
MQTT_SetUserPwd(MQTT_Client *mqttClient, const char* user, const char* pwd)
{
uint32_t len;
// free username
if (mqttClient->connect_info.username != 0) {
os_free(mqttClient->connect_info.username);
mqttClient->connect_info.username = 0;
}
// free password
if (mqttClient->connect_info.password != 0) {
os_free(mqttClient->connect_info.password);
mqttClient->connect_info.password = 0;
}
// copy username
len = os_strlen(user);
mqttClient->connect_info.username = (uint8_t*)os_zalloc(len + 1);
if (len) {
os_strcpy(mqttClient->connect_info.username, user);
}
mqttClient->connect_info.username[len] = 0;
// copy password
len = os_strlen(pwd);
mqttClient->connect_info.password = (uint8_t*)os_zalloc(len + 1);
if (len) {
os_strcpy(mqttClient->connect_info.password, pwd);
}
mqttClient->connect_info.password[len] = 0;
}
示例2: d_elementNew
d_element
d_elementNew(
const char * name,
const char * partition,
const char * topic )
{
d_element element;
element = os_malloc(C_SIZEOF(d_element));
element->name = NULL;
element->partition = NULL;
element->topic = NULL;
/* QAC EXPECT 1253; */
element->strlenName = (os_uint32) (strlen(name) + 1);
/* QAC EXPECT 1253; */
element->strlenPartition = (os_uint32) (strlen(partition) + 1);
/* QAC EXPECT 1253; */
element->strlenTopic = (os_uint32) (strlen(topic) + 1);
element->name = os_malloc(element->strlenName);
/* QAC EXPECT 5007; use of strcpy */
os_strcpy(element->name, name);
element->partition = os_malloc(element->strlenPartition);
/* QAC EXPECT 5007; use of strcpy */
os_strcpy(element->partition, partition);
element->topic = os_malloc(element->strlenTopic);
/* QAC EXPECT 5007; use of strcpy */
os_strcpy(element->topic, topic);
return element;
}
示例3: tplGPIO
//Template code for the led page.
void ICACHE_FLASH_ATTR tplGPIO(HttpdConnData *connData, char *token, void **arg) {
char buff[128];
if (token==NULL) return;
os_strcpy(buff, "Unknown");
if (os_strcmp(token, "relay1name")==0) {
os_strcpy(buff, (char *)sysCfg.relay1name);
}
if (os_strcmp(token, "relay1")==0) {
if (currGPIO12State) {
os_strcpy(buff, "on");
} else {
os_strcpy(buff, "off");
}
os_printf("Relay 1 is now ");
os_printf(buff);
os_printf("\n ");
}
httpdSend(connData, buff, -1);
}
示例4: fetch_code_from_cloud
void ICACHE_FLASH_ATTR fetch_code_from_cloud()
{
char buf0[512], buf1[512];
if ( user_params_get(buf0, sizeof(buf0)) )
{
buf0[sizeof(buf0) - 1] = 0;
char *p = (char*)os_strstr(buf0, ";");
if (p != NULL && p != buf0)
{
p[0] = 0;
char *q = (char*)os_strstr(p + 1, ";");
if (q != NULL && q != p + 1)
{
q[0] = 0;
_miid = (char*)os_malloc(os_strlen(buf0) + 1);
_security = (char*)os_malloc(os_strlen(p + 1) + 1);
os_strcpy(_miid, buf0);
os_strcpy(_security, p + 1);
__printf("Node:%s\n", _miid);
os_sprintf(buf1, CLOUD_FETCH_URL, _miid, _security);
os_sprintf(buf0, HTTP_QUERY, buf1);
http_get(CLOUD_HOST, buf0, user_on_http_response, NULL);
return;
}
}
}
__printf("Please set node ID!\n");
luainit("");
}
示例5: spi_flash_write_test
void ICACHE_FLASH_ATTR spi_flash_write_test(enum RUN_MODE mode)
{
rw_info rw;
os_memset(&rw, 0, sizeof(rw));
rw.server_addr = ipaddr_addr("192.168.0.241");
rw.server_port = 10010;
os_strcpy(rw.ssid, "useease2");
os_strcpy(rw.ssid_pwd, "1CBE991A14");
os_strcpy(rw.ssid_mine, "iPLUG");
os_strcpy(rw.ssid_pwd_mine, "iPLUG123");
rw.run_mode = mode;
rw.dev_type = DEV_PLUG;
show_rw(&rw);
//写入前,需要擦除
if (spi_flash_erase_sector(FLASH_HEAD_ADDR / (4 * 1024))
!= SPI_FLASH_RESULT_OK) {
os_printf("SPI FLASH ERASE ERROR\n");
} else {
os_printf("SPI FLASH ERASE SUCCESS\n");
}
//写入
if (spi_flash_write(FLASH_HEAD_ADDR, (uint32*) &rw, sizeof(rw))
!= SPI_FLASH_RESULT_OK) {
os_printf("SPI FLASH WRITE ERROR\n");
} else {
os_printf("SPI FLASH WRITE SUCCESS\n");
}
}
示例6: strreplace
// This function will replace a substring with a replacement inside a string
// FIXME: Check for length!
bool strreplace( char* str, char* sub, char* rep, unsigned int len )
{
char* temp;
char* start;
char* remaining;
unsigned int lsub;
unsigned int lrep;
// Find substring
start = os_strstr(str, sub);
if(start==NULL) return false;
// Length of substring and replacement
lsub = os_strlen(sub);
lrep = os_strlen(rep);
if(lsub==0||lrep==0) return false;
// Position of remaining string
remaining = start + lsub;
// Alloc temporary buffer and copy
temp=os_malloc(len);
os_strcpy(temp, remaining);
// Replace substring
os_strcpy(start, rep);
// Add temp string and free memory
os_strcat(str, temp);
os_free(temp);
return true;
}
示例7: recvTask
static void ICACHE_FLASH_ATTR recvTask(os_event_t *events) {
RcvMsgBuff *rxBuff = (RcvMsgBuff *)events->par;
char info[256];
char recvd[200];
int ri = 0;
for (; rxBuff->pReadPos < rxBuff->pWritePos; rxBuff->pReadPos++) {
recvd[ri++] = (char)*(rxBuff->pReadPos);
}
recvd[ri] = 0;
if (ri < 1) return; // Empty line
//print(recvd);
if (registration_status != REGISTER_REGISTERED) {
os_strcpy(last_unknown, recvd);
return;
}
if (strncmp("TEMP", recvd, 4) == 0) {
if (os_strcmp(last_temp, recvd+5) != 0) { // Not same as last time
os_strcpy(last_temp, recvd+5);
post_measurement("temperature", "F", last_temp);
}
}
else if (strncmp("HUM", recvd, 3) == 0) {
if (os_strcmp(last_hum, recvd+4) != 0) { // Not same as last time
os_strcpy(last_hum, recvd+4);
post_measurement("humidity", "%", last_hum);
}
}
// Reset RX buffer positions
rxBuff->pWritePos = rxBuff->pRcvMsgBuff;
rxBuff->pReadPos = rxBuff->pRcvMsgBuff;
}
示例8: nixieTplWlan
int ICACHE_FLASH_ATTR nixieTplWlan(HttpdConnData *connData, char *token, void **arg) {
char buff[1024];
int x;
static struct station_config stconf;
if (token==NULL) return HTTPD_CGI_DONE;
wifi_station_get_config(&stconf);
os_strcpy(buff, "Unknown");
if (os_strcmp(token, "WiFiMode")==0) {
x=wifi_get_opmode();
if (x==1) os_strcpy(buff, "Client");
if (x==2) os_strcpy(buff, "SoftAP");
if (x==3) os_strcpy(buff, "Client+AP");
} else if (os_strcmp(token, "currSsid")==0) {
os_strcpy(buff, (char*)stconf.ssid);
} else if (os_strcmp(token, "WiFiPasswd")==0) {
os_strcpy(buff, (char*)stconf.password);
} else if (os_strcmp(token, "DeviceID")==0) {
uint8_t client_id[16];
os_sprintf(client_id, "%08X", system_get_chip_id());
os_strcpy(buff, (char*)client_id);
} else if (os_strcmp(token, "WiFiapwarn")==0) {
x=wifi_get_opmode();
if (x==2) {
os_strcpy(buff, "<b>Can't scan in this mode.</b><a href=\"setmode.cgi?mode=3\">Go to STA+AP mode.</a>");
} else if(x==1) {
os_strcpy(buff, "<a href=\"setmode.cgi?mode=3\">Go back to Client+AP mode.</a>");
} else {
os_strcpy(buff, "<a href=\"setmode.cgi?mode=1\">Go to Client Only Mode</a><br /> To reset hold Button for 5 sec and release");
}
}
httpdSend(connData, buff, -1);
return HTTPD_CGI_DONE;
}
示例9: parse_http
void parse_http(char *http_raw, unsigned short length, char *method, char *path, char *headers, char *body) {
// Parse HTTP request
// TODO: Decipherable variable names
char line[1024];
char lc = 0;
int li = 0;
int i = 0;
int m = 0; // 0=intro 1=headers 2=body
for (; i<length; i++) {
char c = http_raw[i];
if (m < 2 && c == '\n' && lc == '\r') { // Got intro or header line
line[li-1] = 0;
if (li == 1) m++; // Blank line: end of headers / start of body
else if (m == 0) {
m++;
// TODO: Parse method, path
char ll[500];
int im = 0;
int ii = 0;
int cii = 0;
for (; ii<li; ii++) {
if (line[ii] == ' ') {
ll[cii] = 0;
if (im == 0) { // Method
os_strcpy(method, ll);
im++;
} else if (im == 1) { // Path
os_strcpy(path, ll);
break;
}
cii = 0;
} else {
ll[cii++] = line[ii];
}
}
} else if (m == 1) {
// TODO: Parse header
}
li = 0;
lc = 0;
}
else {
lc = c;
line[li++] = c;
}
}
// Set body if it exists
line[li] = 0;
if (li > 0) {
os_strcpy(body, line);
}
}
示例10: rwinfo_init
void rwinfo_init(rw_info* prw)
{
os_memset(prw, 0, sizeof(rw_info));
prw->server_addr = ipaddr_addr(CLOUD_SERVER);
prw->server_port = CLOUD_PORT;
prw->dev_type = DEV_PLUG;
os_strcpy(prw->ssid_mine, DEFAULT_SSID);
os_strcpy(prw->ssid_pwd_mine, DEFAULT_SSID_PWD);
}
示例11: tcp_receive_cb
static void ICACHE_FLASH_ATTR tcp_receive_cb(void *arg, char *pData, unsigned short len) {
HttpdConnData c;
char bfr[100] = { 0 };
struct espconn *conn = (struct espconn*) arg;
httpdParseHeader(pData, &c);
TESTP("URL=%s\n", c.url);
if (httpSetupMode && os_strncmp(c.url, "/setup", 5) == 0) {
if (httpdFindArg(c.getArgs, "Action", bfr, sizeof(bfr)) >= 0) {
TESTP("Action=%s\n", bfr);
if (os_strncmp(bfr, "Update", 6) == 0) {
if (httpdFindArg(c.getArgs, "MQTThost", bfr, sizeof(bfr)) >= 0) {
TESTP("MQTThost=%s\n", bfr);
if (7 < os_strlen(bfr) && os_strlen(bfr) < sizeof(sysCfg.mqtt_host)) {
os_strcpy(sysCfg.mqtt_host, bfr);
}
}
if (httpdFindArg(c.getArgs, "MQTTport", bfr, sizeof(bfr)) >= 0) {
TESTP("MQTTport=%s\n", bfr);
if (1 <= os_strlen(bfr) && os_strlen(bfr) <= 4) {
sysCfg.mqtt_port = atoi(bfr);
}
}
if (httpdFindArg(c.getArgs, "MQTTuser", bfr, sizeof(bfr)) >= 0) {
TESTP("MQTTuser=%s\n", bfr);
if (0 <= os_strlen(bfr) && os_strlen(bfr) < sizeof(sysCfg.mqtt_user)) {
os_strcpy(sysCfg.mqtt_user, bfr);
}
}
if (httpdFindArg(c.getArgs, "MQTTpass", bfr, sizeof(bfr)) >= 0) {
TESTP("MQTTpass=%s\n", bfr);
if (0 <= os_strlen(bfr) && os_strlen(bfr) < sizeof(sysCfg.mqtt_pass)) {
os_strcpy(sysCfg.mqtt_pass, bfr);
}
}
if (httpdFindArg(c.getArgs, "DevPrefix", bfr, sizeof(bfr)) >= 0) {
TESTP("DevPrefix=%s\n", bfr);
if (2 <= os_strlen(bfr) && os_strlen(bfr) < sizeof(sysCfg.deviceID_prefix)) {
os_strcpy(sysCfg.deviceID_prefix, bfr);
os_sprintf(sysCfg.device_id, "%s%lx", sysCfg.deviceID_prefix, system_get_chip_id());
}
}
if (httpdFindArg(c.getArgs, "reboot", bfr, sizeof(bfr)) >= 0) {
TESTP("reboot=%s\n", bfr);
if (strcmp(bfr, "yes") == 0) {
reboot = true;
}
}
CFG_dirty();
}
}
replyOK(conn);
} else {
replyFail(conn);
}
}
示例12: os_strcpy
void MDNSResponder::addService(char *name, char *proto, uint16_t port){
if(_getServicePort(name, proto) != 0) return;
if(os_strlen(name) > 32 || os_strlen(proto) != 3) return; //bad arguments
struct MDNSService *srv = (struct MDNSService*)(os_malloc(sizeof(struct MDNSService)));
os_strcpy(srv->_name, name);
os_strcpy(srv->_proto, proto);
srv->_port = port;
srv->_next = 0;
if(_services) _services->_next = srv;
else _services = srv;
}
示例13: myPassFn
//Function that tells the authentication system what users/passwords live on the system.
//This is disabled in the default build; if you want to try it, enable the authBasic line in
//the builtInUrls below.
int myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pass, int passLen) {
if (no==0) {
os_strcpy(user, "admin");
os_strcpy(pass, "s3cr3t");
return 1;
//Add more users this way. Check against incrementing no for each user added.
// } else if (no==1) {
// os_strcpy(user, "user1");
// os_strcpy(pass, "something");
// return 1;
}
return 0;
}
示例14: myPassFn
//Function that tells the authentication system what users/passwords live on the system.
//This is disabled in the default build; if you want to try it, enable the authBasic line in
//the builtInUrls below.
int ICACHE_FLASH_ATTR myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pass, int passLen) {
if (no==0) {
os_strcpy(user, (char *)sysCfg.httpd_user);
os_strcpy(pass, (char *)sysCfg.httpd_pass);
return 1;
//Add more users this way. Check against incrementing no for each user added.
// } else if (no==1) {
// os_strcpy(user, "user1");
// os_strcpy(pass, "something");
// return 1;
}
return 0;
}
示例15: tplLed
//Template code for the led page.
void ICACHE_FLASH_ATTR tplLed(HttpdConnData *connData, char *token, void **arg) {
char buff[128];
if (token==NULL) return;
os_strcpy(buff, "Unknown");
if (os_strcmp(token, "ledstate")==0) {
if (currLedState) {
os_strcpy(buff, "on");
} else {
os_strcpy(buff, "off");
}
}
espconn_sent(connData->conn, (uint8 *)buff, os_strlen(buff));
}