Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
workflow_dispatch:

permissions:
contents: write
contents: read

jobs:
build:
Expand Down Expand Up @@ -51,6 +51,8 @@ jobs:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Download Artifacts
Expand Down
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
# SPDX-License-Identifier: GPL-3.0-or-later

TOOLS = host-run host-multiview host-shell host-path host-reveal host-notify host-edit host-clip host-info
TESTS = tests/test_host_edit_command.out
COMMON_HEADERS = src/host_common.h src/host_path.h src/host_capture.h src/host_edit_command.h src/uae_pragmas.h
TESTS = tests/test_host_common.out tests/test_host_command_builders.out tests/test_host_edit_command.out
COMMON_HEADERS = src/host_common.h src/host_path.h src/host_capture.h src/host_clip_command.h src/host_edit_command.h src/host_notify_command.h src/host_reveal_command.h src/uae_pragmas.h
PACKAGE = Host-Tools-$(VERSION).lha

.PHONY: all test debug package clean

all: $(TOOLS)
test: $(TESTS)
./$(TESTS)
@for test in $(TESTS); do \
./$$test || exit $$?; \
done

VERSION = 2.3
DATE = 2026-04-30
Expand All @@ -21,7 +25,7 @@ CFLAGS = -mcpu=68020 -noixemul -Os -fomit-frame-pointer -std=c99 -Wall -Wextra
VERFLAGS = -DVERSION_STR="\"$(VERSION)\"" -DDATE_STR="\"$(DATE)\""
HOST_CC ?= $(shell command -v x86_64-linux-gnu-gcc 2>/dev/null || command -v cc 2>/dev/null || printf cc)
HOST_NATIVE_FLAGS = $(if $(findstring x86_64-linux-gnu-gcc,$(notdir $(HOST_CC))),-B/usr/bin/x86_64-linux-gnu- -fuse-ld=bfd,)
HOST_CFLAGS = -std=c99 -Wall -Wextra -Isrc
HOST_CFLAGS = -std=c99 -Wall -Wextra -Wstrict-prototypes -Isrc

host-run: src/host-run.c $(COMMON_HEADERS)
$(CC) $(CFLAGS) $(VERFLAGS) $(INCLUDES) src/host-run.c -o $@
Expand Down Expand Up @@ -50,6 +54,12 @@ host-clip: src/host-clip.c $(COMMON_HEADERS)
host-info: src/host-info.c $(COMMON_HEADERS)
$(CC) $(CFLAGS) $(VERFLAGS) $(INCLUDES) src/host-info.c -o $@

tests/test_host_common.out: tests/test_host_common.c src/host_common.h
$(HOST_CC) $(HOST_NATIVE_FLAGS) $(HOST_CFLAGS) tests/test_host_common.c -o $@

tests/test_host_command_builders.out: tests/test_host_command_builders.c src/host_clip_command.h src/host_common.h src/host_notify_command.h src/host_reveal_command.h
$(HOST_CC) $(HOST_NATIVE_FLAGS) $(HOST_CFLAGS) tests/test_host_command_builders.c -o $@

tests/test_host_edit_command.out: tests/test_host_edit_command.c src/host_edit_command.h src/host_common.h
$(HOST_CC) $(HOST_NATIVE_FLAGS) $(HOST_CFLAGS) tests/test_host_edit_command.c -o $@

Expand Down
20 changes: 3 additions & 17 deletions src/host-clip.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stdio.h>
#include <string.h>
#include "host_capture.h"
#include "host_clip_command.h"

static const char version[] = "$VER: Host-Clip v" VERSION_STR " (" DATE_STR ")";

Expand All @@ -17,27 +18,12 @@ int print_usage()
return 0;
}

static int append_copy_command(char *command, size_t command_size, const char *text)
{
return host_append_literal(command, command_size, "printf %s ") &&
host_append_shell_arg(command, command_size, text, 0) &&
host_append_literal(command, command_size,
" | if command -v pbcopy >/dev/null 2>&1; then pbcopy; elif command -v wl-copy >/dev/null 2>&1; then wl-copy; elif command -v xclip >/dev/null 2>&1; then xclip -selection clipboard; elif command -v xsel >/dev/null 2>&1; then xsel --clipboard --input; else printf 'No host clipboard backend found\\n' >&2; exit 127; fi");
}

