Skip to content

Commit fa34156

Browse files
committed
Add basename variable (Issue #44)
1 parent f772a5e commit fa34156

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ libcups v3.0b1 (Month DD, YYYY)
2626
- Added, modernized, and promoted the localization interfaces to public API
2727
(Issue #24)
2828
- Added public JSON API (Issue #31)
29+
- Added new `basename` variable for use in ipptool files (Issue #44)
2930
- Updated the CUPS API for consistency.
3031
- Fixed ipptool's handling of EXPECT for member attributes (Issue #4)
3132
- Fixed ipptool's support for octetString values (Issue #23)

doc/ipptoolfile.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,12 @@ <h3 id="ipptoolfile-5.description.variables">Variables</h3>
699699
</p>
700700
<p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>$ENV[</strong><em>name</em><strong>]</strong><br>
701701
Inserts the value of the named environment variable, or an empty string if the environment variable is not defined.
702+
</p>
703+
<p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>$basename</strong><br>
704+
Inserts the base filename (without directory path) of the path provided to
705+
<strong>ipptool</strong>(8)
706+
707+
with the <em>-f</em> option.
702708
</p>
703709
<p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>$date-current</strong><br>
704710
Inserts the current date and time using the ISO-8601 format (&quot;yyyy-mm-ddThh:mm:ssZ&quot;).

man/ipptoolfile.5

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,11 @@ Inserts a single "$" character.
669669
\fB$ENV[\fIname\fB]\fR
670670
Inserts the value of the named environment variable, or an empty string if the environment variable is not defined.
671671
.TP 5
672+
\fB$basename\fR
673+
Inserts the base filename (without directory path) of the path provided to
674+
.BR ipptool (8)
675+
with the \fI-f\fR option.
676+
.TP 5
672677
\fB$date-current\fR
673678
Inserts the current date and time using the ISO-8601 format ("yyyy-mm-ddThh:mm:ssZ").
674679
.TP 5

tools/ipptool.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ main(int argc, /* I - Number of command-line args */
267267
*value, /* Pointer to value */
268268
filename[1024], /* Real filename */
269269
testname[1024]; /* Real test filename */
270-
const char *ext, /* Extension on filename */
270+
const char *base, /* Base filename */
271+
*ext, /* Extension on filename */
271272
*testfile; /* Test file to use */
272273
int interval, /* Test interval in microseconds */
273274
repeat; /* Repeat count */
@@ -528,6 +529,11 @@ main(int argc, /* I - Number of command-line args */
528529

529530
ippFileSetVar(data->parent, "filename", filename);
530531

532+
if ((base = strrchr(filename, '/')) != NULL)
533+
ippFileSetVar(data->parent, "basename", base + 1);
534+
else
535+
ippFileSetVar(data->parent, "basename", filename);
536+
531537
if ((ext = strrchr(filename, '.')) != NULL)
532538
{
533539
// Guess the MIME media type based on the extension...

0 commit comments

Comments
 (0)