1 // SPDX-FileCopyrightText: 2025 Lady <https://www.ladys.computer/about/#lady>
2 // SPDX-License-Identifier: GPL-2.0-only
7 // Read in lines from standard input, parse them as path info, and then
8 // reserialize them to standard output.
9 int cmd_main(int argc
, [[maybe_unused
]] const char* argv
[argc
+1]) {
10 char* lineptr
[1] = { nullptr };
11 size_t linelen
[1] = { 0 };
13 ssize_t readlen
= getline(lineptr
, linelen
, stdin
);
14 if (!feof(stdin
) && readlen
> 0) {
16 char* reline
= nullptr;
22 line
= strndup(lineptr
[0], readlen
- 1);
25 fprintf(stderr
, "Error: Failed to allocate string for line.\n");
29 cgirls_req req
= cgirls_path·to·
req(line
);
33 line
= cgirls_req·to·
path(req
);
37 fprintf(stderr
, "Error: Failed to allocate string for path.\n");
40 req
= cgirls_path·to·
req(line
);
41 reline
= cgirls_req·to·
path(req
);
46 fprintf(stderr
, "Error: Failed to allocate another string for path.\n");
49 if (strcmp(line
, reline
) != 0) {
51 fprintf(stderr
, "Error: Path normalization was not idempotent for path <%s> (got <%s>).\n", line
, reline
);
57 fprintf(stdout
, "%s\n", line
);
59 } else if (!feof(stdin
)) {
61 fprintf(stderr
, "Error: Got an error from trying to read from file.\n");
63 } else if (readlen
> 0) {
65 fprintf(stderr
, "Error: Final line in file was not blank.\n");
This page took 0.104884 seconds and 5 git commands to generate.