]> Kevux Git Server - fll/commitdiff
Feature: add -c/--content parameter to FSS read programs.
authorKevin Day <thekevinday@gmail.com>
Sat, 3 Oct 2020 21:43:32 +0000 (16:43 -0500)
committerKevin Day <thekevinday@gmail.com>
Sat, 3 Oct 2020 21:43:32 +0000 (16:43 -0500)
The default behavior is already a -c/--content.
This provides a literal parameter for good practice and better hackability.

This introduces a new possibility where both -o/--object and -c/--content are specified at the same time.
In this case, print both the object and the content.
It must be noted, however, that this only prints the escaped object and content, just like when -o/--object or -c/--content do already.
The objects in the basic read and extended read are printed with a space between them and their respective content.
The objects in the basic list read and extended list read are printed with an EOL ('\n') between them and their respective content.

13 files changed:
level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_list_read/c/fss_basic_list_read.h
level_3/fss_basic_list_read/c/private-fss_basic_list_read.c
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_basic_read/c/fss_basic_read.h
level_3/fss_basic_read/c/private-fss_basic_read.c
level_3/fss_extended_list_read/c/fss_extended_list_read.c
level_3/fss_extended_list_read/c/fss_extended_list_read.h
level_3/fss_extended_list_read/c/private-fss_extended_list_read.c
level_3/fss_extended_list_read/c/private-fss_extended_list_read.h
level_3/fss_extended_read/c/fss_extended_read.c
level_3/fss_extended_read/c/fss_extended_read.h
level_3/fss_extended_read/c/private-fss_extended_read.c

