void ID3V2::parse_comment_frame(FXint framesize) { FXString key,field; const FXuchar & encoding = buffer[p]; const FXchar* textstart = (const FXchar*)(buffer+p+4); const FXint textlength = framesize - 4; if (encoding==UTF16_BOM || encoding==UTF16) { FXint ksize = strwlen(textstart,textlength); FXint vsize = strwlen(textstart+ksize+2,textlength-ksize-2); parse_text(encoding,textstart,ksize,key); parse_text(encoding,textstart+ksize+2,vsize,field); } else { FXint ksize = strnlen(textstart,textlength); FXint vsize = strnlen(textstart+ksize+1,textlength-ksize-1); parse_text(encoding,textstart,ksize,key); parse_text(encoding,textstart+ksize+1,vsize,field); } FXString comment = key + " " + field; if (comment.find("iTunSMPB")>=0) { comment.simplify().scan("iTunSMPB %*x %hx %hx %lx",&padstart,&padend,&length); GM_DEBUG_PRINT("[id3v2] found iTunSMPB (padding %d %d, length %ld)\n",padstart,padend,length); } }
int main (int argc, char* argv[]) { /* * main : recebe o nome do arquivo de entrada e o nome do arquivo de saida. * Lê a entrada, cria uma lista de rótulos e imprime a saída seguindo as * especificações do IAS. */ str* parsed_text = NULL; //receberá o nó cabeça de uma lista de linhas label_node* label_table = NULL; //receberá uma lista de rótulos presendes na entrada //divide o arquivo de entrada em linhas parsed_text = parse_text(argc, argv); //cria e preenche a lista de rótulos label_table = create_label_table(); fill_label_table(parsed_text, label_table); //lê a lista de linhas e a tabela de rótulos para imprimir o mapa de meória write_mem_map(argv[2], parsed_text, label_table); //liberar as memórias return 0; }
void assert_parse_package(const char* package_name, const char* java_text) { JavaDocStructure* java_doc = parse_text(java_text, TRUE, FALSE); ASSERT_NOT_NULL(java_doc); ASSERT_NOT_NULL(java_doc->package_declaration); ASSERT_STR_EQ(package_name, java_doc->package_declaration->package_name); java_doc_free(java_doc); }
static int load_tuning_data(char *filename) { struct file *filp; char *dp; long l ; loff_t pos; int ret, num; mm_segment_t fs; DPRINT("[INFO]:%s called loading file name : [%s]\n",__func__,filename); fs = get_fs(); set_fs(get_ds()); filp = filp_open(filename, O_RDONLY, 0); if(IS_ERR(filp)) { printk(KERN_ERR "[ERROR]:File open failed\n"); return -1; } l = filp->f_path.dentry->d_inode->i_size; DPRINT("[INFO]: Loading File Size : %ld(bytes)", l); dp = kmalloc(l+10, GFP_KERNEL); if(dp == NULL){ DPRINT("[ERROR]:Can't not alloc memory for tuning file load\n"); filp_close(filp, current->files); return -1; } pos = 0; memset(dp, 0, l); DPRINT("[INFO] : before vfs_read()\n"); ret = vfs_read(filp, (char __user *)dp, l, &pos); DPRINT("[INFO] : after vfs_read()\n"); if(ret != l) { DPRINT("[ERROR] : vfs_read() filed ret : %d\n",ret); kfree(dp); filp_close(filp, current->files); return -1; } filp_close(filp, current->files); set_fs(fs); num = parse_text(dp, l); hx8369b_video_display_mDNIe_tune_cmds[0].dlen = num; if(!num) { DPRINT("[ERROR]:Nothing to parse\n"); kfree(dp); return -1; } DPRINT("[INFO] : Loading Tuning Value's Count : %d", num); kfree(dp); return num; }
int main() { std::string text_file_name = "text.txt"; std::deque< std::string > word_list; parse_text(text_file_name,word_list); std::cout << "Token Count: " << word_list.size() << std::endl; return 0; }
int parse_block(int fd1,int fd2) { char tag; read(fd1,&tag,1); switch(GET_TAG(tag)) { case 0x00: parse_titleblock(fd1); break; case 0x01: parse_sheet(fd1); break; case 0x02: parse_component(fd1,fd2); break; case 0x03: parse_wire(fd1); break; case 0x04: parse_bus(fd1); break; case 0x05: parse_junction(fd1); break; case 0x06: parse_port(fd1); break; case 0x07: parse_label(fd1); break; case 0x08: parse_entry(fd1); break; case 0x09: parse_dashed(fd1); break; case 0x0a: parse_power(fd1); break; case 0x0b: parse_text(fd1); break; case 0x0c: parse_marker(fd1); break; case 0x0f: return 0; break; default: fprintf(stderr,"\nUnknown Block Tag\n"); exit(-1); break; } return 1; }
const std::vector<std::string>& topic_text::parsed_text() const { if (generator_) { parsed_text_ = parse_text((*generator_)()); if (--generator_->count == 0) delete generator_; generator_ = NULL; } return parsed_text_; }
static char * test_two_entries() { struct search_t *search; search = create_search(); char text[] = "this is a the first line\nthis is the second line\n"; const char *pattern = "line"; parse_text(search, "fake_file", strlen(text), text, pattern); mu_assert("error in number of entry", search->nbentry == 3); free_search(search); return 0; }
void parse_selection(void) { char *psel=NULL; tex_set_string(&psel); tex_placeholders(1); tex_mode(4); latex_selection(1); tex_unset(); if (psel && parse_text(psel)) include_selection(); cleanup_nodestack(); free(psel); }
static char * test_one_entry_incase() { struct search_t *search; search = create_search(); search->incase_option = 1; char text[] = "this is a the first line\nthis is the second line\n"; const char *pattern = "First"; parse_text(search, "fake_file", strlen(text), text, pattern); mu_assert("error in number of entry", search->nbentry == 2); free_search(search); return 0; }
// message-header = field-name ":" [ field-value ] // field-name = token // field-value = *( field-content | LWS ) // field-content = <the OCTETs making up the field-value // and consisting of either *TEXT or combinations // of token, separators, and quoted-string> const char* parse_message_header(unsigned char** p) { if (parse_token(p)) return ERR; if (parse_char(p, ':')) return ERR; while (0 != (char)**p) { if (parse_text(p)) break; } return NULL; }
static char * test_cursor_down_skip_file() { struct display_t *display; struct search_t *search; int terminal_line_nb; char text[] = "this is a the first line\n"; char text2[] = "this is a the first line\n"; const char *pattern = "line"; display = create_display(); search = create_search(); terminal_line_nb = 10; parse_text(search, "fake_file", strlen(text), text, pattern); parse_text(search, "fake_file2", strlen(text), text, pattern); move_cursor_down(display, search, terminal_line_nb); mu_assert("test_cursor_down_skip_file failed", display->cursor == 3); free_search(search); free_display(display); return 0; }
Flake* Parser::parse_value(){ Flake* f; if(f=parse_text()){ return f; } if(f=parse_tag()){ return f; } if(f=parse_section()){ return f; } //Error checking /* Snow errors are very predictable, so check for common mistakes. By this point, we know the next character is one of the quote characters, ], }, whitespace, a control character, or EOF (if not, something is HORRIBLY wrong) */ if(it==end){ throw ParseError(TAG_EOF,line,col); } char c=*it; if(c==CLOSE_SECTION){ throw ParseError(UNEXPECTED_CLOSE_SECTION,line,col-1); } if(c==CLOSE_TAG){ throw ParseError(UNNAMED_ATTR,colonline,coloncol); } if(c==NAMED_ATTR){ throw ParseError(ILLEGAL_NAMED,line,col-1); } if(isspace(c)){ //This should NEVER happen. Guarantees a problem with the parser. throw ParseError(UNEXPECTED_SPACE,line,col); } //Reserved for cosmic ray errors throw ParseError(COSMIC_RAY_ERR,line,col); }
void test_parse_imports() { JavaDocStructure* java_doc = parse_text( "import java.doc;\r\n" "import test.x; // Post comment\n" "// Comment \n" "import test.y; /* Post comment*/\n" "import /*static*/ test.x;\r" "import static test.x.SA;\n" "\n", FALSE, TRUE); ASSERT_NOT_NULL(java_doc); ASSERT_NOT_NULL(java_doc->import_declarations); int imports = ARRAY_LEN(java_doc->import_declarations); ASSERT_EQ(5, imports); java_doc_free(java_doc); }
int main_fst2txt(struct fst2txt_parameters* p) { p->f_input=u_fopen_existing_versatile_encoding(p->mask_encoding_compatibility_input,p->text_file,U_READ); if (p->f_input==NULL) { error("Cannot open file %s\n",p->text_file); return 1; } p->text_buffer=new_buffer_for_file(UNICHAR_BUFFER,p->f_input,CAPACITY_LIMIT); p->buffer=p->text_buffer->unichar_buffer; p->f_output=u_fopen_creating_versatile_encoding(p->encoding_output,p->bom_output,p->temp_file,U_WRITE); if (p->f_output==NULL) { error("Cannot open temporary file %s\n",p->temp_file); u_fclose(p->f_input); return 1; } p->fst2=load_abstract_fst2(p->fst_file,1,NULL); if (p->fst2==NULL) { error("Cannot load grammar %s\n",p->fst_file); u_fclose(p->f_input); u_fclose(p->f_output); return 1; } if (p->alphabet_file!=NULL && p->alphabet_file[0]!='\0') { p->alphabet=load_alphabet(p->alphabet_file); if (p->alphabet==NULL) { error("Cannot load alphabet file %s\n",p->alphabet_file); u_fclose(p->f_input); u_fclose(p->f_output); free_abstract_Fst2(p->fst2,NULL); return 1; } } u_printf("Applying %s in %s mode...\n",p->fst_file,(p->output_policy==MERGE_OUTPUTS)?"merge":"replace"); build_state_token_trees(p); parse_text(p); u_fclose(p->f_input); u_fclose(p->f_output); af_remove(p->text_file); af_rename(p->temp_file,p->text_file); u_printf("Done.\n"); return 0; }
void construct(std::string text_file) { int64_t n, start, end; _text = parse_text(text_file); int64_t text_size = _text.size(); int64_t remaining_text_size = _text.size(); _size = 0; start = 0; end = 0; _wm = new int64_t[(_block_size + 1) * 4]; if (text_size <= _block_size) { n = 0; _current_block_size = text_size; remaining_text_size = 0; } else { _current_block_size = _block_size; remaining_text_size -= _current_block_size; n = (std::ceil((double) remaining_text_size / _block_size)); end = std::min(start + _current_block_size - 1, text_size); } _old_block = _text.substr(0, _current_block_size); _size += _current_block_size; base_case(); start = end + 1; for (int64_t i = 0; i < n; i++) { std::cout << "Iteration " << i + 1 << " of " << n << "\n"; end = std::min(start + _block_size - 1, text_size - 1); _new_block = _text.substr(start, end - start + 1); _current_block_size = std::min(end - start + 1, remaining_text_size); _size += _current_block_size; //update csa size compute_rank_long(); compute_rank_short(); compute_psi(); start = end + 1; remaining_text_size -= _current_block_size; _old_psi.swap(_new_psi); _new_psi.reset(); _old_block = std::move(_new_block); // for (int64_t i = 0; i < _size; i++) { // std::cout << "PSI(" << i << ") = " << _old_psi.psi(i) << "\n"; // } } _new_psi = std::move(_old_psi); sample_sa(); sample_isa(); }
void ID3V2::parse_text_frame(FXuint frameid,FXint framesize) { FXString text; const FXuchar & encoding = buffer[p]; parse_text(encoding,(const FXchar*)buffer+p+1,framesize-1,text); GM_DEBUG_PRINT("[id3v2] text: \"%s\"\n",text.text()); switch(frameid) { case TP1 : case TPE1 : artist.adopt(text); break; case TAL : case TALB : album.adopt(text); break; case TT2 : case TIT2 : title.adopt(text); break; default : break; } }
static bool read_asap_string(char* source, char** buf, char** buffer_end, char** dest) { if(parse_text(*buf,source) == false) return false; /* set dest pointer */ *dest = *buf; /* move buf ptr */ *buf += strlen(*buf)+1; /* check size */ if(*buf >= *buffer_end) { DEBUGF("Buffer full\n"); return false; } return true; }
static char * test_cursor_down_end_of_page() { struct display_t *display; struct search_t *search; int terminal_line_nb; char text[] = "this is the first line\n this is the second line\n this is the third line\n this is the fourth line \n "; const char *pattern = "line"; display = create_display(); search = create_search(); terminal_line_nb = 3; parse_text(search, "fake_file", strlen(text), text, pattern); move_cursor_down(display, search, terminal_line_nb); move_cursor_down(display, search, terminal_line_nb); mu_assert("test_cursor_down_end_of_page failed", display->cursor == 0); free_search(search); free_display(display); return 0; }
static nxe_ssize_t ssi_buffer_data_in_write(nxe_ostream* os, nxe_istream* is, int fd, nx_file_reader* fr, nxe_data ptr, nxe_size_t size, nxe_flags_t* _flags) { ssi_buffer* ssib=OBJ_PTR_FROM_FLD_PTR(ssi_buffer, data_in, os); //nxe_loop* loop=os->super.loop; nxweb_log_debug("ssi_buffer_data_in_write"); nxe_flags_t flags=*_flags; if (ssib->overflow) { // reached max_ssi_size // swallow input data } else { int wsize=size; if (ssib->data_size+wsize > MAX_SSI_SIZE) wsize=MAX_SSI_SIZE-ssib->data_size; assert(wsize>=0); if (wsize>0) { nx_file_reader_to_mem_ptr(fd, fr, &ptr, &size, &flags); if (((int)size)<wsize) wsize=size; nxb_make_room(ssib->nxb, wsize); char* dptr=nxb_get_room(ssib->nxb, 0); memcpy(dptr, ptr.cptr, wsize); nxb_blank_fast(ssib->nxb, wsize); ssib->data_size+=wsize; while (parse_text(ssib)); if (ssib->data_size >= MAX_SSI_SIZE) { ssib->overflow=1; } } } if (flags&NXEF_EOF) { nxe_ostream_unset_ready(os); int nbytes; char* ptr=nxb_finish_stream(ssib->nxb, &nbytes); if (nbytes) { nxweb_composite_stream_append_bytes(ssib->cs, ptr, nbytes); } nxweb_composite_stream_close(ssib->cs); } return size; }
int main(void) { #ifndef BUFSIZ #define BUFSIZ 64 #endif char send_buf[BUFSIZ]; char recv_buf[BUFSIZ]; int size; gpio_init(); /* FIXME: baud rate doesn't change anything */ uart_init(115200); pwm_init(); OCR1A = 5; OCR1B = 5; while (1) { size = uart_recvline(recv_buf); parse_text(recv_buf, size); /*sprintf(send_buf, "received \"%s\", len %d\n", recv_buf, size);*/ /*uart_print(send_buf);*/ _delay_ms(10); } return 0; }
void wpl_text::parse_value(wpl_namespace *parent_namespace) { ignore_string_match(NEWLINE, NON_NEWLINE_WS); const char *start = get_string_pointer(); const char *end; int par_level = 1; while (par_level > 0 && !at_end()) { end = get_string_pointer(); if (ignore_letter('{')) { if (ignore_string("@LOOP")) { push_chunk (start, end); wpl_text *text = new wpl_text(); wpl_expression *exp = new wpl_expression_par_enclosed(); chunks.emplace_back(new wpl_text_chunks::loop(text, exp)); parse_expression(parent_namespace, exp); ignore_string_match(NEWLINE, NON_NEWLINE_WS); parse_text(parent_namespace, text); start = get_string_pointer(); } else if (ignore_string("@CONDITION")) { push_chunk (start, end); wpl_text *text = new wpl_text(); wpl_expression *exp = new wpl_expression_par_enclosed(); wpl_text *text_else = NULL; wpl_text_chunks::condition *condition = new wpl_text_chunks::condition(text, exp); chunks.emplace_back(condition); parse_expression(parent_namespace, exp); ignore_string_match(NEWLINE, NON_NEWLINE_WS); parse_text(parent_namespace, text); start = get_string_pointer(); } else if (ignore_string("@TEMPLATE")) { push_chunk (start, end); wpl_matcher_position pos = get_position(); char name[WPL_VARNAME_SIZE]; ignore_whitespace(); get_word(name); wpl_template *my_template = parent_namespace->find_template(name); if (!my_template) { load_position(pos); THROW_ELEMENT_EXCEPTION("Unknown template name"); } chunks.emplace_back(new wpl_text_chunks::html_template(my_template)); ignore_whitespace(); if (!ignore_letter ('}')) { THROW_ELEMENT_EXCEPTION("Expected } after TEMPLATE call definition"); } start = get_string_pointer(); } else if (ignore_string("@")) { push_chunk (start, end); wpl_expression *exp = new wpl_expression_loose_end(); chunks.emplace_back(new wpl_text_chunks::expression(exp)); exp->load_position(get_position()); exp->parse_value(parent_namespace); load_position(exp->get_position()); ignore_string_match(WHITESPACE, 0); if (!ignore_letter('}')) { THROW_ELEMENT_EXCEPTION("Expected '}' after expression-in-TEXT"); } start = get_string_pointer(); } else { par_level++; } } else if (ignore_letter('}')) { par_level--; } else { if (!ignore_string_match(NON_CURLY|UTF8, 0)) { cerr << "Unknown character '" << hex << get_letter(ALL) << "'\n"; THROW_ELEMENT_EXCEPTION("Syntax error in text-string"); } } } if (par_level != 0) { THROW_ELEMENT_EXCEPTION("Excepted '}' after TEXT-block"); } end = get_string_pointer() - 2; while (M_NON_NEWLINE_WHITESPACE (*end)) { end--; } end++; if (end > start) { push_chunk (start, end); } }
int mdnie_txtbuf_to_parsing(char *path, u16 size, u16 *buf, char *name) { struct file *filp; char *dp; long l; loff_t pos; int ret, num; mm_segment_t fs; fs = get_fs(); set_fs(get_ds()); if (!path) { pr_err("%s: invalid filepath\n", __func__); goto parse_err; } filp = filp_open(path, O_RDONLY, 0); if (IS_ERR(filp)) { pr_err("file open error: %s\n", path); goto parse_err; } l = filp->f_path.dentry->d_inode->i_size; dp = kmalloc(l, GFP_KERNEL); if (dp == NULL) { pr_err("Out of Memory!\n"); filp_close(filp, current->files); goto parse_err; } pos = 0; memset(dp, 0, l); ret = vfs_read(filp, (char __user *)dp, l, &pos); if (ret != l) { pr_info("read size = %d, l = %ld, size=%d\n", ret, l, size); l = (l > ret) ? ret : l; if (size < l) { KFREE(dp); filp_close(filp, current->files); goto parse_err; } } filp_close(filp, current->files); set_fs(fs); num = parse_text(dp, l, buf, name); if (!num) { pr_err("Nothing to parse!\n"); KFREE(dp); goto parse_err; } KFREE(dp); return num; parse_err: return -EPERM; }
extern skin_t* tcvp_open_ui(xtk_widget_t *w, void *p) { char *buf; widget_data_t *wd; widget_data_t *owd = xtk_widget_get_data(w); char *uifile = owd->action_data; skin_t *s = owd->skin; buf = malloc(strlen(uifile) + strlen(s->path) + 2); sprintf(buf, "%s/%s", s->path, uifile); skin_t *skin = load_skin(buf); if(!skin) { return NULL; } skin->window = xtk_window_create(NULL, 0, 0, skin->width, skin->height); xtk_window_set_dnd_callback(skin->window, tcvp_add_file); xtk_window_set_class(skin->window, "TCVP"); if(create_ui(skin->window, skin, skin->config, NULL) != 0){ tc2_print("TCVPX", TC2_PRINT_ERROR, "Unable to load skin: \"%s\"\n", buf); return NULL; } free(buf); wd = tcallocdz(sizeof(*wd), NULL, widgetdata_free); wd->action = skin->dblclick; wd->skin = tcref(skin); xtk_widget_container_set_data(skin->window, wd); xtk_window_set_doubleclick_callback(skin->window, lookup_action); xtk_window_set_sticky_callback(skin->window, sticky_cb); xtk_window_set_on_top_callback(skin->window, on_top_cb); char *default_text = malloc(1024); tcconf_getvalue(skin->config, "title", "%s", &wd->value); if(wd->value == NULL) { wd->value = strdup(tcvp_ui_tcvpx_conf_window_title); } register_textwidget(skin->window, wd->value); parse_text(wd->value, default_text, 1024); xtk_window_set_title(skin->window, default_text); free(default_text); xtk_window_show(skin->window); if((s->state & ST_STICKY) != 0) { xtk_window_set_sticky(skin->window, 1); skin->state |= ST_STICKY; } if((s->state & ST_ON_TOP) != 0) { xtk_window_set_always_on_top(skin->window, 1); skin->state |= ST_ON_TOP; } tcconf_getvalue(skin->config, "id", "%s", &skin->id); skin->skin_hash = s->skin_hash; if(skin->id != NULL) { tchash_search(skin->skin_hash, skin->id, -1, skin, NULL); } ui_count++; return skin; }
static xtk_widget_t* create_skinned_label(xtk_widget_t *win, skin_t *skin, tcconf_section_t *sec, tchash_table_t *parameters) { int x, y; int width, height; int xoff = 0, yoff = 0; char *font; char *color, *align_s, *stype_s; int alpha = 0xff; int stype, align; int i = 0; char *action = NULL, *bg = NULL, *text, *default_text; widget_data_t *wd = tcallocdz(sizeof(*wd), NULL, widgetdata_free); xtk_widget_t *l, *w; tcconf_section_t *bfnt = NULL; image_t *bg_img; i += tcconf_getvalue(sec, "position", "%d %d", &x, &y); i += tcconf_getvalue(sec, "size", "%d %d", &width, &height); i += tcconf_getvalue(sec, "text", "%s", &text); if((bfnt = tcconf_getsection(sec, "bitmap"))){ tcconf_setvalue(bfnt, "path", "%s", skin->path); i++; } else if(tcconf_getvalue(sec, "font", "%s", &font) == 1){ i++; } i += tcconf_getvalue(sec, "color", "%s %d", &color, &alpha) > 0; if(tcconf_getvalue(sec, "scroll_style", "%s", &stype_s) < 1) stype_s = strdup("none"); if(tcconf_getvalue(sec, "align", "%s", &align_s) < 1) align_s = strdup("left"); if(strcasecmp(align_s, "left") == 0) { align = XTKLABELLEFT; } else if(strcasecmp(align_s, "right") == 0) { align = XTKLABELRIGHT; } else { align = XTKLABELCENTER; } free(align_s); if(strcasecmp(stype_s, "scroll") == 0) { stype = XTKLABELSCROLL; } else if(strcasecmp(stype_s, "pingpong") == 0) { stype = XTKLABELPINGPONG; } else { stype = 0; } free(stype_s); if(i != 7) return NULL; tcconf_getvalue(sec, "text_offset", "%d %d", &xoff, &yoff); tcconf_getvalue(sec, "action", "%s", &action); tcconf_getvalue(sec, "background", "%s", &bg); default_text = malloc(1024); parse_text(text, default_text, 1024); wd->action = action; wd->value = text; wd->skin = tcref(skin); l = xtk_widget_label_create(win, x, y, width, height); if(bfnt){ xtk_widget_label_set_bitmapfont(l, bfnt); tcfree(bfnt); } else { xtk_widget_label_set_font(l, font); free(font); } xtk_widget_label_set_offset(l, xoff, yoff); xtk_widget_label_set_color(l, color, alpha); xtk_widget_label_set_text(l, default_text); xtk_widget_label_set_data(l, wd); xtk_widget_label_set_action(l, lookup_action); xtk_widget_label_set_align(l, align); xtk_widget_label_set_scroll(l, stype); bg_img = load_image(skin->path, bg); w = xtk_widget_image_create(win, x, y, width, height); xtk_widget_image_set_image(w, bg_img); tcfree(bg_img); xtk_widget_show(w); register_textwidget(l, text); l->on_destroy = destroy_skinned_label; free(default_text); if(color) free(color); free(bg); return l; }
int mDNIe_txtbuf_to_parsing2(void) { struct file *filp; char *dp; long l, i ; loff_t pos; int ret, num,type; mm_segment_t fs; printk("cmc623_load_data start!\n"); fs = get_fs(); set_fs(get_ds()); filp = filp_open("sdcard/external_sd/s3cfb_mdnie_value.h", O_RDONLY, 0); type = 2; if(IS_ERR(filp)) { filp = filp_open("sdcard/external_sd/mdnie_tune", O_RDONLY, 0); type = 1; if(IS_ERR(filp)) { printk("file open error:%d\n", (s32)filp); return -1; } } l = filp->f_path.dentry->d_inode->i_size; printk("Size of the file : %ld(bytes)\n", l); //dp = kmalloc(l, GFP_KERNEL); dp = kmalloc(l+10, GFP_KERNEL); // add cushion if(dp == NULL) { printk("Out of Memory!\n"); filp_close(filp, current->files); return -1; } pos = 0; memset(dp, 0, l); printk("== Before vfs_read ======\n"); ret = vfs_read(filp, (char __user *)dp, l, &pos); // P1_LSJ : DE08 : ?�기??죽음 printk("== After vfs_read ======\n"); if(ret != l) { printk("<CMC623> Failed to read file (ret = %d)\n", ret); kfree(dp); filp_close(filp, current->files); return -1; } filp_close(filp, current->files); set_fs(fs); /* for(i=0; i<l; i++) { printk("%x ", dp[i]); } printk("\n"); //*/ if(type == 1) { num = parse_text(dp, l); if(!num) { printk("Nothing to parse!\n"); kfree(dp); return -1; } printk("------ Jun Total number of parsed lines: %d\n", num); mDNIe_data[num] = END_SEQ; printk("read ok\n"); mDNIe_tuning_set(); printk("tuning set ok\n"); mDNIe_Tuning_Mode = TRUE; } else if(type == 2) { num = parse_text2(dp, l); printk("read ok\n"); mDNIe_Set_Mode(current_mDNIe_UI,current_mDNIe_OutDoor_OnOff); num *= 2; printk("tuning set ok\n"); mDNIe_Tuning_Mode = FALSE; } kfree(dp); return num / 2; }
static xtk_widget_t* create_skinned_state(xtk_widget_t *win, skin_t *skin, tcconf_section_t *sec, tchash_table_t *parameters) { int x, y; int ns = 0; image_t **imgs = NULL; char **states = NULL; void *c = NULL; int i; char *img, *st, def_state[512], *bg = NULL; widget_data_t *wd = tcallocdz(sizeof(*wd), NULL, widgetdata_free); xtk_widget_t *s = NULL; i = tcconf_getvalue(sec, "position", "%d %d", &x, &y); i += tcconf_getvalue(sec, "value", "%s", &wd->value); if (i != 3) { return NULL; } while(i = tcconf_nextvalue(sec, "image", &c, "%s %s", &st, &img), c) { if(i == 2) { imgs = realloc(imgs, sizeof(*imgs)*(ns+1)); states = realloc(states, sizeof(*states)*(ns+1)); imgs[ns] = load_image(skin->path, img); states[ns] = st; ns++; free(img); } } tcconf_getvalue(sec, "action", "%s", &wd->action); wd->skin = tcref(skin); parse_text(wd->value, def_state, 512); if(ns > 0) { s = xtk_widget_state_create(win, x, y, imgs[0]->params.width[0], imgs[0]->params.height[0]); for(i=0; i<ns; i++) { xtk_widget_state_add_state(s, states[i], imgs[i]); tcfree(imgs[i]); } xtk_widget_state_set_state(s, def_state); xtk_widget_state_set_data(s, wd); xtk_widget_state_set_action(s, lookup_action); register_textwidget((xtk_widget_t *)s, wd->value); s->on_destroy = destroy_skinned_state; } free(bg); if(imgs) free(imgs); if(states){ for(i = 0; i < ns; i++) free(states[i]); free(states); } return s; }
// Reason-Phrase = *<TEXT, excluding CR, LF> const char* parse_reason_phrase(unsigned char** p) { return parse_text(p); }
static int parse_node(xmlNodePtr node, simple_binary_t **sibxml) { int status = 0; /* Call for the parser function of the node type. */ switch (node->type) { case XML_ELEMENT_NODE: status = parse_element(node, sibxml); break; case XML_TEXT_NODE: status = parse_text(node, sibxml); break; case XML_CDATA_SECTION_NODE: status = parse_cdata(node, sibxml); break; case XML_COMMENT_NODE: case XML_PI_NODE: /* Comments and PIs are ignored. */ break; /* * XML has also many other node types, these are not needed with * SI. Therefore they are assumed to be an error. */ default: error(0, "SI compiler: Unknown XML node in the SI source."); return -1; break; } /* * If node is an element with content, it will need an end tag after it's * children. The status for it is returned by parse_element. */ switch (status) { case 0: if (node->children != NULL) if (parse_node(node->children, sibxml) == -1) return -1; break; case 1: if (node->children != NULL) if (parse_node(node->children, sibxml) == -1) return -1; parse_end(sibxml); break; case -1: /* Something went wrong in the parsing. */ return -1; default: warning(0,"SI compiler: undefined return value in a parse function."); return -1; break; } if (node->next != NULL) if (parse_node(node->next, sibxml) == -1) return -1; return 0; }
void parser::parse( std::istream &in ) { parse_text( in ); }