aboutsummaryrefslogtreecommitdiffstats
path: root/Controler-afb/ctl-misc.c
diff options
context:
space:
mode:
authorfulup <fulup.arfoll@iot.bzh>2017-08-14 00:58:57 +0200
committerfulup <fulup.arfoll@iot.bzh>2017-08-14 00:58:57 +0200
commit96f0057d65fbb90d9faa02a3ae4ae37b357094db (patch)
treee5343b6feaef5296a86cfdd0597405565b79490e /Controler-afb/ctl-misc.c
parent9777a02c7540fdec145feb948b4bbf1cd44c3352 (diff)
Work in Progress
Diffstat (limited to 'Controler-afb/ctl-misc.c')
-rw-r--r--Controler-afb/ctl-misc.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/Controler-afb/ctl-misc.c b/Controler-afb/ctl-misc.c
index a022b38..773e8f9 100644
--- a/Controler-afb/ctl-misc.c
+++ b/Controler-afb/ctl-misc.c
@@ -88,6 +88,26 @@ PUBLIC json_object* ScanForConfig (char* searchPath, CtlScanDirModeT mode, char
return (responseJ);
}
+PUBLIC const char *GetMidleName(const char*name) {
+ char *fullname = strdup(name);
+
+ for (int idx = 0; fullname[idx] != '\0'; idx++) {
+ int start;
+ if (fullname[idx] == '-') {
+ start = idx + 1;
+ for (int jdx = start; fullname[jdx] != '\0'; jdx++) {
+ if (fullname[jdx] == '-') {
+ fullname[jdx] = '\0';
+ return &fullname[start];
+ break;
+ }
+ }
+ break;
+ }
+ }
+ return "";
+}
+
PUBLIC const char *GetBinderName() {
char psName[17];
static char *binderName=NULL;
@@ -96,20 +116,7 @@ PUBLIC const char *GetBinderName() {
// retrieve binder name from process name afb-name-trailer
prctl(PR_GET_NAME, psName,NULL,NULL,NULL);
- for (int idx=0; idx < sizeof(psName); idx++) {
- int start;
- if (psName[idx] == '-') {
- start=idx+1;
- for (int jdx=start; jdx < sizeof(psName); jdx++) {
- if (psName[jdx] == '-') {
- psName[jdx] = '\0';
- binderName=strdup(&psName[start]);
- break;
- }
- }
- break;
- }
- }
+ binderName=GetMidleName(psName);
return binderName;
} \ No newline at end of file