index 8eab6b826b8399771ed77a6f64c78bd193667eda..af054fde90071e377b5370e89cc9e7490be57a0c 100644 (file)
@@ -23,11 +23,12 @@ extern "C" {
     printf("%c", f_string_eol[0]);
 
     fll_program_print_help_option(file, context, fss_basic_list_read_short_at, fss_basic_list_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, "      Select object at this numeric index.");
+    fll_program_print_help_option(file, context, fss_basic_list_read_short_content, fss_basic_list_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the content (default).");
     fll_program_print_help_option(file, context, fss_basic_list_read_short_depth, fss_basic_list_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Select object at this numeric depth.");
     fll_program_print_help_option(file, context, fss_basic_list_read_short_empty, fss_basic_list_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Include empty content when processing.");
     fll_program_print_help_option(file, context, fss_basic_list_read_short_line, fss_basic_list_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Print only the content at the given line.");
     fll_program_print_help_option(file, context, fss_basic_list_read_short_name, fss_basic_list_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Select object with this name.");
-    fll_program_print_help_option(file, context, fss_basic_list_read_short_object, fss_basic_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Print the object instead of the content.");
+    fll_program_print_help_option(file, context, fss_basic_list_read_short_object, fss_basic_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Print the object.");
     fll_program_print_help_option(file, context, fss_basic_list_read_short_select, fss_basic_list_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Select sub-content at this index.");
     fll_program_print_help_option(file, context, fss_basic_list_read_short_total, fss_basic_list_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Print the total number of lines.");
     fll_program_print_help_option(file, context, fss_basic_list_read_short_trim, fss_basic_list_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Trim object names on select or print.");
@@ -122,6 +123,16 @@ extern "C" {
 
     printf("%c", f_string_eol[0]);
 
+    printf("  When specifying both the ");
+    fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object);
+    printf(" parameter and the ");
+    fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_content);
+    printf(" parameter, the entire object and content are printed, including the formatting.%c", f_string_eol[0]);
+    printf("  Both the object and content printed are already escaped.%c", f_string_eol[0]);
+    printf("  Both the object and content are separated by an EOL.%c", f_string_eol[0]);
+
+    printf("%c", f_string_eol[0]);
+
     return F_none;
   }
 #endif // _di_fss_basic_list_read_print_help_
@@ -260,6 +271,21 @@ extern "C" {
           fss_basic_list_read_delete_data(data);
           return F_status_set_error(F_parameter);
         }
+
+        if (data->parameters[fss_basic_list_read_parameter_content].result == f_console_result_found) {
+          if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
+            fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify both the '", fll_error_print_error);
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_object);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' and the '");
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_content);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '");
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_list_read_long_total);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' parameter.%c", f_string_eol[0]);
+
+            fss_basic_list_read_delete_data(data);
+            return F_status_set_error(F_parameter);
+          }
+        }
       }
 
       if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
index 34cd893c3c12ad4864ba2bb71594cca0dc93363b..192db763446679d69be67745910e2e15ea63a978 100644 (file)
@@ -62,25 +62,27 @@ extern "C" {
 #endif // _di_fss_basic_list_read_name_
 
 #ifndef _di_fss_basic_list_read_defines_
-  #define fss_basic_list_read_short_at     "a"
-  #define fss_basic_list_read_short_depth  "d"
-  #define fss_basic_list_read_short_empty  "e"
-  #define fss_basic_list_read_short_line   "l"
-  #define fss_basic_list_read_short_name   "n"
-  #define fss_basic_list_read_short_object "o"
-  #define fss_basic_list_read_short_select "s"
-  #define fss_basic_list_read_short_total  "t"
-  #define fss_basic_list_read_short_trim   "T"
-
-  #define fss_basic_list_read_long_at     "at"
-  #define fss_basic_list_read_long_depth  "depth"
-  #define fss_basic_list_read_long_empty  "empty"
-  #define fss_basic_list_read_long_line   "line"
-  #define fss_basic_list_read_long_name   "name"
-  #define fss_basic_list_read_long_object "object"
-  #define fss_basic_list_read_long_select "select"
-  #define fss_basic_list_read_long_total  "total"
-  #define fss_basic_list_read_long_trim   "trim"
+  #define fss_basic_list_read_short_at      "a"
+  #define fss_basic_list_read_short_content "c"
+  #define fss_basic_list_read_short_depth   "d"
+  #define fss_basic_list_read_short_empty   "e"
+  #define fss_basic_list_read_short_line    "l"
+  #define fss_basic_list_read_short_name    "n"
+  #define fss_basic_list_read_short_object  "o"
+  #define fss_basic_list_read_short_select  "s"
+  #define fss_basic_list_read_short_total   "t"
+  #define fss_basic_list_read_short_trim    "T"
+
+  #define fss_basic_list_read_long_at      "at"
+  #define fss_basic_list_read_long_content "content"
+  #define fss_basic_list_read_long_depth   "depth"
+  #define fss_basic_list_read_long_empty   "empty"
+  #define fss_basic_list_read_long_line    "line"
+  #define fss_basic_list_read_long_name    "name"
+  #define fss_basic_list_read_long_object  "object"
+  #define fss_basic_list_read_long_select  "select"
+  #define fss_basic_list_read_long_total   "total"
+  #define fss_basic_list_read_long_trim    "trim"
 
   enum {
     fss_basic_list_read_parameter_help,
@@ -94,6 +96,7 @@ extern "C" {
     fss_basic_list_read_parameter_version,
 
     fss_basic_list_read_parameter_at,
+    fss_basic_list_read_parameter_content,
     fss_basic_list_read_parameter_depth,
     fss_basic_list_read_parameter_empty,
     fss_basic_list_read_parameter_line,
@@ -116,6 +119,7 @@ extern "C" {
       f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \
       f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \
       f_console_parameter_t_initialize(fss_basic_list_read_short_at, fss_basic_list_read_long_at, 0, 1, f_console_type_normal), \
+      f_console_parameter_t_initialize(fss_basic_list_read_short_content, fss_basic_list_read_long_content, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_basic_list_read_short_depth, fss_basic_list_read_long_depth, 0, 1, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_basic_list_read_short_empty, fss_basic_list_read_long_empty, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_basic_list_read_short_line, fss_basic_list_read_long_line, 0, 1, f_console_type_normal), \
@@ -126,7 +130,7 @@ extern "C" {
       f_console_parameter_t_initialize(fss_basic_list_read_short_trim, fss_basic_list_read_long_trim, 0, 0, f_console_type_normal), \
     }
 
-  #define fss_basic_list_read_total_parameters 18
+  #define fss_basic_list_read_total_parameters 19
 #endif // _di_fss_basic_list_read_defines_
 
 #ifndef _di_fss_basic_list_read_data_t_
index fcc333d228c2b6daac89a47a51514a47eb1c1338..2d0d1a2c2f5f818282e0078f27efa9ca88ffb007 100644 (file)
@@ -231,10 +231,10 @@ extern "C" {
       }
     }
 
-    f_string_length_t select = 0;
+    f_number_unsigned_t select = 0;
 
     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_array_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_t_initialize(strlen(arguments.argv[index]));
 
       status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
@@ -250,10 +250,10 @@ extern "C" {
       }
     }
 
-    f_string_length_t line = 0;
+    f_array_length_t line = 0;
 
     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_array_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_t_initialize(strlen(arguments.argv[index]));
 
       status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
@@ -266,13 +266,16 @@ extern "C" {
 
     bool names[data->objects.used];
 
+    f_array_length_t i = 0;
+    f_array_length_t j = 0;
+
     if (depths.array[0].index_name > 0) {
       memset(names, 0, sizeof(bool) * data->objects.used);
 
       f_string_length_t name_length = 0;
 
       if (data->parameters[fss_basic_list_read_parameter_trim].result == f_console_result_found) {
-        for (f_string_length_t i = 0; i < data->objects.used; i++) {
+        for (i = 0; i < data->objects.used; i++) {
 
           name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1;
 
@@ -284,7 +287,7 @@ extern "C" {
         } // for
       }
       else {
-        for (f_string_length_t i = 0; i < data->objects.used; i++) {
+        for (i = 0; i < data->objects.used; i++) {
           name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1;
 
           if (name_length == depths.array[0].value_name.used) {
@@ -316,9 +319,9 @@ extern "C" {
           }
         }
         else if (depths.array[0].index_name > 0) {
-          f_string_length_t total = 0;
+          f_array_length_t total = 0;
 
-          for (f_string_length_t i = 0; i < data->objects.used; i++) {
+          for (i = 0; i < data->objects.used; i++) {
             if (!names[i]) continue;
 
             total++;
@@ -348,7 +351,18 @@ extern "C" {
           if (names[i]) {
             if (at == depths.array[0].value_at) {
               print_object(f_type_output, data->buffer, data->objects.array[i]);
-              fprintf(f_type_output, "%c", f_string_eol[0]);
+
+              if (data->parameters[fss_basic_list_read_parameter_content].result == f_console_result_found) {
+                if (data->contents.array[i].used) {
+                  fprintf(f_type_output, "%c", f_fss_eol);
+                  f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]);
+                }
+                else {
+                  fprintf(f_type_output, "%c", f_fss_eol);
+                }
+              }
+
+              fprintf(f_type_output, "%c", f_fss_eol);
               break;
             }
 
@@ -359,11 +373,22 @@ extern "C" {
         return F_none;
       }
 
-      for (f_string_length_t i = 0; i < data->objects.used; i++) {
+      for (i = 0; i < data->objects.used; i++) {
         if (!names[i]) continue;
 
         print_object(f_type_output, data->buffer, data->objects.array[i]);
-        fprintf(f_type_output, "%c", f_string_eol[0]);
+
+        if (data->parameters[fss_basic_list_read_parameter_content].result == f_console_result_found) {
+          if (data->contents.array[i].used) {
+            fprintf(f_type_output, "%c", f_fss_eol);
+            f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]);
+          }
+          else {
+            fprintf(f_type_output, "%c", f_fss_eol);
+          }
+        }
+
+        fprintf(f_type_output, "%c", f_fss_eol);
       } // for
 
       return F_none;
@@ -379,7 +404,6 @@ extern "C" {
       }
 
       f_array_length_t at = 0;
-      f_array_length_t i = 0;
 
       for (; i < data->objects.used; i++) {
 
@@ -390,9 +414,9 @@ extern "C" {
                 fprintf(f_type_output, "0%c", f_string_eol[0]);
               }
               else {
-                f_string_length_t total = 1;
+                f_array_length_t total = 1;
 
-                for (f_string_length_t j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) {
+                for (j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) {
                   if (!data->buffer.string[j]) continue;
 
                   if (data->buffer.string[j] == f_string_eol[0]) {
@@ -413,7 +437,7 @@ extern "C" {
                 }
               }
               else {
-                f_string_length_t i = data->contents.array[i].array[0].start;
+                i = data->contents.array[i].array[0].start;
 
                 if (!line) {
                   for (; i <= data->contents.array[i].array[0].stop; i++) {
@@ -427,7 +451,7 @@ extern "C" {
                   } // for
                 }
                 else {
-                  f_string_length_t line_current = 0;
+                  f_array_length_t line_current = 0;
 
                   for (; i <= data->contents.array[i].array[0].stop; i++) {
                     if (!data->buffer.string[i]) continue;
@@ -477,9 +501,9 @@ extern "C" {
     }
 
     if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
-      f_string_length_t total = 0;
+      f_array_length_t total = 0;
 
-      for (f_string_length_t i = 0; i < data->objects.used; i++) {
+      for (i = 0; i < data->objects.used; i++) {
         if (!names[i]) continue;
 
         if (!data->contents.array[i].used) {
@@ -490,7 +514,7 @@ extern "C" {
           continue;
         }
 
-        for (f_string_length_t j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) {
+        for (j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) {
           if (!data->buffer.string[j]) continue;
 
           if (data->buffer.string[j] == f_string_eol[0]) {
@@ -504,11 +528,7 @@ extern "C" {
     }
 
     if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) {
-      f_string_length_t line_current = 0;
-      f_string_length_t i = 0;
-      f_string_length_t j = 0;
-
-      for (; i < data->contents.used; i++) {
+      for (f_array_length_t line_current = 0; i < data->contents.used; i++) {
         if (!names[i]) continue;
 
         if (!data->contents.array[i].used) {
@@ -561,7 +581,7 @@ extern "C" {
       return F_none;
     }
 
-    for (f_string_length_t i = 0; i < data->contents.used; i++) {
+    for (i = 0; i < data->contents.used; i++) {
       if (!names[i]) continue;
 
       if (!data->contents.array[i].used) {
index ba092b1c3d6a8c3774bee6bdd590cf9c464b1cf9..e77bad40b606d55d312afe1f2b64de09be11ca98 100644 (file)
@@ -23,11 +23,12 @@ extern "C" {
     printf("%c", f_string_eol[0]);
 
     fll_program_print_help_option(file, context, fss_basic_read_short_at, fss_basic_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, "      Select object at this numeric index.");
+    fll_program_print_help_option(file, context, fss_basic_read_short_content, fss_basic_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the content (default).");
     fll_program_print_help_option(file, context, fss_basic_read_short_depth, fss_basic_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Select object at this numeric depth.");
     fll_program_print_help_option(file, context, fss_basic_read_short_empty, fss_basic_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Include empty content when processing.");
     fll_program_print_help_option(file, context, fss_basic_read_short_line, fss_basic_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Print only the content at the given line.");
     fll_program_print_help_option(file, context, fss_basic_read_short_name, fss_basic_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Select object with this name.");
-    fll_program_print_help_option(file, context, fss_basic_read_short_object, fss_basic_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Print the object instead of the content.");
+    fll_program_print_help_option(file, context, fss_basic_read_short_object, fss_basic_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Print the object.");
     fll_program_print_help_option(file, context, fss_basic_read_short_select, fss_basic_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Select sub-content at this index.");
     fll_program_print_help_option(file, context, fss_basic_read_short_total, fss_basic_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Print the total number of lines.");
     fll_program_print_help_option(file, context, fss_basic_read_short_trim, fss_basic_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Trim object names on select or print.");
@@ -122,6 +123,16 @@ extern "C" {
 
     printf("%c", f_string_eol[0]);
 
+    printf("  When specifying both the ");
+    fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object);
+    printf(" parameter and the ");
+    fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_content);
+    printf(" parameter, the entire object and content are printed, including the formatting.%c", f_string_eol[0]);
+    printf("  Both the object and content printed are already escaped.%c", f_string_eol[0]);
+    printf("  Both the object and content are separated by a space.%c", f_string_eol[0]);
+
+    printf("%c", f_string_eol[0]);
+
     return F_none;
   }
 #endif // _di_fss_basic_read_print_help_
@@ -260,6 +271,21 @@ extern "C" {
           fss_basic_read_delete_data(data);
           return F_status_set_error(F_parameter);
         }
+
+        if (data->parameters[fss_basic_read_parameter_content].result == f_console_result_found) {
+          if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
+            fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify both the '", fll_error_print_error);
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_object);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' and the '");
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_content);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '");
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_basic_read_long_total);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' parameter.%c", f_string_eol[0]);
+
+            fss_basic_read_delete_data(data);
+            return F_status_set_error(F_parameter);
+          }
+        }
       }
 
       if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
index fcd635173f936bdff42031f0f5a391b4e01b9547..1709fb5bd88f2f2292997e36f159c37061bdc1f3 100644 (file)
@@ -62,25 +62,27 @@ extern "C" {
 #endif // _di_fss_basic_read_name_
 
 #ifndef _di_fss_basic_read_defines_
-  #define fss_basic_read_short_at     "a"
-  #define fss_basic_read_short_depth  "d"
-  #define fss_basic_read_short_empty  "e"
-  #define fss_basic_read_short_line   "l"
-  #define fss_basic_read_short_name   "n"
-  #define fss_basic_read_short_object "o"
-  #define fss_basic_read_short_select "s"
-  #define fss_basic_read_short_total  "t"
-  #define fss_basic_read_short_trim   "T"
-
-  #define fss_basic_read_long_at     "at"
-  #define fss_basic_read_long_depth  "depth"
-  #define fss_basic_read_long_empty  "empty"
-  #define fss_basic_read_long_line   "line"
-  #define fss_basic_read_long_name   "name"
-  #define fss_basic_read_long_object "object"
-  #define fss_basic_read_long_select "select"
-  #define fss_basic_read_long_total  "total"
-  #define fss_basic_read_long_trim   "trim"
+  #define fss_basic_read_short_at      "a"
+  #define fss_basic_read_short_content "c"
+  #define fss_basic_read_short_depth   "d"
+  #define fss_basic_read_short_empty   "e"
+  #define fss_basic_read_short_line    "l"
+  #define fss_basic_read_short_name    "n"
+  #define fss_basic_read_short_object  "o"
+  #define fss_basic_read_short_select  "s"
+  #define fss_basic_read_short_total   "t"
+  #define fss_basic_read_short_trim    "T"
+
+  #define fss_basic_read_long_at      "at"
+  #define fss_basic_read_long_content "content"
+  #define fss_basic_read_long_depth   "depth"
+  #define fss_basic_read_long_empty   "empty"
+  #define fss_basic_read_long_line    "line"
+  #define fss_basic_read_long_name    "name"
+  #define fss_basic_read_long_object  "object"
+  #define fss_basic_read_long_select  "select"
+  #define fss_basic_read_long_total   "total"
+  #define fss_basic_read_long_trim    "trim"
 
   enum {
     fss_basic_read_parameter_help,
@@ -94,6 +96,7 @@ extern "C" {
     fss_basic_read_parameter_version,
 
     fss_basic_read_parameter_at,
+    fss_basic_read_parameter_content,
     fss_basic_read_parameter_depth,
     fss_basic_read_parameter_empty,
     fss_basic_read_parameter_line,
@@ -116,6 +119,7 @@ extern "C" {
       f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \
       f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \
       f_console_parameter_t_initialize(fss_basic_read_short_at, fss_basic_read_long_at, 0, 1, f_console_type_normal), \
+      f_console_parameter_t_initialize(fss_basic_read_short_content, fss_basic_read_long_content, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_basic_read_short_depth, fss_basic_read_long_depth, 0, 1, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_basic_read_short_empty, fss_basic_read_long_empty, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_basic_read_short_line, fss_basic_read_long_line, 0, 1, f_console_type_normal), \
@@ -126,7 +130,7 @@ extern "C" {
       f_console_parameter_t_initialize(fss_basic_read_short_trim, fss_basic_read_long_trim, 0, 0, f_console_type_normal), \
     }
 
-  #define fss_basic_read_total_parameters 18
+  #define fss_basic_read_total_parameters 19
 #endif // _di_fss_basic_read_defines_
 
 #ifndef _di_fss_basic_read_data_t_
index bdcb72f98902cf0be719ce6278f3f2ff9bd6ab15..cb6b9cfc5b42b9fc93a40964f73dea6af8c5fadb 100644 (file)
@@ -231,7 +231,7 @@ extern "C" {
       }
     }
 
-    f_string_length_t select = 0;
+    f_number_unsigned_t select = 0;
 
     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];
@@ -250,10 +250,10 @@ extern "C" {
       }
     }
 
-    f_string_length_t line = 0;
+    f_array_length_t line = 0;
 
     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_array_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_t_initialize(strlen(arguments.argv[index]));
 
       status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
@@ -266,13 +266,15 @@ extern "C" {
 
     bool names[data->objects.used];
 
+    f_array_length_t i = 0;
+
     if (depths.array[0].index_name > 0) {
       memset(names, 0, sizeof(bool) * data->objects.used);
 
       f_string_length_t name_length = 0;
 
       if (data->parameters[fss_basic_read_parameter_trim].result == f_console_result_found) {
-        for (f_string_length_t i = 0; i < data->objects.used; i++) {
+        for (i = 0; i < data->objects.used; i++) {
 
           name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1;
 
@@ -284,7 +286,7 @@ extern "C" {
         } // for
       }
       else {
-        for (f_string_length_t i = 0; i < data->objects.used; i++) {
+        for (i = 0; i < data->objects.used; i++) {
 
           name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1;
 
@@ -317,9 +319,9 @@ extern "C" {
           }
         }
         else if (depths.array[0].index_name > 0) {
-          f_string_length_t total = 0;
+          f_array_length_t total = 0;
 
-          for (f_string_length_t i = 0; i < data->objects.used; i++) {
+          for (i = 0; i < data->objects.used; i++) {
             if (!names[i]) continue;
 
             total++;
@@ -342,14 +344,21 @@ extern "C" {
 
       if (depths.array[0].index_at > 0) {
         f_array_length_t at = 0;
-        f_array_length_t i = 0;
 
         for (; i < data->objects.used; i++) {
 
           if (names[i]) {
             if (at == depths.array[0].value_at) {
               print_object(f_type_output, data->buffer, data->objects.array[i]);
-              fprintf(f_type_output, "%c", f_string_eol[0]);
+
+              if (data->parameters[fss_basic_read_parameter_content].result == f_console_result_found) {
+                if (data->contents.array[i].used) {
+                  fprintf(f_type_output, "%c", f_fss_space);
+                  f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]);
+                }
+              }
+
+              fprintf(f_type_output, "%c", f_fss_eol);
               break;
             }
 
@@ -360,11 +369,19 @@ extern "C" {
         return F_none;
       }
 
-      for (f_array_length_t i = 0; i < data->objects.used; i++) {
+      for (i = 0; i < data->objects.used; i++) {
         if (!names[i]) continue;
 
         print_object(f_type_output, data->buffer, data->objects.array[i]);
-        fprintf(f_type_output, "%c", f_string_eol[0]);
+
+        if (data->parameters[fss_basic_read_parameter_content].result == f_console_result_found) {
+          if (data->contents.array[i].used) {
+            fprintf(f_type_output, "%c", f_fss_space);
+            f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[0]);
+          }
+        }
+
+        fprintf(f_type_output, "%c", f_fss_eol);
       } // for
 
       return F_none;
@@ -386,7 +403,6 @@ extern "C" {
       }
 
       f_array_length_t at = 0;
-      f_array_length_t i = 0;
 
       for (; i < data->objects.used; i++) {
 
@@ -432,7 +448,7 @@ extern "C" {
     if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) {
       f_string_length_t total = 0;
 
-      for (f_string_length_t i = 0; i < data->objects.used; i++) {
+      for (i = 0; i < data->objects.used; i++) {
         if (!names[i]) continue;
 
         if (!data->contents.array[i].used && !include_empty) {
@@ -447,9 +463,9 @@ extern "C" {
     }
 
     if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
-      f_string_length_t line_current = 0;
+      f_array_length_t line_current = 0;
 
-      for (f_string_length_t i = 0; i < data->contents.used; i++) {
+      for (i = 0; i < data->contents.used; i++) {
         if (!names[i]) continue;
 
         if (!data->contents.array[i].used) {
@@ -478,7 +494,7 @@ extern "C" {
       return F_none;
     }
 
-    for (f_string_length_t i = 0; i < data->contents.used; i++) {
+    for (i = 0; i < data->contents.used; i++) {
       if (!names[i]) continue;
 
       if (!data->contents.array[i].used) {
index 991629318e52d6ac4e61f8d6468ae7cb8e225bbf..a02cb3a93bcbdcf30505f00eba6d5fdd6eb6021d 100644 (file)
@@ -23,11 +23,12 @@ extern "C" {
     printf("%c", f_string_eol[0]);
 
     fll_program_print_help_option(file, context, fss_extended_list_read_short_at, fss_extended_list_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, "      Select object at this numeric index.");
+    fll_program_print_help_option(file, context, fss_extended_list_read_short_content, fss_extended_list_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the content (default).");
     fll_program_print_help_option(file, context, fss_extended_list_read_short_depth, fss_extended_list_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Select object at this numeric depth.");
     fll_program_print_help_option(file, context, fss_extended_list_read_short_empty, fss_extended_list_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Include empty content when processing.");
     fll_program_print_help_option(file, context, fss_extended_list_read_short_line, fss_extended_list_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Print only the content at the given line.");
     fll_program_print_help_option(file, context, fss_extended_list_read_short_name, fss_extended_list_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Select object with this name.");
-    fll_program_print_help_option(file, context, fss_extended_list_read_short_object, fss_extended_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Print the object instead of the content.");
+    fll_program_print_help_option(file, context, fss_extended_list_read_short_object, fss_extended_list_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Print the object.");
     fll_program_print_help_option(file, context, fss_extended_list_read_short_select, fss_extended_list_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Select sub-content at this index.");
     fll_program_print_help_option(file, context, fss_extended_list_read_short_total, fss_extended_list_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Print the total number of lines.");
     fll_program_print_help_option(file, context, fss_extended_list_read_short_trim, fss_extended_list_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Trim object names on select or print.");
@@ -122,6 +123,16 @@ extern "C" {
 
     printf("%c", f_string_eol[0]);
 
+    printf("  When specifying both the ");
+    fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object);
+    printf(" parameter and the ");
+    fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_content);
+    printf(" parameter, the entire object and content are printed, including the formatting.%c", f_string_eol[0]);
+    printf("  Both the object and content printed are already escaped.%c", f_string_eol[0]);
+    printf("  Both the object and content are separated by an EOL.%c", f_string_eol[0]);
+
+    printf("%c", f_string_eol[0]);
+
     return F_none;
   }
 #endif // _di_fss_extended_list_read_print_help_
@@ -260,6 +271,21 @@ extern "C" {
           fss_extended_list_read_delete_data(data);
           return F_status_set_error(F_parameter);
         }
+
+        if (data->parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) {
+          if (data->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) {
+            fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify both the '", fll_error_print_error);
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_object);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' and the '");
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_content);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '");
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_list_read_long_total);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' parameter.%c", f_string_eol[0]);
+
+            fss_extended_list_read_delete_data(data);
+            return F_status_set_error(F_parameter);
+          }
+        }
       }
 
       if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) {
index 291e1a79a31973564e6e908482aa11358d0e63c8..516b305cfaa0481e215163833e4994410cd3eb47 100644 (file)
@@ -62,25 +62,27 @@ extern "C" {
 #endif // _di_fss_extended_list_read_name_
 
 #ifndef _di_fss_extended_list_read_defines_
-  #define fss_extended_list_read_short_at     "a"
-  #define fss_extended_list_read_short_depth  "d"
-  #define fss_extended_list_read_short_empty  "e"
-  #define fss_extended_list_read_short_line   "l"
-  #define fss_extended_list_read_short_name   "n"
-  #define fss_extended_list_read_short_object "o"
-  #define fss_extended_list_read_short_select "s"
-  #define fss_extended_list_read_short_total  "t"
-  #define fss_extended_list_read_short_trim   "T"
-
-  #define fss_extended_list_read_long_at     "at"
-  #define fss_extended_list_read_long_depth  "depth"
-  #define fss_extended_list_read_long_empty  "empty"
-  #define fss_extended_list_read_long_line   "line"
-  #define fss_extended_list_read_long_name   "name"
-  #define fss_extended_list_read_long_object "object"
-  #define fss_extended_list_read_long_select "select"
-  #define fss_extended_list_read_long_total  "total"
-  #define fss_extended_list_read_long_trim   "trim"
+  #define fss_extended_list_read_short_at      "a"
+  #define fss_extended_list_read_short_content "c"
+  #define fss_extended_list_read_short_depth   "d"
+  #define fss_extended_list_read_short_empty   "e"
+  #define fss_extended_list_read_short_line    "l"
+  #define fss_extended_list_read_short_name    "n"
+  #define fss_extended_list_read_short_object  "o"
+  #define fss_extended_list_read_short_select  "s"
+  #define fss_extended_list_read_short_total   "t"
+  #define fss_extended_list_read_short_trim    "T"
+
+  #define fss_extended_list_read_long_at      "at"
+  #define fss_extended_list_read_long_content "content"
+  #define fss_extended_list_read_long_depth   "depth"
+  #define fss_extended_list_read_long_empty   "empty"
+  #define fss_extended_list_read_long_line    "line"
+  #define fss_extended_list_read_long_name    "name"
+  #define fss_extended_list_read_long_object  "object"
+  #define fss_extended_list_read_long_select  "select"
+  #define fss_extended_list_read_long_total   "total"
+  #define fss_extended_list_read_long_trim    "trim"
 
   enum {
     fss_extended_list_read_parameter_help,
@@ -94,6 +96,7 @@ extern "C" {
     fss_extended_list_read_parameter_version,
 
     fss_extended_list_read_parameter_at,
+    fss_extended_list_read_parameter_content,
     fss_extended_list_read_parameter_depth,
     fss_extended_list_read_parameter_empty,
     fss_extended_list_read_parameter_line,
@@ -116,6 +119,7 @@ extern "C" {
       f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \
       f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \
       f_console_parameter_t_initialize(fss_extended_list_read_short_at, fss_extended_list_read_long_at, 0, 1, f_console_type_normal), \
+      f_console_parameter_t_initialize(fss_extended_list_read_short_content, fss_extended_list_read_long_content, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_extended_list_read_short_depth, fss_extended_list_read_long_depth, 0, 1, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_extended_list_read_short_empty, fss_extended_list_read_long_empty, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_extended_list_read_short_line, fss_extended_list_read_long_line, 0, 1, f_console_type_normal), \
@@ -126,7 +130,7 @@ extern "C" {
       f_console_parameter_t_initialize(fss_extended_list_read_short_trim, fss_extended_list_read_long_trim, 0, 0, f_console_type_normal), \
     }
 
-  #define fss_extended_list_read_total_parameters 18
+  #define fss_extended_list_read_total_parameters 19
 #endif // _di_fss_extended_list_read_defines_
 
 #ifndef _di_fss_extended_list_read_data_t_
index 29455b66c56f970f8cbd625f747dcde3a5a76942..9f29a959955b10ce8823164e8de4becb23d0f8ce 100644 (file)
@@ -241,7 +241,7 @@ extern "C" {
     }
 
     {
-      f_string_length_t select = 0;
+      f_number_unsigned_t select = 0;
 
       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];
@@ -261,15 +261,13 @@ extern "C" {
       }
     }
 
-    f_string_length_t line = 0;
+    f_array_length_t line = 0;
 
     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_array_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_t_initialize(strlen(arguments.argv[index]));
 
-      f_number_unsigned_t number = 0;
-
-      status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &number, range);
+      status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
 
       if (F_status_is_error(status)) {
         fll_error_parameter_integer_print(data->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_line, arguments.argv[index]);
@@ -288,12 +286,15 @@ extern "C" {
 #endif // _di_fss_extended_list_read_main_process_file_
 
 #ifndef _di_fss_extended_list_read_main_process_for_depth_
-  f_return_status fss_extended_list_read_main_process_for_depth(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depth_t depth_setting, const f_string_length_t line) {
+  f_return_status fss_extended_list_read_main_process_for_depth(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depth_t depth_setting, const f_array_length_t line) {
     f_status_t status = F_none;
 
     f_fss_items_t *items = &data->nest.depth[depth_setting.depth];
     bool names[items->used];
 
+    f_array_length_t i = 0;
+    f_array_length_t j = 0;
+
     if (depth_setting.index_name > 0) {
       memset(names, 0, sizeof(bool) * items->used);
 
@@ -301,14 +302,14 @@ extern "C" {
       value_range.stop = depth_setting.value_name.used - 1;
 
       if (data->parameters[fss_extended_list_read_parameter_trim].result == f_console_result_found) {
-        for (f_string_length_t i = 0; i < items->used; i++) {
+        for (i = 0; i < items->used; i++) {
           if (fl_string_dynamic_partial_compare_trim(data->buffer, depth_setting.value_name, items->array[i].object, value_range) == F_equal_to) {
             names[i] = 1;
           }
         } // for
       }
       else {
-        for (f_string_length_t i = 0; i < items->used; i++) {
+        for (i = 0; i < items->used; i++) {
           if (fl_string_dynamic_partial_compare(data->buffer, depth_setting.value_name, items->array[i].object, value_range) == F_equal_to) {
             names[i] = 1;
           }
@@ -339,9 +340,9 @@ extern "C" {
           return F_none;
         }
         else if (depth_setting.index_name > 0) {
-          f_string_length_t total = 0;
+          f_array_length_t total = 0;
 
-          for (f_string_length_t i = 0; i < items->used; i++) {
+          for (i = 0; i < items->used; i++) {
             if (!names[i]) continue;
 
             total++;
@@ -366,17 +367,39 @@ extern "C" {
       if (depth_setting.index_at > 0) {
         if (depth_setting.value_at < items->used && names[depth_setting.value_at]) {
           print_object(f_type_output, data->buffer, items->array[depth_setting.value_at].object);
-          fprintf(f_type_output, "%c", f_string_eol[0]);
+
+          if (data->parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) {
+            if (items->array[depth_setting.value_at].content.used) {
+              fprintf(f_type_output, "%c", f_fss_eol);
+              f_print_dynamic_partial(f_type_output, data->buffer, items->array[depth_setting.value_at].content.array[0]);
+            }
+            else {
+              fprintf(f_type_output, "%c", f_fss_eol);
+            }
+          }
+
+          fprintf(f_type_output, "%c", f_fss_eol);
         }
 
         return F_none;
       }
 
-      for (f_array_length_t i = 0; i < items->used; i++) {
+      for (i = 0; i < items->used; i++) {
 
         if (names[i]) {
           print_object(f_type_output, data->buffer, items->array[i].object);
-          fprintf(f_type_output, "%c", f_string_eol[0]);
+
+          if (data->parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) {
+            if (items->array[i].content.used) {
+              fprintf(f_type_output, "%c", f_fss_eol);
+              f_print_dynamic_partial(f_type_output, data->buffer, items->array[i].content.array[0]);
+            }
+            else {
+              fprintf(f_type_output, "%c", f_fss_eol);
+            }
+          }
+
+          fprintf(f_type_output, "%c", f_fss_eol);
         }
       } // for
 
@@ -393,7 +416,6 @@ extern "C" {
       }
 
       f_array_length_t at = 0;
-      f_array_length_t i = 0;
 
       for (; i < items->used; i++) {
 
@@ -404,9 +426,9 @@ extern "C" {
                 fprintf(f_type_output, "0%c", f_string_eol[0]);
               }
               else {
-                f_string_length_t total = 1;
+                f_array_length_t total = 1;
 
-                for (f_string_length_t j = items->array[i].content.array[0].start; j <= items->array[i].content.array[0].stop; j++) {
+                for (j = items->array[i].content.array[0].start; j <= items->array[i].content.array[0].stop; j++) {
                   if (!data->buffer.string[j]) continue;
 
                   if (data->buffer.string[j] == f_string_eol[0]) {
@@ -427,7 +449,7 @@ extern "C" {
                 }
               }
               else {
-                f_string_length_t i = items->array[i].content.array[0].start;
+                i = items->array[i].content.array[0].start;
 
                 if (!line) {
                   for (; i <= items->array[i].content.array[0].stop; i++) {
@@ -442,7 +464,7 @@ extern "C" {
                   } // for
                 }
                 else {
-                  f_string_length_t line_current = 0;
+                  f_array_length_t line_current = 0;
 
                   for (; i <= items->array[i].content.array[0].stop; i++) {
                     if (!data->buffer.string[i]) continue;
@@ -492,9 +514,9 @@ extern "C" {
     }
 
     if (data->parameters[fss_extended_list_read_parameter_total].result == f_console_result_found) {
-      f_string_length_t total = 0;
+      f_array_length_t total = 0;
 
-      for (f_string_length_t i = 0; i < items->used; i++) {
+      for (i = 0; i < items->used; i++) {
         if (!names[i]) continue;
 
         if (!items->array[i].content.used) {
@@ -505,7 +527,7 @@ extern "C" {
           continue;
         }
 
-        for (f_string_length_t j = items->array[i].content.array[0].start; j <= items->array[i].content.array[0].stop; j++) {
+        for (j = items->array[i].content.array[0].start; j <= items->array[i].content.array[0].stop; j++) {
           if (!data->buffer.string[j]) continue;
 
           if (data->buffer.string[j] == f_string_eol[0]) {
@@ -519,9 +541,7 @@ extern "C" {
     }
 
     if (data->parameters[fss_extended_list_read_parameter_line].result == f_console_result_additional) {
-      f_string_length_t line_current = 0;
-      f_string_length_t i = 0;
-      f_string_length_t j = 0;
+      f_array_length_t line_current = 0;
 
       for (; i < items->used; i++) {
         if (!names[i]) continue;
@@ -575,7 +595,7 @@ extern "C" {
       return F_none;
     }
 
-    for (f_string_length_t i = 0; i < items->used; i++) {
+    for (i = 0; i < items->used; i++) {
       if (!names[i]) continue;
 
       if (!items->array[i].content.used) {
index 5d1c8cdb64d997525de201f8be9126d1302b71e0..f592c68a7d3c580feb7413a58064858f3e62a9da 100644 (file)
@@ -216,7 +216,7 @@ extern "C" {
  * @see fss_extended_list_read_main_process_file()
  */
 #ifndef _di_fss_extended_list_read_main_process_for_depth_
-  extern f_return_status fss_extended_list_read_main_process_for_depth(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depth_t depth_setting, const f_string_length_t line) f_gcc_attribute_visibility_internal;
+  extern f_return_status fss_extended_list_read_main_process_for_depth(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depth_t depth_setting, const f_array_length_t line) f_gcc_attribute_visibility_internal;
 #endif // _di_fss_extended_list_read_main_process_for_depth_
 
 #ifdef __cplusplus
index 8354d77a57734fb46a7f8b14cedad96da1327f5d..4fa0f4229d1534e7afe3fcf9d799dc58f0883ced 100644 (file)
@@ -23,11 +23,12 @@ extern "C" {
     printf("%c", f_string_eol[0]);
 
     fll_program_print_help_option(file, context, fss_extended_read_short_at, fss_extended_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, "      Select object at this numeric index.");
+    fll_program_print_help_option(file, context, fss_extended_read_short_content, fss_extended_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Print the content (default).");
     fll_program_print_help_option(file, context, fss_extended_read_short_depth, fss_extended_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Select object at this numeric depth.");
     fll_program_print_help_option(file, context, fss_extended_read_short_empty, fss_extended_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Include empty content when processing.");
     fll_program_print_help_option(file, context, fss_extended_read_short_line, fss_extended_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Print only the content at the given line.");
     fll_program_print_help_option(file, context, fss_extended_read_short_name, fss_extended_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Select object with this name.");
-    fll_program_print_help_option(file, context, fss_extended_read_short_object, fss_extended_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Print the object instead of the content.");
+    fll_program_print_help_option(file, context, fss_extended_read_short_object, fss_extended_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Print the object.");
     fll_program_print_help_option(file, context, fss_extended_read_short_select, fss_extended_read_long_select, f_console_symbol_short_enable, f_console_symbol_long_enable, "  Select sub-content at this index.");
     fll_program_print_help_option(file, context, fss_extended_read_short_total, fss_extended_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, "   Print the total number of lines.");
     fll_program_print_help_option(file, context, fss_extended_read_short_trim, fss_extended_read_long_trim, f_console_symbol_short_enable, f_console_symbol_long_enable, "    Trim object names on select or print.");
@@ -122,6 +123,16 @@ extern "C" {
 
     printf("%c", f_string_eol[0]);
 
+    printf("  When specifying both the ");
+    fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object);
+    printf(" parameter and the ");
+    fl_color_print(f_type_output, context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_content);
+    printf(" parameter, the entire object and content are printed, including the formatting.%c", f_string_eol[0]);
+    printf("  Both the object and content printed are already escaped.%c", f_string_eol[0]);
+    printf("  Both the object and content are separated by a space.%c", f_string_eol[0]);
+
+    printf("%c", f_string_eol[0]);
+
     return F_none;
   }
 #endif // _di_fss_extended_read_print_help_
@@ -260,6 +271,21 @@ extern "C" {
           fss_extended_read_delete_data(data);
           return F_status_set_error(F_parameter);
         }
+
+        if (data->parameters[fss_extended_read_parameter_content].result == f_console_result_found) {
+          if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
+            fl_color_print(data->error.to.stream, data->context.set.error, "%sCannot specify both the '", fll_error_print_error);
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_object);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' and the '");
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_content);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' parameter with the '");
+            fl_color_print(data->error.to.stream, data->context.set.notable, "%s%s", f_console_symbol_long_enable, fss_extended_read_long_total);
+            fl_color_print(data->error.to.stream, data->context.set.error, "' parameter.%c", f_string_eol[0]);
+
+            fss_extended_read_delete_data(data);
+            return F_status_set_error(F_parameter);
+          }
+        }
       }
 
       if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) {
index 53ce420984d7eaef36ef475ba20d3602da8b443e..e3e7b83de3911fb0e4b83a33f66e9a824b2d1413 100644 (file)
@@ -62,25 +62,27 @@ extern "C" {
 #endif // _di_fss_extended_read_name_
 
 #ifndef _di_fss_extended_read_defines_
-  #define fss_extended_read_short_at     "a"
-  #define fss_extended_read_short_depth  "d"
-  #define fss_extended_read_short_empty  "e"
-  #define fss_extended_read_short_line   "l"
-  #define fss_extended_read_short_name   "n"
-  #define fss_extended_read_short_object "o"
-  #define fss_extended_read_short_select "s"
-  #define fss_extended_read_short_total  "t"
-  #define fss_extended_read_short_trim   "T"
-
-  #define fss_extended_read_long_at     "at"
-  #define fss_extended_read_long_depth  "depth"
-  #define fss_extended_read_long_empty  "empty"
-  #define fss_extended_read_long_line   "line"
-  #define fss_extended_read_long_name   "name"
-  #define fss_extended_read_long_object "object"
-  #define fss_extended_read_long_select "select"
-  #define fss_extended_read_long_total  "total"
-  #define fss_extended_read_long_trim   "trim"
+  #define fss_extended_read_short_at      "a"
+  #define fss_extended_read_short_content "c"
+  #define fss_extended_read_short_depth   "d"
+  #define fss_extended_read_short_empty   "e"
+  #define fss_extended_read_short_line    "l"
+  #define fss_extended_read_short_name    "n"
+  #define fss_extended_read_short_object  "o"
+  #define fss_extended_read_short_select  "s"
+  #define fss_extended_read_short_total   "t"
+  #define fss_extended_read_short_trim    "T"
+
+  #define fss_extended_read_long_at      "at"
+  #define fss_extended_read_long_content "content"
+  #define fss_extended_read_long_depth   "depth"
+  #define fss_extended_read_long_empty   "empty"
+  #define fss_extended_read_long_line    "line"
+  #define fss_extended_read_long_name    "name"
+  #define fss_extended_read_long_object  "object"
+  #define fss_extended_read_long_select  "select"
+  #define fss_extended_read_long_total   "total"
+  #define fss_extended_read_long_trim    "trim"
 
   enum {
     fss_extended_read_parameter_help,
@@ -94,6 +96,7 @@ extern "C" {
     fss_extended_read_parameter_version,
 
     fss_extended_read_parameter_at,
+    fss_extended_read_parameter_content,
     fss_extended_read_parameter_depth,
     fss_extended_read_parameter_empty,
     fss_extended_read_parameter_line,
@@ -116,6 +119,7 @@ extern "C" {
       f_console_parameter_t_initialize(f_console_standard_short_debug, f_console_standard_long_debug, 0, 0, f_console_type_inverse), \
       f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \
       f_console_parameter_t_initialize(fss_extended_read_short_at, fss_extended_read_long_at, 0, 1, f_console_type_normal), \
+      f_console_parameter_t_initialize(fss_extended_read_short_content, fss_extended_read_long_content, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_extended_read_short_depth, fss_extended_read_long_depth, 0, 1, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_extended_read_short_empty, fss_extended_read_long_empty, 0, 0, f_console_type_normal), \
       f_console_parameter_t_initialize(fss_extended_read_short_line, fss_extended_read_long_line, 0, 1, f_console_type_normal), \
@@ -126,7 +130,7 @@ extern "C" {
       f_console_parameter_t_initialize(fss_extended_read_short_trim, fss_extended_read_long_trim, 0, 0, f_console_type_normal), \
     }
 
-  #define fss_extended_read_total_parameters 18
+  #define fss_extended_read_total_parameters 19
 #endif // _di_fss_extended_read_defines_
 
 #ifndef _di_fss_extended_read_data_t_
index 294ec9aafc9efb2ef63ea29cd3b41a04dd6bccc4..de8cda2603c3d476cd8c00af3177f3ae14a9ecbe 100644 (file)
@@ -231,10 +231,10 @@ extern "C" {
       }
     }
 
-    f_string_length_t select = 0;
+    f_number_unsigned_t select = 0;
 
     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_array_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_t_initialize(strlen(arguments.argv[index]));
 
       status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &select, range);
@@ -245,10 +245,10 @@ extern "C" {
       }
     }
 
-    f_string_length_t line = 0;
+    f_array_length_t line = 0;
 
     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_array_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_t_initialize(strlen(arguments.argv[index]));
 
       status = fl_conversion_string_to_number_unsigned(arguments.argv[index], &line, range);
@@ -261,13 +261,16 @@ extern "C" {
 
     bool names[data->objects.used];
 
+    f_array_length_t i = 0;
+    f_array_length_t j = 0;
+
     if (depths.array[0].index_name > 0) {
       memset(names, 0, sizeof(bool) * data->objects.used);
 
       f_string_length_t name_length = 0;
 
       if (data->parameters[fss_extended_read_parameter_trim].result == f_console_result_found) {
-        for (f_string_length_t i = 0; i < data->objects.used; i++) {
+        for (i = 0; i < data->objects.used; i++) {
 
           name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1;
 
@@ -279,7 +282,7 @@ extern "C" {
         } // for
       }
       else {
-        for (f_string_length_t i = 0; i < data->objects.used; i++) {
+        for (i = 0; i < data->objects.used; i++) {
 
           name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1;
 
@@ -312,9 +315,9 @@ extern "C" {
           }
         }
         else if (depths.array[0].index_name > 0) {
-          f_string_length_t total = 0;
+          f_array_length_t total = 0;
 
-          for (f_string_length_t i = 0; i < data->objects.used; i++) {
+          for (i = 0; i < data->objects.used; i++) {
             if (!names[i]) continue;
 
             total++;
@@ -337,14 +340,29 @@ extern "C" {
 
       if (depths.array[0].index_at > 0) {
         f_array_length_t at = 0;
-        f_array_length_t i = 0;
 
-        for (; i < data->objects.used; i++) {
+        for (j = 0; i < data->objects.used; i++) {
 
           if (names[i]) {
             if (at == depths.array[0].value_at) {
               print_object(f_type_output, data->buffer, data->objects.array[i]);
-              fprintf(f_type_output, "%c", f_string_eol[0]);
+
+              if (data->parameters[fss_extended_read_parameter_content].result == f_console_result_found) {
+                if (data->contents.array[i].used) {
+                  fprintf(f_type_output, "%c", f_fss_space);
+
+                  for (j = 0; j < data->contents.array[i].used; j++) {
+
+                    f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[j]);
+
+                    if (j + 1 < data->contents.array[i].used) {
+                      fprintf(f_type_output, "%c", f_fss_space);
+                    }
+                  } // for
+                }
+              }
+
+              fprintf(f_type_output, "%c", f_fss_eol);
               break;
             }
 
@@ -355,11 +373,27 @@ extern "C" {
         return F_none;
       }
 
-      for (f_string_length_t i = 0; i < data->objects.used; i++) {
+      for (i = 0; i < data->objects.used; i++) {
         if (!names[i]) continue;
 
         print_object(f_type_output, data->buffer, data->objects.array[i]);
-        fprintf(f_type_output, "%c", f_string_eol[0]);
+
+        if (data->parameters[fss_extended_read_parameter_content].result == f_console_result_found) {
+          if (data->contents.array[i].used) {
+            fprintf(f_type_output, "%c", f_fss_space);
+
+            for (j = 0; j < data->contents.array[i].used; j++) {
+
+              f_print_dynamic_partial(f_type_output, data->buffer, data->contents.array[i].array[j]);
+
+              if (j + 1 < data->contents.array[i].used) {
+                fprintf(f_type_output, "%c", f_fss_space);
+              }
+            } // for
+          }
+        }
+
+        fprintf(f_type_output, "%c", f_fss_eol);
       } // for
 
       return F_none;
@@ -375,7 +409,6 @@ extern "C" {
       }
 
       f_array_length_t at = 0;
-      f_array_length_t i = 0;
 
       for (; i < data->objects.used; i++) {
 
@@ -395,7 +428,7 @@ extern "C" {
             if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) {
               if (!line) {
                 if (data->contents.array[i].used > 0) {
-                  f_string_length_t j = 0;
+                  j = 0;
 
                   if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) {
                     if (select < data->contents.array[i].used) {
@@ -431,7 +464,7 @@ extern "C" {
             }
 
             if (data->contents.array[i].used > 0) {
-              f_string_length_t j = 0;
+              j = 0;
 
               if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) {
                 if (select < data->contents.array[i].used) {
@@ -473,9 +506,9 @@ extern "C" {
     }
 
     if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) {
-      f_string_length_t total = 0;
+      f_array_length_t total = 0;
 
-      for (f_string_length_t i = 0; i < data->objects.used; i++) {
+      for (i = 0; i < data->objects.used; i++) {
         if (!names[i]) {
           continue;
         }
@@ -492,11 +525,9 @@ extern "C" {
     }
 
     if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) {
-      f_string_length_t line_current = 0;
-      f_string_length_t i = 0;
-      f_string_length_t j = 0;
+      f_array_length_t line_current = 0;
 
-      for (; i < data->contents.used; i++) {
+      for (i = 0, j = 0; i < data->contents.used; i++) {
         if (!names[i]) continue;
 
         if (!data->contents.array[i].used) {
@@ -540,10 +571,7 @@ extern "C" {
       return F_none;
     }
 
-    f_string_length_t i = 0;
-    f_string_length_t j = 0;
-
-    for (; i < data->contents.used; i++) {
+    for (i = 0, j = 0; i < data->contents.used; i++) {
       if (!names[i]) continue;
 
       if (!data->contents.array[i].used) {