Home | History | Annotate | Download | only in info

Lines Matching defs:file_buffer

37 static void remember_info_file (FILE_BUFFER *file_buffer);
38 static void free_file_buffer_tags (FILE_BUFFER *file_buffer);
40 static void get_nodes_of_tags_table (FILE_BUFFER *file_buffer,
42 static void get_nodes_of_info_file (FILE_BUFFER *file_buffer);
43 static void get_tags_of_indirect_tags_table (FILE_BUFFER *file_buffer,
45 static void info_reload_file_buffer_contents (FILE_BUFFER *fb);
47 static FILE_BUFFER *info_load_file_internal (char *filename, int get_tags);
48 static FILE_BUFFER *info_find_file_internal (char *filename, int get_tags);
49 static NODE *info_node_of_file_buffer_tags (FILE_BUFFER *file_buffer,
59 neccessary to fill in the nodes or tags arrays in FILE_BUFFER. */
70 FILE_BUFFER **info_loaded_files = NULL;
89 FILE_BUFFER *file_buffer = NULL;
111 file_buffer = info_find_file (filename);
112 if (!file_buffer)
121 node = info_get_node_of_file_buffer (nodename, file_buffer);
126 node = info_get_node_of_file_buffer ("Top", file_buffer);
128 node = info_get_node_of_file_buffer ("top", file_buffer);
130 node = info_get_node_of_file_buffer ("TOP", file_buffer);
137 FILE_BUFFER. NODENAME can be passed as NULL, in which case the
141 info_get_node_of_file_buffer (char *nodename, FILE_BUFFER *file_buffer)
147 if (!file_buffer)
151 if (!file_buffer->contents)
152 info_reload_file_buffer_contents (file_buffer);
164 node->filename = file_buffer->fullpath;
167 node->contents = file_buffer->contents;
168 node->nodelen = file_buffer->filesize;
175 else if (file_buffer->flags & N_IsManPage)
177 node = get_manpage_node (file_buffer, nodename);
184 else if (file_buffer->tags)
186 node = info_node_of_file_buffer_tags (file_buffer, nodename);
197 return a NULL FILE_BUFFER *. */
198 FILE_BUFFER *
206 FILE_BUFFER *
221 static FILE_BUFFER *
225 FILE_BUFFER *file_buffer;
230 for (i = 0; (file_buffer = info_loaded_files[i]); i++)
231 if ((FILENAME_CMP (filename, file_buffer->filename) == 0)
232 || (FILENAME_CMP (filename, file_buffer->fullpath) == 0)
235 filename_non_directory (file_buffer->fullpath))
243 return file_buffer;
247 if (file_buffer->flags & N_IsManPage)
248 return file_buffer;
253 if (stat (file_buffer->fullpath, &new_info) == -1)
259 old_info = &file_buffer->finfo;
274 for this file_buffer. In any case, return the file_buffer
276 if (!file_buffer->contents)
279 info_reload_file_buffer_contents (file_buffer);
280 if (!file_buffer->contents)
284 if (get_tags && !file_buffer->tags)
285 build_tags_and_nodes (file_buffer);
287 return file_buffer;
297 file_buffer = create_manpage_file_buffer ();
300 file_buffer = info_load_file_internal (filename, get_tags);
303 if (file_buffer)
304 remember_info_file (file_buffer);
306 return file_buffer;
313 static FILE_BUFFER *
320 FILE_BUFFER *file_buffer = NULL;
370 /* The file was found, and can be read. Allocate FILE_BUFFER and fill
372 file_buffer = make_file_buffer ();
373 file_buffer->filename = xstrdup (filename);
374 file_buffer->fullpath = xstrdup (fullpath);
375 file_buffer->finfo = finfo;
376 file_buffer->filesize = filesize;
377 file_buffer->contents = contents;
379 file_buffer->flags |= N_IsCompressed;
383 build_tags_and_nodes (file_buffer);
385 return file_buffer;
389 /* Grovel FILE_BUFFER->contents finding tags and nodes, and filling in the
392 build_tags_and_nodes (FILE_BUFFER *file_buffer)
397 free_file_buffer_tags (file_buffer);
398 file_buffer->flags &= ~N_HasTagsTable;
401 binding.buffer = file_buffer->contents;
402 binding.start = file_buffer->filesize;
447 /* The file contains a valid tags table. Fill the FILE_BUFFER's
449 file_buffer->flags |= N_HasTagsTable;
456 binding.end = file_buffer->filesize;
462 get_nodes_of_tags_table (file_buffer, &binding);
487 get_tags_of_indirect_tags_table (file_buffer, &indirect, &binding);
494 get_nodes_of_info_file (file_buffer);
497 /* Search through FILE_BUFFER->contents building an array of TAG *,
499 FILE_BUFFER->tags, and the number of allocated slots in
500 FILE_BUFFER->tags_slots. */
502 get_nodes_of_info_file (FILE_BUFFER *file_buffer)
508 binding.buffer = file_buffer->contents;
510 binding.end = file_buffer->filesize;
568 entry->filename = file_buffer->fullpath;
570 /* Add this tag to the array of tag structures in this FILE_BUFFER. */
571 add_pointer_to_array (entry, tags_index, file_buffer->tags,
572 file_buffer->tags_slots, 100, TAG *);
592 /* Build and save the array of nodes in FILE_BUFFER by searching through the
595 get_nodes_of_tags_table (FILE_BUFFER *file_buffer,
679 entry->filename = file_buffer->fullpath;
682 FILE_BUFFER. */
683 add_pointer_to_array (entry, tags_index, file_buffer->tags,
684 file_buffer->tags_slots, 100, TAG *);
696 /* Remember in FILE_BUFFER the nodenames, subfilenames, and offsets within the
700 get_tags_of_indirect_tags_table (FILE_BUFFER *file_buffer,
710 get_nodes_of_tags_table (file_buffer, tags_binding);
712 /* We have the list of tags in file_buffer->tags. Get the list of
748 free_file_buffer_tags (file_buffer);
762 binding.buffer = file_buffer->contents;
764 binding.end = file_buffer->filesize;
773 char *containing_dir = xstrdup (file_buffer->fullpath);
779 if (HAVE_DRIVE (file_buffer->fullpath) &&
793 file_buffer->subfiles = (char **) xmalloc ((1 + i) * sizeof (char *));
805 file_buffer->subfiles[i] = fullpath;
807 file_buffer->subfiles[i] = NULL;
813 for (tags_index = 0; (entry = file_buffer->tags[tags_index]);
830 free (file_buffer->subfiles[i]);
832 file_buffer->subfiles = NULL;
833 free_file_buffer_tags (file_buffer);
842 entry->filename = file_buffer->subfiles[i - 1];
849 file_buffer->flags |= N_TagsIndirect;
863 /* Return the node that contains TAG in FILE_BUFFER, else
866 find_node_of_anchor (FILE_BUFFER *file_buffer, TAG *tag)
873 for (anchor_pos = 0; file_buffer->tags[anchor_pos]; anchor_pos++)
875 TAG *t = file_buffer->tags[anchor_pos];
881 if (!file_buffer->tags[anchor_pos])
888 node_pos >= 0 && file_buffer->tags[node_pos]->nodelen == 0;
898 node_tag = file_buffer->tags[node_pos];
903 node = info_node_of_file_buffer_tags (file_buffer, node_tag->nodename);
915 node->display_pos = file_buffer->tags[anchor_pos]->nodestart
932 /* Return the node from FILE_BUFFER which matches NODENAME by searching
933 the tags table in FILE_BUFFER, or NULL. */
935 info_node_of_file_buffer_tags (FILE_BUFFER *file_buffer, char *nodename)
941 if (!file_buffer->tags) {
945 for (i = 0; (tag = file_buffer->tags[i]); i++)
948 FILE_BUFFER *subfile = info_find_file_internal (tag->filename,
971 if (file_buffer->flags & N_HasTagsTable)
975 if (file_buffer->flags & N_TagsIndirect)
978 node->parent = file_buffer->fullpath;
1034 node = find_node_of_anchor (file_buffer, tag);
1059 FILE_BUFFER *
1062 FILE_BUFFER *file_buffer = xmalloc (sizeof (FILE_BUFFER));
1064 file_buffer->filename = file_buffer->fullpath = NULL;
1065 file_buffer->contents = NULL;
1066 file_buffer->tags = NULL;
1067 file_buffer->subfiles = NULL;
1068 file_buffer->tags_slots = 0;
1069 file_buffer->flags = 0;
1071 return file_buffer;
1074 /* Add FILE_BUFFER to our list of already loaded info files. */
1076 remember_info_file (FILE_BUFFER *file_buffer)
1083 add_pointer_to_array (file_buffer, i, info_loaded_files,
1084 info_loaded_files_slots, 10, FILE_BUFFER *);
1092 FILE_BUFFER *file_buffer;
1097 for (i = 0; (file_buffer = info_loaded_files[i]); i++)
1098 if (FILENAME_CMP (filename, file_buffer->filename) == 0
1099 || FILENAME_CMP (filename, file_buffer->fullpath) == 0)
1101 free (file_buffer->filename);
1102 free (file_buffer->fullpath);
1104 if (file_buffer->contents)
1105 free (file_buffer->contents);
1109 free_file_buffer_tags (file_buffer);
1123 /* Free the tags (if any) associated with FILE_BUFFER. */
1125 free_file_buffer_tags (FILE_BUFFER *file_buffer)
1129 if (file_buffer->tags)
1133 for (i = 0; (tag = file_buffer->tags[i]); i++)
1136 free (file_buffer->tags);
1137 file_buffer->tags = NULL;
1138 file_buffer->tags_slots = 0;
1141 if (file_buffer->subfiles)
1143 for (i = 0; file_buffer->subfiles[i]; i++)
1144 free (file_buffer->subfiles[i]);
1146 free (file_buffer->subfiles);
1147 file_buffer->subfiles = NULL;
1158 subfiles list for the containing FILE_BUFFER. free_info_tags ()
1164 /* Load the contents of FILE_BUFFER->contents. This function is called
1170 info_reload_file_buffer_contents (FILE_BUFFER *fb)