blob: b99b94fe18ab18ecff9d84032e6d11bc59f9e99a [file] [log] [blame]
Austin Schuh36244a12019-09-21 17:52:38 -07001//
2// Copyright 2019 The Abseil Authors.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// https://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#ifndef ABSL_FLAGS_INTERNAL_PROGRAM_NAME_H_
17#define ABSL_FLAGS_INTERNAL_PROGRAM_NAME_H_
18
19#include <string>
20
Austin Schuhb4691e92020-12-31 12:37:18 -080021#include "absl/base/config.h"
Austin Schuh36244a12019-09-21 17:52:38 -070022#include "absl/strings/string_view.h"
23
24// --------------------------------------------------------------------
25// Program name
26
27namespace absl {
Austin Schuhb4691e92020-12-31 12:37:18 -080028ABSL_NAMESPACE_BEGIN
Austin Schuh36244a12019-09-21 17:52:38 -070029namespace flags_internal {
30
31// Returns program invocation name or "UNKNOWN" if `SetProgramInvocationName()`
32// is never called. At the moment this is always set to argv[0] as part of
33// library initialization.
34std::string ProgramInvocationName();
35
36// Returns base name for program invocation name. For example, if
37// ProgramInvocationName() == "a/b/mybinary"
38// then
39// ShortProgramInvocationName() == "mybinary"
40std::string ShortProgramInvocationName();
41
42// Sets program invocation name to a new value. Should only be called once
43// during program initialization, before any threads are spawned.
44void SetProgramInvocationName(absl::string_view prog_name_str);
45
46} // namespace flags_internal
Austin Schuhb4691e92020-12-31 12:37:18 -080047ABSL_NAMESPACE_END
Austin Schuh36244a12019-09-21 17:52:38 -070048} // namespace absl
49
50#endif // ABSL_FLAGS_INTERNAL_PROGRAM_NAME_H_