File: simulaid.c

package info (click to toggle)
cim 3.36-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,964 kB
  • ctags: 2,750
  • sloc: ansic: 25,286; sh: 7,612; yacc: 873; perl: 781; makefile: 155
file content (102 lines) | stat: -rw-r--r-- 2,473 bytes parent folder | download
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
/* $Id: $ */

/* Copyright (C) 1997 Sverre Hvammen Johansen,
 * Department of Informatics, University of Oslo.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "cim.h"
#include "../config.h"

/******************************************************************************
                                              TEXT PROCEDURE SIMULAID        */

extern char *__progname;
#define MAX_HOSTNAME_LEN 100
#define MAX_SITEID_LEN   100
#define MAX_INT_LEN       12
#define MAX_PROGNAME_LEN 100
#define MAX_SIMULAID_LEN (100+MAX_SITEID_LEN+MAX_HOSTNAME_LEN\
			  +3*MAX_INT_LEN+MAX_PROGNAME_LEN)
#if HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
#endif

__txtvp 
__rsimulaid (as)
     long as;
{
  char simulaid[MAX_SIMULAID_LEN];
  char siteid[MAX_SITEID_LEN];
  char cpu[MAX_HOSTNAME_LEN];
  char user[MAX_INT_LEN];
  char job[MAX_INT_LEN];
  char acc[MAX_INT_LEN];
#if HAVE_UNAME
  static struct utsname name;
#endif
#if HAVE_GETDOMAINNAME
  (void) getdomainname (siteid, MAX_SITEID_LEN);
#endif
#if HAVE_UNAME
  (void) uname (&name);
  strcpy (cpu, name.nodename);
#else
#if HAVE_GETHOSTNAME
  (void) gethostname (cpu, MAX_HOSTNAME_LEN);
#endif
#endif
#if HAVE_GETUID
  (void) sprintf (user, "%d", getuid ());
#endif
#if HAVE_GETPID
  (void) sprintf (job, "%d", getpid ());
#endif
#if HAVE_GETEGID
  (void) sprintf (acc, "%d", getegid ());
#endif
  (void) sprintf (simulaid, "%s!!!%s!!!%s!!!%s!!!%s!!!%s!!!%s!!!%s"
		  ,PACKAGE_VERSION
#if HAVE_GETDOMAINNAME
		  ,siteid
#else
		  ,"???"
#endif
		  ,SYSTEM_TYPE
#if HAVE_UNAME || HAVE_GETHOSTNAME
		  ,cpu
#else
		  ,"???"
#endif
#if HAVE_GETUID
		  ,user
#else
		  ,"???"
#endif
#if HAVE_GETPID
		  ,job
#else
		  ,"???"
#endif
#if HAVE_GETEGID
		  ,acc
#else
		  ,"???"
#endif
		  ,__progname);
  (void) __rblanks (as, (long) strlen (simulaid));
  (void) sprintf (__et.obj->string, "%s", simulaid);
  return (&__et);
}