]> git.webhop.me Git - msgbox.git/commitdiff
- introduce current.h to unify console messages and ...
authorsvenhoefer <svenhoefer@svenhoefer.com>
Sun, 27 Nov 2016 22:22:14 +0000 (23:22 +0100)
committersvenhoefer <svenhoefer@svenhoefer.com>
Sun, 27 Nov 2016 22:22:14 +0000 (23:22 +0100)
to simplify includes in gfx, io and text

current.h [new file with mode: 0644]
gfx.c
io.c
msgbox.c
text.c
text.h
txtform.c

diff --git a/current.h b/current.h
new file mode 100644 (file)
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 c96ceed0b7c99748052357fd42e03d2adc6d0185..67288fc1288a34443989540fafe49df070258c82 100644 (file)
--- 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 16453479bda4cc2456e9b5f0f8ea6d5c5b489c43..38fae446f766fae293a8c27624129f6fa25cc05f 100644 (file)
--- a/io.c
+++ b/io.c
@@ -16,9 +16,9 @@
 #include <linux/input.h>
 #include <poll.h>
 #include <stdint.h>
-#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 <open remote control>");
+               perror(__plugin__ " <open remote control>");
                exit(1);
        }
        fcntl(rc, F_SETFL, O_NONBLOCK | O_SYNC);
index 4403d497b99a376775de528ace2d9c58cf14614d..95bad142a1f7eb9cda20cdc7b66e7a968955fd22 100644 (file)
--- a/msgbox.c
+++ b/msgbox.c
@@ -2,7 +2,9 @@
 #include <stdio.h>
 #include <time.h>
 #include <signal.h>
-#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 <Out of memory>\n";
+const char NOMEM[]="MsgBox <Out of memory>\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 <invalid Text-Format>\n");
+                               printf(__plugin__ " <invalid Text-Format>\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 <param error: %s>\n",aptr);
+                                       printf("%s <param error: %s>\n", __plugin__, aptr);
                                        return 0;
                                        break;
                                
                                case 2:
-                                       printf("msgbox <unknown command: %s>\n\n",aptr);
+                                       printf("%s <unknown command: %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 <param error: default=%d>\n",selection);
+                               printf("%s <param error: default=%d>\n", __plugin__, selection);
                                return 0;
                        }
                }
@@ -689,7 +691,7 @@ FILE *fh;
                fb = open(FB_DEVICE, O_RDWR);
                if(fb == -1)
                {
-                       perror("msgbox <open framebuffer device>");
+                       perror(__plugin__ " <open framebuffer device>");
                        exit(1);
                }
 
@@ -705,18 +707,18 @@ FILE *fh;
 
                if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
                {
-                       perror("msgbox <FBIOGET_FSCREENINFO>\n");
+                       perror(__plugin__ " <FBIOGET_FSCREENINFO>\n");
                        return -1;
                }
                if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
                {
-                       perror("msgbox <FBIOGET_VSCREENINFO>\n");
+                       perror(__plugin__ " <FBIOGET_VSCREENINFO>\n");
                        return -1;
                }
 
                if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
                {
-                       perror("msgbox <mapping of Framebuffer>\n");
+                       perror(__plugin__ " <mapping of Framebuffer>\n");
                        return -1;
                }
                
@@ -724,14 +726,14 @@ FILE *fh;
 
                if((error = FT_Init_FreeType(&library)))
                {
-                       printf("msgbox <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
+                       printf("%s <FT_Init_FreeType failed with Errorcode 0x%.2X>", __plugin__, error);
                        munmap(lfb, fix_screeninfo.smem_len);
                        return -1;
                }
 
                if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
                {
-                       printf("msgbox <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
+                       printf("%s <FTC_Manager_New failed with Errorcode 0x%.2X>\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 <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
+                       printf("%s <FTC_SBitCache_New failed with Errorcode 0x%.2X>\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 <FTC_Manager_LookupFace failed with Errorcode 0x%.2X>\n", error);
+                               printf("%s <FTC_Manager_LookupFace failed with Errorcode 0x%.2X>\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 <allocating of Backbuffer>\n");
+                       perror(__plugin__ " <allocating of Backbuffer>\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 <allocating of Backbuffer>\n");
+                       perror(__plugin__ " <allocating of Backbuffer>\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 <allocating of Backbuffer>\n");
+                       perror(__plugin__ " <allocating of Backbuffer>\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 <allocating of Backbuffer>\n");
+                       perror(__plugin__ " <allocating of Backbuffer>\n");
                        FTC_Manager_Done(manager);
                        FT_Done_FreeType(library);
                        free(lbb);
diff --git a/text.c b/text.c
index 2569d572b69f3312750fb2fb61f4d5ff7925d502..f1a52dcd7feff0b36108f7ff5c3466b5403f2c6e 100644 (file)
--- 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 <Font \"%s\" failed>\n", (char*)face_id);
+       if (result)
+               printf("%s <Font \"%s\" failed>\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 <FT_Get_Char_Index for Char \"%c\" failed\n", (int)currentchar);
+               printf("%s <FT_Get_Char_Index for Char \"%c\" failed\n", __plugin__, (int)currentchar);
                return 0;
        }
 
        if((err = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, NULL)))
        {
-               printf("msgbox <FTC_SBitCache_Lookup for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
+               printf("%s <FTC_SBitCache_Lookup for Char \"%c\" failed with Errorcode 0x%.2X>\n", __plugin__, (int)currentchar, error);
                return 0;
        }
 
diff --git a/text.h b/text.h
index 3cfe53c5dec95d37da5f67f98ca5553d4d0e3cd7..592f9675fe7f1a4aab4374c61bdf176f6adde06c 100644 (file)
--- 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);
index 52a73626722c5c2263e8a811b2f1312cc3c8bf34..f0086cd2e4738f464cd1cf2b2a59ae237243ea74 100644 (file)
--- a/txtform.c
+++ b/txtform.c
@@ -5,7 +5,8 @@
 #include <unistd.h>
 #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 */