From: svenhoefer Date: Sun, 27 Nov 2016 22:22:14 +0000 (+0100) Subject: - introduce current.h to unify console messages and ... X-Git-Url: https://git.webhop.me/?a=commitdiff_plain;h=723e4deb0cfbfe996e1d0ac8aa50c1628fc7dff3;p=msgbox.git - introduce current.h to unify console messages and ... to simplify includes in gfx, io and text --- diff --git a/current.h b/current.h new file mode 100644 index 0000000..ad5c62c --- /dev/null +++ b/current.h @@ -0,0 +1,3 @@ +#define __plugin__ "msgbox" + +#include "msgbox.h" diff --git a/gfx.c b/gfx.c index c96ceed..67288fc 100644 --- a/gfx.c +++ b/gfx.c @@ -1,4 +1,4 @@ -#include "msgbox.h" +#include "current.h" void RenderBox(int _sx, int _sy, int _ex, int _ey, int rad, int col) { @@ -10,12 +10,12 @@ void RenderBox(int _sx, int _sy, int _ex, int _ey, int rad, int col) if (dxx<0) { - printf("msgbox RenderBox called with dx < 0 (%d)\n", dxx); + printf("%s RenderBox called with dx < 0 (%d)\n", __plugin__, dxx); dxx=0; } if (dyy > 700) { - printf("msgbox RenderBox called with dyy > 700 (%d)\n", dyy); //FIXME + printf("%s RenderBox called with dyy > 700 (%d)\n", __plugin__, dyy); //FIXME //*** Error in `msgbox': munmap_chunk(): invalid pointer: 0x31459008 *** //Nevis dyy = 700; } diff --git a/io.c b/io.c index 1645347..38fae44 100644 --- a/io.c +++ b/io.c @@ -16,9 +16,9 @@ #include #include #include -#include "io.h" -#include "msgbox.h" +#include "current.h" +#include "io.h" extern int instance; struct input_event ev; @@ -30,7 +30,7 @@ int InitRC(void) rc = open(RC_DEVICE, O_RDONLY | O_CLOEXEC); if(rc == -1) { - perror("msgbox "); + perror(__plugin__ " "); exit(1); } fcntl(rc, F_SETFL, O_NONBLOCK | O_SYNC); diff --git a/msgbox.c b/msgbox.c index 4403d49..95bad14 100644 --- a/msgbox.c +++ b/msgbox.c @@ -2,7 +2,9 @@ #include #include #include -#include "msgbox.h" + +#include "current.h" + #include "text.h" #include "io.h" #include "gfx.h" @@ -44,7 +46,7 @@ char *butmsg[16]={0}; int rbutt[16],hide=0,radius=11; // Misc -const char NOMEM[]="msgbox \n"; +const char NOMEM[]="MsgBox \n"; char TMP_FILE[64]="/tmp/msgbox.tmp"; uint32_t *lfb = NULL, *lbb = NULL, *obb = NULL, *hbb = NULL, *ibb = NULL; char nstr[BUFSIZE]={0}; @@ -87,7 +89,7 @@ FILE *fh; static void quit_signal(int sig) { put_instance(get_instance()-1); - printf("%s Version %.2f killed, signal %d\n", "msgbox", M_VERSION, sig); + printf("%s Version %.2f killed, signal %d\n", __plugin__, M_VERSION, sig); exit(1); } @@ -251,7 +253,7 @@ int i,bx,by,x1,y1,rv=-1,run=1,line=0,action=1,cut,itmp,btns=buttons,lbtns=(butto if(fh_txt_getsize(TMP_FILE, &x1, &y1, size, &cut)) { - printf("msgbox \n"); + printf(__plugin__ " \n"); return -1; } x1+=10; @@ -375,7 +377,7 @@ FILE *xfh; void ShowUsage(void) { - printf("msgbox Version %.2f\n",M_VERSION); + printf("MsgBox Version %.2f\n",M_VERSION); printf("\nSyntax:\n"); printf(" msgbox msg=\"text to show\" [Options]\n"); printf(" msgbox msg=filename [Options]\n"); @@ -419,7 +421,7 @@ FILE *fh; aptr=argv[tv]; if(!strcmp(aptr,"-v") || !strcmp(aptr,"--version")) { - printf("msgbox Version %.2f\n",M_VERSION); + printf("%s Version %.2f\n", __plugin__, M_VERSION); return 0; } if((rptr=strchr(aptr,'='))!=NULL) @@ -570,12 +572,12 @@ FILE *fh; switch (dloop) { case 1: - printf("msgbox \n",aptr); + printf("%s \n", __plugin__, aptr); return 0; break; case 2: - printf("msgbox \n\n",aptr); + printf("%s \n\n", __plugin__, aptr); ShowUsage(); return 0; break; @@ -590,7 +592,7 @@ FILE *fh; /* if(!echo) { - printf("\nmsgbox Message-Box Version %.2f\n",M_VERSION); + printf("\nMsgBox Version %.2f\n", M_VERSION); } */ if(!buttons) @@ -617,7 +619,7 @@ FILE *fh; } if(!found) { - printf("msgbox \n",selection); + printf("%s \n", __plugin__, selection); return 0; } } @@ -689,7 +691,7 @@ FILE *fh; fb = open(FB_DEVICE, O_RDWR); if(fb == -1) { - perror("msgbox "); + perror(__plugin__ " "); exit(1); } @@ -705,18 +707,18 @@ FILE *fh; if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1) { - perror("msgbox \n"); + perror(__plugin__ " \n"); return -1; } if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1) { - perror("msgbox \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("msgbox \n"); + perror(__plugin__ " \n"); return -1; } @@ -724,14 +726,14 @@ FILE *fh; if((error = FT_Init_FreeType(&library))) { - printf("msgbox ", 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("msgbox \n", error); + printf("%s \n", __plugin__, error); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); return -1; @@ -739,7 +741,7 @@ FILE *fh; if((error = FTC_SBitCache_New(manager, &cache))) { - printf("msgbox \n", error); + printf("%s \n", __plugin__, error); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); @@ -750,7 +752,7 @@ FILE *fh; { if((error = FTC_Manager_LookupFace(manager, FONT2, &face))) { - printf("msgbox \n", error); + printf("%s \n", __plugin__, error); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); @@ -770,7 +772,7 @@ FILE *fh; if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)))) { - perror("msgbox \n"); + perror(__plugin__ " \n"); FTC_Manager_Done(manager); FT_Done_FreeType(library); munmap(lfb, fix_screeninfo.smem_len); @@ -780,7 +782,7 @@ FILE *fh; if(!(obb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)))) { - perror("msgbox \n"); + perror(__plugin__ " \n"); FTC_Manager_Done(manager); FT_Done_FreeType(library); free(lbb); @@ -789,7 +791,7 @@ FILE *fh; } if(!(hbb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)))) { - perror("msgbox \n"); + perror(__plugin__ " \n"); FTC_Manager_Done(manager); FT_Done_FreeType(library); free(lbb); @@ -799,7 +801,7 @@ FILE *fh; } if(!(ibb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)))) { - perror("msgbox \n"); + perror(__plugin__ " \n"); FTC_Manager_Done(manager); FT_Done_FreeType(library); free(lbb); diff --git a/text.c b/text.c index 2569d57..f1a52dc 100644 --- a/text.c +++ b/text.c @@ -1,7 +1,6 @@ #include "text.h" #include "gfx.h" #include "io.h" -#include "msgbox.h" int FSIZE_BIG=28; int FSIZE_MED=24; @@ -143,7 +142,8 @@ 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("msgbox \n", (char*)face_id); + if (result) + printf("%s \n", __plugin__, (char*)face_id); return result; } @@ -238,13 +238,13 @@ int RenderChar(FT_ULong currentchar, int _sx, int _sy, int _ex, int color) if(!(glyphindex = FT_Get_Char_Index(face, currentchar))) { - printf("msgbox \n", (int)currentchar, error); + printf("%s \n", __plugin__, (int)currentchar, error); return 0; } diff --git a/text.h b/text.h index 3cfe53c..592f967 100644 --- a/text.h +++ b/text.h @@ -1,7 +1,7 @@ #ifndef __TEXT_H__ #define __TEXT_H__ -#include "msgbox.h" +#include "current.h" FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface); int RenderString(char *string, int sx, int sy, int maxwidth, int layout, int size, int color); diff --git a/txtform.c b/txtform.c index 52a7362..f0086cd 100644 --- a/txtform.c +++ b/txtform.c @@ -5,7 +5,8 @@ #include #include "text.h" #include "gfx.h" -#include "msgbox.h" + +#include "current.h" #define FH_ERROR_OK 0 #define FH_ERROR_FILE 1 /* read/access error */