This commit is contained in:
James 2024-03-20 10:48:21 +10:00
parent 254470e79c
commit fbfec7c9d2
11 changed files with 363 additions and 2 deletions

145
Makefile Normal file
View File

@ -0,0 +1,145 @@
# NMAKE code here \
!ifndef 0 # \
MV=move /Y # \
RM=del /F/Q # \
RMDIR=rmdir /S/Q # \
CP=copy /B/Y # \
PS=\ # \
CAT=type # \
SEVENZ="C:\Program Files\7-Zip\7z.exe" -y # \
SDL2LIB=SDL2.lib # \
SDL2IMGLIB=SDL2_image.lib # \
CCOBJ=cl /c /Iinclude # \
OBJOUT=/Fo#\
EXEOUT=/Fe#\
CCEXE=cl /Iinclude # \
LDFLAGS=SDL2main.lib SDL2.lib shell32.lib /link /subsystem:windows # \
!else
# Make code here
MV=mv -f
RM=rm -f
CP=cp -f
CAT=cat
PS=/
SEVENZ=7z -y
RMDIR=rm -f
SDL2LIB=SDL2.a
SDL2IMGLIB=SDL2_image.so
CCOBJ=gcc -c -Iinclude
OBJOUT=-o
EXEOUT=-o
CCEXE=gcc -Iinclude
LDFLAGS=
# \
!endif
check:
@echo MV=$(MV)
@echo RM=$(RM)
@echo CP=$(CP)
@echo CAT=$(CAT)
@echo PS=$(PS)
@echo RMDIR=$(RMDIR)
@echo SEVENZ=$(SEVENZ)
@echo SDL2LIB=$(SDL2LIB)
@echo LDFLAGS=$(LDFLAGS)
@echo if this is correct, run "make purforce"
@echo other options:
@echo all, purforce, clean, reallyclean, distclean
all: purforce
clean:
-@$(RM) build$(PS)*.obj
-@$(RM) sdl2dev.zip
-@$(RM) sdl2imgdev.zip
-@$(RM) SDL2-2.30.0$(PS)*.txt
-@$(RM) SDL2-2.30.0$(PS)docs$(PS)*.md
-@$(RM) SDL2-2.30.0$(PS)docs$(PS)doxyfile
-@$(RMDIR) SDL2-2.30.0$(PS)docs
-@$(RM) SDL2-2.30.0$(PS)cmake$(PS)*.cmake
-@$(RMDIR) SDL2-2.30.0$(PS)cmake
-@$(RM) SDL2-2.30.0$(PS)include$(PS)*.h
-@$(RMDIR) SDL2-2.30.0$(PS)include
-@$(RM) SDL2-2.30.0$(PS)lib$(PS)x64$(PS)*.lib
-@$(RM) SDL2-2.30.0$(PS)lib$(PS)x64$(PS)*.dll
-@$(RMDIR) SDL2-2.30.0$(PS)lib$(PS)x64
-@$(RM) SDL2-2.30.0$(PS)lib$(PS)x86$(PS)*.lib
-@$(RM) SDL2-2.30.0$(PS)lib$(PS)x86$(PS)*.dll
-@$(RMDIR) SDL2-2.30.0$(PS)lib$(PS)x86
-@$(RMDIR) SDL2-2.30.0$(PS)lib
-@$(RMDIR) SDL2-2.30.0
-@$(RM) SDL2_image-2.8.2$(PS)*.txt
-@$(RM) SDL2_image-2.8.2$(PS)cmake$(PS)*.cmake
-@$(RMDIR) SDL2_image-2.8.2$(PS)cmake
-@$(RM) SDL2_image-2.8.2$(PS)lib$(PS)x64$(PS)*.dll
-@$(RM) SDL2_image-2.8.2$(PS)lib$(PS)x64$(PS)*.lib
-@$(RM) SDL2_image-2.8.2$(PS)lib$(PS)x86$(PS)*.dll
-@$(RM) SDL2_image-2.8.2$(PS)lib$(PS)x86$(PS)*.lib
-@$(RMDIR) SDL2_image-2.8.2$(PS)lib$(PS)x64
-@$(RMDIR) SDL2_image-2.8.2$(PS)lib$(PS)x86
-@$(RMDIR) SDL2_image-2.8.2$(PS)lib
-@$(RM) SDL2_image-2.8.2$(PS)include$(PS)*.h
-@$(RMDIR) SDL2_image-2.8.2$(PS)include
-@$(RMDIR) SDL2_image-2.8.2
veryclean:reallyclean
reallyclean: clean
-@$(RM) purforce.exe
-@$(RMDIR) build
distclean: reallyclean
-@$(RM) SDL2.a
-@$(RM) SDL2.lib
-@$(RM) SDL2.dll
-@$(RM) SDL2_image.lib
-@$(RM) SDL2_image.dll
-@$(RM) SDL2main.lib
-@$(RM) include$(PS)*.h
-@$(RMDIR) include
PUR_OBJS= \
build$(PS)main.obj \
build$(PS)error.obj
build$(PS)main.obj: build Makefile main.c api.h include$(PS)SDL.h include$(PS)SDL_image.h
$(CCOBJ) main.c $(OBJOUT)$@
build$(PS)error.obj: build Makefile api.h error.c
$(CCOBJ) error.c $(OBJOUT)$@
build:
mkdir build
purforce: purforce.exe
purforce.exe: $(PUR_OBJS) $(SDL2LIB) $(SDL2IMGLIB) Makefile
$(CCEXE) $(PUR_OBJS) $(SDL2IMGLIB) $(EXEOUT)$@ $(LDFLAGS)
sdl2dev.zip:
$(CP) ..\..\assets\windows\SDL2-devel-2.30.0-VC.zip $@
sdl2imgdev.zip:
$(CP) ..\..\assets\windows\SDL2_image-devel-2.8.2-VC.zip $@
include:
mkdir include
include$(PS)SDL.h: sdl2dev.zip include
$(SEVENZ) x sdl2dev.zip
$(CP) SDL2-2.30.0$(PS)include$(PS)*.h include$(PS)
touch include$(PS)SDL.h
include$(PS)SDL_image.h: sdl2imgdev.zip include
$(SEVENZ) x sdl2imgdev.zip
$(CP) SDL2_image-2.8.2$(PS)include$(PS)*.h include$(PS)
touch include$(PS)SDL_image.h
SDL2_image.lib: sdl2imgdev.zip
$(SEVENZ) x sdl2imgdev.zip
$(CP) SDL2_image-2.8.2\lib\x64\SDL2_image.dll SDL2_image.dll
$(CP) SDL2_image-2.8.2\lib\x64\SDL2_image.lib SDL2_image.lib
touch SDL2_image.lib
SDL2.lib: sdl2dev.zip
$(SEVENZ) x sdl2dev.zip
$(CP) SDL2-2.30.0\lib\x64\SDL2.dll SDL2.dll
$(CP) SDL2-2.30.0\lib\x64\SDL2.lib SDL2.lib
$(CP) SDL2-2.30.0\lib\x64\SDL2main.lib SDL2main.lib
touch SDL2.lib
SDL2.a:
sudo apt-get install sdl2-dev
ln -s /user/local/lib/sdl2/sdl2.so ./SDL2.a
touch SDL2.a

