Logo Search packages:      
Sourcecode: dazuko-source version File versions

static void Example::main ( String[]  args  )  [inline, static]

programm entry point

Parameters:
args parameters - directories for Dazuko to watch

Definition at line 132 of file Example.java.

References org::dazuko::Dazuko::addExcludePath(), org::dazuko::Dazuko::addIncludePath(), org::dazuko::DazukoAccess::deny, org::dazuko::Dazuko::getAccess(), org::dazuko::Dazuko::register(), org::dazuko::Dazuko::returnAccess(), org::dazuko::Dazuko::setAccessMask(), and org::dazuko::Dazuko::unregister().

      {
            Dazuko dazuko = new Dazuko();
            boolean RUNNING = true;
            DazukoAccess acc;
            boolean args_ok = false;
            int i;
            
            if (dazuko.register("DAZUKO_EXAMPLE_JAVA", "r+") != 0)
            {
                  System.out.println("error: failed to register with Dazuko");
                  System.exit(-1);
            }

            System.out.println("registered with Dazuko successfully");

            if (dazuko.setAccessMask(DazukoAccess.DAZUKO_ON_OPEN | DazukoAccess.DAZUKO_ON_CLOSE | DazukoAccess.DAZUKO_ON_CLOSE_MODIFIED | DazukoAccess.DAZUKO_ON_EXEC | DazukoAccess.DAZUKO_ON_UNLINK | DazukoAccess.DAZUKO_ON_RMDIR) != 0)
            {
                  System.out.println("error: failed to set access mask");
                  dazuko.unregister();
                  System.exit(-1);
            }

            System.out.println("set access mask successfully");

            /* set scan path */
            for (i=0 ; i<args.length ; i++)
            {
                  if (args[i].charAt(0) == '/')
                  {
                        if (dazuko.addIncludePath(args[i]) != 0)
                        {
                              System.out.println("error: failed to add " + args[i] + " include path");
                              dazuko.unregister();
                              System.exit(-1);
                        }

                        args_ok = true;
                  }
            }

            /* ignore /dev/ */
            if (dazuko.addExcludePath("/dev/") != 0)
            {
                  System.out.println("error: failed to add /dev/ exclude path");
                  dazuko.unregister();
                  System.exit(-1);
            }

            if (!args_ok)
            {
                  printUsage();
                  dazuko.unregister();
                  System.exit(-1);
            }

            System.out.println("set scan path successfully");

            while (RUNNING)
            {
                  /* get an access */
                  acc = dazuko.getAccess();

                  if (acc != null)
                  {
                        printAccess(acc);

                        /* always allow access */
                        acc.deny = false;

                        /* return access (IMPORTANT, the kernel is waiting for us!) */
                        if (dazuko.returnAccess(acc) != 0)
                        {
                              System.out.println("error: failed to return access");
                              RUNNING = false;
                        }
                  }
                  else
                  {
                        System.out.println("warning: failed to get an access");
                        RUNNING = false;
                  }
            }

            /* unregister with Dazuko */
            if (dazuko.unregister() != 0)
            {
                  System.out.println("error: failed to unregister with Dazuko");
                  System.exit(-1);
            }

            System.out.println("unregistered with Dazuko successfully");
      }


Generated by  Doxygen 1.6.0   Back to index