static PurpleDesktopItem * ditem_load (FILE *df, gboolean no_translations, const char *uri) { int state; char CharBuffer [1024]; char *next = CharBuffer; int c; Encoding encoding; PurpleDesktopItem *item; Section *cur_section = NULL; char *key = NULL; gboolean old_kde = FALSE; encoding = get_encoding (df); if (encoding == ENCODING_UNKNOWN) { fclose(df); /* spec says, don't read this file */ printf ("Unknown encoding of .desktop file"); return NULL; } /* Rewind since get_encoding goes through the file */ if (fseek(df, 0L, SEEK_SET)) { fclose(df); /* spec says, don't read this file */ printf ("fseek() error on .desktop file"); return NULL; } item = _purple_desktop_item_new (); item->modified = FALSE; /* Note: location and mtime are filled in by the new_from_file * function since it has those values */ #define PURPLE_DESKTOP_ITEM_OVERFLOW (next == &CharBuffer [sizeof(CharBuffer)-1]) state = FirstBrace; while ((c = getc (df)) != EOF) { if (c == '\r') /* Ignore Carriage Return */ continue; switch (state) { case OnSecHeader: if (c == ']' || PURPLE_DESKTOP_ITEM_OVERFLOW) { *next = '\0'; next = CharBuffer; /* keys were inserted in reverse */ if (cur_section != NULL && cur_section->keys != NULL) { cur_section->keys = g_list_reverse (cur_section->keys); } if (strcmp (CharBuffer, "KDE Desktop Entry") == 0) { /* Main section */ cur_section = NULL; old_kde = TRUE; } else if (strcmp (CharBuffer, "Desktop Entry") == 0) { /* Main section */ cur_section = NULL; } else { cur_section = g_new0 (Section, 1); cur_section->name = g_strdup (CharBuffer); cur_section->keys = NULL; item->sections = g_list_prepend (item->sections, cur_section); } state = IgnoreToEOL; } else if (c == '[') { /* FIXME: probably error out instead of ignoring this */ } else { *next++ = c; } break; case IgnoreToEOL: case IgnoreToEOLFirst: if (c == '\n'){ if (state == IgnoreToEOLFirst) state = FirstBrace; else state = KeyDef; next = CharBuffer; } break; case FirstBrace: case KeyDef: case KeyDefOnKey: if (c == '#') { if (state == FirstBrace) state = IgnoreToEOLFirst; else state = IgnoreToEOL; break; } if (c == '[' && state != KeyDefOnKey){ state = OnSecHeader; next = CharBuffer; g_free (key); key = NULL; break; } /* On first pass, don't allow dangling keys */ if (state == FirstBrace) break; if ((c == ' ' && state != KeyDefOnKey) || c == '\t') break; if (c == '\n' || PURPLE_DESKTOP_ITEM_OVERFLOW) { /* Abort Definition */ next = CharBuffer; state = KeyDef; break; } if (c == '=' || PURPLE_DESKTOP_ITEM_OVERFLOW){ *next = '\0'; g_free (key); key = g_strdup (CharBuffer); state = KeyValue; next = CharBuffer; } else { *next++ = c; state = KeyDefOnKey; } break; case KeyValue: if (PURPLE_DESKTOP_ITEM_OVERFLOW || c == '\n'){ *next = '\0'; insert_key (item, cur_section, encoding, key, CharBuffer, old_kde, no_translations); g_free (key); key = NULL; state = (c == '\n') ? KeyDef : IgnoreToEOL; next = CharBuffer; } else { *next++ = c; } break; } /* switch */ } /* while ((c = getc_unlocked (f)) != EOF) */ if (c == EOF && state == KeyValue) { *next = '\0'; insert_key (item, cur_section, encoding, key, CharBuffer, old_kde, no_translations); g_free (key); key = NULL; } #undef PURPLE_DESKTOP_ITEM_OVERFLOW /* keys were inserted in reverse */ if (cur_section != NULL && cur_section->keys != NULL) { cur_section->keys = g_list_reverse (cur_section->keys); } /* keys were inserted in reverse */ item->keys = g_list_reverse (item->keys); /* sections were inserted in reverse */ item->sections = g_list_reverse (item->sections); /* sanitize some things */ sanitize (item, uri); /* make sure that we set up the type */ setup_type (item, uri); fclose (df); return item; }
static void setup_memory(void) { l4_size_t phys_size; l4io_device_handle_t dh; l4io_resource_handle_t hdl; if (fb_vaddr) return; if (l4io_lookup_device("System Control", &dh, 0, &hdl)) { printf("Could not get system controller space\n"); return; } /* System controller -- XXX Wrong Place XXX */ amba_pl110_sys_base_virt = l4io_request_resource_iomem(dh, &hdl); if (amba_pl110_sys_base_virt == 0) { printf("Could not map system controller space\n"); return; } if (l4io_lookup_device("AMBA PL110", &dh, 0, &hdl)) { printf("Could not get PL110 LCD device\n"); return; } amba_pl110_lcd_control_virt_base = l4io_request_resource_iomem(dh, &hdl); if (amba_pl110_lcd_control_virt_base == 0) { printf("Could not map controller space for '%s'\n", arm_lcd_get_info()); return; } setup_type(); if ((read_sys_reg(Reg_sys_clcd) & Sys_clcd_idmask) == 0x1000) { is_qemu = 1; // remember if we run on qemu because of the different // handling of the bpp16 mode with PL110: my hardware has // 5551 mode, qemu does 565 type = PL111; // also set the type to PL111 because qemu only // announces a PL110 but can do the 1024 resolution too printf("Running on QEmu (assuming PL111).\n"); } if (config_request_xga && type == PL111) use_xga = 1; // get some frame buffer l4re_ds_t mem = l4re_util_cap_alloc(); if (l4_is_invalid_cap(mem)) return; if (l4re_ma_alloc(fbmem_size(), mem, L4RE_MA_CONTINUOUS | L4RE_MA_PINNED)) { printf("Error allocating memory\n"); return; } fb_vaddr = 0; if (l4re_rm_attach(&fb_vaddr, fbmem_size(), L4RE_RM_SEARCH_ADDR | L4RE_RM_EAGER_MAP, mem, 0, L4_PAGESHIFT)) { printf("Error getting memory\n"); return; } printf("Video memory is at virtual %p (size: 0x%x Bytes)\n", fb_vaddr, fbmem_size()); // get physical address if (l4re_ds_phys(mem, 0, &fb_paddr, &phys_size) || phys_size != fbmem_size()) { printf("Getting the physical address failed or not contiguous\n"); return; } printf("Physical video memory is at %p\n", (void *)fb_paddr); }