int main(int argc, char *argv[])
{
static char command[HOST_MAX_COMMAND_LEN];
static char text[2048];
int start = 1;

static const char paste_command[] =
"if command -v pbpaste >/dev/null 2>&1; then pbpaste; "
"elif command -v wl-paste >/dev/null 2>&1; then wl-paste -n; "
"elif command -v xclip >/dev/null 2>&1; then xclip -selection clipboard -o; "
"elif command -v xsel >/dev/null 2>&1; then xsel --clipboard --output; "
"else printf 'No host clipboard backend found\\n' >&2; exit 127; fi";

command[0] = '\0';
text[0] = '\0';

Expand All @@ -63,7 +49,7 @@ int main(int argc, char *argv[])
printf("Unexpected argument after paste\n");
return print_usage();
}
return host_print_command_output(paste_command);
return host_print_command_output(HOST_CLIP_PASTE_COMMAND);
}

if (strcmp(argv[1], "copy") == 0 || strcmp(argv[1], "-c") == 0) {
Expand All @@ -80,7 +66,7 @@ int main(int argc, char *argv[])
return HOST_RETURN_ERROR;
}

if (!append_copy_command(command, sizeof(command), text)) {
if (!host_append_clip_copy_command(command, sizeof(command), text)) {
printf("Command is too long\n");
return HOST_RETURN_ERROR;
}
Expand Down
21 changes: 4 additions & 17 deletions src/host-notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stdio.h>
#include <string.h>
#include "host_capture.h"
#include "host_notify_command.h"

static const char version[] = "$VER: Host-Notify v" VERSION_STR " (" DATE_STR ")";

Expand All @@ -17,29 +18,15 @@ int print_usage()
return 0;
}

static int append_notify_command(char *command, size_t command_size,
const char *title, const char *message)
{
return host_append_literal(command, command_size,
"if command -v notify-send >/dev/null 2>&1; then notify-send ") &&
host_append_shell_arg(command, command_size, title, 0) &&
host_append_shell_arg(command, command_size, message, 1) &&
host_append_literal(command, command_size,
"; elif command -v osascript >/dev/null 2>&1; then osascript -e 'on run argv' -e 'display notification (item 2 of argv) with title (item 1 of argv)' -e 'end run' ") &&
host_append_shell_arg(command, command_size, title, 0) &&
host_append_shell_arg(command, command_size, message, 1) &&
host_append_literal(command, command_size,
"; else exit 127; fi");
}

int main(int argc, char *argv[])
{
static char command[HOST_MAX_COMMAND_LEN];
static char title[512];
static char message[2048];

command[0] = '\0';
strcpy(title, "Amiga");
title[0] = '\0';
host_append_literal(title, sizeof(title), "Amiga");
message[0] = '\0';

if (!InitUAEResource())
Expand Down Expand Up @@ -77,7 +64,7 @@ int main(int argc, char *argv[])
}
}

if (!append_notify_command(command, sizeof(command), title, message)) {
if (!host_append_notify_command(command, sizeof(command), title, message)) {
printf("Command is too long\n");
return HOST_RETURN_ERROR;
}
Expand Down
15 changes: 2 additions & 13 deletions src/host-reveal.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string.h>
#include "host_capture.h"
#include "host_path.h"
#include "host_reveal_command.h"

static const char version[] = "$VER: Host-Reveal v" VERSION_STR " (" DATE_STR ")";

Expand All @@ -18,18 +19,6 @@ int print_usage()
return 0;
}

static int append_reveal_command(char *command, size_t command_size, const char *path)
{
return host_append_literal(command, command_size,
"if [ \"$(uname -s)\" = Darwin ] && command -v open >/dev/null 2>&1; then open -R ") &&
host_append_shell_arg(command, command_size, path, 0) &&
host_append_literal(command, command_size,
"; elif command -v xdg-open >/dev/null 2>&1; then xdg-open \"$(dirname -- ") &&
host_append_shell_arg(command, command_size, path, 0) &&
host_append_literal(command, command_size,
")\"; else exit 127; fi");
}

