コード例 #1
0
static void hook_dump_entry()
{
	PLDR_DATA_TABLE_ENTRY table;
	entry_hook           *ehook;

	ExAcquireFastMutex(&dump_sync);

	if (dump_imgbase != NULL && (table = find_image(dump_imgbase)))
	{
		if (table->BaseDllName.Buffer != NULL && table->EntryPoint != NULL &&
			img_cmp(&table->BaseDllName, L"dump_") || img_cmp(&table->BaseDllName, L"hiber_"))
		{
			if (ehook = mm_alloc(sizeof(entry_hook), 0))
			{
				memcpy(ehook->code, jmp_code, sizeof(jmp_code));
				ppv(ehook->code + DEST_OFF)[0] = dump_driver_entry;
				ppv(ehook->code + PARM_OFF)[0] = ehook;
				ehook->old_entry  = table->EntryPoint;
				table->EntryPoint = pv(ehook->code);					
			}
		}
		dump_imgbase = NULL;
	}
	ExReleaseFastMutex(&dump_sync);
}
コード例 #2
0
ファイル: rboot.c プロジェクト: alonewolfx2/esp8266
// small stub method to ensure minimum stack space used
void call_user_start() {
	uint32 addr;
	stage2a *loader;
	
	addr = find_image();
	if (addr != 0) {
		loader = (stage2a*)entry_addr;
		loader(addr);
	}
}
コード例 #3
0
ファイル: skin_parser.c プロジェクト: ntj/rockbox
static int parse_image_display(struct skin_element *element,
                               struct wps_token *token,
                               struct wps_data *wps_data)
{
    char *label = element->params[0].data.text;
    char sublabel = '\0';
    int subimage;
    struct gui_img *img;
    struct image_display *id = skin_buffer_alloc(sizeof(struct image_display));

    if (element->params_count == 1 && strlen(label) <= 2)
    {
        /* backwards compatability. Allow %xd(Aa) to still work */
        sublabel = label[1];
        label[1] = '\0';
    }
    /* sanity check */
    img = find_image(label, wps_data);
    if (!img || !id)
    {
        return WPS_ERROR_INVALID_PARAM;
    }
    id->label = label;
    id->offset = 0;
    id->token = NULL;
    if (img->using_preloaded_icons)
    {
        token->type = SKIN_TOKEN_IMAGE_DISPLAY_LISTICON;
    }
    
    if (element->params_count > 1)
    {
        if (element->params[1].type == CODE)
            id->token = element->params[1].data.code->data;
        /* specify a number. 1 being the first subimage (i.e top) NOT 0 */
        else if (element->params[1].type == INTEGER)
            id->subimage = element->params[1].data.number - 1;
        if (element->params_count > 2)
            id->offset = element->params[2].data.number;
    }
    else
    {
        if ((subimage = get_image_id(sublabel)) != -1)
        {
            if (subimage >= img->num_subimages)
                return WPS_ERROR_INVALID_PARAM;
            id->subimage = subimage;
        } else {
            id->subimage = 0;
        }
    }
    token->value.data = id;
    return 0;
}
コード例 #4
0
ファイル: digest_cmd.c プロジェクト: 1stMaster/syslinux
/**
 * The "digest" command
 *
 * @v argc		Argument count
 * @v argv		Argument list
 * @v digest		Digest algorithm
 * @ret rc		Exit code
 */
static int digest_exec ( int argc, char **argv,
			 struct digest_algorithm *digest ) {
	const char *image_name;
	struct image *image;
	uint8_t digest_ctx[digest->ctxsize];
	uint8_t digest_out[digest->digestsize];
	uint8_t buf[128];
	size_t offset;
	size_t len;
	size_t frag_len;
	int i;
	unsigned j;

	if ( argc < 2 ||
	     !strcmp ( argv[1], "--help" ) ||
	     !strcmp ( argv[1], "-h" ) ) {
		digest_syntax ( argv );
		return 1;
	}

	for ( i = 1 ; i < argc ; i++ ) {
		image_name = argv[i];

		/* find image */
		image = find_image ( image_name );
		if ( ! image ) {
			printf ( "No such image: %s\n", image_name );
			continue;
		}
		offset = 0;
		len = image->len;

		/* calculate digest */
		digest_init ( digest, digest_ctx );
		while ( len ) {
			frag_len = len;
			if ( frag_len > sizeof ( buf ) )
				frag_len = sizeof ( buf );
			copy_from_user ( buf, image->data, offset, frag_len );
			digest_update ( digest, digest_ctx, buf, frag_len );
			len -= frag_len;
			offset += frag_len;
		}
		digest_final ( digest, digest_ctx, digest_out );

		for ( j = 0 ; j < sizeof ( digest_out ) ; j++ )
			printf ( "%02x", digest_out[j] );

		printf ( "  %s\n", image->name );
	}

	return 0;
}
コード例 #5
0
void
cb_compose_images_set_image_progress (CbComposeImages *self,
                                      const char      *image_path,
                                      double           progress)
{
  const Image *image = find_image (self, image_path);

  if (image == NULL)
    return;

  gtk_widget_show (image->progressbar);
  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (image->progressbar), progress);
}
コード例 #6
0
ファイル: parseopt.c プロジェクト: Phlogistique/iPXE
/**
 * Parse image name
 *
 * @v text		Text
 * @ret image		Image
 * @ret rc		Return status code
 */
