Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ if(WITH_CAP)
target_link_libraries(librpm PRIVATE PkgConfig::LIBCAP)
endif()

if(NOT HAVE_SETPROGNAME AND NOT HAVE___PROGNAME)
target_link_libraries(librpm PRIVATE libmisc)
endif()

add_custom_command(OUTPUT tagtbl.inc
COMMAND AWK=${AWK} ${CMAKE_CURRENT_SOURCE_DIR}/gentagtbl.sh ${CMAKE_SOURCE_DIR}/include/rpm/rpmtag.h > tagtbl.inc
DEPENDS ${CMAKE_SOURCE_DIR}/include/rpm/rpmtag.h gentagtbl.sh
Expand Down
2 changes: 1 addition & 1 deletion misc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_library(libmisc OBJECT fts.c rpmfts.h)
add_library(libmisc OBJECT fts.c rpmfts.h rpmxprogname.c rpmxprogname.h)
target_include_directories(libmisc PRIVATE ${Intl_INCLUDE_DIRS})
31 changes: 31 additions & 0 deletions misc/rpmxprogname.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* Original author: Kamil Rytarowski
File: rpmxprogname.c
Date of creation: 2013-08-10
License: the same as RPM itself */

#include "rpmxprogname.h"

#include <string.h> /* strrchr */

const char *_rpmxprogname = NULL;

const char *_rpmxgetprogname(void)
{
const char *empty = "";

if (_rpmxprogname != NULL) /* never return NULL string */
return _rpmxprogname;
else
return empty;
}

void _rpmxsetprogname(const char *pn)
{
if (pn != NULL && _rpmxprogname == NULL /* set the value only once */) {
char *p = strrchr(pn, '/'); /* locate the last occurrence of '/' */
if (p != NULL)
_rpmxprogname = p + 1 /* strip beginning '/' */;
else
_rpmxprogname = pn;
}
}
21 changes: 21 additions & 0 deletions misc/rpmxprogname.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Original author: Kamil Rytarowski
File: rpmxprogname.c
Date of creation: 2013-08-10
License: the same as RPM itself */

#ifndef _RPMXPROGNAME_H
#define _RPMXPROGNAME_H

#ifdef __cplusplus
extern "C" {
#endif

const char *_rpmxgetprogname(void);
void _rpmxsetprogname(const char *pn);

#ifdef __cplusplus
}
#endif

#endif /* _RPMXPROGNAME_H */

6 changes: 4 additions & 2 deletions misc/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ extern int fdatasync(int fildes);
# define xsetprogname(pn)
extern const char *__progname;
# define xgetprogname(pn) __progname
#else
# error "Did not find any sutable implementation of xsetprogname/xgetprogname"
#else /* Reimplement setprogname and getprogname */
# include "rpmxprogname.h"
# define xsetprogname(pn) _rpmxsetprogname(pn)
# define xgetprogname() _rpmxgetprogname()
#endif

/* Take care of NLS matters. */
Expand Down