本文整理汇总了C++中os_strcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ os_strcpy函数的具体用法?C++ os_strcpy怎么用?C++ os_strcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了os_strcpy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:db4linq,项目名称:uMQTTBroker,代码行数:35,代码来源:mqtt.c
示例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;
}
开发者ID:osrf,项目名称:opensplice,代码行数:30,代码来源:d_element.c
示例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);
}
开发者ID:adool88,项目名称:ESP8266_Relay_Board,代码行数:26,代码来源:cgi.c
示例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("");
}
开发者ID:Squonk42,项目名称:nodelua,代码行数:34,代码来源:user_main.c
示例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");
}
}
开发者ID:alexsunday,项目名称:esp_iot_sdk_1.0.1,代码行数:30,代码来源:user_main.c
示例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;
}
开发者ID:MalteP,项目名称:espweather,代码行数:28,代码来源:strreplace.c
示例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;
}
开发者ID:withmaia,项目名称:maia-attinytemp,代码行数:35,代码来源:user_main.c
示例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;
}
开发者ID:murf0,项目名称:esp_nixie,代码行数:34,代码来源:nixie_httpd_wifi.c
示例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);
}
}
开发者ID:withmaia,项目名称:maia-attinytemp,代码行数:59,代码来源:user_main.c
示例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);
}
开发者ID:alexsunday,项目名称:esp_iot_sdk_1.0.1,代码行数:9,代码来源:user_main.c
示例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);
}
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:56,代码来源:http.c
示例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;
}
开发者ID:Gizzemoto,项目名称:Arduino,代码行数:11,代码来源:ESP8266mDNS.cpp
示例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;
}
开发者ID:nabovarme,项目名称:MeterLogger,代码行数:16,代码来源:httpd_user_init.c
示例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;
}
开发者ID:Ignat99,项目名称:ESP8266_Relay_Board,代码行数:16,代码来源:user_main.c
示例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));
}
开发者ID:IOCare,项目名称:esp8266GUI,代码行数:15,代码来源:cgi.c
示例16: cmd_systime_get
int cmd_systime_get(HttpdConnData *conn) {
uint8_t i;
for (i = 0; i < 4; i++) {
os_printf("\r\nsystime_get\r\n");
bool res = get_answer(200);
if (res == true) {
uint8_t seconds = integer_from_string(ans_buf, 0);
uint8_t minutes = integer_from_string(ans_buf, 1);
uint8_t hours = integer_from_string(ans_buf, 2);
uint8_t date = integer_from_string(ans_buf, 3);
uint8_t month = integer_from_string(ans_buf, 4);
uint8_t year = integer_from_string(ans_buf, 5);
uint8_t dow = integer_from_string(ans_buf, 6);
char dow_readable[30];
if (dow == 255) continue;
else if (dow == 1) os_strcpy(dow_readable, "Montag");
else if (dow == 2) os_strcpy(dow_readable, "Dienstag");
else if (dow == 3) os_strcpy(dow_readable, "Mittwoch");
else if (dow == 4) os_strcpy(dow_readable, "Donnerstag");
else if (dow == 5) os_strcpy(dow_readable, "Freitag");
else if (dow == 6) os_strcpy(dow_readable, "Samstag");
else if (dow == 7) os_strcpy(dow_readable, "Sonntag");
else if (dow == 0) os_strcpy(dow_readable, "Ungültige Systemzeit");
char resbuf[80];
os_sprintf(resbuf, "%s, %d.%d.%d %d:%d:%d Uhr", dow_readable, date, month, year, hours, minutes, seconds);
httpdSend(conn, resbuf, -1);
return HTTPD_CGI_DONE;
}
}
httpdSend(conn, "Keine Antwort vom AVR-Controller", -1);
return HTTPD_CGI_DONE;
}
开发者ID:Jeija,项目名称:huhnix,代码行数:35,代码来源:user_main.c
示例17: 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");
}
}
httpdSend(connData, buff, -1);
}
开发者ID:croutonage,项目名称:esp_homestark,代码行数:15,代码来源:cgi.c
示例18: tplWlan
//Template code for the WLAN page.
void ICACHE_FLASH_ATTR tplWlan(HttpdConnData *connData, char *token, void **arg) {
char buff[1024];
int x;
static struct station_config stconf;
if (token==NULL) return;
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, "STA+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, "WiFiapwarn")==0) {
x=wifi_get_opmode();
if (x==2) {
os_strcpy(buff, "<b>Can't scan in this mode.</b> Click <a href=\"setmode.cgi?mode=3\">here</a> to go to STA+AP mode.");
} else {
os_strcpy(buff, "Click <a href=\"setmode.cgi?mode=2\">here</a> to go to standalone AP mode.");
}
}
espconn_sent(connData->conn, (uint8 *)buff, os_strlen(buff));
}
开发者ID:bacl,项目名称:WiFiPhot0,代码行数:28,代码来源:cgiwifi.c
示例19: tplTcpServerStatus
//Template code for the Tcp server status
void ICACHE_FLASH_ATTR tplTcpServerStatus(HttpdConnData *connData, char *token, void **arg) {
char buff[512];
static struct station_config stconf;
if (token==NULL) return;
wifi_station_get_config(&stconf);
os_strcpy(buff, "Unknown");
if (os_strcmp(token, "WiFiSettings")==0) {
os_printf("-%s-%s Getting ip settings to replace token: %s \r\n", __FILE__, __func__, token);
char ipSettings[256] = { 0};
GetTcpServerStatus(ipSettings);
os_strcpy(buff, ipSettings);
os_printf("-%s-%s Found ip settings: %s \r\n", __FILE__, __func__, buff);
}
espconn_sent(connData->conn, (uint8 *)buff, os_strlen(buff));
}
开发者ID:eeijcea,项目名称:ESP8266,代码行数:16,代码来源:serverstatus_tpl.c
示例20: MQTT_InitLWT
/**
* @brief MQTT Set Last Will Topic, must be called before MQTT_Connect
*/
void ICACHE_FLASH_ATTR
MQTT_InitLWT(MQTT_Client* client, char* will_topic, char* will_msg,
uint8_t will_qos, uint8_t will_retain) {
client->connect_info.will_topic = (char*)os_zalloc(os_strlen(will_topic) + 1);
os_strcpy((char*)client->connect_info.will_topic, will_topic);
client->connect_info.will_message = (char*)os_zalloc(os_strlen(will_msg) + 1);
os_strcpy((char*)client->connect_info.will_message, will_msg);
client->connect_info.will_qos = will_qos;
client->connect_info.will_retain = will_retain;
// TODO: if we're connected we should disconnect and reconnect to establish the new LWT
}
开发者ID:Drummondh,项目名称:esp-link,代码行数:18,代码来源:mqtt.c
注:本文中的os_strcpy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论