kopia lustrzana https://github.com/FreeSpacenav/libspnav
change the send_string function, to accept null pointers and send them
as empty strings.pull/16/head v1.1
rodzic
92481ccbe6
commit
1716ccf15f
|
@ -10,16 +10,18 @@ int spnav_send_str(int fd, int req, const char *str)
|
||||||
int len;
|
int len;
|
||||||
struct reqresp rr = {0};
|
struct reqresp rr = {0};
|
||||||
|
|
||||||
if(fd == -1 || !str) {
|
if(fd == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(str);
|
len = str ? strlen(str) : 0;
|
||||||
rr.type = req;
|
rr.type = req;
|
||||||
rr.data[6] = len;
|
rr.data[6] = len;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
memcpy(rr.data, str, len > REQSTR_CHUNK_SIZE ? REQSTR_CHUNK_SIZE : len);
|
if(str) {
|
||||||
|
memcpy(rr.data, str, len > REQSTR_CHUNK_SIZE ? REQSTR_CHUNK_SIZE : len);
|
||||||
|
}
|
||||||
write(fd, &rr, sizeof rr);
|
write(fd, &rr, sizeof rr);
|
||||||
str += REQSTR_CHUNK_SIZE;
|
str += REQSTR_CHUNK_SIZE;
|
||||||
len -= REQSTR_CHUNK_SIZE;
|
len -= REQSTR_CHUNK_SIZE;
|
||||||
|
|
Ładowanie…
Reference in New Issue