The Share Library.
Libshare
Handles management of user-specific configuration options for the Share Library.
Note
The Share Library is hosted at
https://github.com/neonatura/share
https://github.com/neonatura/share
See the function for information on overwriting an option values for the current process session. Specify user specific configuration items.
shpref_sess_set()
group__libshare_1gad814ced5efcb4f0cc806f9da0c9bd299
member
typedef uint64_t shsize_t
A specification of byte size.
Note
This type is typically only used for disk storage or socket communications. A regular size_t is used when the bitsize of a number being reference is not restricted.
typedef long double shnum_t
A large floating-point number.
typedef struct shpeer_addr_t shpeer_addr_t
typedef struct shpeer_key_t shpeer_key_t
typedef struct shpeer_t shpeer_t
A local or remote network address.
char* get_libshare_email
(void)
An email address where bug reports can be submitted.
char* get_libshare_version
(void)
The current libshare library version.
char* get_libshare_title
(void)
The libshare library package name.
const char* get_libshare_path
(void)
Unix: /var/lib/share or ~/.share Windows: C:\.share Mac: ~/Library/Application Support/.share.
Return Value
The directory where share library persistent data is stored.
Note
This value can be overwritten with a shared preference.
const char* get_libshare_account_name
(void)
uint64_t get_libshare_account_id
(void)
int shnum_prec
(shnum_t fval)
Calculates the usable floating point precision (E notation).
shnum_t shnum_prec_dim
(shnum_t fval, int prec)
Reduce the precision of a large number to specific E exponent.
void shnum_set
(shnum_t val, uint64_t *bin_p)
Fills a uint64_t with a compatch version of a large number in network-byte order.
shnum_t shnum_get
(uint64_t val_bin)
Obtains a large number from a compact uint64_t value in host-byte order.
double shnum_getf
(uint64_t val_bin)
Obtain a double representation from a compact shnum_t value.
int shnum_sign
(shnum_t v)
void shpeer_set_default
(shpeer_t *peer)
Set the application's default peer reference.
See
shapp_init()
group__libshare__syspam_1gae81d0a766271573db756b2e09f12302e
member
shpeer_t* shpeer
(void)
Returns the default peer reference to the local user for IPv4.
Return Value
Information relevant to identifying a peer host.
Note
Use to free resources allocated.
shpeer_free()
group__libshare_1gab4154f7e7070c78b331bb9cb3fde93e6
member
shpeer_t* ashpeer
(void)
Returns the default peer reference to the local user for IPv4 without dynamic memory allocation.
Return Value
Information relevant to identifying a peer host.
Note
Do NOT use to free.
shpeer_free()
group__libshare_1gab4154f7e7070c78b331bb9cb3fde93e6
member
shpeer_t* shpeer_init
(char *appname, char *hostname)
Generate a peer reference.
Param
appname
An application name an optional group name in "[@]app" format or NULL for a un-named generic "libshare" app.
hostname
A host and optional port in "[:]" format or NULL for a localhost reference.
Return Value
A peer identity reference.
Note
Use to free.
shpeer_free()
group__libshare_1gab4154f7e7070c78b331bb9cb3fde93e6
member
void shpeer_free
(shpeer_t **peer_p)
Free the resources associated with a peer reference.
char* shpeer_print
(shpeer_t *peer)
A string representation of the libshare peer.
int shpeer_localhost
(shpeer_t *peer)
Test whether a peer identity is referencing localhost.
Return Value
TRUE if a localhost and FALSE if not.
char* shpeer_get_app
(shpeer_t *peer)
Obtain a label referencing the peer entity.
void shpeer_host
(shpeer_t *peer, char *hostname, int *port_p)
struct sockaddr* shpeer_addr
(shpeer_t *peer)
char* shpref_base_dir
(void)
Specifies the preferred location of where the sharefs filesystem is stored on the local file system.
Return Value
The path to a directory on the local file-system.
char* shpref_path
(int uid)
The local filesystem path for storing configuration options.
Return Value
The path to the location on the local file-system that contains user-specific libshare configuration options.
int shpref_init
(void)
Initialize an instance of configuration options in memory.
Note
This function does not need to be called in order to retrieve or set configuration options.
Return Value
A zero (0) on success and a negative one (-1) on failure.
void shpref_free
(void)
Free the configuration options loaded into memory.
Note
This will remove all temporar configuration settings that have been made this process session.
const char* shpref_get
(char *pref, char *default_value)
Retrieve a configuration option value.
Param
pref
The name of the preference.
default_value
The default string value to return if the preference is not set.
Return Value
The configuration option value.
Note
This function is not thread-safe.
int shpref_set
(char *pref, char *value)
Set a persistent value for a particular libshare user-specific configuration option.
Specify user specific configuration items:
-
SHPREF_BASE_DIR The base directory to store sharefs file data.
-
SHPREF_TRACK Whether to automatically track file revisions.
-
SHPREF_OVERLAY Whether to write outside of the base directory. Set a configuration option value.
Param
pref
The name of the preference.
value
The configuration option value.
Return Value
The configuration option value.
PRINT_ERROR
sherr(_err, _msg)
INADDR_LOOPBACK
0x7f000001
MAX_SHARE_NAME_LENGTH
136
MAX_SHARE_PASS_LENGTH
136
MAX_SHARE_HASH_LENGTH
136
SHARE_DEFAULT_EXPIRE_TIME
1514743200
A shtime_t representation of 01/01/60 UTC.
MAX_SHARE_SESSION_TIME
10368000
SHNET_PEER_LOCAL
0
The local machine.
SHNET_PEER_IPV4
1
A remote IPv4 network destination.
SHNET_PEER_IPV6
2
A remote IPv6 network destination.
SHNET_PEER_VPN_IPV4
3
A IPv4 network destination on the sharenet VPN.
SHNET_PEER_VPN_IPV6
4
A IPv6 network destination on the sharenet VPN.
SHNET_BROADCAST
5
Global network destination.
SHARCH_32BIT
(1 << 0)
32bit hardware (i.e.
not 64bit)
SHARCH_LINUX
(1 << 1)
linux
SHARCH_WIN
(1 << 2)
win/doh
SHARCH_MAC
(1 << 3)
apple/mac
SHARCH_BSD
(1 << 4)
bsd/freebsd
SHARCH_SUN
(1 << 5)
sun os
SHARCH_MIPS
(1 << 7)
(android) mips chipset
SHARCH_BIGEND
(1 << 7)
(aix/4) big endian / network byte order
shpeer_kpub
(& (_peer)->key.pub)
public key reference of peer
shpeer_kpriv
(& (_peer)->key.priv)
priveleged key reference of peer
SHPREF_TRUE
"true"
Indicates a positive boolean value.
SHPREF_FALSE
"false"
Indicates a negative boolean value.
SHPREF_BASE_DIR
"base-dir"
Specifies the preferred location of where the sharefs filesystem is stored on the local file system.
Note
The default location is '$HOME/.share'.
Use to temporarily overwrite this value.
shpref_sess_set()
group__libshare_1gad814ced5efcb4f0cc806f9da0c9bd299
member
SHPREF_TRACK
"track"
Specifies whether to track sharefs filesystem revisions.
Note
Use to temporarily overwrite this value.
shpref_sess_set()
group__libshare_1gad814ced5efcb4f0cc806f9da0c9bd299
member
SHPREF_OVERLAY
"overlay"
Specifies whether the sharefs file system references files on the local filesystem.
Note
Use to temporarily overwrite this value.
shpref_sess_set()
group__libshare_1gad814ced5efcb4f0cc806f9da0c9bd299
member
SHPREF_ACC_NAME
SHMETA_USER_EMAIL
The account name is typically comprised of an email address optionally followed by a real name in 'LAST/FIRST' format.
SHPREF_ACC_PASS
SHMETA_USER_PASS
A key reference to the user's account password.
SHPREF_ACC_SALT
SHMETA_USER_SALT
The salt used to perturb the account password key.
SHPREF_ACC_GEO
SHMETA_USER_GEO
SHPREF_MAX
6
Specifies the number of preferences available.
SHPREF_NAME_MAX
4096
Specified the maximum size of a share library global preference name.
SHPREF_VALUE_MAX
4096
Specified the maximum size of a share library global preference value.
shpref_track
(0 == strcmp(shpref_get(SHPREF_TRACK), "true") ? TRUE : FALSE)
Specifies whether to track sharefs filesystem revisions.
Return Value
A zero (0) when disabled and a non-zero value when enabled.
shpref_set_track
(opt ? shpref_set(SHPREF_TRACK, "true") : shpref_set(SHPREF_TRACK, "false"))
Permanently sets the option.
SHPREF_TRACK
Param
opt
A zero to disable the option and a non-zero to enable.
shpref_overlay
(0 == strcmp(shpref_get(SHPREF_OVERLAY), "true") ? TRUE : FALSE)
Specifies whether to overlay the sharefs filesystem ontop of the work directory on the local filesystem.
Note
Disable this option to prevent libshare from writing outside of the base directory.
Return Value
A zero (0) when disabled and a non-zero value when enabled.
shpref_set_overlay
(opt ? shpref_set(SHPREF_OVERLAY, "true") : shpref_set(SHPREF_OVERLAY, "false"))
Permanently sets the option.
SHPREF_OVERLAY
Param
opt
A zero to disable the option and a non-zero to enable.
shpref_unset
shpref_set(pref, NULL)
Persistently unset a libshare configuration option.
shpref_sess_set
shmap_set_astr(_pref, ashkey_str(pref), value)
Overwrite a preference for the current session.
shpref_sess_unset
shmap_unset(_pref, ashkey_str(pref))
Temporarily unset a libshare configuration option.