SNMP Subagent Programmer's Guide
Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-55
Dynamic Directory Program
}
/*****************************************************************************
 *  insert_new_file   Add a new entry to the list of file names.   <-- 
18
 *             This entry is put in the list in increasing
 *             lexical order.
 ****************************************************************************/
static struct file_entry *
insert_new_file(struct file_entry *file_list,
    struct file_entry *file)
{
   struct file_entry   *tmp_file;
   if (file_list == NULL)
   {
       file->next = NULL;
     return(file);   /* empty list */
   }
   if (comp_files(&file->file_name, &file_list->file_name) < 0)
   {
       file->next = file_list; /* put on head of list */
       return(file);
   }
   /*    Find the right spot in the list for the insertion. */
   for (tmp_file = file_list;
     tmp_file->next &&
     comp_files(&file->file_name, &tmp_file->next->file_name) > 0;
     tmp_file = tmp_file->next)
   {
       ;
   }
   if (tmp_file->next &&
     (comp_files(&file->file_name, &tmp_file->next->file_name) == 0))
   {
       free((Void *) tmp_file->file_name.val);
       free((Void *) tmp_file);
       return(file_list);
   }
   file->next = tmp_file->next;
   tmp_file->next = file;
   return(file_list);
}
Example 2-11. Dynamic Directory Include File dirC (page 2 of 3)