int main(int argc, char *argv[])
{
static char filename[HOST_MAX_PATH_LEN];
Expand Down Expand Up @@ -78,7 +67,7 @@ int main(int argc, char *argv[])
continue;
}

if (!append_reveal_command(command, sizeof(command), target)) {
if (!host_append_reveal_command(command, sizeof(command), target)) {
printf("Command is too long\n");
status = HOST_RETURN_ERROR;
continue;
Expand Down
28 changes: 28 additions & 0 deletions src/host_clip_command.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: 2020-2026 Dimitris Panokostas
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#ifndef HOST_CLIP_COMMAND_H
#define HOST_CLIP_COMMAND_H

#include <stddef.h>
#include "host_common.h"

#define HOST_CLIP_PASTE_COMMAND \
"if command -v pbpaste >/dev/null 2>&1; then pbpaste; " \
"elif command -v wl-paste >/dev/null 2>&1; then wl-paste -n; " \
"elif command -v xclip >/dev/null 2>&1; then xclip -selection clipboard -o; " \
"elif command -v xsel >/dev/null 2>&1; then xsel --clipboard --output; " \
"else printf 'No host clipboard backend found\\n' >&2; exit 127; fi"

static inline int host_append_clip_copy_command(char *command, size_t command_size,
const char *text)
{
return host_append_literal(command, command_size, "printf %s ") &&
host_append_shell_arg(command, command_size, text, 0) &&
host_append_literal(command, command_size,
" | if command -v pbcopy >/dev/null 2>&1; then pbcopy; elif command -v wl-copy >/dev/null 2>&1; then wl-copy; elif command -v xclip >/dev/null 2>&1; then xclip -selection clipboard; elif command -v xsel >/dev/null 2>&1; then xsel --clipboard --input; else printf 'No host clipboard backend found\\n' >&2; exit 127; fi");
}

#endif
27 changes: 27 additions & 0 deletions src/host_notify_command.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* SPDX-FileCopyrightText: 2020-2026 Dimitris Panokostas
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#ifndef HOST_NOTIFY_COMMAND_H
#define HOST_NOTIFY_COMMAND_H

#include <stddef.h>
#include "host_common.h"

static inline int host_append_notify_command(char *command, size_t command_size,
const char *title, const char *message)
{
return host_append_literal(command, command_size,
"if command -v notify-send >/dev/null 2>&1; then notify-send ") &&
host_append_shell_arg(command, command_size, title, 0) &&
host_append_shell_arg(command, command_size, message, 1) &&
host_append_literal(command, command_size,
"; elif command -v osascript >/dev/null 2>&1; then osascript -e 'on run argv' -e 'display notification (item 2 of argv) with title (item 1 of argv)' -e 'end run' ") &&
host_append_shell_arg(command, command_size, title, 0) &&
host_append_shell_arg(command, command_size, message, 1) &&
host_append_literal(command, command_size,
"; else exit 127; fi");
}

#endif
25 changes: 25 additions & 0 deletions src/host_reveal_command.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* SPDX-FileCopyrightText: 2020-2026 Dimitris Panokostas
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#ifndef HOST_REVEAL_COMMAND_H
#define HOST_REVEAL_COMMAND_H

#include <stddef.h>
#include "host_common.h"

static inline int host_append_reveal_command(char *command, size_t command_size,
const char *path)
{
return host_append_literal(command, command_size,
"if [ \"$(uname -s)\" = Darwin ] && command -v open >/dev/null 2>&1; then open -R ") &&
host_append_shell_arg(command, command_size, path, 0) &&
host_append_literal(command, command_size,
"; elif command -v xdg-open >/dev/null 2>&1; then xdg-open \"$(dirname -- ") &&
host_append_shell_arg(command, command_size, path, 0) &&
host_append_literal(command, command_size,
")\"; else exit 127; fi");
}

#endif
Loading