30 |
#include "error.h" |
#include "error.h" |
31 |
#include "magic.h" |
#include "magic.h" |
32 |
#include "var.h" |
#include "var.h" |
33 |
|
#include "linked-list.h" |
34 |
|
|
35 |
/* (headers) */ |
/* (headers) */ |
36 |
|
|
37 |
/* File handle. */ |
/* File handle. */ |
217 |
return handle; |
return handle; |
218 |
} |
} |
219 |
|
|
220 |
|
void |
221 |
|
destroy_file_handle(struct file_handle *fh, void *aux UNUSED) |
222 |
|
{ |
223 |
|
free (fh->name); |
224 |
|
free (fh->filename); |
225 |
|
fn_free_identity (fh->identity); |
226 |
|
free (fh); |
227 |
|
} |
228 |
|
|
229 |
static const char * |
static const char * |
230 |
mode_name (const char *mode) |
mode_name (const char *mode) |
231 |
{ |
{ |
315 |
return h->open_cnt; |
return h->open_cnt; |
316 |
} |
} |
317 |
|
|
318 |
|
|
319 |
|
static struct linked_list *handle_list; |
320 |
|
|
321 |
|
|
322 |
/* Parses a file handle name, which may be a filename as a string or |
/* Parses a file handle name, which may be a filename as a string or |
323 |
a file handle name as an identifier. Returns the file handle or |
a file handle name as an identifier. Returns the file handle or |
324 |
NULL on failure. */ |
NULL on failure. */ |
345 |
char *handle_name = xmalloc (strlen (filename) + 3); |
char *handle_name = xmalloc (strlen (filename) + 3); |
346 |
sprintf (handle_name, "\"%s\"", filename); |
sprintf (handle_name, "\"%s\"", filename); |
347 |
handle = create_file_handle (handle_name, filename); |
handle = create_file_handle (handle_name, filename); |
348 |
|
ll_push_front(handle_list, handle); |
349 |
free (handle_name); |
free (handle_name); |
350 |
} |
} |
351 |
|
|
352 |
lex_get (); |
lex_get (); |
353 |
|
|
354 |
|
|
355 |
return handle; |
return handle; |
356 |
} |
} |
357 |
|
|
403 |
return handle->tab_width; |
return handle->tab_width; |
404 |
} |
} |
405 |
|
|
406 |
|
|
407 |
|
void |
408 |
|
fh_init(void) |
409 |
|
{ |
410 |
|
handle_list = ll_create(destroy_file_handle,0); |
411 |
|
} |
412 |
|
|
413 |
|
void |
414 |
|
fh_done(void) |
415 |
|
{ |
416 |
|
assert(handle_list); |
417 |
|
|
418 |
|
ll_destroy(handle_list); |
419 |
|
handle_list = 0; |
420 |
|
} |
421 |
|
|
422 |
|
|
423 |
/* |
/* |
424 |
Local variables: |
Local variables: |
425 |
mode: c |
mode: c |