diff options
| author | Klaatu <[email protected]> | 2015-05-17 15:33:21 +1200 |
|---|---|---|
| committer | Klaatu <[email protected]> | 2015-05-17 15:33:21 +1200 |
| commit | b0de699679e8f1e39af847ed172d1ba605b4370c (patch) | |
| tree | 01dac00471d61f727394e508c613b29cff0ceae5 /tryservice_nsvc.h | |
bulk upload of source
Diffstat (limited to 'tryservice_nsvc.h')
| -rw-r--r-- | tryservice_nsvc.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tryservice_nsvc.h b/tryservice_nsvc.h new file mode 100644 index 0000000..e83feb0 --- /dev/null +++ b/tryservice_nsvc.h @@ -0,0 +1,34 @@ +#ifdef CLEAN_SERVICE +static char *cleanservice(char* service) { + char* x; + size_t len = str_len(initroot); + if (!byte_diff(service,len,initroot) && service[len] == '/') + service += len+1; + x=service+str_len(service); + while (x>service && x[-1]=='/') --x; + x[0]=0; + return service; +} +#endif + + +/* return nonzero if error */ +static int tryservice(char *service, char ch) { + char *y=buf, *x=service; + int len; + +#ifdef CLEAN_SERVICE + x = cleanservice(x); +#endif + + *y++ = ch; + y += str_copyn(y,x,240); + *y++ = 0; + if (nsvc_other) y += str_copyn(y, nsvc_other, 15); + + write(infd,buf,y-buf); + len=read(outfd,buf,BUFFER_TMP_LEN); + + if (ch != 's') return (len != sizeof(struct process)); + return (len!=1 || buf[0]!='1'); +} |
