NAME

catinfo_foreach - traversal of the catinfo tree

SYNOPSIS

#include <cat/cat.h>

int catinfo_foreach(cat_session *sess, char *name, catinfo_fun fun, void *data);

DESCRIPTION

catinfo_foreach() traverses the catinfo tree and invokes the supplied callback fun for each node in the subtree where name is the root (including node name).

If name is ``.'' (the root of the catinfo tree), fun will be invoked for every node in the tree. Catinfo_foreach() forces the reading of values from nodes that are marked as connected to external storage (a file in UNIX or the registry in Windows NT) by previous calls to catinfo_loadfrom(). Only the nodes beneath and including name are read in.

The supplied callback must have the type:

typedef int (*catinfo_fun)(char *name, char *value, void *cbdata);

where name is the node name in the info tree and value is the value in node name. cbdata is data that is specific to the callback. The data in the call to catinfo_foreach() is passed to the callback.

name must be an absolute infopath (that is, starting with ``.'').

A successful call to catinfo_init() must have been made prior to any call to this function.

catinfo_foreach() returns 0 if successful or a negative code on error.

EXAMPLE

The function:

  int
  printit(char *name, char *value, void *data) 
  {
        printf("%s=\"%s\"\n", name, value);
        return 0;
  }

followed by the call:

  catinfo_foreach(sess, ".service.oracle-9_81", printit, NULL);

will print the names and values of all nodes in the subtree where .service.oracle-9_81 is the root.

SEE ALSO

cat, catinfo