adaptions for usage in C++
Stefan Schuermans

Stefan Schuermans commited on 2011-10-22 19:40:19
Showing 11 changed files, with 140 additions and 189 deletions.

... ...
@@ -5,6 +5,10 @@
5 5
 #ifndef INC_BlinkenLib_BlinkenColorizer
6 6
 #define INC_BlinkenLib_BlinkenColorizer
7 7
 
8
+#ifdef __cplusplus
9
+extern "C" {
10
+#endif
11
+
8 12
 // convert string to colorizing mode
9 13
 // returns colorizing mode (>= 0) or -1 on error
10 14
 int BlinkenColorizerStr2Mode(const char *str);
... ...
@@ -16,4 +20,8 @@ const char *BlinkenColorizerMode2Str(int mode);
16 20
 unsigned char BlinkenColorizerGetColor(int channels, int mode, int step,
17 21
                                        int y, int x, int c);
18 22
 
23
+#ifdef __cplusplus
24
+} // extern "C"
25
+#endif
26
+
19 27
 #endif // #ifndef INC_BlinkenLib_BlinkenColorizer
... ...
@@ -90,7 +90,7 @@ stBlinkenFrame *BlinkenFrameNew(int height, int width, int channels,
90 90
   pFrame->duration = duration;
91 91
 
92 92
   pFrame->ppData =
93
-      (unsigned char **)malloc2D(height, width * channels,
93
+      (unsigned char **)BlinkenMalloc2D(height, width * channels,
94 94
                                         sizeof(unsigned char));
95 95
   if (pFrame->ppData == NULL) {
96 96
     free(pFrame);
... ...
@@ -395,7 +395,7 @@ void BlinkenFrameResize(stBlinkenFrame *pFrame, int height, int width,
395 395
 
396 396
   // allocate new data array
397 397
   ppData =
398
-      (unsigned char **)malloc2D(height, width * channels,
398
+      (unsigned char **)BlinkenMalloc2D(height, width * channels,
399 399
                                         sizeof(unsigned char));
400 400
   if (ppData == NULL)
401 401
     return;
... ...
@@ -491,7 +491,7 @@ void BlinkenFrameScale(stBlinkenFrame *pFrame, int height, int width)
491 491
 
492 492
   // allocate new data array
493 493
   ppData =
494
-      (unsigned char **)malloc2D(height, width * pFrame->channels,
494
+      (unsigned char **)BlinkenMalloc2D(height, width * pFrame->channels,
495 495
                                         sizeof(unsigned char));
496 496
   if (ppData == NULL)
497 497
     return;
... ...
@@ -612,7 +612,8 @@ void BlinkenFrameColorize(stBlinkenFrame *pFrame, int channels, int mode,
612 612
 
613 613
   // allocate new data array
614 614
   ppData =
615
-      (unsigned char **)malloc2D(pFrame->height, pFrame->width * channels,
615
+      (unsigned char **)BlinkenMalloc2D(pFrame->height,
616
+                                        pFrame->width * channels,
616 617
                                         sizeof(unsigned char));
617 618
   if (ppData == NULL)
618 619
     return;
... ...
@@ -869,7 +870,7 @@ int BlinkenFrameToNetwork(stBlinkenFrame *pFrame, etBlinkenProto proto,
869 870
   }
870 871
 }
871 872
 
872
-stBlinkenFrame *BlinkenFrameFromNetwork(char *pData, int length,
873
+stBlinkenFrame *BlinkenFrameFromNetwork(const char *pData, int length,
873 874
                                         etBlinkenProto * pProto)
874 875
 // returns protocol in *pProto if pProto not NULL
875 876
 {
... ...
@@ -881,32 +882,14 @@ stBlinkenFrame *BlinkenFrameFromNetwork(char *pData, int length,
881 882
   {
882 883
     if (pProto != NULL) // return protocol
883 884
       *pProto = BlinkenProtoBlp;
884
-    height = ntohs(((stBlinkenProtoBlpHdr *) pData)->height);   // get header 
885
-                                                                // 
886
-    // 
887
-    // 
888
-    // 
889
-    // 
890
-    // data
885
+    // get header data
886
+    height = ntohs(((stBlinkenProtoBlpHdr *) pData)->height);
891 887
     width = ntohs(((stBlinkenProtoBlpHdr *) pData)->width);
892
-    if (length < (int)sizeof(stBlinkenProtoBlpHdr) + height * width)    // check 
893
-                                                                        // 
894
-      // 
895
-      // 
896
-      // 
897
-      // 
898
-      // length 
899
-      // of 
900
-      // packet
888
+    // check length of packet
889
+    if (length < (int)sizeof(stBlinkenProtoBlpHdr) + height * width)
901 890
       return NULL;
902
-    if (height < BlinkenHeightMin || height > BlinkenHeightMax ||       // check 
903
-                                                                        // 
904
-        // 
905
-        // 
906
-        // 
907
-        // 
908
-        // header 
909
-        // data
891
+    // check header data
892
+    if (height < BlinkenHeightMin || height > BlinkenHeightMax ||
910 893
         width < BlinkenWidthMin || width > BlinkenWidthMax)
911 894
       return NULL;
912 895
     pFrame = BlinkenFrameNew(height, width, 1, 1, 0);   // create frame
... ...
@@ -926,32 +909,14 @@ stBlinkenFrame *BlinkenFrameFromNetwork(char *pData, int length,
926 909
       htonl(BlinkenProtoEblpMagic)) {
927 910
     if (pProto != NULL) // return protocol
928 911
       *pProto = BlinkenProtoEblp;
929
-    height = ntohs(((stBlinkenProtoEblpHdr *) pData)->height);  // get header 
930
-                                                                // 
931
-    // 
932
-    // 
933
-    // 
934
-    // 
935
-    // data
912
+    // get header data
913
+    height = ntohs(((stBlinkenProtoEblpHdr *) pData)->height);
936 914
     width = ntohs(((stBlinkenProtoEblpHdr *) pData)->width);
937
-    if (length < (int)sizeof(stBlinkenProtoEblpHdr) + width * height)   // check 
938
-                                                                        // 
939
-      // 
940
-      // 
941
-      // 
942
-      // 
943
-      // length 
944
-      // of 
945
-      // packet
915
+    // check length of packet
916
+    if (length < (int)sizeof(stBlinkenProtoEblpHdr) + width * height)
946 917
       return NULL;
947
-    if (height < BlinkenHeightMin || height > BlinkenHeightMax ||       // check 
948
-                                                                        // 
949
-        // 
950
-        // 
951
-        // 
952
-        // 
953
-        // header 
954
-        // data
918
+    // check header data
919
+    if (height < BlinkenHeightMin || height > BlinkenHeightMax ||
955 920
         width < BlinkenWidthMin || width > BlinkenWidthMax)
956 921
       return NULL;
957 922
     pFrame = BlinkenFrameNew(height, width, 1, 255, 0); // create frame
... ...
@@ -971,49 +936,22 @@ stBlinkenFrame *BlinkenFrameFromNetwork(char *pData, int length,
971 936
       htonl(BlinkenProtoMcufMagic)) {
972 937
     if (pProto != NULL) // return protocol
973 938
       *pProto = BlinkenProtoMcuf;
974
-    height = ntohs(((stBlinkenProtoMcufHdr *) pData)->height);  // get header 
975
-                                                                // 
976
-    // 
977
-    // 
978
-    // 
979
-    // 
980
-    // data
939
+    // get header data
940
+    height = ntohs(((stBlinkenProtoMcufHdr *) pData)->height);
981 941
     width = ntohs(((stBlinkenProtoMcufHdr *) pData)->width);
982 942
     channels = ntohs(((stBlinkenProtoMcufHdr *) pData)->channels);
983 943
     maxval = ntohs(((stBlinkenProtoMcufHdr *) pData)->maxval);
984
-    if (length < (int)sizeof(stBlinkenProtoMcufHdr) + height * width * channels)        // check 
985
-                                                                                        // 
986
-      // 
987
-      // 
988
-      // 
989
-      // 
990
-      // length 
991
-      // of 
992
-      // packet
944
+    // check length of packet
945
+    if (length < (int)sizeof(stBlinkenProtoMcufHdr) + height * width * channels)
993 946
       return NULL;
994
-    if (height < BlinkenHeightMin || height > BlinkenHeightMax ||       // check 
995
-                                                                        // 
996
-        // 
997
-        // 
998
-        // 
999
-        // 
1000
-        // header 
1001
-        // data
947
+    // check header data
948
+    if (height < BlinkenHeightMin || height > BlinkenHeightMax ||
1002 949
         width < BlinkenWidthMin || width > BlinkenWidthMax ||
1003 950
         channels < BlinkenChannelsMin || channels > BlinkenChannelsMax ||
1004 951
         maxval < BlinkenMaxvalMin || maxval > BlinkenMaxvalMax)
1005 952
       return NULL;
1006
-    pFrame = BlinkenFrameNew(height, width, channels, maxval, 0);       // create 
1007
-                                                                        // 
1008
-    // 
1009
-    // 
1010
-    // 
1011
-    // 
1012
-    // frame 
1013
-    // according 
1014
-    // to 
1015
-    // header 
1016
-    // data
953
+    // create frame according to header data
954
+    pFrame = BlinkenFrameNew(height, width, channels, maxval, 0);
1017 955
     if (pFrame == NULL)
1018 956
       return NULL;
1019 957
     i = sizeof(stBlinkenProtoMcufHdr);  // put data into frame
... ...
@@ -5,6 +5,10 @@
5 5
 #ifndef INC_BlinkenLib_BlinkenFrame
6 6
 #define INC_BlinkenLib_BlinkenFrame
7 7
 
8
+#ifdef __cplusplus
9
+extern "C" {
10
+#endif
11
+
8 12
 typedef struct sBlinkenFrame stBlinkenFrame;
9 13
 
10 14
 typedef enum eBlinkenProto { BlinkenProtoNone, BlinkenProtoBlp,
... ...
@@ -58,8 +62,12 @@ int BlinkenFrameToNetwork(stBlinkenFrame *pFrame, etBlinkenProto proto,
58 62
                           char *pData, int maxLength);
59 63
 // returns length or -1 on error
60 64
 
61
-stBlinkenFrame *BlinkenFrameFromNetwork(char *pData, int length,
65
+stBlinkenFrame *BlinkenFrameFromNetwork(const char *pData, int length,
62 66
                                         etBlinkenProto * pProto);
63 67
 // returns protocol in *pProto if pProto not NULL
64 68
 
69
+#ifdef __cplusplus
70
+} // extern "C"
71
+#endif
72
+
65 73
 #endif // #ifndef INC_BlinkenLib_BlinkenFrame
... ...
@@ -231,7 +231,7 @@ void BlMng_compress_frame(stBlinkenFrame *frame, unsigned char **p_out_ptr,
231 231
 }
232 232
 
233 233
 // load a MNG file as BlinkenMovie
234
-stBlinkenMovie *BlinkenMngLoad(char *pFilename)
234
+stBlinkenMovie *BlinkenMngLoad(const char *pFilename)
235 235
 {
236 236
   BlMng_userdata *data;
237 237
   mng_handle hMNG;
... ...
@@ -367,7 +367,7 @@ stBlinkenMovie *BlinkenMngLoad(char *pFilename)
367 367
   return movie;
368 368
 }
369 369
 
370
-int BlinkenMngSave(stBlinkenMovie *pMovie, char *pFilename)
370
+int BlinkenMngSave(stBlinkenMovie *pMovie, const char *pFilename)
371 371
 {
372 372
   BlMng_userdata *data;
373 373
   mng_handle hMNG;
... ...
@@ -13,8 +13,16 @@
13 13
 #error This file is to be used for MNG support only.
14 14
 #endif // #ifndef BLINKENLIB_CFG_MNG
15 15
 
16
-stBlinkenMovie *BlinkenMngLoad(char *pFilename);
16
+#ifdef __cplusplus
17
+extern "C" {
18
+#endif
17 19
 
18
-int BlinkenMngSave(stBlinkenMovie *pMovie, char *pFilename);
20
+stBlinkenMovie *BlinkenMngLoad(const char *pFilename);
21
+
22
+int BlinkenMngSave(stBlinkenMovie *pMovie, const char *pFilename);
23
+
24
+#ifdef __cplusplus
25
+} // extern "C"
26
+#endif
19 27
 
20 28
 #endif // #ifndef INC_BlinkenLib_BlinkenMng
... ...
@@ -94,14 +94,14 @@ stBlinkenMovie *BlinkenMovieNew(int height, int width, int channels,
94 94
   pMovie->channels = channels;
95 95
   pMovie->maxval = maxval;
96 96
   pMovie->infoCnt = 0;
97
-  pMovie->pppInfos = (char ***)malloc2D(0, 2, sizeof(char *));
97
+  pMovie->pppInfos = (char ***)BlinkenMalloc2D(0, 2, sizeof(char *));
98 98
   if (pMovie->pppInfos == NULL) {
99 99
     free(pMovie);
100 100
     return NULL;
101 101
   }
102 102
   pMovie->frameCnt = 0;
103 103
   pMovie->ppFrames =
104
-      (stBlinkenFrame **) malloc1D(0, sizeof(stBlinkenFrame *));
104
+      (stBlinkenFrame **) BlinkenMalloc1D(0, sizeof(stBlinkenFrame *));
105 105
   if (pMovie->ppFrames == NULL) {
106 106
     free(pMovie->pppInfos);
107 107
     free(pMovie);
... ...
@@ -233,8 +233,8 @@ char *BlinkenMovieGetInfoData(stBlinkenMovie *pMovie, int infoNo)
233 233
   return pMovie->pppInfos[infoNo][1];
234 234
 }
235 235
 
236
-void BlinkenMovieSetInfo(stBlinkenMovie *pMovie, int infoNo, char *pInfoType,
237
-                         char *pInfoData)
236
+void BlinkenMovieSetInfo(stBlinkenMovie *pMovie, int infoNo,
237
+                         const char *pInfoType, const char *pInfoData)
238 238
 {
239 239
   char *pType, *pData;
240 240
 
... ...
@@ -257,7 +257,7 @@ void BlinkenMovieSetInfo(stBlinkenMovie *pMovie, int infoNo, char *pInfoType,
257 257
 }
258 258
 
259 259
 void BlinkenMovieInsertInfo(stBlinkenMovie *pMovie, int infoNo,
260
-                            char *pInfoType, char *pInfoData)
260
+                            const char *pInfoType, const char *pInfoData)
261 261
 {
262 262
   char ***pppNewInfos, *pType, *pData;
263 263
   int i;
... ...
@@ -265,7 +265,8 @@ void BlinkenMovieInsertInfo(stBlinkenMovie *pMovie, int infoNo,
265 265
   if (pMovie == NULL || infoNo < 0 || infoNo > pMovie->infoCnt)
266 266
     return;
267 267
 
268
-  pppNewInfos = (char ***)malloc2D(pMovie->infoCnt + 1, 2, sizeof(char *));
268
+  pppNewInfos = (char ***)BlinkenMalloc2D(pMovie->infoCnt + 1, 2,
269
+                                          sizeof(char *));
269 270
   if (pppNewInfos == NULL)
270 271
     return;
271 272
 
... ...
@@ -299,8 +300,8 @@ void BlinkenMovieInsertInfo(stBlinkenMovie *pMovie, int infoNo,
299 300
   pMovie->infoCnt++;
300 301
 }
301 302
 
302
-void BlinkenMovieAppendInfo(stBlinkenMovie *pMovie, char *pInfoType,
303
-                            char *pInfoData)
303
+void BlinkenMovieAppendInfo(stBlinkenMovie *pMovie, const char *pInfoType,
304
+                            const char *pInfoData)
304 305
 {
305 306
   if (pMovie == NULL)
306 307
     return;
... ...
@@ -316,7 +317,8 @@ void BlinkenMovieDeleteInfo(stBlinkenMovie *pMovie, int infoNo)
316 317
   if (pMovie == NULL || infoNo < 0 || infoNo >= pMovie->infoCnt)
317 318
     return;
318 319
 
319
-  pppNewInfos = (char ***)malloc2D(pMovie->infoCnt - 1, 2, sizeof(char *));
320
+  pppNewInfos = (char ***)BlinkenMalloc2D(pMovie->infoCnt - 1, 2,
321
+                                          sizeof(char *));
320 322
   if (pppNewInfos == NULL)
321 323
     return;
322 324
 
... ...
@@ -346,7 +348,7 @@ void BlinkenMovieDeleteInfos(stBlinkenMovie *pMovie)
346 348
   if (pMovie == NULL)
347 349
     return;
348 350
 
349
-  pppNewInfos = (char ***)malloc2D(0, 2, sizeof(char *));
351
+  pppNewInfos = (char ***)BlinkenMalloc2D(0, 2, sizeof(char *));
350 352
   if (pppNewInfos == NULL)
351 353
     return;
352 354
 
... ...
@@ -401,7 +403,7 @@ int BlinkenMovieInsertFrame(stBlinkenMovie *pMovie, int frameNo,
401 403
     return -1;
402 404
 
403 405
   ppNewFrames =
404
-      (stBlinkenFrame **) malloc1D(pMovie->frameCnt + 1,
406
+      (stBlinkenFrame **) BlinkenMalloc1D(pMovie->frameCnt + 1,
405 407
                                           sizeof(stBlinkenFrame *));
406 408
   if (ppNewFrames == NULL)
407 409
     return -1;
... ...
@@ -438,8 +440,7 @@ void BlinkenMovieDeleteFrame(stBlinkenMovie *pMovie, int frameNo)
438 440
   if (pMovie == NULL || frameNo < 0 || frameNo >= pMovie->frameCnt)
439 441
     return;
440 442
 
441
-  ppNewFrames =
442
-      (stBlinkenFrame **) malloc1D(pMovie->frameCnt - 1,
443
+  ppNewFrames = (stBlinkenFrame **)BlinkenMalloc1D(pMovie->frameCnt - 1,
443 444
                                                    sizeof(stBlinkenFrame *));
444 445
   if (ppNewFrames == NULL)
445 446
     return;
... ...
@@ -465,7 +466,8 @@ void BlinkenMovieDeleteFrames(stBlinkenMovie *pMovie)
465 466
   if (pMovie == NULL)
466 467
     return;
467 468
 
468
-  ppNewFrames = (stBlinkenFrame **) malloc1D(0, sizeof(stBlinkenFrame *));
469
+  ppNewFrames =
470
+      (stBlinkenFrame **)BlinkenMalloc1D(0, sizeof(stBlinkenFrame *));
469 471
   if (ppNewFrames == NULL)
470 472
     return;
471 473
 
... ...
@@ -477,10 +479,8 @@ void BlinkenMovieDeleteFrames(stBlinkenMovie *pMovie)
477 479
   pMovie->frameCnt = 0;
478 480
 }
479 481
 
480
-int BlinkenMovieConcat(stBlinkenMovie *pMovie, stBlinkenMovie *pMovie2        /* appended 
481
-                                                                                   and 
482
-                                                                                   freed 
483
-                                                                                 */ )
482
+int BlinkenMovieConcat(stBlinkenMovie *pMovie,
483
+                       stBlinkenMovie *pMovie2 /* appended and freed */)
484 484
 {
485 485
   stBlinkenFrame **ppNewFrames, **ppNewFrames2;
486 486
   int i;
... ...
@@ -492,11 +492,11 @@ int BlinkenMovieConcat(stBlinkenMovie *pMovie, stBlinkenMovie *pMovie2        /*
492 492
                      pMovie->maxval);
493 493
 
494 494
   ppNewFrames =
495
-      (stBlinkenFrame **) malloc1D(pMovie->frameCnt + pMovie2->frameCnt,
495
+      (stBlinkenFrame **)BlinkenMalloc1D(pMovie->frameCnt + pMovie2->frameCnt,
496 496
                                          sizeof(stBlinkenFrame *));
497 497
   if (ppNewFrames == NULL)
498 498
     return -1;
499
-  ppNewFrames2 = (stBlinkenFrame **) malloc1D(0, sizeof(stBlinkenFrame *));
499
+  ppNewFrames2 = (stBlinkenFrame **)BlinkenMalloc1D(0, sizeof(stBlinkenFrame *));
500 500
   if (ppNewFrames2 == NULL) {
501 501
     free(ppNewFrames);
502 502
     return -1;
... ...
@@ -691,7 +691,7 @@ char *BlinkenMovieToString(stBlinkenMovie *pMovie)
691 691
   if (pMovie == NULL)
692 692
     return NULL;
693 693
 
694
-  strs = (char **)malloc1D(pMovie->frameCnt, sizeof(char *));
694
+  strs = (char **)BlinkenMalloc1D(pMovie->frameCnt, sizeof(char *));
695 695
   if (strs == NULL)
696 696
     return NULL;
697 697
 
... ...
@@ -741,7 +741,7 @@ char *BlinkenMovieToString(stBlinkenMovie *pMovie)
741 741
   return str;
742 742
 }
743 743
 
744
-stBlinkenMovie *BlinkenMovieLoadBlm(char *pFilename)
744
+stBlinkenMovie *BlinkenMovieLoadBlm(const char *pFilename)
745 745
 {
746 746
   FILE *pFile;
747 747
   stBlinkenMovie *pMovie;
... ...
@@ -800,13 +800,8 @@ stBlinkenMovie *BlinkenMovieLoadBlm(char *pFilename)
800 800
     else if (fscanf(pFile, "%1[01]", pixel) == 1) {
801 801
       if (pFrame != NULL) {
802 802
         for (x = 0;; x++) {
803
-          BlinkenFrameSetPixel(pFrame, y, x, 0, (unsigned char)(pixel[0] == '1' ? 1 : 0));      // set 
804
-                                                                                                // 
805
-          // 
806
-          // 
807
-          // 
808
-          // 
809
-          // pixel
803
+          BlinkenFrameSetPixel(pFrame, y, x, 0, // set pixel
804
+                               (unsigned char)(pixel[0] == '1' ? 1 : 0));
810 805
           if (fscanf(pFile, "%1[01]", pixel) != 1)      // read next pixel
811 806
             break;
812 807
         }
... ...
@@ -822,7 +817,7 @@ stBlinkenMovie *BlinkenMovieLoadBlm(char *pFilename)
822 817
   return pMovie;
823 818
 }
824 819
 
825
-stBlinkenMovie *BlinkenMovieLoadBmm(char *pFilename)
820
+stBlinkenMovie *BlinkenMovieLoadBmm(const char *pFilename)
826 821
 {
827 822
   FILE *pFile;
828 823
   stBlinkenMovie *pMovie;
... ...
@@ -883,13 +878,8 @@ stBlinkenMovie *BlinkenMovieLoadBmm(char *pFilename)
883 878
         for (x = 0;; x++) {
884 879
           if (sscanf(pixel, "%i", &val) != 1)   // convert pixel to number
885 880
             break;
886
-          BlinkenFrameSetPixel(pFrame, y, x, 0, (unsigned char)val);    // set 
887
-                                                                        // 
888
-          // 
889
-          // 
890
-          // 
891
-          // 
892
-          // pixel
881
+          BlinkenFrameSetPixel(pFrame, y, x, 0, // set pixel
882
+                               (unsigned char)val);
893 883
           fscanf(pFile, "%*[ \t]");     // kill space
894 884
           if (fscanf(pFile, "%7[0-9A-FXa-fx]", pixel) != 1)     // read next
895 885
             // pixel
... ...
@@ -907,7 +897,7 @@ stBlinkenMovie *BlinkenMovieLoadBmm(char *pFilename)
907 897
   return pMovie;
908 898
 }
909 899
 
910
-stBlinkenMovie *BlinkenMovieLoadBml(char *pFilename)
900
+stBlinkenMovie *BlinkenMovieLoadBml(const char *pFilename)
911 901
 {
912 902
   FILE *pFile;
913 903
   stBlinkenMovie *pMovie;
... ...
@@ -972,21 +962,8 @@ stBlinkenMovie *BlinkenMovieLoadBml(char *pFilename)
972 962
         // get number of characters per channel
973 963
         chrs = (bits + 3) >> 2;
974 964
         // get fscanf formart string for reading a pixel
975
-        sprintf(pixelFormat, "%%%d[0-9A-Fa-f]", chrs > 4 ? 5 : chrs);   // read 
976
-                                                                        // 
977
-        // 
978
-        // 
979
-        // 
980
-        // 
981
-        // max 
982
-        // 5
983
-        // chars 
984
-        // (2 
985
-        // already 
986
-        // in 
987
-        // use 
988
-        // by 
989
-        // prefix)
965
+        //   read max 5 chars (2 already in use by prefix)
966
+        sprintf(pixelFormat, "%%%d[0-9A-Fa-f]", chrs > 4 ? 5 : chrs);
990 967
         // initialize pixel buffer with hex prefix
991 968
         strcpy(pixel, "0x");
992 969
       }
... ...
@@ -1085,7 +1062,7 @@ stBlinkenMovie *BlinkenMovieLoadBml(char *pFilename)
1085 1062
   return pMovie;
1086 1063
 }
1087 1064
 
1088
-stBlinkenMovie *BlinkenMovieLoadBbm(char *pFilename)
1065
+stBlinkenMovie *BlinkenMovieLoadBbm(const char *pFilename)
1089 1066
 {
1090 1067
   FILE *pFile;
1091 1068
   stBlinkenMovie *pMovie;
... ...
@@ -1255,14 +1232,14 @@ stBlinkenMovie *BlinkenMovieLoadBbm(char *pFilename)
1255 1232
 
1256 1233
 #ifdef BLINKENLIB_CFG_MNG
1257 1234
 
1258
-stBlinkenMovie *BlinkenMovieLoadMng(char *pFilename)
1235
+stBlinkenMovie *BlinkenMovieLoadMng(const char *pFilename)
1259 1236
 {
1260 1237
   return BlinkenMngLoad(pFilename);
1261 1238
 }
1262 1239
 
1263 1240
 #endif // #ifdef BLINKENLIB_CFG_MNG
1264 1241
 
1265
-stBlinkenMovie *BlinkenMovieLoad(char *pFilename)
1242
+stBlinkenMovie *BlinkenMovieLoad(const char *pFilename)
1266 1243
 {
1267 1244
   int len;
1268 1245
 
... ...
@@ -1285,7 +1262,7 @@ stBlinkenMovie *BlinkenMovieLoad(char *pFilename)
1285 1262
   return NULL;
1286 1263
 }
1287 1264
 
1288
-int BlinkenMovieSaveBlm(stBlinkenMovie *pMovie, char *pFilename)
1265
+int BlinkenMovieSaveBlm(stBlinkenMovie *pMovie, const char *pFilename)
1289 1266
 {
1290 1267
   stBlinkenMovie *pOutMovie;
1291 1268
   FILE *pFile;
... ...
@@ -1340,7 +1317,7 @@ int BlinkenMovieSaveBlm(stBlinkenMovie *pMovie, char *pFilename)
1340 1317
   return 0;
1341 1318
 }
1342 1319
 
1343
-int BlinkenMovieSaveBmm(stBlinkenMovie *pMovie, char *pFilename)
1320
+int BlinkenMovieSaveBmm(stBlinkenMovie *pMovie, const char *pFilename)
1344 1321
 {
1345 1322
   stBlinkenMovie *pOutMovie;
1346 1323
   FILE *pFile;
... ...
@@ -1394,7 +1371,7 @@ int BlinkenMovieSaveBmm(stBlinkenMovie *pMovie, char *pFilename)
1394 1371
   return 0;
1395 1372
 }
1396 1373
 
1397
-int BlinkenMovieSaveBml(stBlinkenMovie *pMovie, char *pFilename)
1374
+int BlinkenMovieSaveBml(stBlinkenMovie *pMovie, const char *pFilename)
1398 1375
 {
1399 1376
   stBlinkenMovie *pOutMovie;
1400 1377
   FILE *pFile;
... ...
@@ -1477,7 +1454,7 @@ int BlinkenMovieSaveBml(stBlinkenMovie *pMovie, char *pFilename)
1477 1454
   return 0;
1478 1455
 }
1479 1456
 
1480
-int BlinkenMovieSaveBbm(stBlinkenMovie *pMovie, char *pFilename)
1457
+int BlinkenMovieSaveBbm(stBlinkenMovie *pMovie, const char *pFilename)
1481 1458
 {
1482 1459
   unsigned char *pFrameData;
1483 1460
   FILE *pFile;
... ...
@@ -1596,14 +1573,14 @@ int BlinkenMovieSaveBbm(stBlinkenMovie *pMovie, char *pFilename)
1596 1573
 
1597 1574
 #ifdef BLINKENLIB_CFG_MNG
1598 1575
 
1599
-int BlinkenMovieSaveMng(stBlinkenMovie *pMovie, char *pFilename)
1576
+int BlinkenMovieSaveMng(stBlinkenMovie *pMovie, const char *pFilename)
1600 1577
 {
1601 1578
   return BlinkenMngSave(pMovie, pFilename);
1602 1579
 }
1603 1580
 
1604 1581
 #endif // #ifdef BLINKENLIB_CFG_MNG
1605 1582
 
1606
-int BlinkenMovieSave(stBlinkenMovie *pMovie, char *pFilename)
1583
+int BlinkenMovieSave(stBlinkenMovie *pMovie, const char *pFilename)
1607 1584
 {
1608 1585
   int len;
1609 1586
 
... ...
@@ -1681,14 +1658,8 @@ stBlinkenMovie *BlinkenMovieReceive(SOCKET udpSocket, int timeout,
1681 1658
     FD_SET(udpSocket, &readFds);
1682 1659
     timeo.tv_sec = timeout / 1000;
1683 1660
     timeo.tv_usec = (timeout % 1000) * 1000;
1684
-    if (select(udpSocket + 1, &readFds, NULL, NULL, &timeo) <= 0)       // timeout 
1685
-                                                                        // 
1686
-      // 
1687
-      // 
1688
-      // 
1689
-      // 
1690
-      // or 
1691
-      // error
1661
+    // timeout or error
1662
+    if (select(udpSocket + 1, &readFds, NULL, NULL, &timeo) <= 0)
1692 1663
       break;
1693 1664
 
1694 1665
     // fetch data
... ...
@@ -15,6 +15,10 @@
15 15
 #define INVALID_SOCKET -1
16 16
 #endif
17 17
 
18
+#ifdef __cplusplus
19
+extern "C" {
20
+#endif
21
+
18 22
 typedef struct sBlinkenMovie stBlinkenMovie;
19 23
 
20 24
 stBlinkenMovie *BlinkenMovieNew(int height, int width, int channels,
... ...
@@ -33,12 +37,12 @@ int BlinkenMovieGetDuration(stBlinkenMovie *pMovie);
33 37
 int BlinkenMovieGetInfoCnt(stBlinkenMovie *pMovie);
34 38
 char *BlinkenMovieGetInfoType(stBlinkenMovie *pMovie, int infoNo);
35 39
 char *BlinkenMovieGetInfoData(stBlinkenMovie *pMovie, int infoNo);
36
-void BlinkenMovieSetInfo(stBlinkenMovie *pMovie, int infoNo, char *pInfoType,
37
-                         char *pInfoData);
40
+void BlinkenMovieSetInfo(stBlinkenMovie *pMovie, int infoNo,
41
+                         const char *pInfoType, const char *pInfoData);
38 42
 void BlinkenMovieInsertInfo(stBlinkenMovie *pMovie, int infoNo,
39
-                            char *pInfoType, char *pInfoData);
40
-void BlinkenMovieAppendInfo(stBlinkenMovie *pMovie, char *pInfoType,
41
-                            char *pInfoData);
43
+                            const char *pInfoType, const char *pInfoData);
44
+void BlinkenMovieAppendInfo(stBlinkenMovie *pMovie, const char *pInfoType,
45
+                            const char *pInfoData);
42 46
 void BlinkenMovieDeleteInfo(stBlinkenMovie *pMovie, int infoNo);
43 47
 void BlinkenMovieDeleteInfos(stBlinkenMovie *pMovie);
44 48
 
... ...
@@ -52,10 +56,8 @@ int BlinkenMovieAppendFrame(stBlinkenMovie *pMovie, stBlinkenFrame *pFrame);
52 56
 void BlinkenMovieDeleteFrame(stBlinkenMovie *pMovie, int frameNo);
53 57
 void BlinkenMovieDeleteFrames(stBlinkenMovie *pMovie);
54 58
 
55
-int BlinkenMovieConcat(stBlinkenMovie *pMovie, stBlinkenMovie *pMovie2        /* appended 
56
-                                                                                   and 
57
-                                                                                   freed 
58
-                                                                                 */ );
59
+int BlinkenMovieConcat(stBlinkenMovie *pMovie,
60
+                       stBlinkenMovie *pMovie2 /* appended and freed */);
59 61
 void BlinkenMovieReverse(stBlinkenMovie *pMovie);
60 62
 
61 63
 void BlinkenMovieResize(stBlinkenMovie *pMovie, int height, int width,
... ...
@@ -68,23 +70,23 @@ void BlinkenMovieCopyRect(stBlinkenMovie *pDest, int destY, int destX,
68 70
 
69 71
 char *BlinkenMovieToString(stBlinkenMovie *pMovie);
70 72
 
71
-stBlinkenMovie *BlinkenMovieLoadBlm(char *pFilename);
72
-stBlinkenMovie *BlinkenMovieLoadBmm(char *pFilename);
73
-stBlinkenMovie *BlinkenMovieLoadBml(char *pFilename);
74
-stBlinkenMovie *BlinkenMovieLoadBbm(char *pFilename);
73
+stBlinkenMovie *BlinkenMovieLoadBlm(const char *pFilename);
74
+stBlinkenMovie *BlinkenMovieLoadBmm(const char *pFilename);
75
+stBlinkenMovie *BlinkenMovieLoadBml(const char *pFilename);
76
+stBlinkenMovie *BlinkenMovieLoadBbm(const char *pFilename);
75 77
 #ifdef BLINKENLIB_CFG_MNG
76
-stBlinkenMovie *BlinkenMovieLoadMng(char *pFilename);
78
+stBlinkenMovie *BlinkenMovieLoadMng(const char *pFilename);
77 79
 #endif // #ifdef BLINKENLIB_CFG_MNG
78
-stBlinkenMovie *BlinkenMovieLoad(char *pFilename);
80
+stBlinkenMovie *BlinkenMovieLoad(const char *pFilename);
79 81
 
80
-int BlinkenMovieSaveBlm(stBlinkenMovie *pMovie, char *pFilename);
81
-int BlinkenMovieSaveBmm(stBlinkenMovie *pMovie, char *pFilename);
82
-int BlinkenMovieSaveBml(stBlinkenMovie *pMovie, char *pFilename);
83
-int BlinkenMovieSaveBbm(stBlinkenMovie *pMovie, char *pFilename);
82
+int BlinkenMovieSaveBlm(stBlinkenMovie *pMovie, const char *pFilename);
83
+int BlinkenMovieSaveBmm(stBlinkenMovie *pMovie, const char *pFilename);
84
+int BlinkenMovieSaveBml(stBlinkenMovie *pMovie, const char *pFilename);
85
+int BlinkenMovieSaveBbm(stBlinkenMovie *pMovie, const char *pFilename);
84 86
 #ifdef BLINKENLIB_CFG_MNG
85
-int BlinkenMovieSaveMng(stBlinkenMovie *pMovie, char *pFilename);
87
+int BlinkenMovieSaveMng(stBlinkenMovie *pMovie, const char *pFilename);
86 88
 #endif // #ifdef BLINKENLIB_CFG_MNG
87
-int BlinkenMovieSave(stBlinkenMovie *pMovie, char *pFilename);
89
+int BlinkenMovieSave(stBlinkenMovie *pMovie, const char *pFilename);
88 90
 
89 91
 void BlinkenMovieSend(stBlinkenMovie *pMovie, SOCKET udpSocket,
90 92
                       etBlinkenProto proto, int maxidle);
... ...
@@ -98,4 +100,8 @@ stBlinkenMovie *BlinkenMovieReceive(SOCKET udpSocket, int timeout,
98 100
 // after timeout ms of no reception, the movie is considered to be complete
99 101
 // returns protocol in *pProto if pProto not NULL
100 102
 
103
+#ifdef __cplusplus
104
+} // extern "C"
105
+#endif
106
+
101 107
 #endif // #ifndef INC_BlinkenLib_BlinkenMovie
... ...
@@ -6,7 +6,7 @@
6 6
 
7 7
 #include <BlinkenLib/Tools.h>
8 8
 
9
-void *malloc1D(int count1, int size)
9
+void *BlinkenMalloc1D(int count1, int size)
10 10
 {
11 11
   if (count1 < 1)
12 12
     count1 = 1;
... ...
@@ -16,7 +16,7 @@ void *malloc1D(int count1, int size)
16 16
   return malloc(count1 * size);
17 17
 }
18 18
 
19
-void **malloc2D(int count1, int count2, int size)
19
+void **BlinkenMalloc2D(int count1, int count2, int size)
20 20
 {
21 21
   int sz, i;
22 22
   char *p;
... ...
@@ -17,8 +17,16 @@
17 17
 #define arr_cnt( arr ) (sizeof( (arr) ) / sizeof( (arr)[0] ))
18 18
 #endif
19 19
 
20
-void *malloc1D(int count1, int size);
20
+#ifdef __cplusplus
21
+extern "C" {
22
+#endif
23
+
24
+void *BlinkenMalloc1D(int count1, int size);
21 25
 
22
-void **malloc2D(int count1, int count2, int size);
26
+void **BlinkenMalloc2D(int count1, int count2, int size);
27
+
28
+#ifdef __cplusplus
29
+} // extern "C"
30
+#endif
23 31
 
24 32
 #endif // #ifndef INC_BlinkenLib_Tools
... ...
@@ -1,3 +1,7 @@
1
+0.6.8 2011-10-22
2
+----------------
3
+adpations for usage in C++ code
4
+
1 5
 0.6.7 2011-10-16
2 6
 ----------------
3 7
 added copying rectangular section to BlinkenConv
... ...
@@ -1,5 +1,5 @@
1 1
 VERSION_MAJOR=0
2 2
 VERSION_MINOR=6
3
-VERSION_REVISION=7
3
+VERSION_REVISION=8
4 4
 VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)
5 5
 
6 6