BRL-CAD
user.h
Go to the documentation of this file.
1 /* U S E R . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2023-2024 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #include "common.h"
22 
23 #include "bu/defines.h"
24 
25 
26 /**
27  * used to specify what name type is desired
28  */
30  BU_USER_ACCT, /**< user account name */
31  BU_USER_REAL, /**< user real full name */
32  BU_USER_AUTO /**< either account or real */
33 };
34 
35 
36 /**
37  * Routine for obtaining user names
38  *
39  * Returns a given user's account name or real full name if available.
40  * May return "unknown" if the name is not available. If 'name' is
41  * empty, then the current user's name will be returned. If 'name' is
42  * not empty, then it is used as a case-insensitive lookup string.
43  *
44  * If 'name' is NULL or size is 0, then dynamic memory will be
45  * allocated with bu_malloc() and returned.
46  *
47  @code
48  char name[128] = {0};
49  (void)bu_user_name(BU_USER_AUTO, name, sizeof(name));
50 
51  char *account = bu_user_name(BU_USER_ACCT, NULL, 0);
52  bu_free(account);
53 
54  char *name = bu_user_name(BU_USER_REAL, "username", 0);
55  bu_free(name);
56  @endcode
57  */
58 BU_EXPORT char *
59 bu_user_name(enum bu_user_type type, char *name, size_t size);
60 
61 
62 /*
63  * Local Variables:
64  * mode: C
65  * tab-width: 8
66  * indent-tabs-mode: t
67  * c-file-style: "stroustrup"
68  * End:
69  * ex: shiftwidth=4 tabstop=8
70  */
Header file for the BRL-CAD common definitions.
void float float int int int int float * size
Definition: tig.h:132
bu_name_type
Definition: user.h:29
@ BU_USER_ACCT
Definition: user.h:30
@ BU_USER_AUTO
Definition: user.h:32
@ BU_USER_REAL
Definition: user.h:31
char * bu_user_name(enum bu_user_type type, char *name, size_t size)