SNMP Subagent Programmer's Guide
Dynamic Directory Program
2-54 119728—SNMP Subagent Programmer’s Guide
Programming Tutorials
Example 2-11. Dynamic Directory Include File dirC (page 1 of 3)
#include "tdmporth"
#include "machtypH"
#include "syspubH"
#include "dirH"
#include <tal.h>                         
#include <cextdecs(FILENAME_FINDSTART_, FILENAME_FINDNEXT_, \
       FILENAME_FINDFINISH_)>
/*Local prototypes */
static int    cmp(char    *x,
        char    *y,
        int   l);
static struct file_entry *insert_new_file(struct file_entry  *file_list,
                 struct file_entry  *file);
...
/*****************************************************************************
 *  comp_files    Lexically compare two DisplayString    <-- 
17
 *             variables.
 ****************************************************************************/
static int
cmp(char *x,
    char *y,
    int l)
{
   while (l--)
   {
       if (*x == *y)
       {
          x++;
          y++;
       }
     else if (*x > * y)
       {
          return(1);
       }
       else
       {
          return(-1);
       }
   }
   return(0);
}int
comp_files(DisplayString *f1,
    DisplayString *f2)
{
   if (f1->len != f2->len)
   {
       return((f1->len > f2->len)? 1 : -1);
   }
   return(cmp((char *)f1->val, (char *)f2->val, f1->len));
}










