group
group__libshare
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
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
typedef long double shnum_t
A large floating-point number.
typedef
typedef struct shpeer_addr_t shpeer_addr_t
typedef
typedef struct shpeer_key_t shpeer_key_t
typedef
typedef struct shpeer_t shpeer_t
A local or remote network address.
function
char* get_libshare_email
(void)
An email address where bug reports can be submitted.
function
char* get_libshare_version
(void)
The current libshare library version.
function
char* get_libshare_title
(void)
The libshare library package name.
function
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.
function
const char* get_libshare_account_name
(void)
function
uint64_t get_libshare_account_id
(void)
function
int shnum_prec
(shnum_t fval)
Calculates the usable floating point precision (E notation).
function
shnum_t shnum_prec_dim
(shnum_t fval, int prec)
Reduce the precision of a large number to specific E exponent.
function
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.
function
shnum_t shnum_get
(uint64_t val_bin)
Obtains a large number from a compact uint64_t value in host-byte order.
function
double shnum_getf
(uint64_t val_bin)
Obtain a double representation from a compact shnum_t value.
function
int shnum_sign
(shnum_t v)
function
void shpeer_set_default
(shpeer_t *peer)
Set the application's default peer reference.
See
shapp_init() group__libshare__syspam_1gae81d0a766271573db756b2e09f12302e member
function
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
function
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
function
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
function
void shpeer_free
(shpeer_t **peer_p)
Free the resources associated with a peer reference.
function
char* shpeer_print
(shpeer_t *peer)
A string representation of the libshare peer.
function
int shpeer_localhost
(shpeer_t *peer)
Test whether a peer identity is referencing localhost.
Return Value
TRUE if a localhost and FALSE if not.
function
char* shpeer_get_app
(shpeer_t *peer)
Obtain a label referencing the peer entity.
function
void shpeer_host
(shpeer_t *peer, char *hostname, int *port_p)
function
struct sockaddr* shpeer_addr
(shpeer_t *peer)
function
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.
function
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.
function
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.
function
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.
function
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.
function
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.
define
FALSE
0
define
TRUE
(!FALSE)
define
MIN
(a < b ? a : b)
define
MAX
(a > b ? a : b)
define
PRINT_RUSAGE
define
PRINT_ERROR
sherr(_err, _msg)
define
INADDR_LOOPBACK
0x7f000001
define
MAX_SHARE_NAME_LENGTH
136
define
MAX_SHARE_PASS_LENGTH
136
define
MAX_SHARE_HASH_LENGTH
136
define
SHARE_PAGE_SIZE
8192
define
SHARE_DEFAULT_EXPIRE_TIME
1514743200
A shtime_t representation of 01/01/60 UTC.
define
MAX_SHARE_SESSION_TIME
10368000
define
SHNET_PEER_LOCAL
0
The local machine.
define
SHNET_PEER_IPV4
1
A remote IPv4 network destination.
define
SHNET_PEER_IPV6
2
A remote IPv6 network destination.
define
SHNET_PEER_VPN_IPV4
3
A IPv4 network destination on the sharenet VPN.
define
SHNET_PEER_VPN_IPV6
4
A IPv6 network destination on the sharenet VPN.
define
SHNET_BROADCAST
5
Global network destination.
define
SHARCH_32BIT
(1 << 0)
32bit hardware (i.e.
not 64bit)
define
SHARCH_LINUX
(1 << 1)
linux
define
SHARCH_WIN
(1 << 2)
win/doh
define
SHARCH_MAC
(1 << 3)
apple/mac
define
SHARCH_BSD
(1 << 4)
bsd/freebsd
define
SHARCH_SUN
(1 << 5)
sun os
define
SHARCH_MIPS
(1 << 7)
(android) mips chipset
define
SHARCH_BIGEND
(1 << 7)
(aix/4) big endian / network byte order
define
shpeer_kpub
(& (_peer)->key.pub)
public key reference of peer
define
shpeer_kpriv
(& (_peer)->key.priv)
priveleged key reference of peer
define
SHPREF_TRUE
"true"
Indicates a positive boolean value.
define
SHPREF_FALSE
"false"
Indicates a negative boolean value.
define
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
define
SHPREF_TRACK
"track"
Specifies whether to track sharefs filesystem revisions.
Note
Use to temporarily overwrite this value.
shpref_sess_set() group__libshare_1gad814ced5efcb4f0cc806f9da0c9bd299 member
define
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
define
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.
define
SHPREF_ACC_PASS
SHMETA_USER_PASS
A key reference to the user's account password.
define
SHPREF_ACC_SALT
SHMETA_USER_SALT
The salt used to perturb the account password key.
define
SHPREF_ACC_GEO
SHMETA_USER_GEO
define
SHPREF_MAX
6
Specifies the number of preferences available.
define
SHPREF_NAME_MAX
4096
Specified the maximum size of a share library global preference name.
define
SHPREF_VALUE_MAX
4096
Specified the maximum size of a share library global preference value.
define
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.
define
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.
define
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.
define
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.
define
shpref_unset
shpref_set(pref, NULL)
Persistently unset a libshare configuration option.
define
shpref_sess_set
shmap_set_astr(_pref, ashkey_str(pref), value)
Overwrite a preference for the current session.
define
shpref_sess_unset
shmap_unset(_pref, ashkey_str(pref))
Temporarily unset a libshare configuration option.