2013-03-20 03:00:05 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2017-12-18 18:00:00 -08:00
|
|
|
#include "private.h"
|
2016-07-30 07:31:56 -07:00
|
|
|
#include "tycommon.h"
|
|
|
|
|
2016-09-01 06:14:39 -07:00
|
|
|
static void
|
|
|
|
print_usage(const char *argv0)
|
|
|
|
{
|
|
|
|
printf("Usage: %s"HELP_ARGUMENT_SHORT" FILE1 [FILE2 ...]\n"
|
|
|
|
" Pop up a given media file/uri right now\n"
|
|
|
|
HELP_ARGUMENT_DOC"\n"
|
|
|
|
"\n",
|
|
|
|
argv0);
|
|
|
|
}
|
|
|
|
|
2013-03-20 03:00:05 -07:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i;
|
2016-07-30 07:31:56 -07:00
|
|
|
|
|
|
|
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
|
2016-09-01 06:14:39 -07:00
|
|
|
ARGUMENT_ENTRY_CHECK(argc, argv, print_usage);
|
2016-07-30 07:31:56 -07:00
|
|
|
|
2013-03-20 03:00:05 -07:00
|
|
|
if (argc <= 1)
|
|
|
|
{
|
2016-09-01 06:14:39 -07:00
|
|
|
print_usage(argv[0]);
|
2013-03-20 03:00:05 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2016-09-01 06:14:39 -07:00
|
|
|
|
2013-03-20 03:00:05 -07:00
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
char *path, buf[PATH_MAX * 2], tbuf[PATH_MAX * 3];
|
|
|
|
|
|
|
|
path = argv[i];
|
|
|
|
if (realpath(path, buf)) path = buf;
|
2019-10-10 14:37:51 -07:00
|
|
|
snprintf(tbuf, sizeof(tbuf), "%c}p%c%s", 0x1b,
|
|
|
|
(i == 1) ? 'n': 'q', path);
|
2017-12-17 06:36:51 -08:00
|
|
|
if (write(1, tbuf, strlen(tbuf) + 1) != (signed)(strlen(tbuf) + 1)) perror("write");
|
2013-03-20 03:00:05 -07:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|