108
README.md
View File

@ -1,3 +1,107 @@
# purrforce # PurrForce
purrforce purforce-purforce-purforce...(drum roll)... its
real-ly the cats me-ow...(meow) (meow)
like the lamas ass winamp thing
it can play that by default on each startup. launches to
the system tray if %APPDATA% has purfoce.ini that tells the
server address, else it prompts for server deets
uses http/https for all comms
because you might want to run it behind nginx with proxy
pass, the server runs just http and you use apache or nginx
reverse proxy to do lets encrypt and add https. client
tries both so we don't force people to setup some https bs.
the program does not need to store two copies (or the full
history) on your local PC. only your current working copy
is stored, and is rsynced to the server.
also, server does not keep too many backups because it will
use up too much space. but users can request a backup via
rightclick menu on any file.
click on systray to get a list of all files currently being
tracked. tracking is via direct file selection not using
any kind of repo.
you can use github for code, and purrforce for the massive
.blend files and such.
server maintains list of users registered and list of users
online. you can ping them a DM and it shows up in their
systemtray, it can reference a file you tracked and suggest
them a path to save it to.
path can use variables that they can set in the GUI
varaibles section which is stored in .ini file locally as
you might have different computers each with the base
project dir in different locations each time.
if you add a file to tracking you add it writeable in
progress or readonly finished. others can DL it but the
systray will constantly set its file flags to readonly,
unless they right click clone private copy (tracked) or
clone private copy (untracked) under a new name. with a
checkbox for remove original from local drive.
normal deleting a file just makes it untracked but still
available in systray file listing on server, can redownload
from server. to delete on server, rightclick and choose
delete on server (keep local) or delete on both server and
local. Server side it moves to recycle bin and old recycle
bin items get deleted to make hdd space free when needed.
systray has a bar meter of how much server HDD is used up.
allows storage slaves to connect to server and provide a
fixed GB amount of storage for the server to use via remote
commands (rename,copy,delete,create,rsync transfer).
sys admin panel shows server HDD and all slave HDD and all
file objects with rectangle size set by file size in mb,
and drag drop to move storage locations.
client access a file stored on storage slave? all client
transfer goes to server, which then proxies to storage
client. only server needs to have a stable IP, storage
slaves can be behind carrier grade NAT, the connection is
storage slave connects to server in an infinite loop and
long holds open and then bidir data transfer through that.
allow screen streaming via rapid screenshots -> video
encode -> upload to server -> all viewers download from
server.
allows remote assistance by request assistance right click
option on systray icon, choose user to gift control, they
get a popup to confirm, they get an SDL window that sees
your desktop stream, and mouse and kb input into that
window are sent to you and emitted by the app using
SendKey() type OS calls. Should allow someone to quickly
jump in and show you how to do something in your local
blender model, etc. also microphone streaming to speakers.
and an optional internet radio streamed from server with
playlist requests voting. Add a track by syncing a local
music file to server radio/ folder and then enqueue it in
the radio requests UI on the systray app.
app tracks mouse / kb activity and provides AFK status and
online status on all registered user avatars.
designed as a blender model and other large binary file
syncing service to complement a github repository for LGDG
collab project mar-apr 2024.
sync binary files

