summaryrefslogtreecommitdiff
path: root/support/dktools/dk-ls.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-09-20 03:03:26 +0000
committerNorbert Preining <norbert@preining.info>2020-09-20 03:03:26 +0000
commit1f457376b478257b88d4a857f5ec1b6155442dd7 (patch)
tree2a06a60551dea362cf8cb0cb0ba66c78608717c4 /support/dktools/dk-ls.c
parentac690ca29ad5bf8a5203a65fd6252f7b564f4727 (diff)
CTAN sync 202009200303
Diffstat (limited to 'support/dktools/dk-ls.c')
-rw-r--r--support/dktools/dk-ls.c364
1 files changed, 181 insertions, 183 deletions
diff --git a/support/dktools/dk-ls.c b/support/dktools/dk-ls.c
index 6ec01d987c..b37d0ff356 100644
--- a/support/dktools/dk-ls.c
+++ b/support/dktools/dk-ls.c
@@ -1,43 +1,21 @@
/*
- WARNING: This file was generated by dkct.
- Changes you make here will be lost if dkct is run again!
- You should modify the original source and run dkct on it.
- Original source: dk-ls.ctr
+Copyright (C) 2015-2020, Dirk Krause
+SPDX-License-Identifier: BSD-3-Clause
*/
/*
-Copyright (C) 2015-2017, Dirk Krause
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above opyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-* Neither the name of the author nor the names of contributors may be used
- to endorse or promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ WARNING: This file was generated by the dkct program (see
+ http://dktools.sourceforge.net/ for details).
+ Changes you make here will be lost if dkct is run again!
+ You should modify the original source and run dkct on it.
+ Original source: dk-ls.ctr
*/
/** @file dk-ls.c The dk-ls module.
*/
-#line 87 "dk-ls.ctr"
+#line 97 "dk-ls.ctr"
#include "dk4conf.h"
@@ -115,12 +93,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "dk4pathd.h"
#include "dk4fopda.h"
#include "dk4symlink.h"
+#include "dk4unused.h"
+#ifndef DK4WMAIN_H_INCLUDED
+#include "dk4wmain.h"
+#endif
-#line 168 "dk-ls.ctr"
+#line 182 "dk-ls.ctr"
@@ -149,12 +131,12 @@ dkT(""),
dkT("Message digest types: md5, sha-1, sha-224, sha-256, sha-384, sha-512,"),
dkT("ripemd-160. Optionally add encoding hex or a85, i.e. ``sha-1.hex''."),
dkT(""),
-dkT("http://dktools.sourceforge.net"),
+dkT("http://sourceforge.net/p/dktools/wiki/dk-ls/"),
dkT(""),
NULL
-#line 200 "dk-ls.ctr"
+#line 214 "dk-ls.ctr"
};
@@ -166,7 +148,8 @@ dkT("This software uses code from the following projects, either directly or as"
dkT("a library:"),
dkT(""),
dkT("dktools\t\tDirk Krause's tools and libraries."),
-dkT("\t\tSee http://dktools.sourceforge.net/ for more information."),
+dkT("\t\tSee http://sourceforge.net/p/dktools/wiki/Home/"),
+dkT("\t\tfor more information."),
#if DK4_HAVE_ZLIB_H
dkT(""),
dkT("zlib\t\tData compression library."),
@@ -204,27 +187,27 @@ dkT(""),
dkT("Redistribution and use in source and binary forms, with or without"),
dkT("modification, are permitted provided that the following conditions are met:"),
dkT(""),
-dkT("* Redistributions of source code must retain the above copyright notice,"),
-dkT(" this list of conditions and the following disclaimer."),
-dkT("* Redistributions in binary form must reproduce the above copyright"),
-dkT(" notice, this list of conditions and the following disclaimer in the"),
-dkT(" documentation and/or other materials provided with the distribution."),
-dkT("* Neither the name of the Dirk Krause nor the names of contributors may be"),
-dkT(" used to endorse or promote products derived from this software without"),
-dkT(" specific prior written permission."),
-dkT(""),
-dkT("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\""),
-dkT("AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE"),
-dkT("IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE"),
-dkT("ARE DISCLAIMED."),
+dkT("1. Redistributions of source code must retain the above copyright notice,"),
+dkT(" this list of conditions and the following disclaimer."),
+dkT("2. Redistributions in binary form must reproduce the above copyright"),
+dkT(" notice, this list of conditions and the following disclaimer in the"),
+dkT(" documentation and/or other materials provided with the distribution."),
+dkT("3. Neither the name of the copyright holder nor the names of its"),
+dkT(" contributors may be used to endorse or promote products derived from"),
+dkT(" this software without specific prior written permission."),
dkT(""),
-dkT("IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,"),
-dkT("INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,"),
-dkT("BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,"),
-dkT("DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY"),
-dkT("OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING"),
-dkT("NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,"),
-dkT("EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."),
+dkT("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"),
+dkT("``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT"),
+dkT("LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR"),
+dkT("A PARTICULAR PURPOSE ARE DISCLAIMED."),
+dkT("IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY"),
+dkT("DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES"),
+dkT("(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR"),
+dkT("SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER"),
+dkT("CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT"),
+dkT("LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY"),
+dkT("OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF"),
+dkT("SUCH DAMAGE."),
#if DK4_HAVE_ZLIB_H
dkT(""),
dkT(""),
@@ -427,7 +410,7 @@ dkT(""),
NULL
-#line 471 "dk-ls.ctr"
+#line 486 "dk-ls.ctr"
};
@@ -474,7 +457,7 @@ dkT("ERROR: Application startup failed!\n"),
NULL
-#line 529 "dk-ls.ctr"
+#line 544 "dk-ls.ctr"
};
@@ -585,7 +568,7 @@ dkT("# Total number of bytes: "),
NULL
-#line 632 "dk-ls.ctr"
+#line 647 "dk-ls.ctr"
};
@@ -844,8 +827,9 @@ sig_pass_pointer(DK4_VOLATILE dk4_sig_atomic_t *ptr)
*/
static
void
-sig_handler_pipe(int signo)
+sig_handler_pipe(int DK4_ARG_UNUSED(signo) )
{
+ DK4_UNUSED_ARG(signo)
*sig_pass_pointer(&sig_had_pipe) = 1;
}
#endif
@@ -855,8 +839,9 @@ sig_handler_pipe(int signo)
*/
static
void
-sig_handler_int(int signo)
+sig_handler_int(int DK4_ARG_UNUSED(signo) )
{
+ DK4_UNUSED_ARG(signo)
*sig_pass_pointer(&sig_had_int) = 1;
}
@@ -865,8 +850,9 @@ sig_handler_int(int signo)
*/
static
void
-sig_handler_term(int signo)
+sig_handler_term(int DK4_ARG_UNUSED(signo) )
{
+ DK4_UNUSED_ARG(signo)
*sig_pass_pointer(&sig_had_term) = 1;
}
@@ -890,10 +876,18 @@ sig_read_atomic(DK4_VOLATILE dk4_sig_atomic_t *ap)
*/
static
int
-sig_can_continue(int check_pipe)
+sig_can_continue(
+#ifdef SIGPIPE
+int check_pipe
+#else
+int DK4_ARG_UNUSED(check_pipe)
+#endif
+)
{
int back = 1;
-#ifdef SIGPIPE
+#ifndef SIGPIPE
+ DK4_UNUSED_ARG(check_pipe)
+#else
if (0 != check_pipe) {
if (0 != sig_read_atomic(&sig_had_pipe)) { back = 0; }
}
@@ -944,7 +938,7 @@ dk_ls_delete_node(dk_ls_node_t *cn)
{
-#line 989 "dk-ls.ctr"
+#line 1015 "dk-ls.ctr"
if (NULL != cn) {
cn->parent = NULL;
cn->child = NULL;
@@ -955,7 +949,7 @@ dk_ls_delete_node(dk_ls_node_t *cn)
dk4mem_free(cn);
}
-#line 998 "dk-ls.ctr"
+#line 1024 "dk-ls.ctr"
}
@@ -976,7 +970,7 @@ dk_ls_new_node(const dkChar *dn, dk_ls_node_t *pa, int level)
int ch = DK4_FILE_INFO_CONTENTS_DATA_TARGET;
-#line 1017 "dk-ls.ctr"
+#line 1043 "dk-ls.ctr"
back = dk4mem_new_app(dk_ls_node_t,1,app);
if (NULL != back) {
DK4_MEMRES(back, sizeof(dk_ls_node_t));
@@ -992,45 +986,45 @@ dk_ls_new_node(const dkChar *dn, dk_ls_node_t *pa, int level)
back->dirptr = dk4dir_open_app(dn, om, app);
if (NULL == back->dirptr) {
-#line 1031 "dk-ls.ctr"
+#line 1057 "dk-ls.ctr"
exval = EXIT_FAILURE;
dk_ls_delete_node(back);
back = NULL;
}
if (NULL != back) {
-#line 1036 "dk-ls.ctr"
+#line 1062 "dk-ls.ctr"
dk4fileinfo_init(&(back->fi));
if (0 != dk4fileinfo_app(&(back->fi), dn, app)) {
if (0 == dk4fileinfo_size(&(back->size), &(back->fi), ch, NULL)) {
back->size = (dk4_um_t)0UL;
-#line 1040 "dk-ls.ctr"
+#line 1066 "dk-ls.ctr"
/* ERROR: Failed to retrieve directory size */
dk_ls_report_fileinfo_size_error(app,dn,ch,dk_ls_msg,dk_ls_sz_msg);
exval = EXIT_FAILURE;
}
} else {
-#line 1045 "dk-ls.ctr"
+#line 1071 "dk-ls.ctr"
/* ERROR: Failed to retrieve file information, already reported */
exval = EXIT_FAILURE;
}
} else {
-#line 1049 "dk-ls.ctr"
+#line 1075 "dk-ls.ctr"
/* ERROR: Failed to open directory, already reported */
exval = EXIT_FAILURE;
}
} else {
-#line 1053 "dk-ls.ctr"
+#line 1079 "dk-ls.ctr"
/* ERROR: Allocation failed, already reported */
exval = EXIT_FAILURE;
}
-#line 1057 "dk-ls.ctr"
+#line 1083 "dk-ls.ctr"
return back;
}
@@ -1058,7 +1052,7 @@ dk_ls_dir_and_file(
int nsep = 1; /* Flag: Separator needed */
-#line 1083 "dk-ls.ctr"
+#line 1109 "dk-ls.ctr"
if (NULL != dirname) {
if (0 != dk4str_cpy_s(bufptr, szbuf, dirname, NULL)) {
while(dkT('\0') != *dirname) {
@@ -1092,19 +1086,19 @@ dk_ls_dir_and_file(
back = 1;
} else {
-#line 1115 "dk-ls.ctr"
+#line 1141 "dk-ls.ctr"
/* BUG: Buffer too small */
exval = EXIT_FAILURE;
}
} else {
-#line 1119 "dk-ls.ctr"
+#line 1145 "dk-ls.ctr"
/* BUG: Buffer too small */
exval = EXIT_FAILURE;
}
} else {
-#line 1123 "dk-ls.ctr"
+#line 1149 "dk-ls.ctr"
/* BUG: Buffer too small */
exval = EXIT_FAILURE;
}
@@ -1112,13 +1106,13 @@ dk_ls_dir_and_file(
back = dk4str_cpy_s(bufptr, szbuf, filename, NULL);
if (0 == back) {
-#line 1129 "dk-ls.ctr"
+#line 1155 "dk-ls.ctr"
/* BUG: Buffer too small */
exval = EXIT_FAILURE;
}
}
-#line 1133 "dk-ls.ctr"
+#line 1159 "dk-ls.ctr"
return back;
}
@@ -1147,7 +1141,7 @@ dk_ls_construct_path(
int back = 0;
-#line 1160 "dk-ls.ctr"
+#line 1186 "dk-ls.ctr"
dk4error_init(&er);
lgt = dk4str_len(filename);
if (NULL != dirname) {
@@ -1161,7 +1155,7 @@ dk_ls_construct_path(
*/
-#line 1172 "dk-ls.ctr"
+#line 1198 "dk-ls.ctr"
back = dk_ls_dir_and_file(*bufptr, *szbufptr, dirname, filename);
} else {
if (dk_ls_max_path > lgt) {
@@ -1170,18 +1164,18 @@ dk_ls_construct_path(
*/
-#line 1179 "dk-ls.ctr"
+#line 1205 "dk-ls.ctr"
nb = dk4mem_new_app(dkChar, lgt, app);
if (NULL != nb) {
-#line 1181 "dk-ls.ctr"
+#line 1207 "dk-ls.ctr"
dk4mem_release(*bufptr);
*bufptr = nb;
*szbufptr = lgt;
back = dk_ls_dir_and_file(*bufptr, *szbufptr, dirname, filename);
} else {
-#line 1186 "dk-ls.ctr"
+#line 1212 "dk-ls.ctr"
/* ERROR: Memory allocation failed, already reported */
exval = EXIT_FAILURE;
}
@@ -1198,7 +1192,7 @@ dk_ls_construct_path(
}
-#line 1201 "dk-ls.ctr"
+#line 1227 "dk-ls.ctr"
return back;
}
@@ -1228,7 +1222,7 @@ dk_ls_write_decimal_number(dk4_um_t value, size_t width)
}
} else {
-#line 1229 "dk-ls.ctr"
+#line 1255 "dk-ls.ctr"
/* ERROR: Failed to write decimal number to buffer (bug) */
exval = EXIT_FAILURE;
}
@@ -1246,36 +1240,36 @@ dk_ls_write_hexadecimal_number(dk4_um_t value, size_t width)
int res;
-#line 1245 "dk-ls.ctr"
+#line 1271 "dk-ls.ctr"
dk4error_init(&er);
res = dk4ma_write_hex_unsigned(
buf, DK4_SIZEOF(buf,dkChar), value, width, &er
);
if (0 != res) {
-#line 1250 "dk-ls.ctr"
+#line 1276 "dk-ls.ctr"
sl = dk4str_len(buf);
while (sl++ < width) {
-#line 1252 "dk-ls.ctr"
+#line 1278 "dk-ls.ctr"
if (0 == dk4fputc(dkT('0'), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
}
}
if (0 == dk4fputs(buf, stdout, NULL)) {
-#line 1257 "dk-ls.ctr"
+#line 1283 "dk-ls.ctr"
write_error = 1; exval = EXIT_FAILURE;
}
} else {
-#line 1260 "dk-ls.ctr"
+#line 1286 "dk-ls.ctr"
/* BUG: Failed to write hexadecimal number to buffer */
exval = EXIT_FAILURE;
}
-#line 1264 "dk-ls.ctr"
+#line 1290 "dk-ls.ctr"
}
@@ -1320,14 +1314,14 @@ dk_ls_write_timestamp(
/** Write indicator for unkown data.
- @param width Field width.
- @param compl Fill complete field.
+ @param width Field width.
+ @param complete Fill complete field.
*/
static
void
-dk_ls_write_unknown(size_t width, int compl)
+dk_ls_write_unknown(size_t width, int complete)
{
- if (0 != compl) {
+ if (0 != complete) {
while (0 < width--) {
if (0 == dk4fputc(dkT('?'), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1349,7 +1343,7 @@ dk_ls_write_unknown(size_t width, int compl)
static
int
-dk_ls_can_create_md(const dkChar *fn, dk4_file_info_t *fiptr)
+dk_ls_can_create_md(dk4_file_info_t *fiptr)
{
int back = 0;
if (0 == dk4fileinfo_is_symlink(fiptr)) {
@@ -1402,30 +1396,30 @@ dk_ls_write_md(
const char *resptr; /* Pointer to encoded digest buffer */
size_t rdbytes; /* Number of bytes read */
int mdok = 0; /* Flag: Digesting ok so far */
- if (0 != dk_ls_can_create_md(fn, fiptr)) {
+ if (0 != dk_ls_can_create_md(fiptr)) {
-#line 1391 "dk-ls.ctr"
+#line 1417 "dk-ls.ctr"
dk4error_init(&er);
if (0 != dk4md_ctx_init(&ctx, digest_type, digest_enco, &er)) {
-#line 1394 "dk-ls.ctr"
+#line 1420 "dk-ls.ctr"
fipo = dk4fopen_app(fn, dkT("rb"), DK4_FOPEN_SC_IS_REGULAR, app);
if (NULL != fipo) {
-#line 1396 "dk-ls.ctr"
+#line 1422 "dk-ls.ctr"
mdok = 1;
do {
if (0 != dk_ls_can_continue()) {
rdbytes = fread(buf, 1, sizeof(buf), fipo);
if (0 < rdbytes) {
-#line 1401 "dk-ls.ctr"
+#line 1427 "dk-ls.ctr"
dk4error_init(&er);
if (1 != dk4md_ctx_add(&ctx, buf, rdbytes, &er)) {
mdok = 0;
-#line 1404 "dk-ls.ctr"
+#line 1430 "dk-ls.ctr"
/* ERROR: Digest failed */
switch (er.ec) {
case DK4_E_NOT_SUPPORTED : {
@@ -1445,49 +1439,49 @@ dk_ls_write_md(
fclose(fipo);
if (1 == mdok) {
-#line 1422 "dk-ls.ctr"
+#line 1448 "dk-ls.ctr"
resptr = NULL; rdbytes = 0;
dk4error_init(&er);
if (1 == dk4md_ctx_finish(&resptr, &rdbytes, &ctx, &er)) {
-#line 1426 "dk-ls.ctr"
+#line 1452 "dk-ls.ctr"
if ((NULL != resptr) && (0 < rdbytes)) {
-#line 1427 "dk-ls.ctr"
+#line 1453 "dk-ls.ctr"
while(rdbytes--) {
if (0 == dk4fputc((dkChar)(*(resptr++)), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
-#line 1430 "dk-ls.ctr"
+#line 1456 "dk-ls.ctr"
}
}
} else {
-#line 1433 "dk-ls.ctr"
+#line 1459 "dk-ls.ctr"
mdok = 0;
/* ERROR: No digest obtained */
dk4app_log_1(app, dk_ls_msg, dk_ls_sz_msg, DK4_LL_ERROR, 29);
}
} else {
-#line 1438 "dk-ls.ctr"
+#line 1464 "dk-ls.ctr"
mdok = 0;
/* ERROR: Failed to obtain digest */
dk4app_log_1(app, dk_ls_msg, dk_ls_sz_msg, DK4_LL_ERROR, 29);
}
} else {
-#line 1443 "dk-ls.ctr"
+#line 1469 "dk-ls.ctr"
}
} else {
-#line 1445 "dk-ls.ctr"
+#line 1471 "dk-ls.ctr"
/* ERROR: Failed to open file, already reported */
}
} else {
-#line 1448 "dk-ls.ctr"
+#line 1474 "dk-ls.ctr"
/* ERROR: Failed to initialize digest ctx */
switch (er.ec) {
case DK4_E_NOT_SUPPORTED : {
@@ -1503,7 +1497,7 @@ dk_ls_write_md(
}
} else {
-#line 1462 "dk-ls.ctr"
+#line 1488 "dk-ls.ctr"
}
if (0 == mdok) {
rdbytes = dk4md_size(digest_type, digest_enco, NULL);
@@ -1537,7 +1531,7 @@ dk_ls_process_item_information(
dkChar buf[8*sizeof(dk4_um_t) + 16]; /* Numbers */
dk4_er_t er; /* Error report */
const dkChar *piptr; /* Print order */
- dk4_um_t fs; /* File size */
+ dk4_um_t fs = (dk4_um_t)0UL; /* File size */
size_t numl; /* Number length */
size_t slen; /* String length */
size_t tlen; /* First part length */
@@ -1550,11 +1544,11 @@ dk_ls_process_item_information(
dkChar lasti; /* Last information printed */
-#line 1507 "dk-ls.ctr"
+#line 1533 "dk-ls.ctr"
last_was_n = habuf = 0;
if ((NULL != fn) && (NULL != fiptr)) {
-#line 1509 "dk-ls.ctr"
+#line 1535 "dk-ls.ctr"
showi = 1;
res = dk4fileinfo_type_attributes(
buf, DK4_SIZEOF(buf,dkChar), fiptr, &er
@@ -1578,28 +1572,31 @@ dk_ls_process_item_information(
}
} else {
-#line 1531 "dk-ls.ctr"
+#line 1557 "dk-ls.ctr"
/* BUG: Failed to write file attributes to buffer */
dk4app_log_1(app, dk_ls_msg, dk_ls_sz_msg, DK4_LL_ERROR, 10);
exval = EXIT_FAILURE;
}
if (0 != showi) {
-#line 1536 "dk-ls.ctr"
+#line 1562 "dk-ls.ctr"
issl = dk4fileinfo_is_symlink(fiptr);
lasti = dkT('\0');
piptr = print_order;
while (dkT('\0') != *piptr) {
-#line 1540 "dk-ls.ctr"
+#line 1566 "dk-ls.ctr"
last_was_n = 0;
+
+#if DK4_CHAR_SIZE > 1
if ((int)(*piptr) <= 255) {
-#line 1542 "dk-ls.ctr"
+#line 1570 "dk-ls.ctr"
+#endif
switch ((char)(*piptr)) {
case 'n' : {
-#line 1544 "dk-ls.ctr"
+#line 1573 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1612,7 +1609,7 @@ dk_ls_process_item_information(
} break;
case 'N' : {
-#line 1555 "dk-ls.ctr"
+#line 1584 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1624,7 +1621,7 @@ dk_ls_process_item_information(
} break;
case 's' : {
-#line 1565 "dk-ls.ctr"
+#line 1594 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1671,7 +1668,7 @@ dk_ls_process_item_information(
/* ERROR: Failed to obtain size */
-#line 1610 "dk-ls.ctr"
+#line 1639 "dk-ls.ctr"
dk_ls_report_fileinfo_size_error(
app, fn,
(
@@ -1693,7 +1690,7 @@ dk_ls_process_item_information(
} break;
case 't' : {
-#line 1630 "dk-ls.ctr"
+#line 1659 "dk-ls.ctr"
dk4error_init(&er);
if (0 == habuf) {
habuf = dk4fileinfo_type_attributes(
@@ -1739,7 +1736,7 @@ dk_ls_process_item_information(
} break;
case 'l' : {
-#line 1674 "dk-ls.ctr"
+#line 1703 "dk-ls.ctr"
fs = (dk4_um_t)1UL;
if (0 != issl) {
if (0 != (DK4_FILE_INFO_CONTENTS_DATA_LINK & fiptr->contents))
@@ -1787,7 +1784,7 @@ dk_ls_process_item_information(
} break;
case 'c' : {
-#line 1720 "dk-ls.ctr"
+#line 1749 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1797,7 +1794,7 @@ dk_ls_process_item_information(
} break;
case 'm' : {
-#line 1728 "dk-ls.ctr"
+#line 1757 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1807,7 +1804,7 @@ dk_ls_process_item_information(
} break;
case 'a' : {
-#line 1736 "dk-ls.ctr"
+#line 1765 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1818,7 +1815,7 @@ dk_ls_process_item_information(
#if !DK4_ON_WINDOWS
case 'u' : {
-#line 1745 "dk-ls.ctr"
+#line 1774 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1854,7 +1851,7 @@ dk_ls_process_item_information(
#if !DK4_ON_WINDOWS
case 'g' : {
-#line 1779 "dk-ls.ctr"
+#line 1808 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1889,7 +1886,7 @@ dk_ls_process_item_information(
#endif
case 'd' : {
-#line 1812 "dk-ls.ctr"
+#line 1841 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -1955,7 +1952,7 @@ dk_ls_process_item_information(
} break;
case 'r' : {
-#line 1876 "dk-ls.ctr"
+#line 1905 "dk-ls.ctr"
#if DK4_ON_WINDOWS
if (0 != issl) {
if (0 != (DK4_FILE_INFO_CONTENTS_DATA_LINK & fiptr->contents))
@@ -2016,7 +2013,7 @@ dk_ls_process_item_information(
} break;
case 'i' : {
-#line 1935 "dk-ls.ctr"
+#line 1964 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (dkT('d') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
@@ -2095,7 +2092,7 @@ dk_ls_process_item_information(
#if DK4_ON_WINDOWS
case 'w' : {
-#line 2012 "dk-ls.ctr"
+#line 2041 "dk-ls.ctr"
if (dkT('\0') != lasti) {
if (0 == dk4fputc(dkT(' '), stdout, NULL)) {
write_error = 1; exval = EXIT_FAILURE;
@@ -2134,7 +2131,8 @@ dk_ls_process_item_information(
exval = EXIT_FAILURE;
} break;
}
- } else {
+#if DK4_CHAR_SIZE > 1
+ } else {
/* ERROR (once): Invalid text in -p argument */
if (0 == print_order_error_reported) {
dk4app_log_1(app, dk_ls_msg, dk_ls_sz_msg, DK4_LL_ERROR, 11);
@@ -2142,6 +2140,7 @@ dk_ls_process_item_information(
}
exval = EXIT_FAILURE;
}
+#endif
lasti = *(piptr++);
}
if (0 != last_was_n) {
@@ -2168,27 +2167,26 @@ dk_ls_process_item_information(
}
} else {
-#line 2083 "dk-ls.ctr"
+#line 2114 "dk-ls.ctr"
}
} else {
-#line 2085 "dk-ls.ctr"
+#line 2116 "dk-ls.ctr"
}
-#line 2087 "dk-ls.ctr"
+#line 2118 "dk-ls.ctr"
}
/** Process non-directory file.
@param fn File name.
- @param level Processing level (0=cmd line arg, 1=direct child,
2 and above=further indicrect siblings).
*/
static
void
-dk_ls_process_non_directory(const dkChar *fn, int level)
+dk_ls_process_non_directory(const dkChar *fn)
{
dk4_file_info_t fili;
@@ -2220,7 +2218,7 @@ dk_ls_process_item_for_node(
int ch = DK4_FILE_INFO_CONTENTS_DATA_TARGET;
-#line 2129 "dk-ls.ctr"
+#line 2159 "dk-ls.ctr"
if ((0 >= dirnode->level) || (0 != recursive) || (0 != size_wanted))
{
dk4error_init(&er);
@@ -2238,7 +2236,7 @@ dk_ls_process_item_for_node(
/* ERROR: Failed to retrieve size */
-#line 2145 "dk-ls.ctr"
+#line 2175 "dk-ls.ctr"
dk_ls_report_fileinfo_size_error(
app, filename, ch, dk_ls_msg, dk_ls_sz_msg
);
@@ -2258,7 +2256,7 @@ dk_ls_process_item_for_node(
}
-#line 2163 "dk-ls.ctr"
+#line 2193 "dk-ls.ctr"
}
@@ -2290,7 +2288,7 @@ dk_ls_process_directory(const dkChar *dn, int level)
int ufich; /* Channel to retrieve UFI */
-#line 2193 "dk-ls.ctr"
+#line 2223 "dk-ls.ctr"
/*
Allocate path name construction buffer.
*/
@@ -2308,10 +2306,10 @@ dk_ls_process_directory(const dkChar *dn, int level)
#endif
while (NULL != cn) {
-#line 2209 "dk-ls.ctr"
+#line 2239 "dk-ls.ctr"
if (0 != dk_ls_can_continue()) {
-#line 2210 "dk-ls.ctr"
+#line 2240 "dk-ls.ctr"
ndn = dk4dir_next_dir(cn->dirptr);
if (NULL != ndn) {
/*
@@ -2439,7 +2437,7 @@ dk_ls_process_directory(const dkChar *dn, int level)
ndn = dk4dir_next_file(cn->dirptr);
if (NULL != ndn) {
-#line 2336 "dk-ls.ctr"
+#line 2366 "dk-ls.ctr"
pa = dk4dir_get_path(cn->dirptr);
if (0 != dk_ls_construct_path(&mybu, &szmb, pa, ndn)) {
dk_ls_process_item_for_node(cn, mybu);
@@ -2453,7 +2451,7 @@ dk_ls_process_directory(const dkChar *dn, int level)
}
if (0 != dk_ls_can_continue()) {
-#line 2348 "dk-ls.ctr"
+#line 2378 "dk-ls.ctr"
if ((0 != size_wanted) || (0 != show_dirs)) {
if ((1 >= cn->level) || (0 != recursive)) {
dk_ls_process_item_information(
@@ -2467,7 +2465,7 @@ dk_ls_process_directory(const dkChar *dn, int level)
if (NULL != on) {
on->child = NULL;
dk4error_init(&er);
- on->size = dk4ma_size_t_add(on->size, cn->size, &er);
+ on->size = dk4ma_um_add(on->size, cn->size, &er);
if (DK4_E_NONE != er.ec) {
on->ovsize = 1;
}
@@ -2484,7 +2482,7 @@ dk_ls_process_directory(const dkChar *dn, int level)
*/
-#line 2377 "dk-ls.ctr"
+#line 2407 "dk-ls.ctr"
on = cn->parent;
if (NULL != on) { on->child = NULL; }
dk_ls_delete_node(cn);
@@ -2493,7 +2491,7 @@ dk_ls_process_directory(const dkChar *dn, int level)
}
} else {
-#line 2384 "dk-ls.ctr"
+#line 2414 "dk-ls.ctr"
/* ERROR: Allocation failed, already reported */
exval = EXIT_FAILURE;
}
@@ -2505,7 +2503,7 @@ dk_ls_process_directory(const dkChar *dn, int level)
}
-#line 2394 "dk-ls.ctr"
+#line 2424 "dk-ls.ctr"
}
@@ -2535,7 +2533,7 @@ dk_ls_is_directory(const dkChar *fn)
int back = -1;
-#line 2422 "dk-ls.ctr"
+#line 2452 "dk-ls.ctr"
if (NULL != fn) {
#if DK4_ON_WINDOWS
#if DK4_CHAR_SIZE > 1
@@ -2585,7 +2583,7 @@ dk_ls_is_directory(const dkChar *fn)
#endif
}
-#line 2470 "dk-ls.ctr"
+#line 2500 "dk-ls.ctr"
return back;
}
@@ -2605,30 +2603,30 @@ run_for_one_name(const dkChar *arg)
{
-#line 2488 "dk-ls.ctr"
+#line 2518 "dk-ls.ctr"
switch (dk_ls_is_directory(arg)) {
case 1 : {
-#line 2490 "dk-ls.ctr"
+#line 2520 "dk-ls.ctr"
dk_ls_process_directory(arg, 0);
} break;
case 0 : {
-#line 2493 "dk-ls.ctr"
+#line 2523 "dk-ls.ctr"
if (0 != show_files) {
- dk_ls_process_non_directory(arg, 0);
+ dk_ls_process_non_directory(arg);
}
} break;
default : {
-#line 2498 "dk-ls.ctr"
+#line 2528 "dk-ls.ctr"
/* ERROR: Failed to obtain information about file, already reported */
exval = EXIT_FAILURE;
} break;
}
-#line 2503 "dk-ls.ctr"
+#line 2533 "dk-ls.ctr"
}
@@ -2652,16 +2650,16 @@ run_for_command_line_arguments(int xargc)
int cc = 1;
-#line 2525 "dk-ls.ctr"
+#line 2555 "dk-ls.ctr"
for (i = 0; ((i < xargc) && (1 == cc)); i++) {
-#line 2526 "dk-ls.ctr"
+#line 2556 "dk-ls.ctr"
if (0 != dk_ls_can_continue()) {
-#line 2527 "dk-ls.ctr"
+#line 2557 "dk-ls.ctr"
xargv = dk4app_get_argv(app, i);
-#line 2528 "dk-ls.ctr"
+#line 2558 "dk-ls.ctr"
#if DK4_ON_WINDOWS
if (0 != dk4path_must_expand(xargv)) {
/* !!!!!
@@ -2721,7 +2719,7 @@ run_for_command_line_arguments(int xargc)
if (0!=dk4str_cat_s(buf,DK4_SIZEOF(buf,dkChar),dk_ls_kwnl[5],NULL))
{
if (0 != dk4str_cat_s(buf,DK4_SIZEOF(buf,dkChar),fn,NULL)) {
- dk_ls_process_non_directory(buf, 0);
+ dk_ls_process_non_directory(buf);
} else {
/* ERROR: File name too long! */
dk4app_log_5(
@@ -2759,7 +2757,7 @@ run_for_command_line_arguments(int xargc)
#endif
-#line 2624 "dk-ls.ctr"
+#line 2654 "dk-ls.ctr"
run_for_one_name(xargv);
#if DK4_ON_WINDOWS
}
@@ -2770,7 +2768,7 @@ run_for_command_line_arguments(int xargc)
}
-#line 2633 "dk-ls.ctr"
+#line 2663 "dk-ls.ctr"
}
@@ -2793,7 +2791,7 @@ run_for_current_dir_contents(void)
int om;
-#line 2654 "dk-ls.ctr"
+#line 2684 "dk-ls.ctr"
dk4error_init(&er);
om = DK4_DIR_OPEN_SORTED | DK4_DIR_SYMLINK_DIR_AS_FILE;
dirptr = dk4dir_open_app(dk_ls_kwnl[4], om, app);
@@ -2807,7 +2805,7 @@ run_for_current_dir_contents(void)
if ((0 != recursive) || (0 != size_wanted)) {
dk_ls_process_directory(fn, 1);
} else {
- dk_ls_process_non_directory(fn, 1);
+ dk_ls_process_non_directory(fn);
}
} else {
cc = 0;
@@ -2823,7 +2821,7 @@ run_for_current_dir_contents(void)
if (0 != dk_ls_can_continue()) {
fn = dk4dir_next_file(dirptr);
if (NULL != fn) {
- dk_ls_process_non_directory(fn, 1);
+ dk_ls_process_non_directory(fn);
} else {
cc = 0;
}
@@ -2839,7 +2837,7 @@ run_for_current_dir_contents(void)
}
-#line 2698 "dk-ls.ctr"
+#line 2728 "dk-ls.ctr"
}
@@ -2857,7 +2855,7 @@ dk_ls_normal_run(void)
int mdset;
-#line 2714 "dk-ls.ctr"
+#line 2744 "dk-ls.ctr"
exval = EXIT_SUCCESS;
/* Process options.
@@ -2946,11 +2944,11 @@ dk_ls_normal_run(void)
xargc = dk4app_get_argc(app);
if (0 < xargc) {
-#line 2801 "dk-ls.ctr"
+#line 2831 "dk-ls.ctr"
run_for_command_line_arguments(xargc);
} else {
-#line 2803 "dk-ls.ctr"
+#line 2833 "dk-ls.ctr"
run_for_current_dir_contents();
}
if (0 != show_summary) {
@@ -2984,7 +2982,7 @@ dk_ls_normal_run(void)
}
-#line 2835 "dk-ls.ctr"
+#line 2865 "dk-ls.ctr"
}
@@ -3190,10 +3188,10 @@ int main(int argc, char *argv[])
{
-#line 3039 "dk-ls.ctr"
+#line 3069 "dk-ls.ctr"
-#line 3040 "dk-ls.ctr"
+#line 3070 "dk-ls.ctr"
dk4fput_initialize_stdout();
dk4fput_initialize_stderr();
dk4error_init(&er_dirs);
@@ -3206,24 +3204,24 @@ int main(int argc, char *argv[])
);
if (NULL != app) {
-#line 3051 "dk-ls.ctr"
+#line 3081 "dk-ls.ctr"
dk_ls_sz_msg = dk4app_string_table_size(dk_ls_kw_def);
dk_ls_msg = dk4app_string_table(app, dk_ls_kwnl[2], dk_ls_kw_def);
if (0 != dk4app_can_run_normally(app)) {
-#line 3054 "dk-ls.ctr"
+#line 3084 "dk-ls.ctr"
dk_ls_run_with_signal_handlers();
} else {
if (0 != dk4app_help_version_license(app)) {
-#line 3057 "dk-ls.ctr"
+#line 3087 "dk-ls.ctr"
exval = EXIT_SUCCESS;
}
}
dk4app_close(app);
} else {
-#line 3062 "dk-ls.ctr"
+#line 3092 "dk-ls.ctr"
dk4fputs(dk_ls_kwnl[11], stdout, NULL);
fflush(stdout);
}
@@ -3233,10 +3231,10 @@ int main(int argc, char *argv[])
dk4fput_cleanup_stdout();
-#line 3070 "dk-ls.ctr"
+#line 3100 "dk-ls.ctr"
-#line 3071 "dk-ls.ctr"
+#line 3101 "dk-ls.ctr"
exit(exval); return exval;
}