#include <libpq-fe.h>
#include "trustDB.h"

char	*FindRepeater(char call[])
{
	char	sql[256];
	PGresult	*res;


	if (call[0] == '/')	/* Area CQ */
	{
		memcpy (&call[0], &call[1], 6);
		call[6] = 0x20;
	}

	sprintf (sql, "select rep_call from call_sign where call = '%8.8s';", call);

	res = PQexec(conDB, sql);
	memset (repeaterCall, 0x20, 8);

	if (PQresultStatus(res) == PGRES_TUPLES_OK)
	{
		if (PQntuples(res) == 1)
		{
			memcpy (repeaterCall, PQgetvalue(res, 0, 0), 8);
		}
	}
	PQclear (res);
	return repeaterCall;
}