int parse_image ( const char *text, struct image **image ) {

	/* Sanity check */
	assert ( text != NULL );

	/* Find network device */
	*image = find_image ( text );
	if ( ! *image ) {
		printf ( "\"%s\": no such image\n", text );
		return -ENOENT;
	}

	return 0;
}
コード例 #7
0
ファイル: hack.cpp プロジェクト: gdbinit/Disable-m3u
void
disable_m3u_processing(struct header_info *hi)
{
    if (find_image(hi) != 0)
    {
        ERROR_MSG("Failed to find valid image.");
        return;
    }
    
    if (find_and_patch_addresses(hi) != 0)
    {
        ERROR_MSG("Failed to find and patch addresses.");
        return;
    }
    hi->active = 1;
}
コード例 #8
0
BImageResources::BImageResources(void* memAddr)
{
    image_id image = find_image(memAddr);
    image_info info;
    if (get_image_info(image, &info) == B_OK) {
#if _SUPPORTS_RESOURCES
        BFile file(&info.name[0], B_READ_ONLY);
#else
        BString name(&info.name[0]);
        name += ".rsrc";
        BFile file(name.String(), B_READ_ONLY);
#endif
        if (file.InitCheck() == B_OK)
            fResources.SetTo(&file);
    }
}
コード例 #9
0
void
cb_compose_images_end_image_progress (CbComposeImages *self,
                                      const char      *image_path,
                                      const char      *error_message)
{
  const Image *image = find_image (self, image_path);

  if (image == NULL)
    return;

  gtk_widget_hide (image->progressbar);

  if (error_message != NULL)
    {
      g_warning (G_STRLOC ": Error in image upload: %s", error_message);
    }
}
コード例 #10
0
ファイル: find_paths.cpp プロジェクト: looncraz/haiku
status_t
__find_path_etc(const void* codePointer, const char* dependency,
	const char* architecture, path_base_directory baseDirectory,
	const char* subPath, uint32 flags, char* pathBuffer, size_t bufferSize)
{
	if (pathBuffer == NULL)
		return B_BAD_VALUE;

	// resolve codePointer to image info
	image_info imageInfo;
	status_t error = find_image(codePointer, imageInfo);
	if (error != B_OK)
		return error;

	if (architecture == NULL)
		architecture = __get_architecture();

	return internal_path_for_path(imageInfo.name, sizeof(imageInfo.name),
		dependency, architecture, baseDirectory, subPath, flags, pathBuffer,
		bufferSize);
}
コード例 #11
0
ファイル: elf.c プロジェクト: HTshandou/newos
addr_t elf_lookup_symbol(image_id id, const char *_symbol)
{
	struct elf_image_info *image;
	struct Elf32_Sym *sym;
	const char *symbol;

	/* some architectures prepend a '_' to symbols, so lets do it here for lookups */
#if ELF_PREPEND_UNDERSCORE
	char new_symbol[SYS_MAX_NAME_LEN];

	new_symbol[0] = '_';
	new_symbol[1] = 0;
	strlcat(new_symbol, _symbol, SYS_MAX_NAME_LEN);
	symbol = new_symbol;
#else
	symbol = _symbol;
#endif

//	dprintf( "elf_lookup_symbol: %s\n", symbol );

	image = find_image(id);
	if(!image)
		return 0;

	sym = elf_find_symbol(image, symbol);
	if(!sym)
		return 0;

	if(sym->st_shndx == SHN_UNDEF) {
		return 0;
	}

//	dprintf( "found: %x (%x + %x)\n", sym->st_value + image->regions[0].delta,
//		sym->st_value, image->regions[0].delta );
	return sym->st_value + image->regions[0].delta;
}
コード例 #12
0
void load_graphics_jf()
{
	meter = find_image("jf-frame.png");
	meter_buf = find_image("jf-frame-overlay.png");
}
コード例 #13
0
ファイル: scope.c プロジェクト: kronihias/meterbridge-0.9.2
void load_graphics_scope()
{
	meter = find_image("scope-frame.png");
	meter_buf = find_image("scope-frame-overlay.png");
}
コード例 #14
0
ファイル: interactive_pga.c プロジェクト: gap-packages/anupq
void interactive_pga(Logical group_present,
                     FILE *StartFile,
                     int group_nmr,
                     int ***auts,
                     struct pga_vars *pga,
                     struct pcp_vars *pcp)
{
   struct pga_vars flag;
   int option;
   Logical soluble_group = TRUE;

   FILE *OutputFile = 0;
   FILE *LINK_input = 0;

   char *StartName = 0;
   int t;

   int **perms = 0;
   int index;
   int **S = 0;
   int k;
   int K;
   int label;
   int *a = 0, *b = 0;
   char *c = 0;
   int *orbit_length = 0;
   int nmr_of_exponents;
   int *subset = 0;
   int alpha;
   int upper_step;
   int rep;
   int i;

   list_interactive_pga_menu();

