summaryrefslogtreecommitdiffstats
path: root/gpglib/options.c
blob: e758872c51fb69f7d005a722ff92599bb4e659b2 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
** Copyright 2004 Double Precision, Inc.  See COPYING for
** distribution information.
*/


#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include "gpg.h"

char *libmail_gpg_options(const char *p)
{
	if (!p || !*p)
		p=getenv("GNUPGHOME");

	if (p && *p)
	{
		char *s=malloc(strlen(p)+sizeof("/options"));

		if (s)
			return (strcat(strcpy(s, p), "/options"));
	}
	else
	{
		p=getenv("HOME");

		if (p && *p)
		{
			char *s=malloc(strlen(p)+sizeof("/.gnupg/options"));

			if (s)
				return (strcat(strcpy(s, p),
					       "/.gnupg/options"));
		}
	}
	return NULL;
}