Fix Media Plugin refresh, add seek API
[src/app-framework-binder.git] / src / main.c
index 5d898ae..b17435e 100644 (file)
@@ -71,9 +71,8 @@ static sigjmp_buf exitPoint; // context save for set/longjmp
  #define SET_CONFIG_SAVE    135
  #define SET_CONFIG_EXIT    138
 
- #define SET_SMACK          140
  #define SET_AUTH_TOKEN     141
- #define SET_PLUGINS        142
+ #define SET_LDPATH        142
  #define SET_APITIMEOUT     143
  #define SET_CNTXTIMEOUT    144
 
@@ -107,8 +106,7 @@ static  AFB_options cliOptions [] = {
   {SET_CONFIG_SAVE  ,0,"save"            , "Save config on disk [default no]"},
   {SET_CONFIG_EXIT  ,0,"saveonly"        , "Save config on disk and then exit"},
 
-  {SET_SMACK        ,1,"smack"           , "Set Smack Label [default demo]"},
-  {SET_PLUGINS      ,1,"mods"            , "Enable module [default all]"},
+  {SET_LDPATH       ,1,"ldpaths"         , "Load Plugins from dir1:dir2:... [default = PLUGIN_INSTALL_DIR"},
   {SET_AUTH_TOKEN   ,1,"token"           , "Initial Secret [default=no-session, --token="" for session without authentication]"},
   
   {DISPLAY_VERSION  ,0,"version"         , "Display version and copyright"},
@@ -159,7 +157,7 @@ void signalQuit (int signum) {
          fprintf (stderr,"  --%-15s %s\n", command, cliOptions[ind].help);
       }
     }
-    fprintf (stderr,"Example:\n  %s\\\n  --verbose --port=1234 --smack=xxxx --token='azerty' --mods=alsa:dbus\n", name);
+    fprintf (stderr,"Example:\n  %s\\\n  --verbose --port=1234 --token='azerty' --ldpaths=build/plugins:/usr/lib64/agl/plugins\n", name);
 } // end printHelp
 
 /*----------------------------------------------------------
@@ -246,7 +244,7 @@ static void listenLoop (AFB_session *session) {
         fprintf (stderr, "hoops returned from infinite loop [report bug]\n");
   }
 }
+  
 /*---------------------------------------------------------
  | main
  |   Parse option and launch action
@@ -344,21 +342,14 @@ int main(int argc, char *argv[])  {
        }     
        break;
        
-    case SET_SMACK:
-       if (optarg == 0) goto needValueForOption;
-       fprintf (stderr, "Not Implemented yet\n");
-       cliconfig.smack   = optarg;
-       break;
-
     case SET_AUTH_TOKEN:
        if (optarg == 0) goto needValueForOption;
        cliconfig.token   = optarg;
        break;
 
-    case SET_PLUGINS:
+    case SET_LDPATH:
        if (optarg == 0) goto needValueForOption;
-       fprintf (stderr, "Not Implemented yet\n");
-       cliconfig.plugins = optarg;
+       cliconfig.ldpaths = optarg;
        break;
 
     case SET_PID_FILE:
@@ -432,7 +423,7 @@ int main(int argc, char *argv[])  {
        printHelp(programName);
        goto normalExit;
 
-  }
+    }
   }
  
   // if exist merge config file with CLI arguments
@@ -451,7 +442,7 @@ int main(int argc, char *argv[])  {
   // open syslog if ever needed
   openlog("AGB-log", 0, LOG_DAEMON);
 
-  // -------------- Try to kill any previsou process if asked ---------------------
+  // -------------- Try to kill any previous process if asked ---------------------
   if (session->killPrevious) {
     pid = readPidFile (session->config);  // enforce commandline option
     switch (pid) {
@@ -510,7 +501,7 @@ int main(int argc, char *argv[])  {
     }
 
     // let's not take the risk to run as ROOT
-    if (getuid() == 0)  goto errorNoRoot;
+    //if (getuid() == 0)  goto errorNoRoot;
 
     // check session dir and create if it does not exist
     if (sessionCheckdir (session) != AFB_SUCCESS) goto errSessiondir;
@@ -583,23 +574,23 @@ int main(int argc, char *argv[])  {
       if (status == -1) goto errorPidFile;
 
       // we are in father process, we don't need this one
-      exit (0);
+      _exit (0);
 
   } // end background-foreground
 
 normalExit:
   closeSession (session);   // try to close everything before leaving
   if (verbose) printf ("\n---- Application Framework Binder Normal End ------\n");
-  exit (0);
+  exit(0);
 
 // ------------- Fatal ERROR display error and quit  -------------
 errorSetuid:
   fprintf (stderr,"\nERR:AFB-daemon Failed to change UID to username=[%s]\n\n", session->config->setuid);
   exit (-1);
   
-errorNoRoot:
-  fprintf (stderr,"\nERR:AFB-daemon Not allow to run as root [use --seteuid=username option]\n\n");
-  exit (-1);
+//errorNoRoot:
+//  fprintf (stderr,"\nERR:AFB-daemon Not allow to run as root [use --seteuid=username option]\n\n");
+//  exit (-1);
 
 errorPidFile:
   fprintf (stderr,"\nERR:AFB-daemon Failed to write pid file [%s]\n\n", session->config->pidfile);