   do {
      option = read_option(MAX_INTERACTIVE_OPTION);
      switch (option) {

      case -1:
         list_interactive_pga_menu();
         break;

      case SUPPLY_AUTS:
         auts = read_auts(PGA, &pga->m, &nmr_of_exponents, pcp);
#ifdef HAVE_GMP
         autgp_order(pga, pcp);
#endif
         pga->soluble = TRUE;
         start_group(&StartFile, auts, pga, pcp);
         break;

      case EXTEND_AUTS:
         extend_automorphisms(auts, pga->m, pcp);
         print_auts(pga->m, pcp->lastg, auts, pcp);
         break;

      case RESTORE_GP:
         StartName = GetString("Enter input file name: ");
         StartFile = OpenFileInput(StartName);
         if (StartFile != NULL) {
            read_value(TRUE, "Which group? ", &group_nmr, 0);
            auts = restore_group(TRUE, StartFile, group_nmr, pga, pcp);
            RESET(StartFile);
         }
         break;

      case DISPLAY_GP:
         print_presentation(FALSE, pcp);
         print_structure(1, pcp->lastg, pcp);
         print_pcp_relations(pcp);
         break;

      case SINGLE_STAGE:
         t = runTime();
         if (group_present && pga->m == 0)
            start_group(&StartFile, auts, pga, pcp);
         assert(OutputFile);
         construct(1,
                   &flag,
                   SINGLE_STAGE,
                   OutputFile,
                   StartFile,
                   0,
                   ALL,
                   group_nmr,
                   pga,
                   pcp);
         t = runTime() - t;
         printf("Time for intermediate stage is %.2f seconds\n", t * CLK_SCALE);
         break;

      case DEGREE:
         read_step_size(pga, pcp);
         read_subgroup_rank(&k);
         query_exponent_law(pga);
         enforce_laws(pga, pga, pcp);
         extend_automorphisms(auts, pga->m, pcp);
         step_range(k, &pga->s, &upper_step, auts, pga, pcp);

         if (pga->s > upper_step)
            printf("Desired step size is invalid for current group\n");
         else {
            if (pga->s < upper_step) {
               printf("The permitted relative step sizes range from %d to %d\n",
                      pga->s,
                      upper_step);
               read_value(
                   TRUE, "Input the chosen relative step size: ", &pga->s, 0);
            }


            store_definition_sets(pga->r, pga->s, pga->s, pga);
            get_definition_sets(pga);
            pga->print_degree = TRUE;
            compute_degree(pga);
            pga->print_degree = FALSE;
         }
         break;

      case PERMUTATIONS:
         if (pga->Degree != 0) {
            t = runTime();

            query_solubility(pga);
            pga->trace = FALSE;
            if (pga->soluble)
               query_space_efficiency(pga);
            else
               pga->space_efficient = FALSE;
            query_perm_information(pga);

            strip_identities(auts, pga, pcp);
            soluble_group =
                (pga->soluble || pga->Degree == 1 || pga->nmr_of_perms == 0);
            if (!soluble_group) {
#if defined(GAP_LINK)
               StartGapFile(pga);
#else
#if defined(GAP_LINK_VIA_FILE)
               start_GAP_file(&LINK_input, auts, pga, pcp);
#endif
#endif
            }
            perms = permute_subgroups(LINK_input, &a, &b, &c, auts, pga, pcp);

#if defined(GAP_LINK_VIA_FILE)
            if (!soluble_group)
               CloseFile(LINK_input);
#endif
            t = runTime() - t;
            printf("Time to compute permutations is %.2f seconds\n",
                   t * CLK_SCALE);
         } else
            printf("You must first select option %d\n", DEGREE);

         break;

      case ORBITS:
         orbit_option(option, perms, &a, &b, &c, &orbit_length, pga);
         break;

      case STABILISERS:
      case STABILISER:
         assert(perms);
         stabiliser_option(
             option, auts, perms, a, b, c, orbit_length, pga, pcp);
         /*
           free_space (pga->soluble, perms, orbit_length,
           a, b, c, pga);
           */
         break;

      case MATRIX_TO_LABEL:
         S = allocate_matrix(pga->s, pga->q, 0, FALSE);
         subset = allocate_vector(pga->s, 0, FALSE);
         printf("Input the %d x %d subgroup matrix:\n", pga->s, pga->q);
         read_matrix(S, pga->s, pga->q);
         K = echelonise_matrix(S, pga->s, pga->q, pga->p, subset, pga);
         printf("The standard matrix is:\n");
         print_matrix(S, pga->s, pga->q);
         printf("The label is %d\n", subgroup_to_label(S, K, subset, pga));
         free_vector(subset, 0);
         break;

      case LABEL_TO_MATRIX:
         read_value(TRUE, "Input allowable subgroup label: ", &label, 1);
         S = label_to_subgroup(&index, &subset, label, pga);
         printf("The corresponding standard matrix is\n");
         print_matrix(S, pga->s, pga->q);
         break;

      case IMAGE:
         t = runTime();
         /*
           invert_automorphisms (auts, pga, pcp);
           print_auts (pga->m, pcp->lastg, auts, pcp);
           */
         printf("Input the subgroup label and automorphism number: ");
         read_value(TRUE, "", &label, 1);
         read_value(FALSE, "", &alpha, 1);
         printf("Image is %d\n", find_image(label, auts[alpha], pga, pcp));
         t = runTime() - t;
         printf("Computation time in seconds is %.2f\n", t * CLK_SCALE);
         break;

      case SUBGROUP_RANK:
         read_subgroup_rank(&k);
         printf("Closure of initial segment subgroup has rank %d\n",
                close_subgroup(k, auts, pga, pcp));
         break;

      case ORBIT_REP:
         printf("Input label for subgroup: ");
         read_value(TRUE, "", &label, 1);
         rep = abs(a[label]);
         for (i = 1; i <= pga->nmr_orbits && pga->rep[i] != rep; ++i)
            ;
         printf("Subgroup with label %d has representative %d and is in orbit "
                "%d\n",
                label,
                rep,
                i);
         break;


      case COMPACT_DESCRIPTION:
         Compact_Description = TRUE;
         read_value(TRUE,
                    "Lower bound for order (0 for all groups generated)? ",
                    &Compact_Order,
                    0);
         break;

      case AUT_CLASSES:
         t = runTime();
         permute_elements();
         t = runTime() - t;
         printf("Time to compute orbits is %.2f seconds\n", t * CLK_SCALE);
         break;

      /*
        printf ("Input label: ");
        scanf ("%d", &l);
        process_complete_orbit (a, l, pga, pcp);
        break;

        case TEMP:
        printf ("Input label: ");
        scanf ("%d", &l);
        printf ("Input label: ");
        scanf ("%d", &u);
        for (i = l; i <= u; ++i) {
        x = IsValidAllowableSubgroup (i, pga);
        printf ("%d is %d\n", i, x);
        }
        StartName = GetString ("Enter output file name: ");
        OutputFile = OpenFileOutput (StartName);
        part_setup_reps (pga->rep, pga->nmr_orbits, orbit_length, perms, a, b,
        c,
        auts, OutputFile, OutputFile, pga, pcp);

        list_word (pga, pcp);

        read_value (TRUE, "Input the rank of the subgroup: ", &pga->q, 1);
        strip_identities (auts, pga, pcp);
        break;
        */

      case EXIT:
      case MAX_INTERACTIVE_OPTION:
         printf("Exiting from interactive p-group generation menu\n");
         break;

      } /* switch */

   } while (option != 0 && option != MAX_INTERACTIVE_OPTION);

#if defined(GAP_LINK)
   if (!soluble_group)
      QuitGap();
#endif
}
コード例 #15
0
ファイル: monodiet.c プロジェクト: ANahr/mono
static void
load_roots (const char* filename)
{
	FILE *file;
	char buf [2048];
	char *p, *s;
	int line = 0;
	MonoImage *image = NULL;
	MonoClass *klass = NULL;
	MonoClassField *field;
	MonoMethodDesc *mdesc;
	MonoMethod *method;

	if (!(file = fopen (filename, "r")))
		return;
	
	while (fgets (buf, sizeof (buf), file)) {
		/* FIXME:
		 * decide on the format to use to express types, fields, methods,
		 * maybe the same used on output from the tool, but with explicit
		 * names and signatures instead of token indexes
		 * add wildcard support
		 */
		++line;
		s = buf;
		while (*s && g_ascii_isspace (*s)) ++s;
		switch (*s) {
		case 0:
		case '#':
			continue; /* comment */
		case '[':
			p = strchr (s, ']');
			if (!p)
				g_error ("invalid assembly format at line %d\n", line);
			*p = 0;
			p = s + 1;
			image = find_image (p);
			if (!image)
				g_error ("image not loaded: %s\n", p);
			klass = NULL;
		 	break;
		case 'T':
			if (s [1] != ':')
				g_error ("invalid type format at line %d\n", line);
			if (!image)
				break;
			klass = find_class (image, s + 2);
			break;
		case 'F':
			if (s [1] != ':')
				g_error ("invalid field format at line %d\n", line);
			if (!image || !klass)
				break;
			p = s + 2;
			if (*p == '*') {
				handle_type (klass, TYPE_FIELDS);
				break;
			}
			field = mono_class_get_field_from_name (klass, p);
			if (!field)
				g_warning ("no field '%s' at line %d\n", p, line);
			else
				add_field (field);
			break;
		case 'M':
			if (s [1] != ':')
				g_error ("invalid method format at line %d\n", line);
			if (!image || !klass)
				break;
			p = s + 2;
			if (*p == '*') {
				handle_type (klass, TYPE_METHODS);
				break;
			}
			mdesc = mono_method_desc_new (p, FALSE);
			if (!mdesc) {
				g_error ("invalid method desc at line %d\n", line);
			}
			method = mono_method_desc_search_in_class (mdesc, klass);
			if (!method)
				g_warning ("no method '%s' at line %d\n", p, line);
			else
				add_types_from_method (method);
			mono_method_desc_free (mdesc);
			break;
		default:
			g_error ("invalid format at line %d\n", line);
		}
	}
	fclose (file);
}
コード例 #16
0
ファイル: skin_parser.c プロジェクト: ntj/rockbox
static int parse_progressbar_tag(struct skin_element* element,
                                 struct wps_token *token,
                                 struct wps_data *wps_data)
{
#ifdef HAVE_LCD_BITMAP
    struct progressbar *pb;
    struct viewport *vp = &curr_vp->vp;
    struct skin_tag_parameter *param = element->params;
    int curr_param = 0;
    char *image_filename = NULL;
    
