#ifndef _di_f_file_close_
f_return_status f_file_close(int *id) {
- #ifndef _di_level_0_parameter_checking_
- if (id == 0) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
return private_f_file_close(id);
}
#endif // _di_f_file_close_
}
#endif // _di_f_file_mode_to_mode_
-#ifndef _di_f_file_rename_
- f_return_status f_file_rename(const f_string_t source, const f_string_t destination) {
- #ifndef _di_level_0_parameter_checking_
- if (source == 0) return F_status_set_error(F_parameter);
- if (destination == 0) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (rename(source, destination) < 0) {
- if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == EBUSY) return F_status_set_error(F_busy);
- if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
- if (errno == EFAULT) return F_status_set_error(F_buffer);
- if (errno == EINVAL) return F_status_set_error(F_parameter);
- if (errno == EISDIR) return F_status_set_error(F_file_type_directory);
- if (errno == ELOOP) return F_status_set_error(F_loop);
- if (errno == EMLINK) return F_status_set_error(F_link);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
- if (errno == ENOENT) return F_status_set_error(F_file_found_not);
- if (errno == ENOMEM) return F_status_set_error(F_memory_out);
- if (errno == ENOSPC) return F_status_set_error(F_space_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == ENOTEMPTY) return F_status_set_error(F_directory_empty_not);
- if (errno == EEXIST) return F_status_set_error(F_directory_empty_not);
- if (errno == EPERM) return F_status_set_error(F_prohibited);
- if (errno == EROFS) return F_status_set_error(F_read_only);
- if (errno == EXDEV) return F_status_set_error(F_mount);
-
- return F_status_set_error(F_failure);
- }
-
- return F_none;
- }
-#endif // _di_f_file_rename_
-
-#ifndef _di_f_file_rename_at_
- f_return_status f_file_rename_at(const int at_id, const int to_id, const f_string_t source, const f_string_t destination) {
- #ifndef _di_level_0_parameter_checking_
- if (source == 0) return F_status_set_error(F_parameter);
- if (destination == 0) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (renameat(at_id, source, to_id, destination) < 0) {
- if (errno == EACCES) return F_status_set_error(F_access_denied);
- if (errno == EBUSY) return F_status_set_error(F_busy);
- if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
- if (errno == EFAULT) return F_status_set_error(F_buffer);
- if (errno == EINVAL) return F_status_set_error(F_parameter);
- if (errno == EISDIR) return F_status_set_error(F_file_type_directory);
- if (errno == ELOOP) return F_status_set_error(F_loop);
- if (errno == EMLINK) return F_status_set_error(F_link);
- if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
- if (errno == ENOENT) return F_status_set_error(F_file_found_not);
- if (errno == ENOMEM) return F_status_set_error(F_memory_out);
- if (errno == ENOSPC) return F_status_set_error(F_space_not);
- if (errno == ENOTDIR) return F_status_set_error(F_directory);
- if (errno == ENOTEMPTY) return F_status_set_error(F_directory_empty_not);
- if (errno == EEXIST) return F_status_set_error(F_directory_empty_not);
- if (errno == EPERM) return F_status_set_error(F_prohibited);
- if (errno == EROFS) return F_status_set_error(F_read_only);
- if (errno == EXDEV) return F_status_set_error(F_mount);
- if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
-
- return F_status_set_error(F_failure);
- }
-
- return F_none;
- }
-#endif // _di_f_file_rename_at_
-
#ifndef _di_f_file_name_base_
f_return_status f_file_name_base(const f_string_t path, const f_string_length_t length, f_string_dynamic_t *name_base) {
#ifndef _di_level_0_parameter_checking_
if (buffer->used > buffer->size) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (file.id < 0) return F_status_set_error(F_file);
- if (file.id == 0) return F_status_set_error(F_file_closed);
+ if (file.id == -1) return F_status_set_error(F_file_closed);
f_status_t status = F_none;
ssize_t size_read = 0;
if (buffer->used > buffer->size) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (file.id < 0) return F_status_set_error(F_file);
- if (file.id == 0) return F_status_set_error(F_file_closed);
+ if (file.id == -1) return F_status_set_error(F_file_closed);
f_status_t status = F_none;
ssize_t size_read = 0;
#endif // _di_f_file_read_block_
#ifndef _di_f_file_read_until_
- f_return_status f_file_read_until(const f_file_t file, f_string_dynamic_t *buffer, const f_string_length_t total) {
+ f_return_status f_file_read_until(const f_file_t file, const f_string_length_t total, f_string_dynamic_t *buffer) {
#ifndef _di_level_0_parameter_checking_
if (file.size_read == 0) return F_status_set_error(F_parameter);
if (buffer->used > buffer->size) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (file.id < 0) return F_status_set_error(F_file);
- if (file.id == 0) return F_status_set_error(F_file_closed);
+ if (file.id == -1) return F_status_set_error(F_file_closed);
f_status_t status = F_none;
ssize_t size_read = 0;
memset(&buffer_read, 0, sizeof(buffer_size));
while (buffer_count < total && (size_read = read(file.id, buffer_read, buffer_size)) > 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);
}
#endif // _di_f_file_remove_at_
+#ifndef _di_f_file_rename_
+ f_return_status f_file_rename(const f_string_t source, const f_string_t destination) {
+ #ifndef _di_level_0_parameter_checking_
+ if (source == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (rename(source, destination) < 0) {
+ if (errno == EACCES) return F_status_set_error(F_access_denied);
+ if (errno == EBUSY) return F_status_set_error(F_busy);
+ if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
+ if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == EINVAL) return F_status_set_error(F_parameter);
+ if (errno == EISDIR) return F_status_set_error(F_file_type_directory);
+ if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == EMLINK) return F_status_set_error(F_link);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
+ if (errno == ENOENT) return F_status_set_error(F_file_found_not);
+ if (errno == ENOMEM) return F_status_set_error(F_memory_out);
+ if (errno == ENOSPC) return F_status_set_error(F_space_not);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOTEMPTY) return F_status_set_error(F_directory_empty_not);
+ if (errno == EEXIST) return F_status_set_error(F_directory_empty_not);
+ if (errno == EPERM) return F_status_set_error(F_prohibited);
+ if (errno == EROFS) return F_status_set_error(F_read_only);
+ if (errno == EXDEV) return F_status_set_error(F_mount);
+
+ return F_status_set_error(F_failure);
+ }
+
+ return F_none;
+ }
+#endif // _di_f_file_rename_
+
+#ifndef _di_f_file_rename_at_
+ f_return_status f_file_rename_at(const int at_id, const int to_id, const f_string_t source, const f_string_t destination) {
+ #ifndef _di_level_0_parameter_checking_
+ if (source == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (renameat(at_id, source, to_id, destination) < 0) {
+ if (errno == EACCES) return F_status_set_error(F_access_denied);
+ if (errno == EBUSY) return F_status_set_error(F_busy);
+ if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
+ if (errno == EFAULT) return F_status_set_error(F_buffer);
+ if (errno == EINVAL) return F_status_set_error(F_parameter);
+ if (errno == EISDIR) return F_status_set_error(F_file_type_directory);
+ if (errno == ELOOP) return F_status_set_error(F_loop);
+ if (errno == EMLINK) return F_status_set_error(F_link);
+ if (errno == ENAMETOOLONG) return F_status_set_error(F_name);
+ if (errno == ENOENT) return F_status_set_error(F_file_found_not);
+ if (errno == ENOMEM) return F_status_set_error(F_memory_out);
+ if (errno == ENOSPC) return F_status_set_error(F_space_not);
+ if (errno == ENOTDIR) return F_status_set_error(F_directory);
+ if (errno == ENOTEMPTY) return F_status_set_error(F_directory_empty_not);
+ if (errno == EEXIST) return F_status_set_error(F_directory_empty_not);
+ if (errno == EPERM) return F_status_set_error(F_prohibited);
+ if (errno == EROFS) return F_status_set_error(F_read_only);
+ if (errno == EXDEV) return F_status_set_error(F_mount);
+ if (errno == EBADF) return F_status_set_error(F_directory_descriptor);
+
+ return F_status_set_error(F_failure);
+ }
+
+ return F_none;
+ }
+#endif // _di_f_file_rename_at_
+
#ifndef _di_f_file_role_change_
f_return_status f_file_role_change(const f_string_t path, const uid_t uid, const gid_t gid, const bool dereference) {
#ifndef _di_level_0_parameter_checking_
if (buffer.used > buffer.size) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (file.id < 0) return F_status_set_error(F_file);
- if (file.id == 0) return F_status_set_error(F_file_closed);
+ if (file.id == -1) return F_status_set_error(F_file_closed);
if (buffer.used == 0) {
if (written) *written = 0;
if (buffer.used > buffer.size) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (file.id < 0) return F_status_set_error(F_file);
- if (file.id == 0) return F_status_set_error(F_file_closed);
+ if (file.id == -1) return F_status_set_error(F_file_closed);
if (buffer.used == 0) {
if (written) *written = 0;
if (buffer.used > buffer.size) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (file.id < 0) return F_status_set_error(F_file);
- if (file.id == 0) return F_status_set_error(F_file_closed);
+ if (file.id == -1) return F_status_set_error(F_file_closed);
if (buffer.used == 0 || total == 0) {
if (written) *written = 0;
if (range.start >= buffer.used) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (file.id < 0) return F_status_set_error(F_file);
- if (file.id == 0) return F_status_set_error(F_file_closed);
+ if (file.id == -1) return F_status_set_error(F_file_closed);
if (buffer.used == 0) {
if (written) *written = 0;
/**
* Commonly used file related properties.
*
- * id: File descriptor.
+ * id: File descriptor, with a value of -1 represents a closed file.
* flag: Flags used for opening the file.
* size_read: The default number of 1-byte characters to read at a time and is often used for the read buffer size.
* size_write: The default number of 1-byte characters to read at a time and is often used for the write buffer size.
size_t size_write;
} f_file_t;
- #define f_file_t_initialize { 0, f_file_flag_read_only, f_file_default_read_size, f_file_default_write_size }
+ #define f_file_t_initialize { -1, f_file_flag_read_only, f_file_default_read_size, f_file_default_write_size }
#define f_macro_file_t_clear(file) \
- file.id = 0; \
+ file.id = -1; \
file.flag = 0; \
file.size_read = 0; \
file.size_write = 0;
#define f_macro_file_t_reset(file) \
- file.id = 0; \
+ file.id = -1; \
file.flag = f_file_flag_read_only; \
file.size_read = f_file_default_read_size; \
file.size_write = f_file_default_write_size;
* F_filesystem_quota_block (with error bit) if filesystem's disk blocks or inodes are exhausted.
* F_input_output (with error bit) on I/O error.
* F_interrupted (with error bit) when program received an interrupt signal, halting operation.
- * F_parameter (with error bit) if a parameter is invalid.
* F_space_not (with error bit) if filesystem is out of space (or filesystem quota is reached).
*
* @see fclose()
#endif // _di_f_file_mode_to_mode_
/**
- * Rename a file.
- *
- * The paths must not contain NULL except for the terminating NULL.
- * The paths must be NULL terminated.
- *
- * This essentially renames a file but can also change the file's path, which is identical to a move.
- * However, renames only work within a filesystem and cannot be moved to another filesystem.
- *
- * If destination already exists, then according to rename(), destination will be atomically replaced.
- * Which, if destination is a directory, then that directory must either not exist or be empty.
- *
- * @param source
- * The path to the file to copy from.
- * @param destination
- * The path to copy to.
- *
- * @return
- * F_none on success.
- * F_access_denied (with error bit) on access denied.
- * F_buffer (with error bit) if the buffer is invalid.
- * F_busy (with error bit) if filesystem is too busy to perform write.
- * F_directory (with error bit) if a supposed directory in path is not actually a directory.
- * F_directory_empty_not (with error bit) if the destination is a non-empty directory.
- * F_file_found_not (with error bit) if file at path was not found.
- * F_file_type_directory (with error bit) if destination is a directory but source is not.
- * F_filesystem_quota_block (with error bit) if filesystem's disk blocks or inodes are exhausted.
- * F_link (with error bit) if source or destination has the maxiumum associated links.
- * F_loop (with error bit) on loop error.
- * F_memory_out (with error bit) if out of memory.
- * F_mount (with error bit) if source and destination are not within the same mounted filesystems.
- * F_name (with error bit) on path name error.
- * F_parameter (with error bit) if a parameter is invalid.
- * F_prohibited (with error bit) if filesystem does not allow for making changes.
- * F_read_only (with error bit) if file is read-only.
- * 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 rename()
- */
-#ifndef _di_f_file_rename_
- extern f_return_status f_file_rename(const f_string_t source, const f_string_t destination);
-#endif // _di_f_file_rename_
-
-/**
- * Rename a file.
- *
- * The paths must not contain NULL except for the terminating NULL.
- * The paths must be NULL terminated.
- *
- * This essentially renames a file but can also change the file's path, which is identical to a move.
- * However, renames only work within a filesystem and cannot be moved to another filesystem.
- *
- * If destination already exists, then according to rename(), destination will be atomically replaced.
- * Which, if destination is a directory, then that directory must either not exist or be empty.
- *
- * @param at_id
- * The parent directory, as an open directory file descriptor, in which the source is relative to.
- * @param to_id
- * The parent directory, as an open directory file descriptor, in which the destination is relative to.
- * @param source
- * The path to the file to copy from.
- * @param destination
- * The path to copy to.
- *
- * @return
- * F_none on success.
- * F_access_denied (with error bit) on access denied.
- * F_buffer (with error bit) if the buffer is invalid.
- * F_busy (with error bit) if filesystem is too busy to perform write.
- * F_directory (with error bit) if a supposed directory in path is not actually a directory.
- * F_directory_descriptor (with error bit) for bad directory descriptor for at_id or to_id.
- * F_directory_empty_not (with error bit) if the destination is a non-empty directory.
- * F_file_found_not (with error bit) if file at path was not found.
- * F_file_type_directory (with error bit) if destination is a directory but source is not.
- * F_filesystem_quota_block (with error bit) if filesystem's disk blocks or inodes are exhausted.
- * F_link (with error bit) if source or destination has the maxiumum associated links.
- * F_loop (with error bit) on loop error.
- * F_memory_out (with error bit) if out of memory.
- * F_mount (with error bit) if source and destination are not within the same mounted filesystems.
- * F_name (with error bit) on path name error.
- * F_parameter (with error bit) if a parameter is invalid.
- * F_prohibited (with error bit) if filesystem does not allow for making changes.
- * F_read_only (with error bit) if file is read-only.
- * 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 renameat()
- */
-#ifndef _di_f_file_rename_at_
- extern f_return_status f_file_rename_at(const int at_id, const int to_id, const f_string_t source, const f_string_t destination);
-#endif // _di_f_file_rename_at_
-
-/**
* Get the base name of a file path.
*
* @param path
* F_none_eof on success and EOF was reached.
* F_block (with error bit) if file descriptor is set to non-block and the read would result in a blocking operation.
* F_buffer (with error bit) if the buffer is invalid.
- * F_file (with error bit) if file descriptor is in an error state.
* F_file_closed (with error bit) if file is not open.
* F_file_descriptor (with error bit) if the file descriptor is invalid.
* F_file_type_directory (with error bit) if file descriptor represents a directory.
* F_none_eof on success and EOF was reached.
* F_block (with error bit) if file descriptor is set to non-block and the read would result in a blocking operation.
* F_buffer (with error bit) if the buffer is invalid.
- * F_file (with error bit) if file descriptor is in an error state.
* F_file_closed (with error bit) if file is not open.
* F_file_descriptor (with error bit) if the file descriptor is invalid.
* F_file_type_directory (with error bit) if file descriptor represents a directory.
*
* @see read()
*/
-#ifndef _di_f_file_read_
+#ifndef _di_f_file_read_block_
extern f_return_status f_file_read_block(const f_file_t file, f_string_dynamic_t *buffer);
-#endif // _di_f_file_read_
+#endif // _di_f_file_read_block_
/**
* Read until a given number or EOF is reached, storing it in the buffer.
* @param file
* The file to read.
* The file must already be open.
- * @param buffer
- * The buffer the file is being read into.
* @param total
* The total bytes to read, unless EOF is reached first.
+ * @param buffer
+ * The buffer the file is being read into.
*
* @return
* F_none on success.
* F_none_eof on success and EOF was reached.
* F_block (with error bit) if file descriptor is set to non-block and the read would result in a blocking operation.
* F_buffer (with error bit) if the buffer is invalid.
- * F_file (with error bit) if file descriptor is in an error state.
* F_file_closed (with error bit) if file is not open.
* F_file_descriptor (with error bit) if the file descriptor is invalid.
* F_file_type_directory (with error bit) if file descriptor represents a directory.
* @see read()
*/
#ifndef _di_f_file_read_until_
- extern f_return_status f_file_read_until(const f_file_t file, f_string_dynamic_t *buffer, const f_string_length_t total);
+ extern f_return_status f_file_read_until(const f_file_t file, const f_string_length_t total, f_string_dynamic_t *buffer);
#endif // _di_f_file_read_until_
/**
#endif // _di_f_file_remove_at_
/**
+ * Rename a file.
+ *
+ * The paths must not contain NULL except for the terminating NULL.
+ * The paths must be NULL terminated.
+ *
+ * This essentially renames a file but can also change the file's path, which is identical to a move.
+ * However, renames only work within a filesystem and cannot be moved to another filesystem.
+ *
+ * If destination already exists, then according to rename(), destination will be atomically replaced.
+ * Which, if destination is a directory, then that directory must either not exist or be empty.
+ *
+ * @param source
+ * The path to the file to copy from.
+ * @param destination
+ * The path to copy to.
+ *
+ * @return
+ * F_none on success.
+ * F_access_denied (with error bit) on access denied.
+ * F_buffer (with error bit) if the buffer is invalid.
+ * F_busy (with error bit) if filesystem is too busy to perform write.
+ * F_directory (with error bit) if a supposed directory in path is not actually a directory.
+ * F_directory_empty_not (with error bit) if the destination is a non-empty directory.
+ * F_file_found_not (with error bit) if file at path was not found.
+ * F_file_type_directory (with error bit) if destination is a directory but source is not.
+ * F_filesystem_quota_block (with error bit) if filesystem's disk blocks or inodes are exhausted.
+ * F_link (with error bit) if source or destination has the maxiumum associated links.
+ * F_loop (with error bit) on loop error.
+ * F_memory_out (with error bit) if out of memory.
+ * F_mount (with error bit) if source and destination are not within the same mounted filesystems.
+ * F_name (with error bit) on path name error.
+ * F_parameter (with error bit) if a parameter is invalid.
+ * F_prohibited (with error bit) if filesystem does not allow for making changes.
+ * F_read_only (with error bit) if file is read-only.
+ * 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 rename()
+ */
+#ifndef _di_f_file_rename_
+ extern f_return_status f_file_rename(const f_string_t source, const f_string_t destination);
+#endif // _di_f_file_rename_
+
+/**
+ * Rename a file.
+ *
+ * The paths must not contain NULL except for the terminating NULL.
+ * The paths must be NULL terminated.
+ *
+ * This essentially renames a file but can also change the file's path, which is identical to a move.
+ * However, renames only work within a filesystem and cannot be moved to another filesystem.
+ *
+ * If destination already exists, then according to rename(), destination will be atomically replaced.
+ * Which, if destination is a directory, then that directory must either not exist or be empty.
+ *
+ * @param at_id
+ * The parent directory, as an open directory file descriptor, in which the source is relative to.
+ * @param to_id
+ * The parent directory, as an open directory file descriptor, in which the destination is relative to.
+ * @param source
+ * The path to the file to copy from.
+ * @param destination
+ * The path to copy to.
+ *
+ * @return
+ * F_none on success.
+ * F_access_denied (with error bit) on access denied.
+ * F_buffer (with error bit) if the buffer is invalid.
+ * F_busy (with error bit) if filesystem is too busy to perform write.
+ * F_directory (with error bit) if a supposed directory in path is not actually a directory.
+ * F_directory_descriptor (with error bit) for bad directory descriptor for at_id or to_id.
+ * F_directory_empty_not (with error bit) if the destination is a non-empty directory.
+ * F_file_found_not (with error bit) if file at path was not found.
+ * F_file_type_directory (with error bit) if destination is a directory but source is not.
+ * F_filesystem_quota_block (with error bit) if filesystem's disk blocks or inodes are exhausted.
+ * F_link (with error bit) if source or destination has the maxiumum associated links.
+ * F_loop (with error bit) on loop error.
+ * F_memory_out (with error bit) if out of memory.
+ * F_mount (with error bit) if source and destination are not within the same mounted filesystems.
+ * F_name (with error bit) on path name error.
+ * F_parameter (with error bit) if a parameter is invalid.
+ * F_prohibited (with error bit) if filesystem does not allow for making changes.
+ * F_read_only (with error bit) if file is read-only.
+ * 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 renameat()
+ */
+#ifndef _di_f_file_rename_at_
+ extern f_return_status f_file_rename_at(const int at_id, const int to_id, const f_string_t source, const f_string_t destination);
+#endif // _di_f_file_rename_at_
+
+/**
* Change owner and/or group of a given file at the specified path.
*
* At least one of uid or gid must not be -1.
* F_none_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
* F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation.
* F_buffer (with error bit) if the buffer is invalid.
- * F_file (with error bit) if file descriptor is in an error state.
* F_file_closed (with error bit) if file is not open.
* F_file_descriptor (with error bit) if the file descriptor is invalid.
* F_file_type_directory (with error bit) if file descriptor represents a directory.
* F_none_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
* F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation.
* F_buffer (with error bit) if the buffer is invalid.
- * F_file (with error bit) if file descriptor is in an error state.
* F_file_closed (with error bit) if file is not open.
* F_file_descriptor (with error bit) if the file descriptor is invalid.
* F_file_type_directory (with error bit) if file descriptor represents a directory.
* F_none_eos on success but range.stop exceeded buffer.used (only wrote up to buffer.used).
* F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation.
* F_buffer (with error bit) if the buffer is invalid.
- * F_file (with error bit) if file descriptor is in an error state.
* F_file_closed (with error bit) if file is not open.
* F_file_descriptor (with error bit) if the file descriptor is invalid.
* F_file_type_directory (with error bit) if file descriptor represents a directory.
* F_none_eos on success but range.stop exceeded buffer.used (only wrote up to buffer.used).
* F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation.
* F_buffer (with error bit) if the buffer is invalid.
- * F_file (with error bit) if file descriptor is in an error state.
- * F_file_closed (with error bit) if file is not open.
* F_file_descriptor (with error bit) if the file descriptor is invalid.
* F_file_type_directory (with error bit) if file descriptor represents a directory.
* F_input_output (with error bit) on I/O error.
#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 (close(*id) < 0) {
return F_status_set_error(F_file_close);
}
- *id = 0;
+ *id = -1;
return F_none;
}
#endif // !defined(_di_f_file_close_) || !defined(_di_f_file_copy_)
file->id = open(path, file->flag, mode);
}
- if (file->id < 0) {
+ if (file->id == -1) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
if (errno == EEXIST) return F_status_set_error(F_file_found);
file->id = openat(at_id, path, file->flag, mode);
}
- if (file->id < 0) {
+ if (file->id == -1) {
if (errno == EACCES) return F_status_set_error(F_access_denied);
if (errno == EDQUOT) return F_status_set_error(F_filesystem_quota_block);
if (errno == EEXIST) return F_status_set_error(F_file_found);
#ifndef _di_fss_object_t_
typedef f_string_range_t f_fss_object_t;
- #define f_fss_object_t_initialize f_string_range_initialize
+ #define f_fss_object_t_initialize f_string_range_t_initialize
- #define f_macro_fss_object_t_clear(object) f_macro_string_range_clear(object)
+ #define f_macro_fss_object_t_clear(object) f_macro_string_range_t_clear(object)
#endif // _di_fss_object_t_
/**
if (dynamic == 0) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
f_status_t status = private_f_serialize_un_simple_find(serialize, index, &range);
if (F_status_is_error(status)) return status;
* Therefore, a range from 0 to 0 would be include position 0.
* Set start to some value larger than stop to designate that there is no range (such as start = 1, stop = 0).
*
- * A special f_macro_string_range_initialize() is provided for the special purpose of easily initialize a static string range.
+ * A special f_macro_string_range_t_initialize() is provided for the special purpose of easily initialize a static string range.
*
* start: the start position.
* stop: the stop position.
f_string_length_t stop;
} f_string_range_t;
- #define f_string_range_initialize { 1, 0 }
+ #define f_string_range_t_initialize { 1, 0 }
- #define f_macro_string_range_initialize(length) { length ? 0 : 1, length ? length - 1 : 0 }
+ #define f_macro_string_range_t_initialize(length) { length ? 0 : 1, length ? length - 1 : 0 }
- #define f_macro_string_range_clear(range) \
+ #define f_macro_string_range_t_clear(range) \
range.start = 1; \
range.stop = 0;
#endif // _di_f_string_range_t_
return F_status_set_error(F_number);
}
- f_string_range_t location_offset = f_string_range_initialize;
+ f_string_range_t location_offset = f_string_range_t_initialize;
location_offset.start = range.start + offset;
location_offset.stop = range.stop;
return F_status_set_error(F_number);
}
- f_string_range_t location_offset = f_string_range_initialize;
+ f_string_range_t location_offset = f_string_range_t_initialize;
location_offset.start = range.start + offset;
location_offset.stop = range.stop;
if (range->start > range->stop) return F_data_not_stop;
else if (range->start >= content.used) return F_data_not_eos;
- f_string_range_t input_position = f_string_range_initialize;
- f_string_range_t buffer_position = f_string_range_initialize;
+ f_string_range_t input_position = f_string_range_t_initialize;
+ f_string_range_t buffer_position = f_string_range_t_initialize;
// ensure that there is room for the terminating newline.
f_string_length_t size_allocate = destination->used + content.used + 1 + f_fss_default_allocation_step_string;
f_status_t status = F_none;
- f_string_range_t buffer_position = f_string_range_initialize;
+ f_string_range_t buffer_position = f_string_range_t_initialize;
f_string_length_t start_position = f_string_t_initialize;
f_string_length_t size_allocate = 0;
f_string_length_t start_buffer = 0;
bool is_comment = F_false;
bool has_graph = F_false;
- f_string_range_t buffer_position = f_string_range_initialize;
+ f_string_range_t buffer_position = f_string_range_t_initialize;
f_string_length_t start_position = f_string_t_initialize;
f_string_length_t size_allocate = 0;
uint8_t content_found = 0;
while (range->start <= range->stop && range->start < buffer->used) {
- f_string_range_t content_partial = f_string_range_initialize;
+ f_string_range_t content_partial = f_string_range_t_initialize;
f_fss_quoted_t quoted = 0;
status = private_fl_fss_basic_object_read(buffer, range, &content_partial, "ed, &delimits);
f_status_t status = F_none;
- f_string_range_t buffer_position = f_string_range_initialize;
+ f_string_range_t buffer_position = f_string_range_t_initialize;
f_string_length_t start_position = f_string_t_initialize;
f_string_length_t size_allocate = 0;
f_string_length_t start_buffer = 0;
bool is_comment = F_false;
bool has_graph = F_false;
- f_string_range_t buffer_position = f_string_range_initialize;
+ f_string_range_t buffer_position = f_string_range_t_initialize;
f_string_length_t start_position = f_string_t_initialize;
f_string_length_t size_allocate = 0;
const f_string_length_t position_start = range->start;
- f_string_range_t destination_position = f_string_range_initialize;
+ f_string_range_t destination_position = f_string_range_t_initialize;
destination_position.start = destination->used;
destination_position.stop = destination->used;
}
#endif // _di_fl_string_dynamic_prepend_nulless_
+#ifndef _di_fl_string_dynamic_rip_
+ f_return_status fl_string_dynamic_rip(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination) {
+ #ifndef _di_level_1_parameter_checking_
+ if (source.used <= range.start) return F_status_set_error(F_parameter);
+ if (source.used <= range.stop) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (source.used == 0) return F_data_not_eos;
+ if (range.start > range.stop) return F_data_not_stop;
+
+ return private_fl_string_append(source.string + range.start, (range.stop - range.start) + 1, destination);
+ }
+#endif // _di_fl_string_dynamic_rip_
+
+#ifndef _di_fl_string_dynamic_rip_nulless_
+ f_return_status fl_string_dynamic_rip_nulless(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination) {
+ #ifndef _di_level_1_parameter_checking_
+ if (source.used <= range.start) return F_status_set_error(F_parameter);
+ if (source.used <= range.stop) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ if (source.used == 0) return F_data_not_eos;
+ if (range.start > range.stop) return F_data_not_stop;
+
+ return private_fl_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination);
+ }
+#endif // _di_fl_string_dynamic_rip_nulless_
+
#ifndef _di_fl_string_dynamic_size_decrease_
f_return_status fl_string_dynamic_size_decrease(const f_string_length_t length, f_string_dynamic_t *string) {
#ifndef _di_level_1_parameter_checking_
}
#endif // _di_fl_string_dynamic_size_increase_
-#ifndef _di_fl_string_dynamics_size_decrease_
- f_return_status fl_string_dynamics_size_decrease(const f_array_length_t length, f_string_dynamics_t *strings) {
- #ifndef _di_level_1_parameter_checking_
- if (length == 0) return F_status_set_error(F_parameter);
- if (strings == 0) return F_status_set_error(F_parameter);
- #endif // _di_level_1_parameter_checking_
-
- f_status_t status = F_none;
-
- if (strings->size - length > 0) {
- f_macro_string_dynamics_resize(status, (*strings), strings->size - length);
- }
- else if (strings->size - length <= 0) {
- f_macro_string_dynamics_t_delete(status, (*strings));
- }
-
- return status;
- }
-#endif // _di_fl_string_dynamics_size_decrease_
-
-#ifndef _di_fl_string_dynamics_size_increase_
- f_return_status fl_string_dynamics_size_increase(const f_array_length_t length, f_string_dynamics_t *strings) {
+#ifndef _di_fl_string_dynamic_seek_line_
+ f_return_status fl_string_dynamic_seek_line(const f_string_t string, f_string_range_t *range) {
#ifndef _di_level_1_parameter_checking_
- if (length == 0) return F_status_set_error(F_parameter);
- if (strings == 0) return F_status_set_error(F_parameter);
- #endif // _di_level_1_parameter_checking_
-
- f_status_t status = F_none;
-
- if (strings->size + length > f_array_length_t_size) {
- if (strings->size == f_array_length_t_size) {
- return F_status_set_error(F_string_too_large);
- }
-
- f_macro_string_dynamics_resize(status, (*strings), f_array_length_t_size);
- return F_string_too_large;
- }
-
- f_macro_string_dynamics_resize(status, (*strings), strings->size + length);
- return status;
- }
-#endif // _di_fl_string_dynamics_size_increase_
-
-#ifndef _di_fl_string_dynamic_rip_
- f_return_status fl_string_dynamic_rip(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination) {
- #ifndef _di_level_1_parameter_checking_
- if (source.used <= range.start) return F_status_set_error(F_parameter);
- if (source.used <= range.stop) return F_status_set_error(F_parameter);
- if (destination == 0) return F_status_set_error(F_parameter);
+ if (range == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (source.used == 0) return F_data_not_eos;
- if (range.start > range.stop) return F_data_not_stop;
-
- return private_fl_string_append(source.string + range.start, (range.stop - range.start) + 1, destination);
- }
-#endif // _di_fl_string_dynamic_rip_
+ if (!string) return F_data_not;
+ if (range->start > range->stop) return F_data_not_stop;
-#ifndef _di_fl_string_dynamic_rip_nulless_
- f_return_status fl_string_dynamic_rip_nulless(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination) {
- #ifndef _di_level_1_parameter_checking_
- if (source.used <= range.start) return F_status_set_error(F_parameter);
- if (source.used <= range.stop) return F_status_set_error(F_parameter);
- if (destination == 0) return F_status_set_error(F_parameter);
- #endif // _di_level_1_parameter_checking_
+ while (string[range->start] != f_string_eol[0]) {
+ range->start++;
- if (source.used == 0) return F_data_not_eos;
- if (range.start > range.stop) return F_data_not_stop;
+ if (range->start > range->stop) return F_none_stop;
+ } // while
- return private_fl_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination);
+ return F_none;
}
-#endif // _di_fl_string_dynamic_rip_nulless_
+#endif // _di_fl_string_dynamic_seek_line_
#ifndef _di_fl_string_dynamic_seek_line_to_
- f_return_status fl_string_dynamic_seek_line_to(const f_string_static_t buffer, f_string_range_t *range, const int8_t seek_to_this) {
+ f_return_status fl_string_dynamic_seek_line_to(const f_string_t string, f_string_range_t *range, const int8_t seek_to_this) {
#ifndef _di_level_1_parameter_checking_
if (range == 0) return F_status_set_error(F_parameter);
- if (buffer.used <= range->start) return F_status_set_error(F_parameter);
- if (buffer.used <= range->stop) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (buffer.used == 0) return F_data_not_eos;
+ if (!string) return F_data_not;
if (range->start > range->stop) return F_data_not_stop;
- while (buffer.string[range->start] != seek_to_this) {
- if (buffer.string[range->start] == f_string_eol[0]) return F_none_eol;
+ while (string[range->start] != seek_to_this) {
+
+ if (string[range->start] == f_string_eol[0]) return F_none_eol;
range->start++;
- if (range->start >= buffer.used) return F_none_eos;
if (range->start > range->stop) return F_none_stop;
} // while
#endif // _di_fl_string_dynamic_seek_line_to_
#ifndef _di_fl_string_dynamic_seek_line_to_utf_character_
- f_return_status fl_string_dynamic_seek_line_to_utf_character(const f_string_static_t buffer, f_string_range_t *range, const f_utf_character_t seek_to_this) {
+ f_return_status fl_string_dynamic_seek_line_to_utf_character(const f_string_t string, f_string_range_t *range, const f_utf_character_t seek_to_this) {
#ifndef _di_level_1_parameter_checking_
if (range == 0) return F_status_set_error(F_parameter);
- if (buffer.used <= range->start) return F_status_set_error(F_parameter);
- if (buffer.used <= range->stop) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (buffer.used == 0) return F_data_not_eos;
+ if (!string) return F_data_not;
if (range->start > range->stop) return F_data_not_stop;
const unsigned short seek_width = f_macro_utf_character_t_width(seek_to_this);
f_string_length_t width_max = 0;
- while (range->start < buffer.used) {
+ while (range->start <= range->stop) {
width_max = (range->stop - range->start) + 1;
-
- if (width_max > buffer.used - range->start) {
- width_max = buffer.used - range->start;
- }
-
- width = f_macro_utf_byte_width_is(buffer.string[range->start]);
+ width = f_macro_utf_byte_width_is(string[range->start]);
if (width == 0) {
width = 1;
- if (buffer.string[range->start] == f_string_eol[0]) return F_none_eol;
+ if (string[range->start] == f_string_eol[0]) return F_none_eol;
if (seek_width == width) {
- if (buffer.string[range->start] == seek_to_this) return F_none;
+ if (string[range->start] == seek_to_this) return F_none;
}
}
// Do not operate on UTF-8 fragments that are not the first byte of the character.
return F_status_set_error(F_incomplete_utf);
}
else {
- if (range->start + width >= buffer.used) return F_status_set_error(F_incomplete_utf_eos);
if (range->start + width > range->stop) return F_status_set_error(F_incomplete_utf_stop);
if (width == seek_width) {
f_utf_character_t character = 0;
- status = f_utf_char_to_character(buffer.string + range->start, width_max, &character);
+
+ status = f_utf_char_to_character(string + range->start, width_max, &character);
if (F_status_is_error(status)) return status;
if (character == seek_to_this) return F_none;
#endif // _di_fl_string_dynamic_seek_line_to_utf_character_
#ifndef _di_fl_string_dynamic_seek_line_until_graph_
- f_return_status fl_string_dynamic_seek_line_until_graph(const f_string_static_t buffer, f_string_range_t *range, const int8_t placeholder) {
+ f_return_status fl_string_dynamic_seek_line_until_graph(const f_string_t string, f_string_range_t *range, const int8_t placeholder) {
#ifndef _di_level_1_parameter_checking_
if (range == 0) return F_status_set_error(F_parameter);
- if (buffer.used <= range->start) return F_status_set_error(F_parameter);
- if (buffer.used <= range->stop) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (buffer.used == 0) return F_data_not_eos;
+ if (!string) return F_data_not;
if (range->start > range->stop) return F_data_not_stop;
f_status_t status = F_none;
f_string_length_t width_max = (range->stop - range->start) + 1;
- if (width_max > buffer.used - range->start) {
- width_max = buffer.used - range->start;
- }
+ while (string[range->start] == placeholder || (status = f_utf_is_graph(string + range->start, width_max)) == F_false) {
- while (buffer.string[range->start] == placeholder || (status = f_utf_is_graph(buffer.string + range->start, width_max)) == F_false) {
if (F_status_is_error(status)) return status;
- if (buffer.string[range->start] == f_string_eol[0]) return F_none_eol;
+ if (string[range->start] == f_string_eol[0]) return F_none_eol;
- width = f_macro_utf_byte_width_is(buffer.string[range->start]);
+ width = f_macro_utf_byte_width_is(string[range->start]);
if (width == 0) {
width = 1;
return F_status_set_error(F_incomplete_utf);
}
else {
- if (range->start + width >= buffer.used) return F_status_set_error(F_incomplete_utf_eos);
if (range->start + width > range->stop) return F_status_set_error(F_incomplete_utf_stop);
}
range->start += width;
- if (range->start >= buffer.used) return F_none_eos;
if (range->start > range->stop) return F_none_stop;
width_max = (range->stop - range->start) + 1;
-
- if (width_max > buffer.used - range->start) {
- width_max = buffer.used - range->start;
- }
} // while
if (F_status_is_error(status)) return status;
#endif // _di_fl_string_dynamic_seek_line_until_graph_
#ifndef _di_fl_string_dynamic_seek_line_until_non_graph_
- f_return_status fl_string_dynamic_seek_line_until_non_graph(const f_string_static_t buffer, f_string_range_t *range, const int8_t placeholder) {
+ f_return_status fl_string_dynamic_seek_line_until_non_graph(const f_string_t string, f_string_range_t *range, const int8_t placeholder) {
#ifndef _di_level_1_parameter_checking_
if (range == 0) return F_status_set_error(F_parameter);
- if (buffer.used <= range->start) return F_status_set_error(F_parameter);
- if (buffer.used <= range->stop) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (buffer.used == 0) return F_data_not_eos;
+ if (!string) return F_data_not;
if (range->start > range->stop) return F_data_not_stop;
f_status_t status = F_none;
f_string_length_t width_max = (range->stop - range->start) + 1;
- if (width_max > buffer.used - range->start) {
- width_max = buffer.used - range->start;
- }
-
- while (buffer.string[range->start] == placeholder || (status = f_utf_is_whitespace(buffer.string + range->start, width_max)) == F_false) {
+ while (string[range->start] == placeholder || (status = f_utf_is_whitespace(string + range->start, width_max)) == F_false) {
if (F_status_is_error(status)) return status;
- if (buffer.string[range->start] == f_string_eol[0]) return F_none_eol;
+ if (string[range->start] == f_string_eol[0]) return F_none_eol;
- width = f_macro_utf_byte_width_is(buffer.string[range->start]);
+ width = f_macro_utf_byte_width_is(string[range->start]);
if (width == 0) {
width = 1;
return F_status_set_error(F_incomplete_utf);
}
else {
- if (range->start + width >= buffer.used) return F_status_set_error(F_incomplete_utf_eos);
if (range->start + width > range->stop) return F_status_set_error(F_incomplete_utf_stop);
}
range->start += width;
- if (range->start >= buffer.used) return F_none_eos;
if (range->start > range->stop) return F_none_stop;
width_max = (range->stop - range->start) + 1;
-
- if (width_max > buffer.used - range->start) {
- width_max = buffer.used - range->start;
- }
} // while
if (F_status_is_error(status)) return status;
#endif // _di_fl_string_dynamic_seek_line_until_non_graph_
#ifndef _di_fl_string_dynamic_seek_to_
- f_return_status fl_string_dynamic_seek_to(const f_string_static_t buffer, f_string_range_t *range, const int8_t seek_to_this) {
+ f_return_status fl_string_dynamic_seek_to(const f_string_t string, f_string_range_t *range, const int8_t seek_to_this) {
#ifndef _di_level_1_parameter_checking_
if (range == 0) return F_status_set_error(F_parameter);
- if (buffer.used <= range->start) return F_status_set_error(F_parameter);
- if (buffer.used <= range->stop) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (buffer.used == 0) return F_data_not_eos;
+ if (!string) return F_data_not;
if (range->start > range->stop) return F_data_not_stop;
- while (buffer.string[range->start] != seek_to_this) {
+ while (string[range->start] != seek_to_this) {
range->start++;
- if (range->start >= buffer.used) return F_none_eos;
if (range->start > range->stop) return F_none_stop;
} // while
#endif // _di_fl_string_dynamic_seek_to_
#ifndef _di_fl_string_dynamic_seek_to_utf_character_
- f_return_status fl_string_dynamic_seek_to_utf_character(const f_string_static_t buffer, f_string_range_t *range, const f_utf_character_t seek_to_this) {
+ f_return_status fl_string_dynamic_seek_to_utf_character(const f_string_t string, f_string_range_t *range, const f_utf_character_t seek_to_this) {
#ifndef _di_level_1_parameter_checking_
if (range == 0) return F_status_set_error(F_parameter);
- if (buffer.used <= range->start) return F_status_set_error(F_parameter);
- if (buffer.used <= range->stop) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (buffer.used == 0) return F_data_not_eos;
+ if (!string) return F_data_not;
if (range->start > range->stop) return F_data_not_stop;
const unsigned short seek_width = f_macro_utf_character_t_width(seek_to_this);
f_string_length_t width_max = 0;
- while (range->start < buffer.used) {
+ while (range->start <= range->stop) {
width_max = (range->stop - range->start) + 1;
-
- if (width_max > buffer.used - range->start) {
- width_max = buffer.used - range->start;
- }
-
- width = f_macro_utf_byte_width_is(buffer.string[range->start]);
+ width = f_macro_utf_byte_width_is(string[range->start]);
if (width == 0) {
width = 1;
if (seek_width == width) {
- if (buffer.string[range->start] == seek_to_this) return F_none;
+ if (string[range->start] == seek_to_this) return F_none;
}
}
// Do not operate on UTF-8 fragments that are not the first byte of the character.
return F_status_set_error(F_incomplete_utf);
}
else {
- if (range->start + width >= buffer.used) return F_status_set_error(F_incomplete_utf_eos);
if (range->start + width > range->stop) return F_status_set_error(F_incomplete_utf_stop);
if (width == seek_width) {
f_utf_character_t character = 0;
- status = f_utf_char_to_character(buffer.string + range->start, width_max, &character);
+ status = f_utf_char_to_character(string + range->start, width_max, &character);
if (F_status_is_error(status)) return status;
if (character == seek_to_this) return F_none;
}
#endif // _di_fl_string_dynamic_terminate_after_
+#ifndef _di_fl_string_dynamics_size_decrease_
+ f_return_status fl_string_dynamics_size_decrease(const f_array_length_t length, f_string_dynamics_t *strings) {
+ #ifndef _di_level_1_parameter_checking_
+ if (length == 0) return F_status_set_error(F_parameter);
+ if (strings == 0) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ f_status_t status = F_none;
+
+ if (strings->size - length > 0) {
+ f_macro_string_dynamics_resize(status, (*strings), strings->size - length);
+ }
+ else if (strings->size - length <= 0) {
+ f_macro_string_dynamics_t_delete(status, (*strings));
+ }
+
+ return status;
+ }
+#endif // _di_fl_string_dynamics_size_decrease_
+
+#ifndef _di_fl_string_dynamics_size_increase_
+ f_return_status fl_string_dynamics_size_increase(const f_array_length_t length, f_string_dynamics_t *strings) {
+ #ifndef _di_level_1_parameter_checking_
+ if (length == 0) return F_status_set_error(F_parameter);
+ if (strings == 0) return F_status_set_error(F_parameter);
+ #endif // _di_level_1_parameter_checking_
+
+ f_status_t status = F_none;
+
+ if (strings->size + length > f_array_length_t_size) {
+ if (strings->size == f_array_length_t_size) {
+ return F_status_set_error(F_string_too_large);
+ }
+
+ f_macro_string_dynamics_resize(status, (*strings), f_array_length_t_size);
+ return F_string_too_large;
+ }
+
+ f_macro_string_dynamics_resize(status, (*strings), strings->size + length);
+ return status;
+ }
+#endif // _di_fl_string_dynamics_size_increase_
+
#ifndef _di_fl_string_lengths_size_decrease_
f_return_status fl_string_lengths_size_decrease(const f_array_length_t length, f_string_lengths_t *lengths) {
#ifndef _di_level_1_parameter_checking_
#endif // _di_fl_string_dynamic_prepend_nulless_
/**
- * Resize the dynamic string to a smaller size.
+ * Allocate a new string from the provided range in the buffer.
*
- * This will resize making the string smaller based on the given length.
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
+ * Ignores leading and trailing whitespace.
+ * As a result, resulting size may be smaller than requested range.
*
- * @param length
- * A positive number greater than 0 representing how much to decrease the size by.
- * @param string
- * The string to resize.
+ * @param source
+ * The buffer to rip from.
+ * @param range
+ * A range within the buffer representing the string to rip.
+ * @param destination
+ * The new string, which will be allocated or reallocated as necessary.
*
* @return
* F_none on success.
+ * F_data_not_eos if source length is 0.
+ * F_data_not_stop if range.start > range.stop.
* F_memory_allocation (with error bit) on memory allocation error.
* F_memory_reallocation (with error bit) on memory reallocation error.
* F_parameter (with error bit) if a parameter is invalid.
* F_string_too_large (with error bit) if the combined string is too large.
*/
-#ifndef _di_fl_string_dynamic_size_decrease_
- extern f_return_status fl_string_dynamic_size_decrease(const f_string_length_t length, f_string_dynamic_t *string);
-#endif // _di_fl_string_dynamic_size_decrease_
+#ifndef _di_fl_string_dynamic_rip_
+ extern f_return_status fl_string_dynamic_rip(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination);
+#endif // _di_fl_string_dynamic_rip_
/**
- * Resize the dynamic string to a larger size.
+ * Allocate a new string from the provided range in the buffer.
*
- * This will resize making the string larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (f_string_length_t_size).
- * If already set to the maximum buffer size, then the resize will fail.
+ * Ignores leading and trailing whitespace.
+ * As a result, resulting size may be smaller than requested range.
*
- * @param length
- * A positive number greater than 0 representing how much to increase the size by.
- * @param string
- * The string to resize.
+ * Skips over NULL characters from source when appending.
+ *
+ * @param source
+ * The string to rip from.
+ * @param range
+ * A range within the buffer representing the string to rip.
+ * @param destination
+ * The new string, which will be allocated or reallocated as necessary.
*
* @return
* F_none on success.
- * F_string_too_large on success, but the requested length is too large for the buffer.
+ * F_data_not_eos if source length is 0.
+ * F_data_not_stop if range.start > range.stop.
* F_memory_allocation (with error bit) on memory allocation error.
* F_memory_reallocation (with error bit) on memory reallocation error.
* F_parameter (with error bit) if a parameter is invalid.
- * F_string_too_large (with error bit) if the combined string is too large.
*/
-#ifndef _di_fl_string_dynamic_size_increase_
- extern f_return_status fl_string_dynamic_size_increase(const f_string_length_t length, f_string_dynamic_t *string);
-#endif // _di_fl_string_dynamic_size_increase_
+#ifndef _di_fl_string_dynamic_rip_nulless_
+ extern f_return_status fl_string_dynamic_rip_nulless(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination);
+#endif // _di_fl_string_dynamic_rip_nulless_
/**
- * Resize the array of dynamic strings to a smaller size.
+ * Resize the dynamic string to a smaller size.
*
* This will resize making the string smaller based on the given length.
* If the given length is too small, then the resize will fail.
*
* @param length
* A positive number greater than 0 representing how much to decrease the size by.
- * @param strings
- * The string array to resize.
+ * @param string
+ * The string to resize.
*
* @return
* F_none on success.
* F_parameter (with error bit) if a parameter is invalid.
* F_string_too_large (with error bit) if the combined string is too large.
*/
-#ifndef _di_fl_string_dynamics_size_decrease_
- extern f_return_status fl_string_dynamics_size_decrease(const f_array_length_t length, f_string_dynamics_t *strings);
-#endif // _di_fl_string_dynamics_size_decrease_
+#ifndef _di_fl_string_dynamic_size_decrease_
+ extern f_return_status fl_string_dynamic_size_decrease(const f_string_length_t length, f_string_dynamic_t *string);
+#endif // _di_fl_string_dynamic_size_decrease_
/**
- * Resize the array of dynamic strings to a larger size.
+ * Resize the dynamic string to a larger size.
*
* This will resize making the string larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size).
+ * If the given length is too large for the buffer, then attempt to set max buffer size (f_string_length_t_size).
* If already set to the maximum buffer size, then the resize will fail.
*
* @param length
* A positive number greater than 0 representing how much to increase the size by.
- * @param strings
- * The string array to resize.
+ * @param string
+ * The string to resize.
*
* @return
* F_none on success.
* F_parameter (with error bit) if a parameter is invalid.
* F_string_too_large (with error bit) if the combined string is too large.
*/
-#ifndef _di_fl_string_dynamics_size_increase_
- extern f_return_status fl_string_dynamics_size_increase(const f_array_length_t length, f_string_dynamics_t *strings);
-#endif // _di_fl_string_dynamics_size_increase_
-
-/**
- * Allocate a new string from the provided range in the buffer.
- *
- * Ignores leading and trailing whitespace.
- * As a result, resulting size may be smaller than requested range.
- *
- * @param source
- * The buffer to rip from.
- * @param range
- * A range within the buffer representing the string to rip.
- * @param destination
- * The new string, which will be allocated or reallocated as necessary.
- *
- * @return
- * F_none on success.
- * F_data_not_eos if source length is 0.
- * F_data_not_stop if range.start > range.stop.
- * F_memory_allocation (with error bit) on memory allocation error.
- * F_memory_reallocation (with error bit) on memory reallocation error.
- * F_parameter (with error bit) if a parameter is invalid.
- * F_string_too_large (with error bit) if the combined string is too large.
- */
-#ifndef _di_fl_string_dynamic_rip_
- extern f_return_status fl_string_dynamic_rip(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination);
-#endif // _di_fl_string_dynamic_rip_
+#ifndef _di_fl_string_dynamic_size_increase_
+ extern f_return_status fl_string_dynamic_size_increase(const f_string_length_t length, f_string_dynamic_t *string);
+#endif // _di_fl_string_dynamic_size_increase_
/**
- * Allocate a new string from the provided range in the buffer.
- *
- * Ignores leading and trailing whitespace.
- * As a result, resulting size may be smaller than requested range.
- *
- * Skips over NULL characters from source when appending.
+ * Seek the buffer location forward until EOL is reached.
*
- * @param source
- * The string to rip from.
+ * @param string
+ * The string to traverse.
* @param range
- * A range within the buffer representing the string to rip.
- * @param destination
- * The new string, which will be allocated or reallocated as necessary.
+ * A range within the buffer representing the start and stop locations.
+ * The start location will be incremented by seek.
*
* @return
* F_none on success.
- * F_data_not_eos if source length is 0.
- * F_data_not_stop if range.start > range.stop.
- * F_memory_allocation (with error bit) on memory allocation error.
- * F_memory_reallocation (with error bit) on memory reallocation error.
+ * F_none_stop on success, but stopped at end of range.
+ * F_data_not on success, but there was no string data to seek.
+ * F_data_not_stop on success, but the range.start > range.stop.
* F_parameter (with error bit) if a parameter is invalid.
*/
-#ifndef _di_fl_string_dynamic_rip_nulless_
- extern f_return_status fl_string_dynamic_rip_nulless(const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination);
-#endif // _di_fl_string_dynamic_rip_nulless_
+#ifndef _di_fl_string_dynamic_seek_line_
+ extern f_return_status fl_string_dynamic_seek_line(const f_string_t string, f_string_range_t *range);
+#endif // _di_fl_string_dynamic_seek_line_
/**
* Seek the buffer location forward until the character (1-byte wide) or EOL is reached.
*
- * @param buffer
- * The buffer to traverse.
+ * @param string
+ * The string to traverse.
* @param range
* A range within the buffer representing the start and stop locations.
* The start location will be incremented by seek.
* @return
* F_none on success.
* F_none_eol on success, but stopped at EOL.
- * F_none_eos on success, but stopped at end of buffer.
- * F_none_stop on success, but stopped stop location.
- * F_data_not_eos if buffer length is 0.
- * F_data_not_stop if range.start > range.stop.
+ * F_none_stop on success, but stopped at end of range.
+ * F_data_not on success, but there was no string data to seek.
+ * F_data_not_stop on success, but the range.start > range.stop.
* F_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_fl_string_dynamic_seek_line_to_
- extern f_return_status fl_string_dynamic_seek_line_to(const f_string_static_t buffer, f_string_range_t *range, const int8_t seek_to_this);
+ extern f_return_status fl_string_dynamic_seek_line_to(const f_string_t string, f_string_range_t *range, const int8_t seek_to_this);
#endif // _di_fl_string_dynamic_seek_line_to_
/**
* Seek the buffer location forward until the character (up to 4-byte wide) or EOL is reached.
*
- * @param buffer
- * The buffer to traverse.
+ * @param string
+ * The string to traverse.
* @param range
* A range within the buffer representing the start and stop locations.
* The start location will be incremented by seek.
* @return
* F_none on success.
* F_none_eol on success, but stopped at EOL.
- * F_none_eos on success, but stopped at end of buffer.
- * F_data_not_eos if buffer length is 0.
- * F_data_not_stop if range.start > range.stop.
+ * F_none_stop on success, but stopped at end of range.
+ * F_data_not on success, but there was no string data to seek.
+ * F_data_not_stop on success, but the range.start > range.stop.
* F_incomplete_utf (with error bit) if character is an incomplete UTF-8 fragment.
- * F_incomplete_utf_eos (with error bit) if end of string is reached before a complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* F_parameter (with error bit) if a parameter is invalid.
* F_utf (with error bit) if character is an invalid UTF-8 character.
* @see f_utf_char_to_character()
*/
#ifndef _di_fl_string_dynamic_seek_line_to_utf_character_
- extern f_return_status fl_string_dynamic_seek_line_to_utf_character(const f_string_static_t buffer, f_string_range_t *range, const f_utf_character_t seek_to_this);
+ extern f_return_status fl_string_dynamic_seek_line_to_utf_character(const f_string_t string, f_string_range_t *range, const f_utf_character_t seek_to_this);
#endif // _di_fl_string_dynamic_seek_line_to_utf_character_
/**
* Increment buffer location until a graph character (including UTF-8) or an EOL is matched.
*
- * @param buffer
- * The buffer to traverse.
+ * @param string
+ * The string to traverse.
* @param range
* A range within the buffer representing the start and stop locations.
* @param placeholder
* @return
* F_none on success.
* F_none_eol on success, but stopped at EOL.
- * F_none_eos on success, but stopped at end of buffer.
- * F_data_not_eos if buffer length is 0.
- * F_data_not_stop if range.start > range.stop.
+ * F_none_stop on success, but stopped at end of range.
+ * F_data_not on success, but there was no string data to seek.
+ * F_data_not_stop on success, but the range.start > range.stop.
* F_incomplete_utf (with error bit) if character is an incomplete UTF-8 fragment.
- * F_incomplete_utf_eos (with error bit) if end of string is reached before a complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* F_memory_allocation (with error bit) on memory allocation error.
* F_memory_reallocation (with error bit) on memory reallocation error.
* @see f_utf_is_graph()
*/
#ifndef _di_fl_string_dynamic_seek_line_until_graph_
- extern f_return_status fl_string_dynamic_seek_line_until_graph(const f_string_static_t buffer, f_string_range_t *range, const int8_t placeholder);
+ extern f_return_status fl_string_dynamic_seek_line_until_graph(const f_string_t string, f_string_range_t *range, const int8_t placeholder);
#endif // _di_fl_string_dynamic_seek_line_until_graph_
/**
* Increment buffer location until a non-graph character (including UTF-8) or an EOL is matched.
*
- * @param buffer
- * The buffer to traverse.
+ * @param string
+ * The string to traverse.
* @param range
* A range within the buffer representing the start and stop locations.
* @param placeholder
* @return
* F_none on success.
* F_none_eol on success, but stopped at EOL.
- * F_none_eos on success, but stopped at end of buffer.
- * F_none_stop on success, but stopped stop location.
- * F_data_not_eos if buffer length is 0.
- * F_data_not_stop if range.start > range.stop.
+ * F_none_stop on success, but stopped at end of range.
+ * F_data_not on success, but there was no string data to seek.
+ * F_data_not_stop on success, but the range.start > range.stop.
* F_incomplete_utf (with error bit) if character is an incomplete UTF-8 fragment.
- * F_incomplete_utf_eos (with error bit) if end of string is reached before a complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* F_memory_allocation (with error bit) on memory allocation error.
* F_memory_reallocation (with error bit) on memory reallocation error.
* @see f_utf_is_graph()
*/
#ifndef _di_fl_string_dynamic_seek_line_until_non_graph_
- extern f_return_status fl_string_dynamic_seek_line_until_non_graph(const f_string_static_t buffer, f_string_range_t *range, const int8_t placeholder);
+ extern f_return_status fl_string_dynamic_seek_line_until_non_graph(const f_string_t string, f_string_range_t *range, const int8_t placeholder);
#endif // _di_fl_string_dynamic_seek_line_until_non_graph_
/**
* Seek the buffer location forward until the character (1-byte wide) is reached.
*
- * @param buffer
- * The buffer to traverse.
+ * @param string
+ * The string to traverse.
* @param range
* A range within the buffer representing the start and stop locations.
* The start location will be incremented by seek.
*
* @return
* F_none on success.
- * F_none_eos on success, but stopped at end of buffer.
- * F_none_stop on success, but stopped stop location.
- * F_data_not_eos if buffer length is 0.
- * F_data_not_stop if range.start > range.stop.
+ * F_none_stop on success, but stopped at end of range.
+ * F_data_not on success, but there was no string data to seek.
+ * F_data_not_stop on success, but the range.start > range.stop.
* F_incomplete_utf (with error bit) if character is an incomplete UTF-8 fragment.
- * F_incomplete_utf_eos (with error bit) if end of string is reached before a complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* F_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_fl_string_dynamic_seek_to_
- extern f_return_status fl_string_dynamic_seek_to(const f_string_static_t buffer, f_string_range_t *range, const int8_t seek_to_this);
+ extern f_return_status fl_string_dynamic_seek_to(const f_string_t string, f_string_range_t *range, const int8_t seek_to_this);
#endif // _di_fl_string_dynamic_seek_to_
/**
* Seek the buffer location forward until the UTF-8 character (up to 4-byte wide) is reached.
*
- * @param buffer
- * The buffer to traverse.
+ * @param string
+ * The string to traverse.
* @param range
* A range within the buffer representing the start and stop locations.
* The start location will be incremented by seek.
*
* @return
* F_none on success.
- * F_none_eos on success, but stopped at end of buffer.
- * F_none_stop on success, but stopped stop location.
- * F_data_not_eos if buffer length is 0.
- * F_data_not_stop if range.start > range.stop.
+ * F_none_stop on success, but stopped at end of range.
+ * F_data_not on success, but there was no string data to seek.
+ * F_data_not_stop on success, but the range.start > range.stop.
* F_incomplete_utf (with error bit) if character is an incomplete UTF-8 fragment.
- * F_incomplete_utf_eos (with error bit) if end of string is reached before a complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* F_parameter (with error bit) if a parameter is invalid.
* F_utf (with error bit) if character is an invalid UTF-8 character.
* @see f_utf_char_to_character()
*/
#ifndef _di_fl_string_dynamic_seek_to_utf_character_
- extern f_return_status fl_string_dynamic_seek_to_utf_character(const f_string_static_t buffer, f_string_range_t *range, const f_utf_character_t seek_to_this);
+ extern f_return_status fl_string_dynamic_seek_to_utf_character(const f_string_t string, f_string_range_t *range, const f_utf_character_t seek_to_this);
#endif // _di_fl_string_dynamic_seek_to_utf_character_
/**
#endif // _di_fl_string_dynamic_terminate_after_
/**
+ * Resize the array of dynamic strings to a smaller size.
+ *
+ * This will resize making the string smaller based on the given length.
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param length
+ * A positive number greater than 0 representing how much to decrease the size by.
+ * @param strings
+ * The string array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_memory_allocation (with error bit) on memory allocation error.
+ * F_memory_reallocation (with error bit) on memory reallocation error.
+ * F_parameter (with error bit) if a parameter is invalid.
+ * F_string_too_large (with error bit) if the combined string is too large.
+ */
+#ifndef _di_fl_string_dynamics_size_decrease_
+ extern f_return_status fl_string_dynamics_size_decrease(const f_array_length_t length, f_string_dynamics_t *strings);
+#endif // _di_fl_string_dynamics_size_decrease_
+
+/**
+ * Resize the array of dynamic strings to a larger size.
+ *
+ * This will resize making the string larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param length
+ * A positive number greater than 0 representing how much to increase the size by.
+ * @param strings
+ * The string array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_string_too_large on success, but the requested length is too large for the buffer.
+ * F_memory_allocation (with error bit) on memory allocation error.
+ * F_memory_reallocation (with error bit) on memory reallocation error.
+ * F_parameter (with error bit) if a parameter is invalid.
+ * F_string_too_large (with error bit) if the combined string is too large.
+ */
+#ifndef _di_fl_string_dynamics_size_increase_
+ extern f_return_status fl_string_dynamics_size_increase(const f_array_length_t length, f_string_dynamics_t *strings);
+#endif // _di_fl_string_dynamics_size_increase_
+
+/**
* Resize the array of string lengths to a smaller size.
*
* This will resize making the string smaller based on the given length.
f_utf_string_length_t first = 0;
for (f_utf_string_length_t i = 0; i <= length; i++) {
+
if (i == length) {
if (i > first) {
f_utf_string_length_t size = i - first;
// skip past leading whitespace in string1.
for (; i1 < stop1; i1++) {
+
// skip past NULL in string1.
while (i1 < stop1 && string1[i1] == 0) i1++;
if (i1 == stop1) break;
// determine where the last non-whitespace is in string2.
for (f_utf_string_length_t j = i2; j < stop2; j++) {
+
// skip past NULL in string2.
while (j < stop2 && string2[j] == 0) j++;
if (j == stop2) break;
}
for (; i1 < last1 && i2 < last2; i1++, i2++) {
+
// skip past NULL in string1.
while (i1 < last1 && string1[i1] == 0) i1++;
if (i1 == last1) break;
f_utf_string_length_t offset = 0;
for (f_utf_string_length_t i = 0; i <= length; i++) {
+
if (i == length) {
if (i > first) {
const f_utf_string_length_t size = i - first;
// skip past leading whitespace.
for (; *start <= *stop; (*start)++) {
+
// skip past NULL.
while (*start < *stop && source[*start] == 0) (*start)++;
if (*start > *stop) break;
f_utf_string_length_t j = 1;
while (i <= length && j <= destination->used) {
+
if (source[length - i] == f_utf_character_t_eos) {
i++;
continue;
f_utf_string_length_t j = 1;
while (i <= length && j <= destination->used) {
+
if (source[length - i] == f_utf_character_t_eos) {
i++;
continue;
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_utf_string_length_t_size) {
return F_status_set_error(F_string_too_large);
#endif // _di_fl_utf_file_read_block_
#ifndef _di_fl_utf_file_read_until_
- f_return_status fl_utf_file_read_until(const f_file_t file, f_utf_string_dynamic_t *buffer, const f_utf_string_length_t total) {
+ f_return_status fl_utf_file_read_until(const f_file_t file, const f_utf_string_length_t total, f_utf_string_dynamic_t *buffer) {
#ifndef _di_level_1_parameter_checking_
if (file.size_read == 0) return F_status_set_error(F_parameter);
if (buffer->used > buffer->size) return F_status_set_error(F_parameter);
memset(&buffer_read, 0, sizeof(buffer_size));
while (buffer_count < total && (size_read = read(file.id, buffer_read, buffer_size)) > 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);
* @param file
* The file to read.
* The file must already be open.
- * @param buffer
- * The buffer the file is being read into.
* @param total
* The total bytes to read, unless EOF is reached first.
+ * @param buffer
+ * The buffer the file is being read into.
*
* @return
* F_none on success.
* F_interrupted (with error bit) if interrupt was received.
* F_parameter (with error bit) if a parameter is invalid.
*
- * @see read
+ * @see read()
*/
#ifndef _di_fl_utf_file_read_until_
- extern f_return_status fl_utf_file_read_until(const f_file_t file, f_utf_string_dynamic_t *buffer, const f_utf_string_length_t total);
+ extern f_return_status fl_utf_file_read_until(const f_file_t file, const f_utf_string_length_t total, f_utf_string_dynamic_t *buffer);
#endif // _di_fl_utf_file_read_until_
/**
f_macro_string_dynamic_t_resize(status, buffer, f_fss_max_header_length + 1);
if (F_status_is_error(status)) return status;
- status = f_file_read_until(*file, &buffer, f_fss_max_header_length + 1);
+ status = f_file_read_until(*file, f_fss_max_header_length + 1, &buffer);
if (F_status_is_error(status)) return status;
return private_fll_fss_identify(buffer, header);
f_status_t status = 0;
f_array_length_t current = 0;
- f_string_range_t range = f_macro_string_range_initialize(object.used);
+ f_string_range_t range = f_macro_string_range_t_initialize(object.used);
status = fl_fss_basic_object_write(object, 0, &range, destination);
f_status_t status = 0;
f_array_length_t current = 0;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
range.start = 0;
range.stop = object.used - 1;
f_status_t status = 0;
f_array_length_t current = 0;
- f_string_range_t range = f_macro_string_range_initialize(object.used);
+ f_string_range_t range = f_macro_string_range_t_initialize(object.used);
status = fl_fss_extended_object_write(object, 0, &range, buffer);
f_status_t status = 0;
f_array_length_t current = 0;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
range.start = 0;
range.stop = object.used - 1;
if (f_conversion_character_is_hexidecimal(buffer.string[i]) == F_true) {
i++;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
range.start = i - 4;
range.stop = i;
// @todo this needs to be changed to support sub-headers (maybe something like FL_fss_accepted_additional).
i++;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
range.start = i - 4;
range.stop = i;
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, byte_dump_total_parameters };
+ const f_console_parameters_t parameters = { data->parameters, byte_dump_total_parameters };
f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize;
// Identify priority of color parameters.
}
else if (data->parameters[byte_dump_parameter_width].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[byte_dump_parameter_width].additional.array[data->parameters[byte_dump_parameter_width].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
f_number_unsigned_t number = 0;
}
else if (data->parameters[byte_dump_parameter_first].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[byte_dump_parameter_first].additional.array[data->parameters[byte_dump_parameter_first].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
f_number_unsigned_t number = 0;
}
else if (data->parameters[byte_dump_parameter_last].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[byte_dump_parameter_last].additional.array[data->parameters[byte_dump_parameter_last].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
f_number_unsigned_t number = 0;
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, fake_total_parameters };
+ const f_console_parameters_t parameters = { data->parameters, fake_total_parameters };
// Load all parameters and identify priority of color parameters.
{
}
} // for
- // ensure a newline is always put at the end of the program execution, unless in quite mode.
+ // ensure a newline is always put at the end of the program execution, unless in quiet mode.
if (data->verbosity != fake_verbosity_quiet) {
if (F_status_is_error(status) || status == F_signal) {
fprintf(f_type_error, "%c", f_string_eol[0]);
*status = F_status_set_error(F_signal);
}
else if (F_status_is_error_not(*status)) {
- f_string_range_t range = f_macro_string_range_initialize(buffer.used);
+ f_string_range_t range = f_macro_string_range_t_initialize(buffer.used);
*status = fll_fss_extended_read(&buffer, &range, &objects, &contents, 0, 0);
return F_status_set_error(F_false);
}
- const f_string_range_t range = f_macro_string_range_initialize(data_make->path.stack.array[0].used);
+ const f_string_range_t range = f_macro_string_range_t_initialize(data_make->path.stack.array[0].used);
if (range.start <= range.stop) {
status = fl_string_dynamic_partial_compare(data_make->path.stack.array[0], data_make->path_cache, range, range);
#ifndef _di_fake_make_get_id_group_
f_return_status fake_make_get_id_group(const fake_data_t data, const fake_make_print_t print, const f_string_static_t buffer, gid_t *id) {
- const f_string_range_t range = f_macro_string_range_initialize(buffer.used);
+ const f_string_range_t range = f_macro_string_range_t_initialize(buffer.used);
f_number_unsigned_t number = 0;
#ifndef _di_fake_make_get_id_owner_
f_return_status fake_make_get_id_owner(const fake_data_t data, const fake_make_print_t print, const f_string_static_t buffer, uid_t *id) {
- const f_string_range_t range = f_macro_string_range_initialize(buffer.used);
+ const f_string_range_t range = f_macro_string_range_t_initialize(buffer.used);
f_number_unsigned_t number = 0;
f_fss_contents_t list_contents = f_fss_contents_t_initialize;
{
- f_string_range_t range = f_macro_string_range_initialize(data_make->buffer.used);
+ f_string_range_t range = f_macro_string_range_t_initialize(data_make->buffer.used);
*status = fll_fss_basic_list_read(&data_make->buffer, &range, &list_objects, &list_contents);
const f_string_static_t name_settings = f_macro_string_static_t_initialize(fake_make_section_settings, fake_make_section_settings_length);
const f_string_static_t name_main = f_macro_string_static_t_initialize(fake_make_section_main, fake_make_section_main_length);
- const f_string_range_t name_settings_range = f_macro_string_range_initialize(fake_make_section_settings_length);
- const f_string_range_t name_main_range = f_macro_string_range_initialize(fake_make_section_main_length);
+ const f_string_range_t name_settings_range = f_macro_string_range_t_initialize(fake_make_section_settings_length);
+ const f_string_range_t name_main_range = f_macro_string_range_t_initialize(fake_make_section_main_length);
f_macro_fss_nameds_t_new((*status), data_make->fakefile, list_objects.used);
}
{
- f_string_range_t content_range = f_string_range_initialize;
+ f_string_range_t content_range = f_string_range_t_initialize;
for (f_array_length_t i = 0; i < list_objects.used; i++) {
const f_string_static_t vocabulary_define = f_macro_string_static_t_initialize(iki_vocabulary_0002_define, iki_vocabulary_0002_define_length);
const f_string_static_t vocabulary_parameter = f_macro_string_static_t_initialize(iki_vocabulary_0002_parameter, iki_vocabulary_0002_parameter_length);
- const f_string_range_t range_define = f_macro_string_range_initialize(iki_vocabulary_0002_define_length);
- const f_string_range_t range_parameter = f_macro_string_range_initialize(iki_vocabulary_0002_parameter_length);
+ const f_string_range_t range_define = f_macro_string_range_t_initialize(iki_vocabulary_0002_define_length);
+ const f_string_range_t range_parameter = f_macro_string_range_t_initialize(iki_vocabulary_0002_parameter_length);
f_iki_variable_t iki_variable = f_iki_variable_t_initialize;
f_iki_vocabulary_t iki_vocabulary = f_iki_vocabulary_t_initialize;
f_iki_content_t iki_content = f_iki_content_t_initialize;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
f_string_map_multis_t *parameter = &data_make->setting_make.parameter;
bool unmatched = F_true;
};
const f_string_range_t operations_range[] = {
- f_macro_string_range_initialize(fake_make_operation_break_length),
- f_macro_string_range_initialize(fake_make_operation_build_length),
- f_macro_string_range_initialize(fake_make_operation_clean_length),
- f_macro_string_range_initialize(fake_make_operation_clone_length),
- f_macro_string_range_initialize(fake_make_operation_compile_length),
- f_macro_string_range_initialize(fake_make_operation_copy_length),
- f_macro_string_range_initialize(fake_make_operation_define_length),
- f_macro_string_range_initialize(fake_make_operation_delete_length),
- f_macro_string_range_initialize(fake_make_operation_deletes_length),
- f_macro_string_range_initialize(fake_make_operation_else_length),
- f_macro_string_range_initialize(fake_make_operation_exit_length),
- f_macro_string_range_initialize(fake_make_operation_fail_length),
- f_macro_string_range_initialize(fake_make_operation_group_length),
- f_macro_string_range_initialize(fake_make_operation_groups_length),
- f_macro_string_range_initialize(fake_make_operation_if_length),
- f_macro_string_range_initialize(fake_make_operation_index_length),
- f_macro_string_range_initialize(fake_make_operation_link_length),
- f_macro_string_range_initialize(fake_make_operation_mode_length),
- f_macro_string_range_initialize(fake_make_operation_modes_length),
- f_macro_string_range_initialize(fake_make_operation_move_length),
- f_macro_string_range_initialize(fake_make_operation_operate_length),
- f_macro_string_range_initialize(fake_make_operation_owner_length),
- f_macro_string_range_initialize(fake_make_operation_owners_length),
- f_macro_string_range_initialize(fake_make_operation_pop_length),
- f_macro_string_range_initialize(fake_make_operation_print_length),
- f_macro_string_range_initialize(fake_make_operation_run_length),
- f_macro_string_range_initialize(fake_make_operation_shell_length),
- f_macro_string_range_initialize(fake_make_operation_skeleton_length),
- f_macro_string_range_initialize(fake_make_operation_to_length),
- f_macro_string_range_initialize(fake_make_operation_top_length),
- f_macro_string_range_initialize(fake_make_operation_touch_length),
+ f_macro_string_range_t_initialize(fake_make_operation_break_length),
+ f_macro_string_range_t_initialize(fake_make_operation_build_length),
+ f_macro_string_range_t_initialize(fake_make_operation_clean_length),
+ f_macro_string_range_t_initialize(fake_make_operation_clone_length),
+ f_macro_string_range_t_initialize(fake_make_operation_compile_length),
+ f_macro_string_range_t_initialize(fake_make_operation_copy_length),
+ f_macro_string_range_t_initialize(fake_make_operation_define_length),
+ f_macro_string_range_t_initialize(fake_make_operation_delete_length),
+ f_macro_string_range_t_initialize(fake_make_operation_deletes_length),
+ f_macro_string_range_t_initialize(fake_make_operation_else_length),
+ f_macro_string_range_t_initialize(fake_make_operation_exit_length),
+ f_macro_string_range_t_initialize(fake_make_operation_fail_length),
+ f_macro_string_range_t_initialize(fake_make_operation_group_length),
+ f_macro_string_range_t_initialize(fake_make_operation_groups_length),
+ f_macro_string_range_t_initialize(fake_make_operation_if_length),
+ f_macro_string_range_t_initialize(fake_make_operation_index_length),
+ f_macro_string_range_t_initialize(fake_make_operation_link_length),
+ f_macro_string_range_t_initialize(fake_make_operation_mode_length),
+ f_macro_string_range_t_initialize(fake_make_operation_modes_length),
+ f_macro_string_range_t_initialize(fake_make_operation_move_length),
+ f_macro_string_range_t_initialize(fake_make_operation_operate_length),
+ f_macro_string_range_t_initialize(fake_make_operation_owner_length),
+ f_macro_string_range_t_initialize(fake_make_operation_owners_length),
+ f_macro_string_range_t_initialize(fake_make_operation_pop_length),
+ f_macro_string_range_t_initialize(fake_make_operation_print_length),
+ f_macro_string_range_t_initialize(fake_make_operation_run_length),
+ f_macro_string_range_t_initialize(fake_make_operation_shell_length),
+ f_macro_string_range_t_initialize(fake_make_operation_skeleton_length),
+ f_macro_string_range_t_initialize(fake_make_operation_to_length),
+ f_macro_string_range_t_initialize(fake_make_operation_top_length),
+ f_macro_string_range_t_initialize(fake_make_operation_touch_length),
};
const uint8_t operations_type[] = {
if (*operation_if == fake_make_operation_if_type_if_greater || *operation_if == fake_make_operation_if_type_if_greater_equal || *operation_if == fake_make_operation_if_type_if_less || *operation_if == fake_make_operation_if_type_if_less_equal) {
f_status_t status_number = F_none;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
f_number_unsigned_t number_left = 0;
f_number_unsigned_t number_right = 0;
}
f_status_t status_number = F_none;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
f_number_unsigned_t number = 0;
bool is_negative = F_false;
return F_status_set_error(F_failure);
}
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
range.start = data_make->path.stack.array[0].used + 1;
range.stop = range.start + (path.used - range.start) - 1;
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, firewall_total_parameters };
f_console_parameter_id_t ids[3] = { firewall_parameter_no_color, firewall_parameter_light, firewall_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, firewall_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (found_command) {
firewall_local_data_t local = firewall_local_data_t_initialize;
firewall_reserved_chains_t reserved = firewall_reserved_chains_t_initialize;
- f_string_range_t input = f_string_range_initialize;
+ f_string_range_t input = f_string_range_t_initialize;
if (command == firewall_parameter_command_show) {
// Warning: these are hardcoded print commands (I am not certain how I am going to implement external 'show' rules as the default-firewall setting file is the wrong place to put this)
}
else {
{
- f_string_range_t input = f_string_range_initialize;
+ f_string_range_t input = f_string_range_t_initialize;
input.stop = local_buffer.used - 1;
f_array_length_t j = 0;
f_string_length_t length = 0;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
f_string_dynamics_t arguments = f_string_dynamics_t_initialize;
f_string_dynamic_t fixed_string = f_string_dynamic_t_initialize;
return status;
}
else {
- f_string_range_t input = f_string_range_initialize;
+ f_string_range_t input = f_string_range_t_initialize;
input.stop = local->buffer.used - 1;
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, fss_basic_list_read_total_parameters };
f_console_parameter_id_t ids[3] = { fss_basic_list_read_parameter_no_color, fss_basic_list_read_parameter_light, fss_basic_list_read_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, fss_basic_list_read_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
}
}
- status = f_file_read_until(file, &data->buffer, data->quantity.total);
+ status = f_file_read_until(file, data->quantity.total, &data->buffer);
f_file_close(&file.id);
else {
position_depth = data.parameters[fss_basic_list_read_parameter_depth].additional.array[i];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[position_depth]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[position_depth]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range);
if (F_status_is_error(status)) {
depths->array[i].index_at = data.parameters[fss_basic_list_read_parameter_at].additional.array[position_at];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[depths->array[i].index_at]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[depths->array[i].index_at]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range);
if (F_status_is_error(status)) {
f_status_t status = F_none;
{
- f_string_range_t input = f_string_range_initialize;
+ f_string_range_t input = f_string_range_t_initialize;
input.start = 0;
input.stop = data->buffer.used - 1;
if (data->parameters[fss_basic_list_read_parameter_select].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[fss_basic_list_read_parameter_select].additional.array[data->parameters[fss_basic_list_read_parameter_select].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
if (F_status_is_error(status)) {
if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[fss_basic_list_read_parameter_line].additional.array[data->parameters[fss_basic_list_read_parameter_line].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
if (F_status_is_error(status)) {
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, fss_basic_list_write_total_parameters };
f_console_parameter_id_t ids[3] = { fss_basic_list_write_parameter_no_color, fss_basic_list_write_parameter_light, fss_basic_list_write_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, fss_basic_list_write_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (F_status_is_error(status)) {
bool object = (data->parameters[fss_basic_list_write_parameter_object].result == f_console_result_found);
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
if (data->process_pipe) {
f_file_t file = f_file_t_initialize;
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, fss_basic_read_total_parameters };
f_console_parameter_id_t ids[3] = { fss_basic_read_parameter_no_color, fss_basic_read_parameter_light, fss_basic_read_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, fss_basic_read_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
}
}
- status = f_file_read_until(file, &data->buffer, data->quantity.total);
+ status = f_file_read_until(file, data->quantity.total, &data->buffer);
f_file_close(&file.id);
else {
position_depth = data.parameters[fss_basic_read_parameter_depth].additional.array[i];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[position_depth]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[position_depth]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range);
if (F_status_is_error(status)) {
depths->array[i].index_at = data.parameters[fss_basic_read_parameter_at].additional.array[position_at];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[depths->array[i].index_at]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[depths->array[i].index_at]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range);
if (F_status_is_error(status)) {
f_status_t status = F_none;
{
- f_string_range_t input = f_string_range_initialize;
+ f_string_range_t input = f_string_range_t_initialize;
input.start = 0;
input.stop = data->buffer.used - 1;
if (data->parameters[fss_basic_read_parameter_select].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[fss_basic_read_parameter_select].additional.array[data->parameters[fss_basic_read_parameter_select].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
if (F_status_is_error(status)) {
if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[fss_basic_read_parameter_line].additional.array[data->parameters[fss_basic_read_parameter_line].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
if (F_status_is_error(status)) {
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, fss_basic_write_total_parameters };
f_console_parameter_id_t ids[3] = { fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, fss_basic_write_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (F_status_is_error(status)) {
bool object = (data->parameters[fss_basic_write_parameter_object].result == f_console_result_found);
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
if (data->process_pipe) {
f_file_t file = f_file_t_initialize;
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, fss_extended_list_read_total_parameters };
f_console_parameter_id_t ids[3] = { fss_extended_list_read_parameter_no_color, fss_extended_list_read_parameter_light, fss_extended_list_read_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, fss_extended_list_read_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
}
}
- status = f_file_read_until(file, &data->buffer, data->quantity.total);
+ status = f_file_read_until(file, data->quantity.total, &data->buffer);
f_file_close(&file.id);
else {
position_depth = data.parameters[fss_extended_list_read_parameter_depth].additional.array[i];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[position_depth]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[position_depth]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range);
if (F_status_is_error(status)) {
depths->array[i].index_at = data.parameters[fss_extended_list_read_parameter_at].additional.array[position_at];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[depths->array[i].index_at]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[depths->array[i].index_at]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range);
if (F_status_is_error(status)) {
f_status_t status = F_none;
{
- f_string_range_t input = f_string_range_initialize;
+ f_string_range_t input = f_string_range_t_initialize;
input.start = 0;
input.stop = data->buffer.used - 1;
if (data->parameters[fss_extended_list_read_parameter_select].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[fss_extended_list_read_parameter_select].additional.array[data->parameters[fss_extended_list_read_parameter_select].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
if (F_status_is_error(status)) {
if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[fss_extended_list_read_parameter_line].additional.array[data->parameters[fss_extended_list_read_parameter_line].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
f_number_unsigned_t number = 0;
if (depth_setting.index_name > 0) {
memset(names, 0, sizeof(bool) * items->used);
- f_string_range_t value_range = f_string_range_initialize;
+ f_string_range_t value_range = f_string_range_t_initialize;
value_range.stop = depth_setting.value_name.used - 1;
if (data->parameters[fss_extended_list_read_parameter_trim].result == f_console_result_found) {
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, fss_extended_read_total_parameters };
f_console_parameter_id_t ids[3] = { fss_extended_read_parameter_no_color, fss_extended_read_parameter_light, fss_extended_read_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, fss_extended_read_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
}
}
- status = f_file_read_until(file, &data->buffer, data->quantity.total);
+ status = f_file_read_until(file, data->quantity.total, &data->buffer);
f_file_close(&file.id);
else {
position_depth = data.parameters[fss_extended_read_parameter_depth].additional.array[i];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[position_depth]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[position_depth]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[position_depth], &depths->array[i].depth, range);
if (F_status_is_error(status)) {
depths->array[i].index_at = data.parameters[fss_extended_read_parameter_at].additional.array[position_at];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[depths->array[i].index_at]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[depths->array[i].index_at]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[depths->array[i].index_at], &depths->array[i].value_at, range);
if (F_status_is_error(status)) {
f_status_t status = F_none;
{
- f_string_range_t input = f_string_range_initialize;
+ f_string_range_t input = f_string_range_t_initialize;
input.start = 0;
input.stop = data->buffer.used - 1;
if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[fss_extended_read_parameter_select].additional.array[data->parameters[fss_extended_read_parameter_select].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
if (F_status_is_error(status)) {
if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[fss_extended_read_parameter_line].additional.array[data->parameters[fss_extended_read_parameter_line].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
if (F_status_is_error(status)) {
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, fss_extended_write_total_parameters };
f_console_parameter_id_t ids[3] = { fss_extended_write_parameter_no_color, fss_extended_write_parameter_light, fss_extended_write_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, fss_extended_write_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (F_status_is_error(status)) {
bool object = (data->parameters[fss_extended_write_parameter_object].result == f_console_result_found);
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
if (data->process_pipe) {
f_file_t file = f_file_t_initialize;
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, fss_status_code_total_parameters };
f_console_parameter_id_t ids[3] = { fss_status_code_parameter_no_color, fss_status_code_parameter_light, fss_status_code_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, fss_status_code_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
f_status_t status = F_none;
{
- const f_string_range_t range = f_macro_string_range_initialize(strlen(value));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(value));
f_number_unsigned_t number = 0;
#ifndef _di_fss_status_code_convert_number_
f_return_status fss_status_code_convert_number(const fss_status_code_data_t data, const f_string_t value, f_number_unsigned_t *number) {
- const f_string_range_t range = f_macro_string_range_initialize(strlen(value));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(value));
f_status_t status = fl_conversion_string_to_number_unsigned(value, number, range);
printf("%c", f_string_eol[0]);
- fll_program_print_help_option(context, iki_read_short_substitute, iki_read_long_substitute, f_console_symbol_short_enable, f_console_symbol_long_enable,"Substitute the entire variable for the given name and content value with the given string.");
+ fll_program_print_help_option(context, iki_read_short_substitute, iki_read_long_substitute, f_console_symbol_short_enable, f_console_symbol_long_enable, "Substitute the entire variable for the given name and content value with the given string.");
fll_program_print_help_usage(context, iki_read_name, "filename(s)");
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, iki_read_total_parameters };
f_console_parameter_id_t ids[3] = { iki_read_parameter_no_color, iki_read_parameter_light, iki_read_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, iki_read_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (F_status_is_error(status)) {
}
else if (data->parameters[iki_read_parameter_at].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[iki_read_parameter_at].additional.array[data->parameters[iki_read_parameter_at].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
f_number_unsigned_t number = 0;
}
else if (data->parameters[iki_read_parameter_line].result == f_console_result_additional) {
const f_string_length_t index = data->parameters[iki_read_parameter_line].additional.array[data->parameters[iki_read_parameter_line].additional.used - 1];
- const f_string_range_t range = f_macro_string_range_initialize(strlen(arguments.argv[index]));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(arguments.argv[index]));
f_number_unsigned_t number = 0;
continue;
}
- status = f_file_read_until(file, &data->buffer, total);
+ status = f_file_read_until(file, total, &data->buffer);
f_file_close(&file.id);
}
}
- // ensure a newline is always put at the end of the program execution, unless in quite mode.
+ // ensure a newline is always put at the end of the program execution, unless in quiet mode.
if (data->verbosity != iki_read_verbosity_quiet) {
if (F_status_is_error(status) || data->mode == 0) {
fprintf(f_type_error, "%c", f_string_eol[0]);
* API Version: 0.5
* Licenses: lgplv2.1
*
- * This is the FSS Basic Read program
+ * This is the IKI Read program.
+ *
* This program utilizes the Featureless Linux Library.
* This program processes files or other input in fss format and stores the results in the iki_read_data_t.
*
- * This processes in accordance to the FSS-0000 Basic specification.
+ * This processes in accordance to the IKI specification.
*/
#ifndef _iki_read_h
f_iki_content_t content = f_iki_content_t_initialize;
if (data->parameters[iki_read_parameter_whole].result == f_console_result_found) {
- f_string_range_t buffer_range = f_macro_string_range_initialize(data->buffer.used);
+ f_string_range_t buffer_range = f_macro_string_range_t_initialize(data->buffer.used);
status = iki_read_process_at(arguments, file_name, data, &buffer_range);
status = iki_read_process_buffer_total(arguments, file_name, data, &variable, &vocabulary, &content);
}
else {
- f_string_range_t buffer_range = f_macro_string_range_initialize(data->buffer.used);
+ f_string_range_t buffer_range = f_macro_string_range_t_initialize(data->buffer.used);
status = iki_read_process_at(arguments, file_name, data, &buffer_range);
}
f_string_dynamics_t names = f_string_dynamics_t_initialize;
- f_string_range_t name_range = f_string_range_initialize;
- f_string_range_t substitution_range = f_string_range_initialize;
+ f_string_range_t name_range = f_string_range_t_initialize;
+ f_string_range_t substitution_range = f_string_range_t_initialize;
bool name_missed = F_true;
#ifndef _di_iki_read_process_buffer_total_
f_return_status iki_read_process_buffer_total(const f_console_arguments_t arguments, const f_string_t file_name, iki_read_data_t *data, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content) {
f_status_t status = F_none;
- f_string_range_t range = f_macro_string_range_initialize(data->buffer.used);
+ f_string_range_t range = f_macro_string_range_t_initialize(data->buffer.used);
status = iki_read_process_at(arguments, file_name, data, &range);
f_status_t status = F_none;
f_string_length_t i = 0;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
range.start = 0;
unsigned short do_socket_port = F_false;
{
- f_console_parameters_t parameters = { data->parameters, init_total_parameters };
f_console_parameter_id_t ids[3] = { init_parameter_no_color, init_parameter_light, init_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, init_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
f_macro_file_t_reset_position(quantity, file)
fflush(stdout);
- status = f_file_read_until(file, buffer, quantity);
+ status = f_file_read_until(file, quantity, buffer);
f_file_close(&file.id);
return F_status_set_error(status);
} else {
- f_string_range_t input = f_string_range_initialize;
+ f_string_range_t input = f_string_range_t_initialize;
input.stop = buffer->used - 1;
f_return_status init_process_main_rule(const init_data_t data, f_string_dynamic_t *buffer, init_data_t *settings) {
f_status_t status = F_none;
f_string_dynamic_t buffer = f_string_dynamic_t_initialize;
- f_string_range_t range = f_string_range_initialize;
+ f_string_range_t range = f_string_range_t_initialize;
f_fss_objects_t objects = f_fss_objects_t_initialize;
f_fss_contents_t contents = f_fss_contents_t_initialize;
f_string_length_t position = 0;
f_status_t status = F_none;
{
- const f_string_range_t range = f_macro_string_range_initialize(strlen(value));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(value));
f_number_unsigned_t number = 0;
#ifndef _di_status_code_convert_number_
f_return_status status_code_convert_number(const status_code_data_t data, const f_string_t value, f_number_unsigned_t *number) {
- const f_string_range_t range = f_macro_string_range_initialize(strlen(value));
+ const f_string_range_t range = f_macro_string_range_t_initialize(strlen(value));
f_status_t status = fl_conversion_string_to_number_unsigned(value, number, range);
f_status_t status = F_none;
{
- f_console_parameters_t parameters = { data->parameters, status_code_total_parameters };
f_console_parameter_id_t ids[3] = { status_code_parameter_no_color, status_code_parameter_light, status_code_parameter_dark };
- f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameter_ids_t choices = { ids, 3 };
+ const f_console_parameters_t parameters = { data->parameters, status_code_total_parameters };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);