From f07979f5179305c522d85a2281db37d2c47869db Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Fri, 23 Sep 2016 08:39:02 +0200 Subject: [PATCH] - introduce current.h to unify console messages and ... to simplify includes in gfx, io and text --- current.h | 3 +++ gfx.c | 6 +++--- io.c | 5 +++-- shellexec.c | 34 ++++++++++++++++++---------------- shellexec.h | 2 +- starter.c | 2 +- text.c | 8 +++----- text.h | 2 +- 8 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 current.h diff --git a/current.h b/current.h new file mode 100644 index 0000000..aadc827 --- /dev/null +++ b/current.h @@ -0,0 +1,3 @@ +#define __plugin__ "shellexec" + +#include "shellexec.h" diff --git a/gfx.c b/gfx.c index caf0803..50a0539 100644 --- a/gfx.c +++ b/gfx.c @@ -1,6 +1,6 @@ #include -#include "shellexec.h" +#include "current.h" #include "gfx.h" char circle[] = @@ -40,7 +40,7 @@ void RenderBox(int sx, int sy, int ex, int ey, int rad, int col) if (dxx<0) { - printf("[shellexec] RenderBox called with dx < 0 (%d)\n", dxx); + printf("[%s] RenderBox called with dx < 0 (%d)\n", __plugin__, dxx); dxx=0; } @@ -161,7 +161,7 @@ void RenderCircle(int sx, int sy, char col) if (fd == -1) { - printf("shellexec \n", filename); + printf("%s \n", __plugin__, filename); return; } diff --git a/io.c b/io.c index 2861c83..0b74a78 100644 --- a/io.c +++ b/io.c @@ -17,7 +17,8 @@ #include #include #include -#include "shellexec.h" + +#include "current.h" #include "io.h" extern int instance; @@ -30,7 +31,7 @@ int InitRC(void) rc = open(RC_DEVICE, O_RDONLY | O_CLOEXEC); if(rc == -1) { - perror("shellexec "); + perror(__plugin__ " "); exit(1); } fcntl(rc, F_SETFL, O_NONBLOCK | O_SYNC); diff --git a/shellexec.c b/shellexec.c index 17cfcd6..e4511d2 100644 --- a/shellexec.c +++ b/shellexec.c @@ -1,7 +1,9 @@ #include #include #include -#include "shellexec.h" + +#include "current.h" + #include "text.h" #include "io.h" #include "gfx.h" @@ -120,7 +122,7 @@ void put_instance(int pval) static void quit_signal(int sig) { put_instance(get_instance()-1); - printf("shellexec Version %.2f killed, signal %d\n",SH_VERSION,sig); + printf("%s Version %.2f killed, signal %d\n", __plugin__, SH_VERSION, sig); exit(1); } @@ -1541,7 +1543,7 @@ int main (int argc, char **argv) char tstr[BUFSIZE], *rptr; PLISTENTRY pl; - printf("shellexec Version %.2f\n",SH_VERSION); + printf("%s Version %.2f\n", __plugin__, SH_VERSION); for(tv=1; tv"); + perror(__plugin__ " "); exit(1); } @@ -1632,31 +1634,31 @@ int main (int argc, char **argv) //init framebuffer if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1) { - perror("shellexec \n"); + perror(__plugin__ " \n"); return -1; } if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1) { - perror("shellexec \n"); + perror(__plugin__ " \n"); return -1; } if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0))) { - perror("shellexec \n"); + perror(__plugin__ " \n"); return -1; } //init fontlibrary if((error = FT_Init_FreeType(&library))) { - printf("shellexec ", error); + printf("%s ", __plugin__, error); munmap(lfb, fix_screeninfo.smem_len); return -1; } if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager))) { - printf("shellexec \n", error); + printf("%s \n", __plugin__, error); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; @@ -1664,7 +1666,7 @@ int main (int argc, char **argv) if((error = FTC_SBitCache_New(manager, &cache))) { - printf("shellexec \n", error); + printf("%s \n", __plugin__, error); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); @@ -1674,7 +1676,7 @@ int main (int argc, char **argv) memset(&menu,0,sizeof(MENU)); if(Check_Config()) { - printf("shellexec Unable to read Config %s\n",CFG_FILE); + printf("%s Unable to read Config %s\n", __plugin__, CFG_FILE); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); @@ -1685,10 +1687,10 @@ int main (int argc, char **argv) if((error = FTC_Manager_LookupFace(manager, FONT, &face))) { - printf("shellexec \n", error); + printf("%s \n", __plugin__, error); if((error = FTC_Manager_LookupFace(manager, FONT2, &face))) { - printf("shellexec \n", error); + printf("%s \n", __plugin__, error); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); @@ -1699,7 +1701,7 @@ int main (int argc, char **argv) } else desc.face_id = FONT; - printf("shellexec \n", desc.face_id); + printf("%s \n", __plugin__, desc.face_id); use_kerning = FT_HAS_KERNING(face); desc.flags = FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT; @@ -1707,7 +1709,7 @@ int main (int argc, char **argv) //init backbuffer if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)))) { - printf("shellexec \n"); + printf("%s \n", __plugin__); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); @@ -1733,7 +1735,7 @@ int main (int argc, char **argv) menu.act_entry=0; if(Get_Menu(1)) { - printf("ShellExec \n"); + printf("%s \n", __plugin__); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); diff --git a/shellexec.h b/shellexec.h index a32f832..40e959c 100644 --- a/shellexec.h +++ b/shellexec.h @@ -116,7 +116,7 @@ enum {SMALL, MED, BIG}; FT_Error error; FT_Library library; FTC_Manager manager; -FTC_SBitCache cache; +FTC_SBitCache cache; FTC_SBit sbit; #if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0 FTC_Image_Desc desc; diff --git a/starter.c b/starter.c index 2e15301..01a85b7 100644 --- a/starter.c +++ b/starter.c @@ -24,7 +24,7 @@ #include #include #include -#define SCRIPT "shellexec" +#define SCRIPT __plugin__ void main() { diff --git a/text.c b/text.c index 36364af..afb737c 100644 --- a/text.c +++ b/text.c @@ -1,7 +1,6 @@ #include "text.h" #include "gfx.h" #include "io.h" -#include "shellexec.h" int FSIZE_BIG=28; int FSIZE_MED=24; @@ -159,7 +158,7 @@ FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library lib, FT_Pointer request_ result = FT_New_Face(lib, face_id, 0, aface); if (result) - printf("shellexec \n", (char*)face_id); + printf("%s \n", __plugin__, (char*)face_id); return result; } @@ -253,20 +252,19 @@ int RenderChar(FT_ULong currentchar, int _sx, int _sy, int _ex, int color) //load char if(!(glyphindex = FT_Get_Char_Index(face, currentchar))) { - printf("shellexec \n", (int)currentchar); + printf("%s \n", __plugin__, (int)currentchar); return 0; } if((err = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, NULL))) { - printf("shellexec \n", (int)currentchar, err); + printf("%s \n", __plugin__, (int)currentchar, err); return 0; } int _d = 0; if (1) { - //printf("shellexec \n"); FT_UInt _i = FT_Get_Char_Index(face, 'g'); FTC_SBit _g; FTC_SBitCache_Lookup(cache, &desc, _i, &_g, NULL); diff --git a/text.h b/text.h index ea34e76..83bafe3 100644 --- a/text.h +++ b/text.h @@ -1,7 +1,7 @@ #ifndef __TEXT_H__ #define __TEXT_H__ -#include "shellexec.h" +#include "current.h" extern int FSIZE_BIG; extern int FSIZE_MED; -- 2.39.5