    if (element->params_count == 0 && 
        element->tag->type != SKIN_TOKEN_PROGRESSBAR)
        return 0; /* nothing to do */
    pb = (struct progressbar*)skin_buffer_alloc(sizeof(struct progressbar));
    
    token->value.data = pb;
    
    if (!pb)
        return WPS_ERROR_INVALID_PARAM;
    pb->vp = vp;
    pb->follow_lang_direction = follow_lang_direction > 0;
    pb->nofill = false;
    pb->nobar = false;
    pb->image = NULL;
    pb->slider = NULL;
    pb->invert_fill_direction = false;
    pb->horizontal = true;
    
    if (element->params_count == 0)
    {
        pb->x = 0;
        pb->width = vp->width;
        pb->height = SYSFONT_HEIGHT-2;
        pb->y = -1; /* Will be computed during the rendering */
        pb->type = element->tag->type;
        return 0;
    }
    
    /* (x, y, width, height, ...) */
    if (!isdefault(param))
        pb->x = param->data.number;
    else
        pb->x = 0;
    param++;
    
    if (!isdefault(param))
        pb->y = param->data.number;
    else
        pb->y = -1; /* computed at rendering */
    param++;
    
    if (!isdefault(param))
        pb->width = param->data.number;
    else
        pb->width = vp->width - pb->x;
    param++;
    
