summaryrefslogtreecommitdiff
path: root/src/tet3/apilib/getsysid.c
blob: 35b16fcacef0aca2ecb54683bd5777eb5cde25d5 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 *	SCCS: @(#)getsysid.c	1.1 (98/08/28)
 *
 *	UniSoft Ltd., London, England
 *
 * Copyright (c) 1996 The Open Group
 * All rights reserved.
 *
 * No part of this source code may be reproduced, stored in a retrieval
 * system, or transmitted, in any form or by any means, electronic,
 * mechanical, photocopying, recording or otherwise, except as stated
 * in the end-user licence agreement, without the prior permission of
 * the copyright owners.
 * A copy of the end-user licence agreement is contained in the file
 * Licence which accompanies this distribution.
 * 
 * Motif, OSF/1, UNIX and the "X" device are registered trademarks and
 * IT DialTone and The Open Group are trademarks of The Open Group in
 * the US and other countries.
 *
 * X/Open is a trademark of X/Open Company Limited in the UK and other
 * countries.
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/************************************************************************

SCCS:   	@(#)getsysid.c	1.1 98/08/28 TETware release 3.3
NAME:		getsysid.c
PRODUCT:	TETware
AUTHOR:		Geoff Clare, UniSoft Ltd.
DATE CREATED:	September 1996

SYNOPSIS:
	#include "tet_api.h"
	int tet_getsysbyid(int sysid, struct tet_sysent *sysp);

DESCRIPTION:
	DTET API function

	Tet_getsysbyid() places the `systems' file entry for the
	specified system ID into the space pointed to by sysp.
	It is not supported in TETware-Lite.

MODIFICATIONS:

	Andrew Dingwall, UniSoft Ltd., August 1998
	Moved tet_getsysbyid() from getsys.c to here.
 
************************************************************************/

#ifndef TET_LITE /* -START-LITE-CUT- */

#include <string.h>
#include "dtmac.h"
#include "dtthr.h"
#include "globals.h"
#include "sysent.h"
#include "tet_api.h"

TET_IMPORT int tet_getsysbyid(sysid, sysp)
int sysid;
struct tet_sysent *sysp;
{
	struct sysent *entp;

	if (!sysp)
	{
		tet_errno = TET_ER_INVAL;
		return -1;
	}

	API_LOCK;

	entp = tet_libgetsysbyid(sysid);
	if (!entp)
	{
		tet_errno = TET_ER_SYSID;
		API_UNLOCK;
		return -1;
	}

	/* copy the sy_sysid */
	sysp->ts_sysid = entp->sy_sysid;

	/* copy the sy_name - the sizes must be the same */
#if TET_SNAMELEN != SNAMELEN
#error "TET_SNAMELEN != SNAMELEN"
#endif
	(void) strncpy(sysp->ts_name, entp->sy_name, sizeof(sysp->ts_name));
	sysp->ts_name[sizeof(sysp->ts_name) - 1] = '\0';

	/* ignore the sy_tccd */
	
	API_UNLOCK;
	return 0;
}

#else /* -END-LITE-CUT- */

int tet_getsysid_c_not_used;

#endif /* -LITE-CUT-LINE- */