Beispiel #1
0
/**
 * printf()-style function that appends the output to an autobuffer.
 * The function accepts a variable number of arguments based on the format string.
 * @param autobuf pointer to autobuf object
 * @param fmt printf format string
 * @return -1 if an out-of-memory error happened,
 *   otherwise it returns the number of written characters
 *   (excluding the \0)
 */
int
abuf_appendf(struct autobuf *autobuf, const char *fmt, ...)
{
  int rc;
  va_list ap;

  if (autobuf == NULL) return 0;

  va_start(ap, fmt);
  rc = abuf_vappendf(autobuf, fmt, ap);
  va_end(ap);
  return rc;
}
Beispiel #2
0
{
  int rv;
  va_list ap;
  char *first;

  if (!comments) {
    va_start(ap, fmt);
    first = va_arg(ap, char*);
    va_end(ap);
    if (*first) {
      return 0;
    }
  }

  va_start(ap, fmt);
  rv = abuf_vappendf(autobuf, fmt, ap);
  va_end(ap);
  return rv;
}

static void olsrd_write_if_autobuf(struct autobuf *out, struct if_config_options *cnfi, bool comments) {
  struct ipaddr_str ipbuf;
  struct olsr_lq_mult *mult;

  abuf_puts(out, "{\n");
  if (comments) abuf_puts(out,
    "    # Interface Mode is used to prevent unnecessary\n"
    "    # packet forwarding on switched ethernet interfaces\n"
    "    # valid Modes are \"mesh\" and \"ether\"\n"
    "    # (default is \"mesh\")\n"
    "    \n");