    if (!isdefault(param))
    {
        /* A zero height makes no sense - reject it */
        if (param->data.number == 0)
            return WPS_ERROR_INVALID_PARAM;

        pb->height = param->data.number;
    }
    else
    {
        if (vp->font > FONT_UI)
            pb->height = -1; /* calculate at display time */
        else
        {
#ifndef __PCTOOL__
            pb->height = font_get(vp->font)->height;
#else
            pb->height = 8;
#endif
        }
    }
    /* optional params, first is the image filename if it isnt recognised as a keyword */
    
    curr_param = 4;
    if (isdefault(&element->params[curr_param]))
    {
        param++;
        curr_param++;
    }

    pb->horizontal = pb->width > pb->height;
    while (curr_param < element->params_count)
    {
        param++;
        if (!strcmp(param->data.text, "invert"))
            pb->invert_fill_direction = true;
        else if (!strcmp(param->data.text, "nofill"))
            pb->nofill = true;
        else if (!strcmp(param->data.text, "nobar"))
            pb->nobar = true;
        else if (!strcmp(param->data.text, "slider"))
        {
            if (curr_param+1 < element->params_count)
            {
                curr_param++;
                param++;
                pb->slider = find_image(param->data.text, wps_data);
            }
            else /* option needs the next param */
                return -1;
        }
        else if (!strcmp(param->data.text, "image"))
        {
            if (curr_param+1 < element->params_count)
            {
                curr_param++;
                param++;
                image_filename = param->data.text;
                
            }
            else /* option needs the next param */
                return -1;
        }
        else if (!strcmp(param->data.text, "vertical"))
        {
            pb->horizontal = false;
            if (isdefault(&element->params[3]))
                pb->height = vp->height - pb->y;
        }
        else if (!strcmp(param->data.text, "horizontal"))
            pb->horizontal = true;
        else if (curr_param == 4)
            image_filename = param->data.text;
            
        curr_param++;
    }

    if (image_filename)
    {
        pb->image = find_image(image_filename, wps_data);
        if (!pb->image) /* load later */
        {           
            struct gui_img* img = (struct gui_img*)skin_buffer_alloc(sizeof(struct gui_img));
            if (!img)
                return WPS_ERROR_INVALID_PARAM;
            /* save a pointer to the filename */
            img->bm.data = (char*)image_filename;
            img->label = image_filename;
            img->x = 0;
            img->y = 0;
            img->num_subimages = 1;
            img->always_display = false;
            img->display = -1;
            img->using_preloaded_icons = false;
            img->vp = &curr_vp->vp;
            struct skin_token_list *item = 
                    (struct skin_token_list *)new_skin_token_list_item(NULL, img);
            if (!item)
                return WPS_ERROR_INVALID_PARAM;
            add_to_ll_chain(&wps_data->images, item);
            pb->image = img;
        }
    }
        
        
    if (token->type == SKIN_TOKEN_VOLUME)
        token->type = SKIN_TOKEN_VOLUMEBAR;
    else if (token->type == SKIN_TOKEN_BATTERY_PERCENT)
        token->type = SKIN_TOKEN_BATTERY_PERCENTBAR;
    else if (token->type == SKIN_TOKEN_TUNER_RSSI)
        token->type = SKIN_TOKEN_TUNER_RSSI_BAR;
    pb->type = token->type;
        
    return 0;
    
#else
    (void)element;
    if (token->type == SKIN_TOKEN_PROGRESSBAR ||
        token->type == SKIN_TOKEN_PLAYER_PROGRESSBAR)
    {
        wps_data->full_line_progressbar = 
                        token->type == SKIN_TOKEN_PLAYER_PROGRESSBAR;
    }
    return 0;

#endif
}
コード例 #17
0
ファイル: skin_parser.c プロジェクト: ntj/rockbox
static int parse_image_load(struct skin_element *element,
                            struct wps_token *token,
                            struct wps_data *wps_data)
{
    const char* filename;
    const char* id;
    int x,y;
    struct gui_img *img;

    /* format: %x(n,filename.bmp,x,y)
       or %xl(n,filename.bmp,x,y)
       or %xl(n,filename.bmp,x,y,num_subimages)
    */

    id = element->params[0].data.text;
    filename = element->params[1].data.text;
    x = element->params[2].data.number;
    y = element->params[3].data.number;

    /* check the image number and load state */
    if(find_image(id, wps_data))
    {
        /* Invalid image ID */
        return WPS_ERROR_INVALID_PARAM;
    }
    img = (struct gui_img*)skin_buffer_alloc(sizeof(struct gui_img));
    if (!img)
        return WPS_ERROR_INVALID_PARAM;
    /* save a pointer to the filename */
    img->bm.data = (char*)filename;
    img->label = id;
    img->x = x;
    img->y = y;
    img->num_subimages = 1;
    img->always_display = false;
    img->display = -1;
    img->using_preloaded_icons = false;

    /* save current viewport */
    img->vp = &curr_vp->vp;

    if (token->type == SKIN_TOKEN_IMAGE_DISPLAY)
    {
        img->always_display = true;
    }
    else if (element->params_count == 5)
    {
        img->num_subimages = element->params[4].data.number;
        if (img->num_subimages <= 0)
            return WPS_ERROR_INVALID_PARAM;
    }

