Beispiel #1
0
void SkipPair(char LToken,char RToken)
{
	int Count;
	char token;
	//char *StPos = FilePtr;
	
	token = *FilePtr++;

	if (token != LToken)
	{
		printf("Expected '%c'",LToken);
		ExitApp(1);
	}

	Count = 1;
	
	while (1)
	{
		token = *FilePtr;

		if (token == 0)
		{
			printf("Expected '%c'",RToken);
			ExitApp(1);
		}
		
		if (token == LToken)
			Count++;

		if (token == RToken)
		{
			--Count;
			if (Count == 0)
				break;
		}

		if (token == '(' && LToken != '(')
		{
			SkipPair('(',')');
			continue;
		}	
	
		if (token == '\'')
		{
			SkipQuote(token);
			continue;
		}	

		if (token == '"')
		{
			SkipQuote(token);
			continue;
		}	
	
		FilePtr++;
		SkipWhiteSpace();	
	}

	FilePtr++;
	return;
}
Beispiel #2
0
bool cDll::Load(bool Log)
{
  if (Log)
     isyslog("loading plugin: %s", fileName);
  if (handle) {
     esyslog("attempt to load plugin '%s' twice!", fileName);
     return false;
     }
  handle = dlopen(fileName, RTLD_NOW);
  const char *error = dlerror();
  if (!error) {
     void *(*creator)(void);
     creator = (void *(*)(void))dlsym(handle, "VDRPluginCreator");
     if (!(error = dlerror()))
        plugin = (cPlugin *)creator();
     }
  if (!error) {
     if (plugin && args) {
        int argc = 0;
        char *argv[MAXPLUGINARGS];
        char *p = skipspace(stripspace(args));
        char *q = NULL;
        bool done = false;
        while (!done) {
              if (!q)
                 q = p;
              switch (*p) {
                case '\\': strcpy(p, p + 1);
                           if (*p)
                              p++;
                           else {
                              esyslog("ERROR: missing character after \\");
                              fprintf(stderr, "vdr: missing character after \\\n");
                              return false;
                              }
                           break;
                case '"':
                case '\'': if ((p = SkipQuote(p)) == NULL)
                              return false;
                           break;
                default: if (!*p || isspace(*p)) {
                            done = !*p;
                            *p = 0;
                            if (q) {
                               if (argc < MAXPLUGINARGS - 1)
                                  argv[argc++] = q;
                               else {
                                  esyslog("ERROR: plugin argument list too long");
                                  fprintf(stderr, "vdr: plugin argument list too long\n");
                                  return false;
                                  }
                               q = NULL;
                               }
                            }
                         if (!done)
                            p = *p ? p + 1 : skipspace(p + 1);
                }
              }
        argv[argc] = NULL;
        if (argc)
           plugin->SetName(argv[0]);
        optind = 0; // to reset the getopt() data
        return !Log || !argc || plugin->ProcessArgs(argc, argv);
        }
     }
  else {
     esyslog("ERROR: %s", error);
     esyslog("WARNING: failed to load plugin %s. Continuing anyway.", fileName);
     fprintf(stderr, "vdr: %s\n", error);
     }
  return !error && plugin;
}