More maintenance commits to come.
char buffer[f_account_pwd_length_fallback_second];
- int result = getgrnam_r(name, &grp, buffer, length, &pointer);
+ const int result = getgrnam_r(name, &grp, buffer, length, &pointer);
if (result) {
if (errno == EINTR) return F_status_set_error(F_interrupted);
errno = 0;
char buffer[length];
- int result = getpwnam_r(name, &password, buffer, length, &pointer);
+ const int result = getpwnam_r(name, &password, buffer, length, &pointer);
if (result) {
if (errno == EINTR) return F_status_set_error(F_interrupted);
char buffer[f_account_pwd_length_fallback_second];
- int result = getpwnam_r(name, &password, buffer, length, &pointer);
+ const int result = getpwnam_r(name, &password, buffer, length, &pointer);
if (result) {
if (errno == EINTR) return F_status_set_error(F_interrupted);
}
if (console_short != f_console_none) {
+
// The sub_location is used on a per increment basis (such as 'tar -xcf', the '-' would have an increment of 1, therefore x, c, and f would all be three separate parameters).
while (sub_location < string_length) {
+
for (i = 0; i < parameters.used; i++) {
+
if (parameters.parameter[i].type != console_type) {
continue;
}
found = F_false;
for (i = 0; i < parameters.used; i++) {
+
if (parameters.parameter[i].type != f_console_type_other) continue;
if (parameters.parameter[i].symbol_other == 0) continue;
} // for
if (!found) {
+
// populate list of remaining parameters.parameter not associated with anything.
if (remaining->used == remaining->size) {
f_macro_memory_structure_macro_increment(status, (*remaining), 1, f_console_default_allocation_step, f_macro_string_lengths_t_resize, F_buffer_too_large);
f_console_parameter_id_t priority = 0;
for (f_array_length_t i = 0; i < choices.used; i++) {
+
if (choices.id[i] > parameters.used) return F_status_set_error(F_parameter);
if (parameters.parameter[choices.id[i]].result == f_console_result_found) {
f_console_parameter_id_t priority = 0;
for (f_array_length_t i = 0; i < choices.used; i++) {
+
if (choices.id[i] > parameters.used) return F_status_set_error(F_parameter);
if (parameters.parameter[choices.id[i]].result == f_console_result_found) {
memset(&file_stat, 0, sizeof(struct stat));
if (fstatat(at_id, path, &file_stat, flag) < 0) {
-
if (errno == ENOENT) {
return private_f_directory_create_at(at_id, path, mode);
}
}
if (utimensat(at_id, path, 0, flag) < 0) {
-
if (errno == EACCES) return F_status_set_error(F_access_denied);
if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
if (errno == EFAULT) return F_status_set_error(F_buffer);
#if !defined(_di_f_environment_set_) || !defined(_di_f_environment_set_dynamic_)
f_return_status private_f_environment_set(const f_string_t name, const f_string_t value, const bool replace) {
+
if (setenv(name, value, replace) < 0) {
if (errno == EINVAL) {
return F_status_set_error(F_invalid);
#if !defined(_di_f_environment_unset_) || !defined(_di_f_environment_unset_dynamic_)
f_return_status private_f_environment_unset(const f_string_t name) {
+
if (unsetenv(name) < 0) {
if (errno == EINVAL) {
return F_status_set_error(F_invalid);
syntax = 0;
}
else if (how == 2) {
+
// if there are only '0's then the standard and setuid/setgid/sticky bits are to be replaced.
if (*mode == 0) {
*replace = f_file_mode_t_replace_standard | f_file_mode_t_replace_special;
memset(&stat_file, 0, sizeof(struct stat));
- f_status_t status = private_f_file_stat(path, F_true, &stat_file);
+ const f_status_t status = private_f_file_stat(path, F_true, &stat_file);
if (F_status_is_error(status)) {
return status;
}
memset(&stat_file, 0, sizeof(struct stat));
- f_status_t status = private_f_file_stat(path, F_true, &stat_file);
+ const f_status_t status = private_f_file_stat(path, F_true, &stat_file);
if (F_status_is_error(status)) {
return status;
}
memset(&stat_file, 0, sizeof(struct stat));
- f_status_t status = private_f_file_stat(path, F_true, &stat_file);
+ const f_status_t status = private_f_file_stat(path, F_true, &stat_file);
if (F_status_is_error(status)) {
return status;
}
memset(&buffer_read, 0, sizeof(file.size_read));
while ((size_read = read(file.id, buffer_read, file.size_read)) > 0) {
+
if (buffer->used + size_read > buffer->size) {
if (buffer->size + size_read > f_string_length_t_size) {
return F_status_set_error(F_string_too_large);
#if !defined(_di_f_file_close_) || !defined(_di_f_file_copy_)
f_return_status private_f_file_close(int *id) {
+
if (*id == -1) return F_none;
if (F_status_is_error(private_f_file_flush(*id))) return F_status_set_error(F_file_synchronize);
if (F_status_is_error(status)) return status;
status = private_f_file_open(destination, 0, &file_destination);
+
if (F_status_is_error(status)) {
private_f_file_close(&file_source.id);
return status;
memset(buffer, 0, size_block);
while ((size_read = read(file_source.id, buffer, size_block)) > 0) {
+
size_write = write(file_destination.id, buffer, size_read);
if (size_write < 0 || size_write != size_read) {
if (F_status_is_error(status)) return status;
status = private_f_file_open_at(at_id, destination, 0, &file_destination);
+
if (F_status_is_error(status)) {
private_f_file_close(&file_source.id);
return status;
memset(buffer, 0, size_block);
while ((size_read = read(file_source.id, buffer, size_block)) > 0) {
+
size_write = write(file_destination.id, buffer, size_read);
if (size_write < 0 || size_write != size_read) {
file.flag |= f_file_flag_exclusive;
}
- f_status_t status = private_f_file_open(path, mode, &file);
+ const f_status_t status = private_f_file_open(path, mode, &file);
- if (file.id > 0) {
+ if (file.id != -1) {
return private_f_file_close(&file.id);
}
file.flag |= f_file_flag_exclusive;
}
- f_status_t status = private_f_file_open_at(at_id, path, mode, &file);
+ const f_status_t status = private_f_file_open_at(at_id, path, mode, &file);
- if (file.id > 0) {
+ if (file.id != -1) {
return private_f_file_close(&file.id);
}
#if !defined(_di_f_file_open_) || !defined(_di_f_file_copy_)
f_return_status private_f_file_open(const f_string_t path, const mode_t mode, f_file_t *file) {
+
if (mode == 0) {
file->id = open(path, file->flag);
}
#if !defined(_di_f_file_open_at_) || !defined(_di_f_file_copy_at_)
f_return_status private_f_file_open_at(const int at_id, const f_string_t path, const mode_t mode, f_file_t *file) {
+
if (mode == 0) {
file->id = openat(at_id, path, file->flag);
}
#if !defined(_di_f_file_stat_by_id_) || !defined(_di_f_file_size_by_id_)
f_return_status private_f_file_stat_by_id(const int id, struct stat *file_stat) {
- int result = fstat(id, file_stat);
+ const int result = fstat(id, file_stat);
if (result < 0) {
if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
* F_failure (with error bit) for any other error.
*
* @see f_file_copy()
- * @see mkdir()
*/
#if !defined(_di_f_file_copy_)
extern f_return_status private_f_file_create_directory(const f_string_t path, const mode_t mode) f_gcc_attribute_visibility_internal;
* F_space_not (with error bit) if filesystem is out of space (or filesystem quota is reached).
* F_failure (with error bit) for any other error.
*
- * @see mkdirat()
+ * @see f_file_copy_at()
*/
#if !defined(_di_f_file_copy_at_)
extern f_return_status private_f_file_create_directory_at(const int at_id, const f_string_t path, const mode_t mode) f_gcc_attribute_visibility_internal;
* F_unsupported (with error bit) for unsupported file types.
* F_failure (with error bit) for any other error.
*
- * @see mkfifo()
+ * @see f_file_create_fifo()
+ * @see f_file_copy()
*/
#if !defined(_di_f_file_create_fifo_) || !defined(_di_f_file_copy_)
extern f_return_status private_f_file_create_fifo(const f_string_t path, const mode_t mode) f_gcc_attribute_visibility_internal;
* F_unsupported (with error bit) for unsupported file types.
* F_failure (with error bit) for any other error.
*
- * @see mkfifoat()
+ * @see f_file_create_fifo_at()
+ * @see f_file_copy_at()
*/
#if !defined(_di_f_file_create_fifo_at_) || !defined(_di_f_file_copy_at_)
extern f_return_status private_f_file_create_fifo_at(const int at_id, const f_string_t path, const mode_t mode) f_gcc_attribute_visibility_internal;
* F_unsupported (with error bit) for unsupported file types.
* F_failure (with error bit) for any other error.
*
+ * @see f_file_copy()
* @see f_file_create_device()
* @see f_file_create_node()
*/
* F_failure (with error bit) for any other error.
* F_unsupported (with error bit) for unsupported file types.
*
+ * @see f_file_copy_at()
* @see f_file_create_device_at()
* @see f_file_create_node_at()
*/
* F_string_too_large (with error bit) if link target path is too large for string buffer size.
* F_failure (with error bit) for any other error.
*
+ * @see f_file_copy()
* @see f_file_link_read()
*/
#if !defined(_di_f_file_link_read_) || !defined(_di_f_file_copy_)
* F_string_too_large (with error bit) if link target path is too large for string buffer size.
* F_failure (with error bit) for any other error.
*
+ * @see f_file_copy_at()
* @see f_file_link_read_at()
*/
#if !defined(_di_f_file_link_read_at_) || !defined(_di_f_file_copy_at_)
* F_read_only (with error bit) if file is read-only.
* F_failure (with error bit) for any other error.
*
- * @see f_file_mode_set()
* @see f_file_copy()
+ * @see f_file_mode_set()
*/
#if !defined(_di_f_file_mode_set_) || !defined(_di_f_file_copy_)
extern f_return_status private_f_file_mode_set(const f_string_t path, const mode_t mode) f_gcc_attribute_visibility_internal;
* F_read_only (with error bit) if file is read-only.
* F_failure (with error bit) for any other error.
*
- * @see f_file_role_change()
* @see f_file_copy()
+ * @see f_file_role_change()
*/
#if !defined(_di_f_file_role_change_) || !defined(_di_f_file_copy_)
extern f_return_status private_f_file_role_change(const f_string_t path, const uid_t uid, const gid_t gid, const bool dereference) f_gcc_attribute_visibility_internal;
* F_parameter (with error bit) if a parameter is invalid.
*
* @see f_file_copy()
- * @see f_file_stat()
* @see f_file_exists()
+ * @see f_file_is()
+ * @see f_file_stat()
* @see f_file_touch()
*/
#if !defined(_di_f_file_stat_) || !defined(_di_f_file_copy_) || !defined(_di_f_file_exists_) || !defined(_di_f_file_is_) || !defined(_di_f_file_touch_)
position = range.start;
while (position < buffer->used && position <= range.stop) {
+
if (buffer->string[position] == f_fss_delimit_placeholder) {
distance++;
}
utf_width = f_macro_utf_byte_width_is(buffer->string[position]);
if (utf_width > 1) {
+
// not enough space in buffer or in range range to process UTF-8 character.
if (position + utf_width >= buffer->used || position + utf_width > range.stop) {
return F_status_set_error(F_utf);
}
}
else {
+
// shift everything down one for each placeholder found
if (distance > 0) {
buffer->string[position] = buffer->string[position + distance];
}
for (;;) {
+
if (buffer.string[range->start] != f_fss_delimit_placeholder) {
status = f_utf_is_graph(buffer.string + range->start, width_max);
* The purpose of compression is not to compression the entire file's contents but only and individual objects content, so the file is still partially readable.
* NOTE: all start/stop locations must be defined as a (start < stop) and not (start <= stop), therefore if (start == stop) then stop.
*
- * @todo identify all special UTF-8 characters that would violate the concepts, such as "Ogham space mark ( )" is not valid as whitespace in FSS because it is a visible non-whitespace character.
+ * @todo identify all special UTF-8 characters that would violate the FSS design concepts, such as "Ogham space mark ( )" is not valid as whitespace in FSS because it is a visible non-whitespace character.
*/
#ifndef _F_fss_h
#define _F_fss_h
f_string_lengths_t delimits = f_string_lengths_t_initialize;
do {
+
// find the start and end of the vocabulary name.
while (range->start <= range->stop && range->start < buffer->used) {
+
if (buffer->string[range->start] == f_iki_syntax_placeholder) {
range->start++;
continue;
if (buffer->string[range->start] == f_iki_syntax_separator) {
if (range->start == found_vocabulary.start) {
status = f_utf_buffer_increment(*buffer, range, 1);
+
if (F_status_is_error(status)) {
f_macro_string_lengths_t_delete(status, delimits);
return status;
}
status = f_utf_buffer_increment(*buffer, range, 1);
+
if (F_status_is_error(status)) {
f_macro_string_lengths_t_delete(status, delimits);
return status;
f_macro_iki_determine_width_max(buffer, range, width_max);
status = f_utf_is_word_dash_plus(buffer->string + range->start, width_max, F_false);
+
if (F_status_is_error(status)) {
f_macro_string_lengths_t_delete(status, delimits);
return status;
}
status = f_utf_buffer_increment(*buffer, range, 1);
+
if (F_status_is_error(status)) {
f_macro_string_lengths_t_delete(status, delimits);
return status;
found_content = range->start;
while (range->start <= range->stop && range->start < buffer->used) {
+
if (buffer->string[range->start] == f_iki_syntax_placeholder) {
range->start++;
continue;
// this is a valid vocabulary name and content, but if it is delimited, save the delimit and ignore.
if (vocabulary_delimited) {
f_macro_iki_allocate_delimits_if_necessary(status, delimits);
+
if (F_status_is_error(status)) {
f_macro_string_lengths_t_delete(status, delimits);
return status;
f_array_length_t content_slash_total = 0;
while (range->start <= range->stop && range->start < buffer->used) {
+
if (buffer->string[range->start] == f_iki_syntax_placeholder) {
range->start++;
continue;
content_range.stop = range->stop;
while (i < content_slash_delimits) {
+
if (buffer->string[content_range.start] == f_iki_syntax_slash) {
delimits.array[delimits.used] = content_range.start;
delimits.used++;
}
status = f_utf_buffer_increment(*buffer, (&content_range), 1);
+
if (F_status_is_error(status)) {
f_macro_string_lengths_t_delete(status, delimits);
return status;
// this is a valid vocabulary name and content, but if it is delimited, save the delimit and ignore.
if (vocabulary_delimited) {
f_macro_iki_allocate_delimits_if_necessary(status, delimits);
+
if (F_status_is_error(status)) {
f_macro_string_lengths_t_delete(status, delimits);
return status;
content_slash_total++;
status = f_utf_buffer_increment(*buffer, range, 1);
+
if (F_status_is_error(status)) {
f_macro_string_lengths_t_delete(status, delimits);
return status;
}
status = f_utf_buffer_increment(*buffer, range, 1);
+
if (F_status_is_error(status)) {
f_macro_string_lengths_t_delete(status, delimits);
return status;
if (pointer == 0) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- // prevent double-allocations
+ // prevent double-allocations.
if (*pointer != 0) return F_none;
// Some people use malloc(type * length) to produce the same results.
- // I have noticed this sometimes causes an increase in L1/L2 cache misses (0.02% L1 increase, 0.01% L2 increase).
+ // This has been observed to sometimes causes an increase in L1/L2 cache misses (0.02% L1 increase, 0.01% L2 increase).
*pointer = calloc(type, length);
if (*pointer) {
*
* Provide means to use memory routines, with error checking.
*
- * @todo consider adding f_memory__scramble() and f_memory__juggle().
+ * @todo consider adding f_memory_scramble() and f_memory_juggle().
* f_memory_scramble() is like f_destroy() but it writes random data instead of 0.
* f_memory_juggle() is like f_adjust() but it writes random data instead of 0.
*/