Exemplo n.º 1
0
static exception_t register_skyeye_module(char* module_name, char* filename, void* handler){
	exception_t ret;
	skyeye_module_t* node;
	skyeye_module_t* list;
	list = get_module_list();
	//skyeye_log(Debug_log, __FUNCTION__, "module_name = %s\n", module_name);
	if(module_name == NULL|| filename == NULL)
		return Invarg_exp;

	node = malloc(sizeof(skyeye_module_t));
	if(node == NULL){
		skyeye_log(Error_log, __FUNCTION__, get_exp_str(Malloc_exp));
		return Malloc_exp;
	}
		
	node->module_name = strdup(module_name);
	if(node->module_name == NULL){
		free(node);
		return Malloc_exp;
	}

	node->filename = strdup(filename);
	if(node->filename == NULL){
		free(node->module_name);
		free(node);
		return Malloc_exp;
	}
	
	node->handler = handler;

	node->next = list;
	set_module_list(node);
	return No_exp;
}
Exemplo n.º 2
0
skyeye_module_t * get_module_by_name(const char* module_name){
	skyeye_module_t* list = get_module_list();
	while(list != NULL){
		if(!strncmp(list->module_name, module_name, strlen(module_name)))
			return list;
		list = list->next;
	}
	return NULL;
}
Exemplo n.º 3
0
	void _module_finished(Value module) {
		ModuleList& list = *get_module_list();
		for (ModuleList::iterator it = list.begin(); it != list.end(); ++it) {
			if ((*it)->module == module) {
				delete *it;
				list.erase(it);
				return;
			}
		}
	}
