summaryrefslogtreecommitdiffstats
path: root/ldapaddressbook/abookadd.c
blob: 11c61362bcd18b336251bd6fe2d6ecdc43d2a201 (plain)
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
/*
** Copyright 2006, Double Precision Inc.
**
** See COPYING for distribution information.
*/

#include	"config.h"
#include	"ldapaddressbook.h"

#include	<stdio.h>
#include	<string.h>
#include	<stdlib.h>

int ldapabook_add(const char *f, const struct ldapabook *a)
{
FILE	*fp=fopen(f, "a");

	if (!fp)	return (-1);

	ldapabook_writerec(a, fp);

	if (fflush(fp) || fclose(fp))
	{
		fclose(fp);
		return (-1);
	}
	return (0);
}