    if (!strcmp(img->bm.data, "__list_icons__"))
    {
        img->num_subimages = Icon_Last_Themeable;
        img->using_preloaded_icons = true;
    }
    
    struct skin_token_list *item = 
            (struct skin_token_list *)new_skin_token_list_item(NULL, img);
    if (!item)
        return WPS_ERROR_INVALID_PARAM;
    add_to_ll_chain(&wps_data->images, item);

    return 0;
}
コード例 #18
0
ファイル: mainmenu.cpp プロジェクト: edeproject/svn
void MainMenu::build_menu_item(Fl_XmlNode *node)
{
    if(!node) return;

    int type = str_to_type(node->get_attribute("Type"));
    if(type==ITEM_NONE) return;

    Fl_Widget *w=0;
    EItemGroup *g=0;
    EItem *i=0;

    switch(type) {
    case ITEM_EXEC:
        i = new EItem(this);
        i->callback((Fl_Callback*)cb_exec_item);
        set_exec(i, node->get_attribute("Exec"));
        i->image(run_pix);
        w = (Fl_Widget *)i;
        break;

    case ITEM_APPDIR:
        g = new EItemGroup(this, APP_GROUP);
        g->image(programs_pix);
        g->dir(get_item_dir(node));
        break;

    case ITEM_SUBDIR:
        g = new EItemGroup(this, APP_GROUP);
        g->image(programs_pix);
        break;

    case ITEM_FILEBROWSER:
        g = new EItemGroup(this, BROWSER_GROUP);
        g->dir(get_item_dir(node));
        g->image(find_pix);
        break;

    case ITEM_DIVIDER:
        w = (Fl_Widget *)new Fl_Menu_Divider();
        break;
    }

    if(g) {
        g->begin();
        w = (Fl_Widget*)g;
    }

    Fl_Image *im=0;
    if(node->has_attribute("Icon")) {
        im = find_image(node->get_attribute("Icon"));
    } else {
        Fl_String im_path(node->get_attribute("Exec"));
        im_path += ".png";
        im = find_image(im_path);
    }
    if(im) w->image(im);

    Fl_String label = get_item_name(node);
    w->label(label);

    for(uint n=0; n<node->children(); n++) {
        Fl_XmlNode *np = node->child(n);
        if((np->is_element() || np->is_leaf()) && np->name()=="Item")
            build_menu_item(np);
    }

    if(w->is_group())
        ((Fl_Group*)w)->end();
}
コード例 #19
0
ファイル: wps_debug.c プロジェクト: Megaco/rockbox
static char *get_token_desc(struct wps_token *token, char *buf,
                            int bufsize, struct wps_data *data)
{
    unsigned i;
#ifndef HAVE_LCD_BITMAP
    (void)data; /* kill charcell warning */
#endif
    bool next = token->next;
    switch(token->type)
    {
        case WPS_NO_TOKEN:
            snprintf(buf, bufsize, "No token");
            break;

        case WPS_TOKEN_UNKNOWN:
            snprintf(buf, bufsize, "Unknown token");
            break;

        case WPS_TOKEN_CHARACTER:
            if (token->value.c == '\n')
                snprintf(buf, bufsize, "Character '\\n'");
            else
                snprintf(buf, bufsize, "Character '%c'",
                        token->value.c);
            break;

        case WPS_TOKEN_STRING:
            snprintf(buf, bufsize, "String '%s'",
                     (char*)token->value.data);
            break;
        case WPS_TOKEN_TRANSLATEDSTRING:
            snprintf(buf, bufsize, "String ID '%d'", token->value.i);
            break;

#ifdef HAVE_LCD_BITMAP
        case WPS_TOKEN_ALIGN_LEFT:
            snprintf(buf, bufsize, "align left");
            break;

        case WPS_TOKEN_ALIGN_CENTER:
            snprintf(buf, bufsize, "align center");
            break;

        case WPS_TOKEN_ALIGN_RIGHT:
            snprintf(buf, bufsize, "align right");
            break;
#endif

        case WPS_TOKEN_SUBLINE_TIMEOUT:
            snprintf(buf, bufsize, "subline timeout value: %d",
                    token->value.i);
            break;

        case WPS_TOKEN_CONDITIONAL:
            snprintf(buf, bufsize, "conditional, %d options",
                    token->value.i);
            break;

        case WPS_TOKEN_CONDITIONAL_START:
            snprintf(buf, bufsize, "conditional start, next cond: %d",
                    token->value.i);
            break;

        case WPS_TOKEN_CONDITIONAL_OPTION:
            snprintf(buf, bufsize, "conditional option, next cond: %d",
                    token->value.i);
            break;

        case WPS_TOKEN_CONDITIONAL_END:
            snprintf(buf, bufsize, "conditional end");
            break;

#ifdef HAVE_LCD_BITMAP
        case WPS_TOKEN_IMAGE_PRELOAD:
            snprintf(buf, bufsize, "preload image");
            break;

        case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
        {
            char subimage = '\0';
            char label = token->value.i&0xFF;
            struct gui_img *img = find_image(label, data);
            if (img && img->num_subimages > 1)
                subimage = 'a' + (token->value.i>>8);
            snprintf(buf, bufsize, "display preloaded image '%c%c'",
                    label, subimage);
        }
            break;

        case WPS_TOKEN_IMAGE_DISPLAY:
            snprintf(buf, bufsize, "display image");
            break;
#endif

#ifdef HAS_BUTTON_HOLD
        case WPS_TOKEN_MAIN_HOLD:
            snprintf(buf, bufsize, "mode hold");
            break;
#endif

#ifdef HAS_REMOTE_BUTTON_HOLD
        case WPS_TOKEN_REMOTE_HOLD:
            snprintf(buf, bufsize, "mode remote hold");
            break;
#endif

        case WPS_TOKEN_REPEAT_MODE:
            snprintf(buf, bufsize, "mode repeat");
            break;

        case WPS_TOKEN_PLAYBACK_STATUS:
            snprintf(buf, bufsize, "mode playback");
            break;
            
        case WPS_TOKEN_RTC_PRESENT:
            snprintf(buf, bufsize, "rtc: present?");
            break;
        case WPS_TOKEN_RTC_DAY_OF_MONTH:
            snprintf(buf, bufsize, "rtc: day of month (01..31)");
            break;
        case WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED:
            snprintf(buf, bufsize,
                    "rtc: day of month, blank padded ( 1..31)");
            break;
        case WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED:
            snprintf(buf, bufsize, "rtc: hour (00..23)");
            break;
        case WPS_TOKEN_RTC_HOUR_24:
            snprintf(buf, bufsize, "rtc: hour ( 0..23)");
            break;
        case WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED:
            snprintf(buf, bufsize, "rtc: hour (01..12)");
            break;
        case WPS_TOKEN_RTC_HOUR_12:
            snprintf(buf, bufsize, "rtc: hour ( 1..12)");
            break;
        case WPS_TOKEN_RTC_MONTH:
            snprintf(buf, bufsize, "rtc: month (01..12)");
            break;
        case WPS_TOKEN_RTC_MINUTE:
            snprintf(buf, bufsize, "rtc: minute (00..59)");
            break;
        case WPS_TOKEN_RTC_SECOND:
            snprintf(buf, bufsize, "rtc: second (00..59)");
            break;
        case WPS_TOKEN_RTC_YEAR_2_DIGITS:
            snprintf(buf, bufsize,
                    "rtc: last two digits of year (00..99)");
            break;
        case WPS_TOKEN_RTC_YEAR_4_DIGITS:
            snprintf(buf, bufsize, "rtc: year (1970...)");
            break;
        case WPS_TOKEN_RTC_AM_PM_UPPER:
            snprintf(buf, bufsize,
                    "rtc: upper case AM or PM indicator");
            break;
        case WPS_TOKEN_RTC_AM_PM_LOWER:
            snprintf(buf, bufsize,
                    "rtc: lower case am or pm indicator");
            break;
        case WPS_TOKEN_RTC_WEEKDAY_NAME:
            snprintf(buf, bufsize,
                    "rtc: abbreviated weekday name (Sun..Sat)");
            break;
        case WPS_TOKEN_RTC_MONTH_NAME:
            snprintf(buf, bufsize,
                    "rtc: abbreviated month name (Jan..Dec)");
            break;
        case WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON:
            snprintf(buf, bufsize,
                    "rtc: day of week (1..7); 1 is Monday");
            break;
        case WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN:
            snprintf(buf, bufsize,
                    "rtc: day of week (0..6); 0 is Sunday");
            break;

#if (CONFIG_CODEC == SWCODEC)
        case WPS_TOKEN_CROSSFADE:
            snprintf(buf, bufsize, "crossfade");
            break;

        case WPS_TOKEN_REPLAYGAIN:
            snprintf(buf, bufsize, "replaygain");
            break;
#endif

#ifdef HAVE_ALBUMART
        case WPS_TOKEN_ALBUMART_DISPLAY:
            snprintf(buf, bufsize, "album art display");
            break;

        case WPS_TOKEN_ALBUMART_FOUND:
            snprintf(buf, bufsize, "%strack album art conditional",
                     next_str(next));
            break;
#endif

#ifdef HAVE_LCD_BITMAP
        case WPS_TOKEN_IMAGE_BACKDROP:
            snprintf(buf, bufsize, "backdrop image");
            break;

        case WPS_TOKEN_IMAGE_PROGRESS_BAR:
            snprintf(buf, bufsize, "progressbar bitmap");
            break;

        case WPS_TOKEN_PEAKMETER:
            snprintf(buf, bufsize, "peakmeter");
            break;
#endif

        case WPS_TOKEN_PROGRESSBAR:
            snprintf(buf, bufsize, "progressbar");
            break;

#ifdef HAVE_LCD_CHARCELLS
        case WPS_TOKEN_PLAYER_PROGRESSBAR:
            snprintf(buf, bufsize, "full line progressbar");
            break;
#endif

        case WPS_TOKEN_TRACK_TIME_ELAPSED:
            snprintf(buf, bufsize, "time elapsed in track");
            break;

        case WPS_TOKEN_TRACK_ELAPSED_PERCENT:
            snprintf(buf, bufsize, "played percentage of track");
            break;

        case WPS_TOKEN_PLAYLIST_ENTRIES:
            snprintf(buf, bufsize, "number of entries in playlist");
            break;

        case WPS_TOKEN_PLAYLIST_NAME:
            snprintf(buf, bufsize, "playlist name");
            break;

        case WPS_TOKEN_PLAYLIST_POSITION:
            snprintf(buf, bufsize, "position in playlist");
            break;

        case WPS_TOKEN_TRACK_TIME_REMAINING:
            snprintf(buf, bufsize, "time remaining in track");
            break;

        case WPS_TOKEN_PLAYLIST_SHUFFLE:
            snprintf(buf, bufsize, "playlist shuffle mode");
            break;

        case WPS_TOKEN_TRACK_LENGTH:
            snprintf(buf, bufsize, "track length");
            break;

        case WPS_TOKEN_VOLUME:
            snprintf(buf, bufsize, "volume");
            break;

        case WPS_TOKEN_METADATA_ARTIST:
            snprintf(buf, bufsize, "%strack artist",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_COMPOSER:
            snprintf(buf, bufsize, "%strack composer",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_ALBUM:
            snprintf(buf, bufsize, "%strack album",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_GROUPING:
            snprintf(buf, bufsize, "%strack grouping",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_GENRE:
            snprintf(buf, bufsize, "%strack genre",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_DISC_NUMBER:
            snprintf(buf, bufsize, "%strack disc", next_str(next));
            break;

        case WPS_TOKEN_METADATA_TRACK_NUMBER:
            snprintf(buf, bufsize, "%strack number",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_TRACK_TITLE:
            snprintf(buf, bufsize, "%strack title",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_VERSION:
            snprintf(buf, bufsize, "%strack ID3 version",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_ALBUM_ARTIST:
            snprintf(buf, bufsize, "%strack album artist",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_COMMENT:
            snprintf(buf, bufsize, "%strack comment",
                    next_str(next));
            break;

        case WPS_TOKEN_METADATA_YEAR:
            snprintf(buf, bufsize, "%strack year", next_str(next));
            break;

#ifdef HAVE_TAGCACHE
        case WPS_TOKEN_DATABASE_PLAYCOUNT:
            snprintf(buf, bufsize, "track playcount (database)");
            break;

        case WPS_TOKEN_DATABASE_RATING:
            snprintf(buf, bufsize, "track rating (database)");
            break;

        case WPS_TOKEN_DATABASE_AUTOSCORE:
            snprintf(buf, bufsize, "track autoscore (database)");
            break;
#endif

        case WPS_TOKEN_BATTERY_PERCENT:
            snprintf(buf, bufsize, "battery percentage");
            break;

        case WPS_TOKEN_BATTERY_VOLTS:
            snprintf(buf, bufsize, "battery voltage");
            break;

        case WPS_TOKEN_BATTERY_TIME:
            snprintf(buf, bufsize, "battery time left");
            break;

        case WPS_TOKEN_BATTERY_CHARGER_CONNECTED:
            snprintf(buf, bufsize, "battery charger connected");
            break;

        case WPS_TOKEN_BATTERY_CHARGING:
            snprintf(buf, bufsize, "battery charging");
            break;

        case WPS_TOKEN_BATTERY_SLEEPTIME:
            snprintf(buf, bufsize, "sleep timer");
            break;

        case WPS_TOKEN_FILE_BITRATE:
            snprintf(buf, bufsize, "%sfile bitrate", next_str(next));
            break;

        case WPS_TOKEN_FILE_CODEC:
            snprintf(buf, bufsize, "%sfile codec", next_str(next));
            break;

        case WPS_TOKEN_FILE_FREQUENCY:
            snprintf(buf, bufsize, "%sfile audio frequency in Hz",
                    next_str(next));
            break;

        case WPS_TOKEN_FILE_FREQUENCY_KHZ:
            snprintf(buf, bufsize, "%sfile audio frequency in KHz",
                    next_str(next));
            break;

        case WPS_TOKEN_FILE_NAME:
            snprintf(buf, bufsize, "%sfile name", next_str(next));
            break;

        case WPS_TOKEN_FILE_NAME_WITH_EXTENSION:
            snprintf(buf, bufsize, "%sfile name with extension",
                    next_str(next));
            break;

        case WPS_TOKEN_FILE_PATH:
            snprintf(buf, bufsize, "%sfile path", next_str(next));
            break;

        case WPS_TOKEN_FILE_SIZE:
            snprintf(buf, bufsize, "%sfile size", next_str(next));
            break;

        case WPS_TOKEN_FILE_VBR:
            snprintf(buf, bufsize, "%sfile is vbr", next_str(next));
            break;

        case WPS_TOKEN_FILE_DIRECTORY:
            snprintf(buf, bufsize, "%sfile directory, level: %d",
                    next_str(next), token->value.i);
            break;

#if (CONFIG_CODEC != MAS3507D)
        case WPS_TOKEN_SOUND_PITCH:
            snprintf(buf, bufsize, "pitch value");
            break;
#endif

#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
        case WPS_TOKEN_VLED_HDD:
            snprintf(buf, bufsize, "display virtual HDD LED");
            break;
#endif
        case WPS_VIEWPORT_ENABLE:
            snprintf(buf, bufsize, "enable VP: %c",
                     (char)token->value.i);
            break;
        case WPS_TOKEN_BUTTON_VOLUME:
            snprintf(buf, bufsize, "Volume button timeout: %d",
                     token->value.i);
            break;
        case WPS_TOKEN_SETTING:
            snprintf(buf, bufsize, "Setting value: '%s'",
                 settings[token->value.i].cfg_name);
            break;
        case WPS_TOKEN_LANG_IS_RTL:
            snprintf(buf, bufsize, "lang: is_rtl?");
            break;
        default:
            for(i=1; i<sizeof(tokens)/sizeof(*token); i++)
            {
                if (token->type < tokens[i].start_marker)
                {
                    snprintf(buf, bufsize, "FIXME: %s + %d\n", tokens[i-1].desc,
					         token->type - tokens[i-1].start_marker);
                    break;
                }
            } 
            break;
    }

    return buf;
}