Main Page   Modules   Data Structures   File List   Data Fields   Globals  

tools.h File Reference

C wrappers for some useful tools included in the C++ libdar library. More...

#include "translations.h"

Go to the source code of this file.

File size tools

The main purpose of the infinint is the elimination of file and archive size limits.

As such, these functions provide minor assistance in wrapping system calls and string interpretation into the infinint infrastructure. Of the internal toolset in the libdar library, interfaces to the file size query and string parsing mechanism are provided.

#define DAR_TOOLS_SI_BASE   1000
 Base size of prefixes for SI system.

#define DAR_TOOLS_BIN_BASE   1024
 Base size of prefixes for Binary system.

DLLIMPORT dar_infinintdar_tools_get_extended_size (char *s, U_I base)
 Converts string containing an integer with size factor.

DLLIMPORT char * dar_tools_display_date (dar_infinint *date)
 Converts date in seconds to a human readable format.


Text formatting

Libdar has an internal tool called tools_addspacebefore.

This function provides a very simple text allignment method for alligning text to the right of a given field length and expanding the length of the field as needed.

This funtion has been renamed to dar_tools_string_justify_right. The new name provides a clearer idea of what the function does and also creates an attractive naming convention for an expanded family of functions for simplistic text formatting.

Only the first function was implemented in libdar. Center, left, and truncating methods were created to model the right justify method. These are completely implemented in the C binding and are not available in libdar at this time.

DLLIMPORT char * dar_tools_string_justify_right (char *s, U_I min_size)
 Given a minimum text field size, justifies text to the right of that field.

DLLIMPORT char * dar_tools_string_justify_center (char *s, U_I min_size)
 Given a minimum text field size, justifies text to the centermost possible, expanding the field as neccessary.

DLLIMPORT char * dar_tools_string_justify_left (char *s, U_I min_size)
 Given a minimum text field size, justifies text to the leftmost possible, expanding the field as neccessary.

DLLIMPORT char * dar_tools_string_justify_right_truncate (char *s, U_I fixed_size)
 Given a fixed text field size, justifies text to the rightmost possible, truncating overflow from the right, making overlarge strings appear to be truncated after left justification.

DLLIMPORT char * dar_tools_string_justify_center_truncate (char *s, U_I fixed_size)
 Given a fixed text field size, justifies text to the centermost possible, truncating all data that does not fit in that size.

DLLIMPORT char * dar_tools_string_justify_left_truncate (char *s, U_I fixed_size)
 Given a fixed text field size, justifies text to the leftmost possible, truncating all data that does not fit in that size.


System environment access

A small collection of functions for accessing simple system information.

DLLIMPORT char * dar_tools_name_of_uid (U_16 uid)
 Obtains string name of integer user id.

DLLIMPORT char * dar_tools_name_of_gid (U_16 gid)
 Obtains string name of integer group id.

DLLIMPORT char * dar_tools_get_cwd ()
 Obtains string representation of current working directory.


Detailed Description

C wrappers for some useful tools included in the C++ libdar library.

The functions in this file are similiar to those provided in translations.h; the difference being that these are more pure wrappers of libdars internal toolset, where the translations functions are more libdarc specific tools that attempt to smooth over the differences between C and C++ data types and standard libraries.

Definition in file tools.h.


Function Documentation

DLLIMPORT char* dar_tools_get_cwd  
 

Obtains string representation of current working directory.

NEEDS IMPROVEMENT NOTE: (1) is this absolute path?

Definition at line 237 of file tools.cpp.

DLLIMPORT char* dar_tools_name_of_gid U_16    gid
 

Obtains string name of integer group id.

Returns null if group name does not exist.

Definition at line 226 of file tools.cpp.

DLLIMPORT char* dar_tools_name_of_uid U_16    uid
 

Obtains string name of integer user id.

Returns null if user name does not exist.

Definition at line 209 of file tools.cpp.

DLLIMPORT char* dar_tools_string_justify_center_truncate char *    s,
U_I    fixed_size
 

Given a fixed text field size, justifies text to the centermost possible, truncating all data that does not fit in that size.

All truncations will occur from the rightmost of the text, making overlarge strings appear to be truncated after left justification.

Definition at line 174 of file tools.cpp.

DLLIMPORT char* dar_tools_string_justify_left char *    s,
U_I    min_size
 

Given a minimum text field size, justifies text to the leftmost possible, expanding the field as neccessary.

This is the same as simply increasing a string to the desired length if currently shorter than that length.

Definition at line 142 of file tools.cpp.

DLLIMPORT char* dar_tools_string_justify_left_truncate char *    s,
U_I    fixed_size
 

Given a fixed text field size, justifies text to the leftmost possible, truncating all data that does not fit in that size.

For too small strings, this is the same as simply adding blank space to the end. For too long strings, this is the same as simply clipping the end.

Definition at line 192 of file tools.cpp.

DLLIMPORT char* dar_tools_string_justify_right char *    s,
U_I    min_size
 

Given a minimum text field size, justifies text to the right of that field.

If the input string length is longer than the minimum size, the text will be pressed against the left and the field size will be expanded to fit the entire string.

This is a wrapper for tools_addspacebefore in libdar. This renaming allows for increased clarity when symmetricizing the function set (justify left, center, truncate, etc).

Parameters:
s  String data.
min_size  Resultant string will be no shorter than this length, with string justified to the right of the field.
Returns:
Final output string equal to or larger than the requested minimum size.

Definition at line 109 of file tools.cpp.