File: dummydebconfclient.c

package info (click to toggle)
autopartkit 1.07
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,060 kB
  • ctags: 198
  • sloc: ansic: 2,489; sh: 843; makefile: 103
file content (55 lines) | stat: -rw-r--r-- 1,208 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "dummydebconfclient.h"

struct {
  const char *valname;
  const char *value;
} defaults[] = {
  {"autopartkit/device_name", "testdevice"},
  {"autopartkit/confirm", "true"},
  {"debian-installer/profile", "Server, LTSP-server"},
  {NULL, NULL}
};

static void
my_debconfclient_command(struct debconfclient *client,
			 const char *operation, ...)
{
  va_list ap;
  va_start(ap, operation);
  if (0 == strcmp(operation, "GET")) {
    char *valname;
    int i;
    valname = va_arg(ap, char *);
    client->value = NULL;
    for (i=0; defaults[i].valname; i++) {
      if (0 == strcmp(valname, defaults[i].valname)) {
	client->value = defaults[i].value;
      }
    }
    printf("debconf get valname: '%s' = '%s'\n",
	   valname ? valname : "[null]",
	   client->value ? client->value : "[null]");
  }
  va_end(ap);
}

struct debconfclient *
my_debconfclient_new(void)
{
  struct debconfclient *retval = malloc(sizeof(*retval));
  if (retval) {
    retval->value = NULL;
    retval->command = my_debconfclient_command;
  }
  return retval;
}

void
my_debconfclient_delete(struct debconfclient *client)
{
  free(client);
}