Open Files 5.3.0
Multi-Platform Event-Driven Application Framework
framework.h File Reference
#include "ofc/types.h"
#include "ofc/config.h"
#include "ofc/core.h"
#include "ofc/net.h"
#include "ofc/path.h"
#include "ofc/file.h"
Include dependency graph for framework.h:

Go to the source code of this file.

Data Structures

struct  OFC_FRAMEWORK_WINSLIST
 
struct  OFC_FRAMEWORK_INTERFACE
 
struct  OFC_FRAMEWORK_INTERFACES
 
struct  OFC_FRAMEWORK_MAP
 
struct  OFC_FRAMEWORK_MAPS
 
enum  OFC_CONFIG_MODE {
  OFC_CONFIG_BMODE = 0 , OFC_CONFIG_PMODE , OFC_CONFIG_MMODE , OFC_CONFIG_HMODE ,
  OFC_CONFIG_MODE_MAX
}
 
OFC_CORE_LIB OFC_VOID ofc_framework_init (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_framework_destroy (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_framework_startup (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_framework_shutdown (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_framework_load (OFC_LPCTSTR filename)
 
OFC_CORE_LIB OFC_VOID ofc_framework_loadbuf (OFC_LPVOID buf, OFC_SIZET len)
 
OFC_CORE_LIB OFC_VOID ofc_framework_save (OFC_LPCTSTR filename)
 
OFC_CORE_LIB OFC_VOID ofc_framework_savebuf (OFC_LPVOID *buf, OFC_SIZET *len)
 
OFC_CORE_LIB OFC_BOOL ofc_get_config_dir (OFC_TCHAR *config_dir, OFC_SIZET len)
 
OFC_CORE_LIB OFC_VOID ofc_set_config_path (OFC_TCHAR *filename)
 
OFC_CORE_LIB OFC_VOID ofc_framework_set_netbios (OFC_BOOL enabled)
 
OFC_CORE_LIB OFC_VOID ofc_framework_set_host_name (OFC_LPCTSTR name, OFC_LPCTSTR workgroup, OFC_LPCTSTR desc)
 
OFC_CORE_LIB OFC_LPTSTR ofc_framework_get_host_name (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_framework_free_host_name (OFC_LPTSTR str)
 
OFC_CORE_LIB OFC_LPTSTR ofc_framework_get_workgroup (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_framework_free_workgroup (OFC_LPTSTR str)
 
OFC_CORE_LIB OFC_LPTSTR ofc_framework_get_description (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_framework_free_description (OFC_LPTSTR str)
 
OFC_VOID ofc_framework_set_realm (const OFC_CHAR *realm)
 
OFC_CCHARofc_framework_get_realm (OFC_VOID)
 
OFC_VOID ofc_framework_set_uuid (const OFC_CHAR *cuuid)
 
OFC_CHARofc_framework_get_uuid (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_framework_free_uuid (OFC_LPSTR str)
 
OFC_CORE_LIB OFC_LPTSTR ofc_framework_get_root_dir (OFC_VOID)
 
OFC_CORE_LIB OFC_VOID ofc_framework_free_root_dir (OFC_LPTSTR str)
 
OFC_CORE_LIB OFC_VOID ofc_framework_set_logging (OFC_UINT log_level, OFC_BOOL log_console)
 
OFC_VOID ofc_framework_set_interface_discovery (OFC_BOOL on)
 
OFC_BOOL ofc_framework_get_interface_discovery (OFC_VOID)
 
OFC_VOID ofc_framework_add_interface (OFC_FRAMEWORK_INTERFACE *iface)
 
OFC_VOID ofc_framework_remove_interface (OFC_IPADDR *ip)
 
OFC_FRAMEWORK_INTERFACESofc_framework_get_interfaces (OFC_VOID)
 
OFC_VOID ofc_framework_free_interfaces (OFC_FRAMEWORK_INTERFACES *ifaces)
 
OFC_BOOL ofc_framework_add_map (OFC_FRAMEWORK_MAP *map)
 
OFC_FRAMEWORK_MAPSofc_framework_get_maps (OFC_VOID)
 
OFC_VOID ofc_framework_free_maps (OFC_FRAMEWORK_MAPS *maps)
 
OFC_VOID ofc_framework_remove_map (OFC_LPCTSTR tszPrefix)
 
OFC_VOID ofc_framework_update (OFC_VOID)
 
OFC_VOID ofc_framework_dump_heap (OFC_VOID)
 
OFC_VOID ofc_framework_stats_heap (OFC_VOID)
 

Enumeration Type Documentation

◆ OFC_CONFIG_MODE

Netbios Modes

NetBIOS can operate in a number of different modes that govern whether names are registered and resolved by broadcast, or by querying a WINS server.

Enumerator
OFC_CONFIG_BMODE 

Broadcast Mode

OFC_CONFIG_PMODE 

WINS Mode

OFC_CONFIG_MMODE 

Mixed Mode, Broadcast first

OFC_CONFIG_HMODE 

Hybrid Mode, WINS first

OFC_CONFIG_MODE_MAX 

Number of Modes

Function Documentation

◆ ofc_framework_add_interface()

OFC_VOID ofc_framework_add_interface ( OFC_FRAMEWORK_INTERFACE iface)

Add an interface.

Only useful if interface discovery is off See the description of interface parameters.

Parameters
ifaceInterface description to add
Note
There are client deployments which do not care which interface is used for a connection to the server. In these situations, it may be useful to turn off interface discovery,disable the network monitor and add a single default interface using this call. The default interface configuration can contain 0.0.0.0 as the interface IP, 255.255.255.255 for the broadcast address, and 0.0.0.0 for the netmask
Default netbios mode and WINS configuration can alo be specified.
See also
ofc_framework_set_interface_discovery
Configuration Platform Behavior
Examples
smbinit.c.

◆ ofc_framework_add_map()

OFC_BOOL ofc_framework_add_map ( OFC_FRAMEWORK_MAP map)

Add an alias

This allows a shortened name for a path

Parameters
mapMap to add
Returns
Status of add

◆ ofc_framework_destroy()

OFC_CORE_LIB OFC_VOID ofc_framework_destroy ( OFC_VOID  )

Destroy the Open Files framework

This will release all memory and destroy the heap. The state of the application should be as if Open Files has not been run.

If INIT_ON_LOAD is defined, there is no need to call thi function.

Examples
smbinit.c, and test_path.c.

◆ ofc_framework_dump_heap()

OFC_VOID ofc_framework_dump_heap ( OFC_VOID  )

Dump the heap

Used in debug mode only

◆ ofc_framework_free_description()

OFC_CORE_LIB OFC_VOID ofc_framework_free_description ( OFC_LPTSTR  str)

Free the returned description of the host

Parameters
strDescription String to free

◆ ofc_framework_free_host_name()

OFC_CORE_LIB OFC_VOID ofc_framework_free_host_name ( OFC_LPTSTR  str)

Free the hostname returned from ofc_framework_get_host_name

Parameters
strString to free

◆ ofc_framework_free_interfaces()

OFC_VOID ofc_framework_free_interfaces ( OFC_FRAMEWORK_INTERFACES ifaces)

Free interfaces returned from getinterfaces

Parameters
ifacesInterface array to free

◆ ofc_framework_free_maps()

OFC_VOID ofc_framework_free_maps ( OFC_FRAMEWORK_MAPS maps)

Free the returned aliases

Parameters
mapsArray of maps to free

◆ ofc_framework_free_root_dir()

OFC_CORE_LIB OFC_VOID ofc_framework_free_root_dir ( OFC_LPTSTR  str)

Free the string returned from getrootdir

Parameters
strString to free

◆ ofc_framework_free_uuid()

OFC_CORE_LIB OFC_VOID ofc_framework_free_uuid ( OFC_LPSTR  str)

Free the UUID returned from GetUUID

Parameters
strString to free
Examples
smbls.c.

◆ ofc_framework_free_workgroup()

OFC_CORE_LIB OFC_VOID ofc_framework_free_workgroup ( OFC_LPTSTR  str)

Free the workgroup name returned by ofc_framework_get_workgroup

Parameters
strWorkgroup name to free

◆ ofc_framework_get_description()

OFC_CORE_LIB OFC_LPTSTR ofc_framework_get_description ( OFC_VOID  )

Get the description of the host

Returns
Description

◆ ofc_framework_get_host_name()

OFC_CORE_LIB OFC_LPTSTR ofc_framework_get_host_name ( OFC_VOID  )

Return the OpenFiles Host Name

This returns a hostname allocated from the heap. You must call ofc_framework_free_host_name to free the returned name

/returns Hostname

◆ ofc_framework_get_interface_discovery()

OFC_BOOL ofc_framework_get_interface_discovery ( OFC_VOID  )

Return the setting of interface discovery

Returns
True if interface discovery is enabled

◆ ofc_framework_get_interfaces()

OFC_FRAMEWORK_INTERFACES* ofc_framework_get_interfaces ( OFC_VOID  )

Get configured interfaces. Interface array must subsequently be freed.

Returns
Array of interfaces

◆ ofc_framework_get_maps()

OFC_FRAMEWORK_MAPS* ofc_framework_get_maps ( OFC_VOID  )

Return the aliases, maps must subsequently be freed

Returns
Array of maps

◆ ofc_framework_get_realm()

OFC_CCHAR* ofc_framework_get_realm ( OFC_VOID  )

Return the default realm.

This is intended to be called internally.

Returns
Default Realm of your target servers

◆ ofc_framework_get_root_dir()

OFC_CORE_LIB OFC_LPTSTR ofc_framework_get_root_dir ( OFC_VOID  )

Get the Home/Root directory of the stack

Used by the Android app only

Returns
Root Directory

◆ ofc_framework_get_uuid()

OFC_CHAR* ofc_framework_get_uuid ( OFC_VOID  )

Get the stacks UUID

Returns
UUID
Examples
smbls.c.

◆ ofc_framework_get_workgroup()

OFC_CORE_LIB OFC_LPTSTR ofc_framework_get_workgroup ( OFC_VOID  )

Get the workgroup that this instance is part of

The returned workgroup name must be freed with ofc_framework_free_workgroup

Returns
Workgroup

◆ ofc_framework_init()

OFC_CORE_LIB OFC_VOID ofc_framework_init ( OFC_VOID  )

Initialize the Open iles Stack

This routine should be called before any other OpenFiles function. It initializes heap and other variables.

If the build param INIT_ON_LOAD is defined, the routine will implicitly be called when the library is loaded.
In that case, there is no need for the application to call it.

Examples
smbinit.c, and test_path.c.

◆ ofc_framework_load()

OFC_CORE_LIB OFC_VOID ofc_framework_load ( OFC_LPCTSTR  filename)

Load the ConnectedSMB configuration from a file

This is an optional call mainly used for SMB Server configuration. It is not needed by the client unless you have stored drive maps in the configuration file

Parameters
filenamePath to filename to load configuration from
Examples
smbinit.c.

◆ ofc_framework_loadbuf()

OFC_CORE_LIB OFC_VOID ofc_framework_loadbuf ( OFC_LPVOID  buf,
OFC_SIZET  len 
)

Load the ConnectedSMB configuration from a buffer

This is an optional call mainly used for SMB Server configuration. It is not needed by the client unless you have stored drive maps in the configuration file

Parameters
bufBuffer to load configuration from
lenlength of buffer

◆ ofc_framework_remove_interface()

OFC_VOID ofc_framework_remove_interface ( OFC_IPADDR *  ip)

Remove an interface

Only useful if interface discovery is off

Parameters
ipIP of interface to remove

◆ ofc_framework_remove_map()

OFC_VOID ofc_framework_remove_map ( OFC_LPCTSTR  tszPrefix)

Remove a map

Parameters
tszPrefixPrefix (i.e.alias) to remove

◆ ofc_framework_save()

OFC_CORE_LIB OFC_VOID ofc_framework_save ( OFC_LPCTSTR  filename)

Save the current configuration to a file

Useful if you've configured the stack using the various API calls and wish to capture them so they can be later loaded.

Parameters
filenamePath to Filename to save configuration in

◆ ofc_framework_savebuf()

OFC_CORE_LIB OFC_VOID ofc_framework_savebuf ( OFC_LPVOID buf,
OFC_SIZET len 
)

Save the current configuration to heap allocated buffer

Useful if you've configured the stack using the various API calls and wish to capture them so they can be later loaded.

NOTE: buf must be freed by caller

Parameters
bufBuffer to store configuration in
lenLength of buffer
Returns
True if configuration stored

◆ ofc_framework_set_host_name()

OFC_CORE_LIB OFC_VOID ofc_framework_set_host_name ( OFC_LPCTSTR  name,
OFC_LPCTSTR  workgroup,
OFC_LPCTSTR  desc 
)

Set the host name of the running instance

Mostly used to set the server name but this will also set the client host name as well.

Parameters
nameName of System
workgroupWorkgroup of System
descDescription of system
Examples
smbinit.c.

◆ ofc_framework_set_interface_discovery()

OFC_VOID ofc_framework_set_interface_discovery ( OFC_BOOL  on)

Set whether the stack should query the underlying platform for available interfaces and IP addresses or whether the network configuration is done manually or not

Parameters
onTrue if interfaces should be discovered
Examples
smbinit.c.

◆ ofc_framework_set_logging()

OFC_CORE_LIB OFC_VOID ofc_framework_set_logging ( OFC_UINT  log_level,
OFC_BOOL  log_console 
)

Set the logging behavior of Openfiles

Parameters
log_levelThe log level to capture. All log levels less than or equal to this level will be captured. Those greater will be ignored.
See also
OFC_LOG_LEVEL
Parameters
log_consoleSet to OFC_TRUE if log messages should be output to console
Note
On Linux, captured logs are output to the syslog. On Android, captured logs are output to the application's file directory. On Windows, log file is written to the file "openfiles.log" in the current directory. On other platforms, see ConnectedWay support
Examples
smbinit.c.

◆ ofc_framework_set_netbios()

OFC_CORE_LIB OFC_VOID ofc_framework_set_netbios ( OFC_BOOL  enabled)

Enable/Disable NetBIOS

Parameters
enabledIf OFC_TRUE, enable netbios, if OFC_FALSE, disable
Examples
smbinit.c.

◆ ofc_framework_set_realm()

OFC_VOID ofc_framework_set_realm ( const OFC_CHAR realm)

Set the default Kerberos Realm

This should be called to set the default Kerberos Realm for target SMB Servers. If this is not called during system initialization, you should be sure to configure the "default_realm" property within the libdefaults section of the krb5.conf file. If neither this nor the krb5.conf default_realm property is not set, you will receive a missing default realm GSAPI error upon attempting to authenticate with Kerberos or Active Directory.

Parameters
realmDefault Realm for your target servers
Examples
smbinit.c.

◆ ofc_framework_set_uuid()

OFC_VOID ofc_framework_set_uuid ( const OFC_CHAR cuuid)

Set the UUID of the host

This should be called to set the UUID of the host used in SMB authentication.

Parameters
cuuidUUID of system
Examples
smbinit.c.

◆ ofc_framework_shutdown()

OFC_CORE_LIB OFC_VOID ofc_framework_shutdown ( OFC_VOID  )

Shutdown the OpenFiles Components

Thi function will gracefully bring down core components of the Open Files stack. If INIT_ON_LOAD is defined, then this function will be called implicitly when the application is unloaded. In that case, there would be no reason to call this routine.

Examples
smbinit.c, and test_path.c.

◆ ofc_framework_startup()

OFC_CORE_LIB OFC_VOID ofc_framework_startup ( OFC_VOID  )

Start up the OpenFiles Stack

This routine should be called after the stack has been initialized and after all configuration has been performed. It will start the various components running.

If INIT_ON_LOAD is defined, this function will be called implicitly. In that case, the application need not call this function.

Examples
smbinit.c.

◆ ofc_framework_stats_heap()

OFC_VOID ofc_framework_stats_heap ( OFC_VOID  )

Print Heap Statistics

◆ ofc_framework_update()

OFC_VOID ofc_framework_update ( OFC_VOID  )

Reconfigure the stack

Used to propogate configuration changes to all components

◆ ofc_get_config_dir()

OFC_CORE_LIB OFC_BOOL ofc_get_config_dir ( OFC_TCHAR config_dir,
OFC_SIZET  len 
)

Find the application directory (i.e. directory that config file is in

returns a TSTR of the config directory that needs to be freed after use

Parameters
config_dirbuffer to hold config directory
lenLength of buffer
Returns
True if config directory stored.

◆ ofc_set_config_path()

OFC_CORE_LIB OFC_VOID ofc_set_config_path ( OFC_TCHAR filename)

Set Configuration File Path

Parameters
filenamePath to configuration file