-/* Sets up some fields in H; caller should fill in
- H->{NAME,NORM_FN,FN}. */
-static void
-init_file_handle (struct file_handle *h)
-{
- h->recform = FH_RF_VARIABLE;
- h->mode = FH_MD_CHARACTER;
- h->ext = NULL;
- h->class = NULL;
-}
-
-/* Returns the handle corresponding to FILENAME. Creates the handle
- if no handle exists for that file. All filenames are normalized
- first, so different filenames referring to the same file will
- return the same file handle. */
-struct file_handle *
-fh_get_handle_by_filename (const char *filename)
-{
- struct file_handle f, *fp;
- char *fn;
- char *name;
- int len;
-
- /* Get filename. */
- fn = fn_normalize (filename);
- len = strlen (fn);
-
- /* Create handle name with invalid identifier character to prevent
- conflicts with handles created with FILE HANDLE. */
- name = xmalloc (len + 2);
- name[0] = '*';
- strcpy (&name[1], fn);
-
- f.name = name;
- fp = hsh_find (files, &f);
- if (!fp)
- {
- fp = xmalloc (sizeof *fp);
- init_file_handle (fp);
- fp->name = name;
- fp->norm_fn = fn;
- fp->where.filename = fp->fn = xstrdup (filename);
- hsh_force_insert (files, fp);
- }
- else
- {
- free (fn);
- free (name);
- }
- return fp;
-}
-
-/* Returns the handle with identifier NAME, if it exists; otherwise
- reports error to user and returns NULL. */
-struct file_handle *
-fh_get_handle_by_name (const char name[9])
+/* Creates and returns a new file handle with the given values
+ and defaults for other values. Adds the created file handle
+ to the global list. */
+static struct file_handle *
+create_file_handle (const char *handle_name, const char *filename)