diff --git a/Makefile b/Makefile index d67dcbb..5502d64 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ CFLAGS := -Wall -Werror all: $(ELF) -$(ELF): main.c cmd.c +$(ELF): main.c cmd.c notify.c $(CC) $(CFLAGS) -o $@ $^ clean: diff --git a/main.c b/main.c index 2c98432..1cf1709 100644 --- a/main.c +++ b/main.c @@ -36,6 +36,7 @@ along with this program; see the file COPYING. If not, see #include "cmd.h" #include "log.h" +#include "notify.h" /** @@ -263,6 +264,7 @@ static int ftp_serve(uint16_t port) { struct sockaddr_in server_addr; struct sockaddr_in client_addr; + static int notify_user = 0; char ip[INET_ADDRSTRLEN]; struct ifaddrs *ifaddr; int ifaddr_wait = 1; @@ -301,6 +303,10 @@ ftp_serve(uint16_t port) { continue; } + if(!notify_user) { + notify("Serving FTP on %s:%d (%s)\n", ip, port, ifa->ifa_name); + notify_user = 1; + } FTP_LOG_PRINTF("Serving FTP on %s:%d (%s)\n", ip, port, ifa->ifa_name); ifaddr_wait = 0; } diff --git a/notify.c b/notify.c new file mode 100644 index 0000000..4e5b23c --- /dev/null +++ b/notify.c @@ -0,0 +1,42 @@ +/* Copyright (C) 2024 John Törnblom + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; see the file COPYING. If not, see +. */ + +#include +#include +#include + + +typedef struct notify_request { + char useless1[45]; + char message[3075]; +} notify_request_t; + + +int sceKernelSendNotificationRequest(int, notify_request_t*, size_t, int); + + +void +notify(const char *fmt, ...) { + notify_request_t req; + va_list args; + + bzero(&req, sizeof req); + va_start(args, fmt); + vsnprintf(req.message, sizeof req.message, fmt, args); + va_end(args); + + sceKernelSendNotificationRequest(0, &req, sizeof req, 0); +} diff --git a/notify.h b/notify.h new file mode 100644 index 0000000..5e21bb3 --- /dev/null +++ b/notify.h @@ -0,0 +1,20 @@ +/* Copyright (C) 2024 John Törnblom + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; see the file COPYING. If not, see +. */ + +#pragma once + + +void notify(const char *fmt, ...);