All Projects → gpakosz → Whereami

gpakosz / Whereami

Licence: other
Locate the current executable and the current module/library on the file system

Programming Languages

c
50402 projects - #5 most used programming language
cpp
1120 projects
introspection
24 projects

Projects that are alternatives of or similar to Whereami

Ui Neumorphism
📕 React component library designed on the "new skeuomorphism" or "neumorphism" UI/UX trend.
Stars: ✭ 258 (-4.44%)
Mutual labels:  library
Ristretto
A high performance memory-bound Go cache
Stars: ✭ 3,584 (+1227.41%)
Mutual labels:  library
I Use Arch Btw
"I use Arch btw" but it's a Turing-complete programming language.
Stars: ✭ 266 (-1.48%)
Mutual labels:  library
Hypre
Parallel solvers for sparse linear systems featuring multigrid methods.
Stars: ✭ 260 (-3.7%)
Mutual labels:  library
Zformat
The Hoa\Zformat library.
Stars: ✭ 265 (-1.85%)
Mutual labels:  library
Prdownloader
PRDownloader - A file downloader library for Android with pause and resume support
Stars: ✭ 2,947 (+991.48%)
Mutual labels:  library
Reachability
You can easily access the top of the screen in Android. Like a iPhone 6 & 6 Plus.
Stars: ✭ 259 (-4.07%)
Mutual labels:  library
Paper Switch
🎚 RAMPaperSwitch is a Swift material design UI module which paints over the parent view when the switch is turned on. iOS library by @Ramotion
Stars: ✭ 2,902 (+974.81%)
Mutual labels:  library
Pygogo
A Python logging library with superpowers
Stars: ✭ 265 (-1.85%)
Mutual labels:  library
Cordova Plugin Dialogs
Apache Cordova Plugin dialogs
Stars: ✭ 267 (-1.11%)
Mutual labels:  library
Node Window Manager
Manage windows in Windows, macOS and Linux using Node.js
Stars: ✭ 263 (-2.59%)
Mutual labels:  library
Public Transport Enabler
Unleash public transport data in your Java project.
Stars: ✭ 264 (-2.22%)
Mutual labels:  library
Landscapist
🍂 Jetpack Compose image loading library which can fetch and display network images using Glide, Coil, and Fresco.
Stars: ✭ 264 (-2.22%)
Mutual labels:  library
Incrementproductview
Interesting concept of products incrementation
Stars: ✭ 262 (-2.96%)
Mutual labels:  library
Rustface
Face detection library for the Rust programming language
Stars: ✭ 269 (-0.37%)
Mutual labels:  library
Robotframework Appiumlibrary
AppiumLibrary is an appium testing library for RobotFramework
Stars: ✭ 259 (-4.07%)
Mutual labels:  library
Flutter Ui Nice
More than 130+ pages in this beautiful app and more than 45 developers has contributed to it.
Stars: ✭ 3,092 (+1045.19%)
Mutual labels:  plugins
Gorequest
GoRequest -- Simplified HTTP client ( inspired by nodejs SuperAgent )
Stars: ✭ 3,063 (+1034.44%)
Mutual labels:  library
Visitor
The Hoa\Visitor library.
Stars: ✭ 269 (-0.37%)
Mutual labels:  library
Bottomsheet Imagepicker
Modern image picker for Android
Stars: ✭ 267 (-1.11%)
Mutual labels:  library

Where Am I?

A drop-in two files library to locate the current executable and the current module on the file system.

Supported platforms:

  • Windows
  • Linux
  • Mac
  • iOS
  • Android
  • QNX Neutrino
  • FreeBSD
  • NetBSD
  • DragonFly BSD
  • SunOS

Just drop whereami.h and whereami.c into your build and get started. (see also customizing compilation)


Usage

  • wai_getExecutablePath() returns the path of the enclosing executable
  • wai_getModulePath() returns the path of the enclosing module

Example usage:

  • first call int length = wai_getExecutablePath(NULL, 0, NULL); to retrieve the length of the path
  • allocate the destination buffer with path = (char*)malloc(length + 1);
  • call wai_getExecutablePath(path, length, &dirname_length) again to retrieve the path
  • add a terminal NUL character with path[length] = '\0';

Here is the output of the example:

$ make -j -C _gnu-make
$ cp ./bin/mac-x86_64/library.dylib /tmp/
$ ./bin/mac-x86_64/executable --load-library=/tmp/library.dylib

executable path: /Users/gregory/Projects/whereami/bin/mac-x86_64/executable
  dirname: /Users/gregory/Projects/whereami/bin/mac-x86_64
  basename: executable
module path: /Users/gregory/Projects/whereami/bin/mac-x86_64/executable
  dirname: /Users/gregory/Projects/whereami/bin/mac-x86_64
  basename: executable

library loaded
executable path: /Users/gregory/Projects/whereami/bin/mac-x86_64/executable
  dirname: /Users/gregory/Projects/whereami/bin/mac-x86_64
  basename: executable
module path: /private/tmp/library.dylib
  dirname: /private/tmp
  basename: library.dylib
library unloaded

Customizing compilation

You can customize the library's behavior by defining the following macros:

  • WAI_FUNCSPEC
  • WAI_PREFIX
  • WAI_MALLOC
  • WAI_REALLOC
  • WAI_FREE

Compiling for Windows

There is a Visual Studio 2015 solution in the _win-vs14/ folder.

Compiling for Linux or Mac

There is a GNU Make 3.81 MakeFile in the _gnu-make/ folder:

$ make -j -C _gnu-make/

Compiling for Mac

See above if you want to compile from command line. Otherwise there is an Xcode project located in the _mac-xcode/ folder.

Compiling for iOS

There is an Xcode project located in the _ios-xcode/ folder.

If you prefer compiling from command line and deploying to a jailbroken device through SSH, use:

$ make -j -C _gnu-make/ binsubdir=ios CC="$(xcrun --sdk iphoneos --find clang) -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -arch armv7 -arch armv7s -arch arm64" postbuild="codesign -s 'iPhone Developer'"

Compiling for Android

You will have to install the Android NDK, and point the $NDK_ROOT environment variable to the NDK path: e.g. export NDK_ROOT=/opt/android-ndk (without a trailing / character).

Next, the easy way is to make a standalone Android toolchain with the following command:

$ $NDK_ROOT/build/tools/make_standalone_toolchain.py --arch=arm64 --api 21 --install-dir=/tmp/android-toolchain

Now you can compile the example by running:

$ make -j -C _gnu-make/ platform=android architecture=arm64 CC=/tmp/android-toolchain/bin/aarch64-linux-android-gcc CXX=/tmp/android-toolchain/bin/aarch64-linux-android-g++

Loading page aligned library straight from APKs is supported. To test, use the following:

$ zip -Z store app bin/android/library.so
$ zipalign -v -f -p 4 ./app.zip ./app.apk

Then copy bin/android/executable and app.apk to your Android device and there launch:

$ ./executable --load-library=$PWD/app.apk!/bin/android/library.so
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].