Exemplo n.º 4
0
void SKY_unload_all_modules(){
	skyeye_module_t* list = get_module_list();
        while(list != NULL){
		skyeye_module_t* node = list;
                list = list->next;
		
		//skyeye_log(Debug_log, __FUNCTION__, "Free module %s\n", node->module_name);
		/* unload a module and free its memory */
		if(node->handler != NULL)
			lt_dlclose(node->handler);
		if(node->module_name != NULL)
			skyeye_free(node->module_name);
		if(node->filename != NULL)
			skyeye_free(node->filename);
		skyeye_free(node);	
        }
	skyeye_modules->list = NULL;	
        return;
}
Exemplo n.º 5
0
static int modules_read_proc(char *page, char **start, off_t off,
				 int count, int *eof, void *data)
{
	int len = get_module_list(page);
	return proc_calc_metrics(page, start, off, count, eof, len);
}
Exemplo n.º 6
0
static void
modules_init (MBDesktop *mb)
{
  MBDesktopFolderModule *mod_details = NULL;
  void                  *handle = NULL;
  char                  *error;
  char                 **mods   = NULL;
  int                    n_mods = 0;
  int                    i, successes = 0;
  MBDesktopModuleslist  *module_current = NULL;

  mods = get_module_list(mb, &n_mods);

  if (mods == NULL)
    {
      fprintf(stderr, "matchbox-desktop: failed to load modules. Exiting ...\n");
      exit(1);
    }

  for (i = 0; i < n_mods; i++ )
    { 
      char *args = NULL;

      args = strchr(mods[i], ' ');

      if (args != NULL)
	{
	  *args = '\0'; args++;
	}

      printf("matchbox-desktop: loading %s with args %s\n", mods[i], 
	     args ? args : "( None )");

      if (i == 0 || (i > 0 && strcmp(mods[i], mods[i-1])))
	{
	  handle = dlopen (mods[i], RTLD_LAZY |RTLD_GLOBAL);

	  if (!handle) 
	    {
	      fputs (dlerror(), stderr);
	      continue;
	    }
	  
	  mod_details = dlsym(handle, "folder_module" );

	  if ((error = dlerror()) != NULL) 
	    {
	      fputs(error, stderr);
	      free(error);
	      continue;
	    }
	}

      if (mod_details->mod_init(mb, mod_details, args) != -1)
	{
	  /* add to out list of modules */
	  if (mb->modules == NULL)
	    {
	      mb->modules = malloc(sizeof(MBDesktopModuleslist));
	      memset(mb->modules, 0, sizeof(MBDesktopModuleslist));
	      
	      mb->modules->module_handle = mod_details;
	      mb->modules->dl_handle  = handle;
	      mb->modules->next          = NULL;
	      
	      module_current = mb->modules;
	    }
	  else
	    {
	      module_current->next = malloc(sizeof(MBDesktopModuleslist));
	      memset(module_current->next, 0, sizeof(MBDesktopModuleslist));
	      
	      module_current = module_current->next;
	      
	      module_current->module_handle = mod_details;
	      module_current->dl_handle     = handle;
	      module_current->next          = NULL;
	    }
	  successes++;
	}
      else
	{
	  fprintf(stderr,"matchbox-desktop: failed to initialise module %s\n",
		  mods[i]);
	  dlclose(handle);
	}
    }

  if (successes == 0)
    {
      fprintf(stderr, "matchbox-desktop: failed to load any item modules.\n");
    }
}
Exemplo n.º 7
0
static int get_root_array(char * page, int type, char **start, off_t offset, int length)
{
    switch (type) {
    case PROC_LOADAVG:
        return get_loadavg(page);

    case PROC_UPTIME:
        return get_uptime(page);

    case PROC_MEMINFO:
        return get_meminfo(page);

#ifdef CONFIG_PCI
    case PROC_PCI:
        return get_pci_list(page);
#endif

    case PROC_CPUINFO:
        return get_cpuinfo(page);

    case PROC_VERSION:
        return get_version(page);

#ifdef CONFIG_DEBUG_MALLOC
    case PROC_MALLOC:
        return get_malloc(page);
#endif

#ifdef CONFIG_MODULES
    case PROC_MODULES:
        return get_module_list(page);

    case PROC_KSYMS:
        return get_ksyms_list(page, start, offset, length);
#endif

    case PROC_STAT:
        return get_kstat(page);

    case PROC_DEVICES:
        return get_device_list(page);

    case PROC_INTERRUPTS:
        return get_irq_list(page);

    case PROC_FILESYSTEMS:
        return get_filesystem_list(page);

    case PROC_DMA:
        return get_dma_list(page);

    case PROC_IOPORTS:
        return get_ioport_list(page);
#ifdef CONFIG_BLK_DEV_MD
    case PROC_MD:
        return get_md_status(page);
#endif
#ifdef __SMP_PROF__
    case PROC_SMP_PROF:
        return get_smp_prof_list(page);
#endif
    case PROC_CMDLINE:
        return get_cmdline(page);

    case PROC_MTAB:
        return get_filesystem_info( page );
#ifdef CONFIG_RTC
    case PROC_RTC:
        return get_rtc_status(page);
#endif
    case PROC_LOCKS:
        return get_locks_status(page);
    }
    return -EBADF;
}
Exemplo n.º 8
0
static int array_read(struct inode * inode, struct file * file,char * buf, int count)
{
	char * page;
	int length;
	int end;
	unsigned int type, pid;

	if (count < 0)
		return -EINVAL;
	if (!(page = (char*) __get_free_page(GFP_KERNEL)))
		return -ENOMEM;
	type = inode->i_ino;
	pid = type >> 16;
	type &= 0x0000ffff;
	switch (type) {
		case 2:
			length = get_loadavg(page);
			break;
		case 3:
			length = get_uptime(page);
			break;
		case 4:
			length = get_meminfo(page);
			break;
		case 6:
			length = get_version(page);
			break;
		case 9:
			length = get_env(pid, page);
			break;
		case 10:
			length = get_arg(pid, page);
			break;
		case 11:
			length = get_stat(pid, page);
			break;
		case 12:
			length = get_statm(pid, page);
			break;
#ifdef CONFIG_DEBUG_MALLOC
		case 13:
			length = get_malloc(page);
			break;
#endif
		case 14:
			free_page((unsigned long) page);
			return read_core(inode, file, buf, count);
		case 15:
			length = get_maps(pid, page);
			break;
		case 16:
			length = get_module_list(page);
			break;
		case 17:
			length = get_kstat(page);
			break;
		default:
			free_page((unsigned long) page);
			return -EBADF;
	}
	if (file->f_pos >= length) {
		free_page((unsigned long) page);
		return 0;
	}
	if (count + file->f_pos > length)
		count = length - file->f_pos;
	end = count + file->f_pos;
	memcpy_tofs(buf, page + file->f_pos, count);
	free_page((unsigned long) page);
	file->f_pos = end;
	return count;
}