7
api.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef api_h
#define api_h
#include <stdarg.h>
void reportError(const char *fmt,...);
#endif//api_h

26
error.c Normal file
View File

@ -0,0 +1,26 @@
#include <stdio.h>
#include <string.h>
#include "api.h"
#ifdef _WIN32
#include <Windows.h>
static void showError(const char *er) {
int ret = MessageBoxA(NULL,er,"Quit the program?",MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2|MB_APPLMODAL);
if(ret = IDYES) {
exit(1);
}
}
#else
static void showError(const char *er){
fprintf(stderr,"%s\n",er);
return;
}
#endif
void reportError(const char *fmt,...){
va_list ap;
char buf[512];
va_start(ap,fmt);
vsnprintf(buf,sizeof buf,fmt,ap);
va_end(ap);
}

1
ls.bat Normal file
View File

@ -0,0 +1 @@
dir %*

56
main.c Normal file
View File

@ -0,0 +1,56 @@
#include <stdlib.h>
#include <SDL.h>
#include <SDL_image.h>
#include "api.h"
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Texture* lettuce_tex;
int main(int argc, char* argv[]) {
SDL_Surface* lettuce_sur;
reportError("startup purrforce?");
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
reportError("Error SDL2 Initialization : %s",SDL_GetError());
return 1;
}
window = SDL_CreateWindow("First program", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL);
if (window == NULL) {
reportError("Error window creation");
return 3;
}
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (renderer == NULL) {
reportError("Error renderer creation");
return 4;
}
lettuce_sur = IMG_Load("lettuce.png");
if (lettuce_sur == NULL) {
reportError("Error loading image: %s",IMG_GetError());
return 5;
}
lettuce_tex = SDL_CreateTextureFromSurface(renderer, lettuce_sur);
if (lettuce_tex == NULL) {
reportError("Error creating texture");
return 6;
}
SDL_FreeSurface(lettuce_sur);
while (1) {
SDL_Event e;
if (SDL_WaitEvent(&e)) {
if (e.type == SDL_QUIT) {
break;
}
}
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, lettuce_tex, NULL, NULL);
SDL_RenderPresent(renderer);
}
SDL_DestroyTexture(lettuce_tex);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
IMG_Quit();
SDL_Quit();
return 0;
}

1
make.bat Normal file
View File

@ -0,0 +1 @@
nmake %*

0
pull_fromgit.bat Normal file
View File

1
rm.bat Normal file
View File

@ -0,0 +1 @@
del %*

11
sync2git.bat Normal file
View File

@ -0,0 +1,11 @@
copy /B /Y api.h D:\dev\db\purrforce\
copy /B /Y error.c D:\dev\db\purrforce\
copy /B /Y ls.bat D:\dev\db\purrforce\
copy /B /Y main.c D:\dev\db\purrforce\
copy /B /Y make.bat D:\dev\db\purrforce\
copy /B /Y Makefile D:\dev\db\purrforce\
copy /B /Y pull_fromgit.bat D:\dev\db\purrforce\
copy /B /Y readme.md D:\dev\db\purrforce\
copy /B /Y rm.bat D:\dev\db\purrforce\
copy /B /Y sync2git.bat D:\dev\db\purrforce\
copy /B /Y touch.bat D:\dev\db\purrforce\

9
touch.bat Normal file
View File

@ -0,0 +1,9 @@
@echo off
REM copy /b %* +,,
IF EXIST %1 (
type %1 >temp.tou
move temp.tou %1
) ELSE (
REM echo ERROR cannot find '%1' file, use double quotes or check path
copy /b NUL %1
)