コード例 #1
0
ファイル: store.c プロジェクト: OPSF/uClinux
int store_get_plugin(struct plugin * p, char * name)
{
 int e = store_get_plugin_f(p, NULL, usr_store_dir, name);
 if(p->id < 0)
  return store_get_plugin_f(p, NULL, sys_store_dir, name);
 else
  return e;
}
コード例 #2
0
ファイル: store.c プロジェクト: miettal/armadillo420_standard
struct arglist * store_load_plugin(char * dir, char * file, char * md5, struct arglist * prefs)
{
 char desc_file[PATH_MAX+1];
 char plug_file[PATH_MAX+1];
 char * str;
 char store_dir[PATH_MAX+1];
 struct plugin p;
 struct pprefs pp[MAX_PREFS];
 
 struct arglist * ret;
 int i;
 
 bzero(pp, sizeof(pp));
 
 snprintf(desc_file, sizeof(desc_file), "%s/.desc/%s", dir, file);

 str = strrchr(desc_file, '.');
 if( str != NULL )
 {
  str[0] = '\0';
  if(	strlen(desc_file) + 6 < sizeof(desc_file) )
  	strcat(desc_file, ".desc");
 }
 snprintf(plug_file, sizeof(plug_file), "%s/%s", dir, file);
 snprintf(store_dir, sizeof(store_dir), "%s/.desc", dir);
 if(store_get_plugin_f(&p, pp, store_dir, file) < 0)
  return NULL;
  
 if(p.magic != MAGIC)
 	return NULL;
	
	
 if(p.id > 0)
 {
  if(md5 != NULL && strcmp(p.md5, md5) != 0)
   return NULL;
 }
 else return NULL;
    
 ret = emalloc(sizeof(struct arglist));   
 plug_set_id(ret, p.id);
 plug_set_category(ret, p.category);
 plug_set_fname(ret, file);
 arg_add_value(ret, "preferences", ARG_ARGLIST, -1, prefs);
 
 if(p.has_prefs)
 {
 for(i=0;pp[i].type[0] != '\0';i++)
  { 
   _add_plugin_preference(prefs, p.name, pp[i].name, pp[i].type, pp[i].dfl);
  }
 }

 return ret;
}
コード例 #3
0
ファイル: store.c プロジェクト: OPSF/uClinux
struct arglist * store_load_plugin(char * dir, char * file,  struct arglist * prefs)
{
 char desc_file[PATH_MAX+1];
 char plug_file[PATH_MAX+1];
 char * str;
 char store_dir[PATH_MAX+1];
 struct plugin p;
 struct pprefs pp[MAX_PREFS];
 
 struct arglist * ret;
 int i;
 struct stat st1, st2;
 struct arglist * al;
 
 bzero(pp, sizeof(pp));
 
 snprintf(desc_file, sizeof(desc_file), "%s/.desc/%s", dir, file);
 str = strrchr(desc_file, '.');
 if( str != NULL )
 {
  str[0] = '\0';
  if(	strlen(desc_file) + 6 < sizeof(desc_file) )
  	strcat(desc_file, ".desc");

 }
 snprintf(plug_file, sizeof(plug_file), "%s/%s", dir, file);

 if (  stat(plug_file, &st1) < 0 || 
       stat(desc_file, &st2) < 0 ) 
		return NULL;

 /* 
  * Look if the plugin is newer, and if that's the case also make sure that
  * the plugin mtime is not in the future...
  */
 if ( st1.st_mtime > st2.st_mtime && st1.st_mtime <= time(NULL) )
	return NULL;
	
 snprintf(store_dir, sizeof(store_dir), "%s/.desc", dir);
 if(store_get_plugin_f(&p, pp, store_dir, file) < 0)
  return NULL;
  
 if(p.magic != MAGIC)
 	return NULL;
	
	
 if(p.id <= 0) return NULL;
    
 ret = emalloc(sizeof(struct arglist));   
 plug_set_id(ret, p.id);
 plug_set_category(ret, p.category);
 plug_set_fname(ret, file);
 plug_set_path(ret, p.path);
 plug_set_family(ret, p.family, NULL);

  al = str2arglist(p.required_ports);
 if ( al != NULL ) arg_add_value(ret, "required_ports", ARG_ARGLIST, -1, al);

 al = str2arglist(p.required_keys);
 if ( al != NULL ) arg_add_value(ret, "required_keys", ARG_ARGLIST, -1, al);

 al = str2arglist(p.required_udp_ports);
 if ( al != NULL ) arg_add_value(ret, "required_udp_ports", ARG_ARGLIST, -1, al)
;

 al = str2arglist(p.excluded_keys);
 if ( al != NULL ) arg_add_value(ret, "excluded_keys", ARG_ARGLIST, -1, al);

 al = str2arglist(p.dependencies);
 if ( al != NULL ) arg_add_value(ret, "DEPENDENCIES", ARG_ARGLIST, -1, al);

 
 if ( p.timeout != 0 ) arg_add_value(ret, "TIMEOUT", ARG_INT, -1, (void*)p.timeout);

 arg_add_value(ret, "NAME", ARG_STRING, strlen(p.name), estrdup(p.name));


 arg_add_value(ret, "preferences", ARG_ARGLIST, -1, prefs);
 
 if(p.has_prefs)
 {
 for(i=0;pp[i].type[0] != '\0';i++)
  { 
   _add_plugin_preference(prefs, p.name, pp[i].name, pp[i].type, pp[i].dfl);
  }
 }

 return ret;
}