From 69bb94daa370115ef4895f3ffbd28a7d8ccd960e Mon Sep 17 00:00:00 2001 From: Koichi KAMICHI Date: Tue, 20 Apr 2004 05:25:59 +0000 Subject: [PATCH] Unused Glib functions. --- kagecgi/Makefile | 102 ++++---- kagecgi/README.en | 2 - kagecgi/kagecgi.c | 410 ++++++++++++++--------------- kagecgi/kagecgi.h | 58 ++-- kagecgi/kagechar.c | 742 ++++++++++++++++++++++++++-------------------------- kagecgi/kagecomb.c | 10 +- kagecgi/kagedb.c | 238 ++++++++--------- kagecgi/kageeg.c | 54 ++-- kagecgi/kageic.c | 14 +- kagecgi/kagetool.c | 20 +- kagecgi/sysdep.h | 3 +- 11 files changed, 825 insertions(+), 828 deletions(-) diff --git a/kagecgi/Makefile b/kagecgi/Makefile index 9500ba6..3de3da3 100755 --- a/kagecgi/Makefile +++ b/kagecgi/Makefile @@ -1,54 +1,54 @@ -# Makefile -# - -CC=gcc -Wall -INSTALL=install -WGET=wget -BINDIR=/usr/local/bin -SHAREDIR=/usr/local/share/kagecgi -DBURL=http://fonts.jp/kagedb/kagedb - -#for cygwin with glib -#CFLAGS= -I/usr/local/include -I/usr/local/include/glib-2.0 -I/usr/local/include/glib-2.0/glib -I/usr/local/lib/glib-2.0/include -#LIBS= -L/usr/local/lib -lpng -ldb -lglib-2.0 - -#for linux -CFLAGS= -I/usr/local/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -LIBS= -L/usr/local/lib -lpng -ldb -lglib-2.0 - -#for MacOSX with fink -#CFLAGS= -I/sw/include -I/sw/include/db3 -I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include/ -I/sw/include/libpng/ -I/usr/include -#LIBS= -L/sw/lib -lpng -lglib-2.0 -L/usr/lib -ldb - -all: kage.cgi - -kage.cgi: kagecgi.o kagepng.o kagedf.o kagecd.o kageic.o kagepoly.o kagedb.o kageeg.o kagecomb.o kagechar.o kagetool.o - $(CC) $(CFLAGS) -o kage.cgi kagecgi.o kagepng.o kagedf.o kagecd.o kageic.o kagepoly.o kagedb.o kageeg.o kagecomb.o kagechar.o kagetool.o $(LIBS) - -kagecgi.o: kagecgi.c -kagedf.o: kagedf.c -kagecd.o: kagecd.c -kageic.o: kageic.c -kagepoly.o: kagepoly.c -kagedb.o: kagedb.c -kageeg.o: kageeg.c -kagechar.o: kagechar.c -kagecomb.o: kagecomb.c -kagetool.o: kagetool.c -kagepng.o: kagepng.c - -clean: - \rm -r -f *.o *~ *.exe *.cgi *.stackdump kagedb - -install: kage.cgi +# Makefile +# + +CC=gcc -Wall +INSTALL=install +WGET=wget +BINDIR=/usr/local/bin +SHAREDIR=/usr/local/share/kagecgi +DBURL=http://fonts.jp/kagedb/kagedb + +#for cygwin +CFLAGS= +LIBS= -lpng -ldb + +#for linux +#CFLAGS= -I/usr/local/include +#LIBS= -L/usr/local/lib -lpng -ldb + +#for MacOSX with fink +#CFLAGS= -I/sw/include -I/sw/include/db3 -I/sw/include/libpng/ +#LIBS= -L/sw/lib -lpng -ldb + +all: kage.cgi + +kage.cgi: kagecgi.o kagepng.o kagedf.o kagecd.o kageic.o kagepoly.o kagedb.o kageeg.o kagecomb.o kagechar.o kagetool.o kagestr.o + $(CC) $(CFLAGS) -o kage.cgi kagecgi.o kagepng.o kagedf.o kagecd.o kageic.o kagepoly.o kagedb.o kageeg.o kagecomb.o kagechar.o kagetool.o kagestr.o $(LIBS) + +kagecgi.o: kagecgi.c +kagedf.o: kagedf.c +kagecd.o: kagecd.c +kageic.o: kageic.c +kagepoly.o: kagepoly.c +kagedb.o: kagedb.c +kageeg.o: kageeg.c +kagechar.o: kagechar.c +kagecomb.o: kagecomb.c +kagetool.o: kagetool.c +kagepng.o: kagepng.c +kagestr.o: kagestr.c + +clean: + \rm -r -f *.o *~ *.exe *.cgi *.stackdump kagedb + +install: kage.cgi mkdir -p $(BINDIR) - $(INSTALL) -c -m 755 kage.cgi $(BINDIR) - mkdir -p $(SHAREDIR) + $(INSTALL) -c -m 755 kage.cgi $(BINDIR) + mkdir -p $(SHAREDIR) $(INSTALL) -c -m 644 error.png $(SHAREDIR) - -kagedb: - $(WGET) $(DBURL) - -database: kagedb + +kagedb: + $(WGET) $(DBURL) + +database: kagedb $(INSTALL) -c -m 644 kagedb $(SHAREDIR) - diff --git a/kagecgi/README.en b/kagecgi/README.en index c39d2a2..df61ccd 100644 --- a/kagecgi/README.en +++ b/kagecgi/README.en @@ -10,7 +10,6 @@ KAGE/cgi needs following librarys: - Berkely DB 3 - libpng - - glib2.0 CONFIGURATION @@ -19,7 +18,6 @@ CONFIGURATION Please edit `Makefile' fit with your environment. - RUNNING MAKE ============ diff --git a/kagecgi/kagecgi.c b/kagecgi/kagecgi.c index 94caf6f..24fb599 100755 --- a/kagecgi/kagecgi.c +++ b/kagecgi/kagecgi.c @@ -1,205 +1,205 @@ -//kagecgi.c -// - -#include "kage.h" -#include "kagecgi.h" -#include "sysdep.h" - -int main(int argc, char *argv[]){ - GString *tmp1, *tmp2, *test1, *test2, *filename; - FILE *err; - char errbuf[errorFileSize]; - char *pos, *cur; - int dummy; - int type; - - dummy = initDB(); - - //set default - kShotai = kMincho; -// kShotai = kGothic; - kSize = 200; - kType = 0; //png - kInput = 0; //ids or direct - kResultText = g_string_new(""); - kMode = 0; - - //confirm request - type = 0; - //GET request - if(type == 0){ - tmp1 = g_string_new((gchar *)getenv("QUERY_STRING")); - if(tmp1->len != 0) type = 2; - } - //argv(detect after GET request) - if(type == 0){ - tmp1 = g_string_new((gchar *)argv[1]); - if(tmp1->len != 0) type = 1; - } - //redirect - if(type == 0){ - tmp1 = g_string_new((gchar *)getenv("REDIRECT_URL")); - if(tmp1->len != 0) type = 3; - } - //error - if(type == 0){ - fprintf(stderr, "Request Error.\n"); - return 0; - } - pos = tmp1->str; - - //separate token - if(type == 1 || type == 2){ //argv or GET request - while(1){ - cur = strchr(pos, '&'); - tmp2 = g_string_new(pos); - if(cur != NULL) g_string_set_size(tmp2, cur - pos); - //got request string - if(strncmp(tmp2->str, "shotai=mincho", 13) == 0) kShotai = kMincho; - else if(strncmp(tmp2->str, "shotai=gothic", 13) == 0) kShotai = kGothic; - else if(strncmp(tmp2->str, "shotai=skeleton", 15) == 0) kShotai = kGothic; - else if(strncmp(tmp2->str, "type=png", 8) == 0) kType = 0; - else if(strncmp(tmp2->str, "type=svg", 8) == 0) kType = 1; - else if(strncmp(tmp2->str, "type=eps", 8) == 0) kType = 2; - else if(strncmp(tmp2->str, "type=raw", 8) == 0) kType = 3; - else if(strncmp(tmp2->str, "input=ids", 9) == 0) kInput = 0; - else if(strncmp(tmp2->str, "input=directwithadjust", 22) == 0) kInput = 2; - else if(strncmp(tmp2->str, "input=direct", 12) == 0) kInput = 1; - else if(strncmp(tmp2->str, "size=24", 7) == 0) kSize = 24; - else if(strncmp(tmp2->str, "size=200", 8) == 0) kSize = 200; - else test1 = g_string_new(tmp2->str); - if(cur == NULL) break; - pos = cur + 1; - } - } - else{ // redirected request - kInput = 0; - while(1){ - cur = strchr(pos, '/'); - tmp2 = g_string_new(pos); - if(cur != NULL) g_string_set_size(tmp2, cur - pos); - //got request string - if(strncmp(tmp2->str, "mincho", 6) == 0) kShotai = kMincho; - else if(strncmp(tmp2->str, "gothic", 6) == 0) kShotai = kGothic; - else if(strncmp(tmp2->str, "skeleton", 8) == 0) kShotai = kGothic; - else if(strncmp(tmp2->str, "v0.4", 4) == 0); - else test1 = g_string_new(tmp2->str); - if(cur == NULL) break; - pos = cur + 1; - } - if(strncmp(test1->str + test1->len - 4, ".png", 4) == 0) kType = 0; - if(strncmp(test1->str + test1->len - 4, ".svg", 4) == 0) kType = 1; - if(strncmp(test1->str + test1->len - 4, ".eps", 4) == 0) kType = 2; - if(strncmp(test1->str + test1->len - 4, ".raw", 4) == 0) kType = 3; - g_string_set_size(test1, test1->len - 4); - } - - //clear result buffer - test2 = g_string_new(""); - if(kType == 1){ //svg - g_string_append(kResultText, "\n"); - g_string_append(kResultText, "\n"); - g_string_append(kResultText, ""); - } - else if(kType == 2){ //eps - g_string_append(kResultText, "%!PS-Adobe-3.0 EPSF-3.0\n"); - g_string_append(kResultText, "%%BoundingBox: 0 -208 1024 816\n"); - g_string_append(kResultText, "%%Pages: 0\n"); - g_string_append(kResultText, "%%Title: "); - g_string_append(kResultText, test1->str); - g_string_append(kResultText, "\n"); - g_string_append(kResultText, "%%Creator: KAGE System\n"); - g_string_append(kResultText, "%%CreationDate: 00:00 1-1-2004\n"); - g_string_append(kResultText, "%%EndComments\n"); - g_string_append(kResultText, "%%EndProlog\n"); - g_string_append(kResultText, "%%Page \""); - g_string_append(kResultText, test1->str); - g_string_append(kResultText, "\" 1\n"); - g_string_append(kResultText, "newpath\n"); - } - kageCanvas = initPng(canvasWidth, canvasHeight); - if(kInput == 0) generateGlyph(test1, test2); - else{ - convert99(test1, test2); - // g_string_append(test2, test1->str); - } - - if(kType == 0){ //png(image) - if(test2->len != 0){ - if(kInput != 1){ //0 and 2 - test2 = CalcSizes(test2, 1); - } - DrawBox(); - drawGlyph(test2, 0); - //output to file - filename = g_string_new(pngFilePath); - if(kShotai == kMincho) g_string_append(filename, "mincho/"); - else if(kShotai == kGothic) g_string_append(filename, "gothic/");//skeleton?? - g_string_append(filename, test1->str); - g_string_append(filename, ".png"); - -//skip for adjustment mode -// fp = fopen(filename->str, "w"); -// writePng(pngWidth, pngHeight, kageCanvas, fp); -// fclose(fp); - //output to stdout - if(type != 1) fprintf(stdout, "Content-type: image/png\n\n"); - writePng(pngWidth, pngHeight, kageCanvas, stdout); - //done - closePng(pngWidth, pngHeight, kageCanvas); - } - else{ - err = fopen(errorFileName, "r"); - fread(errbuf, sizeof(char), errorFileSize, err); - // printf("An error occurred.\r\n"); - if(type != 1) fprintf(stdout, "Content-type: image/png\n\n"); - fwrite(errbuf, sizeof(char), errorFileSize, stdout); - fclose(err); - } - } - else if(kType == 1){ //svg(vector graphics) - if(test2->len != 0){ - test2 = CalcSizes(test2, 1); - kMode = 1; - drawGlyph(test2, 0); - g_string_append(kResultText, "\n"); - if(type != 1) fprintf(stdout, "Content-type: image/svg-xml\n\n"); - fprintf(stdout, "%s", kResultText->str); - } - else{ - if(type != 1) fprintf(stdout, "Content-type: text/plain\n\n"); - fprintf(stdout, "An error occurred."); - } - } - else if(kType == 2){ //eps(vector graphics) - if(test2->len != 0){ - test2 = CalcSizes(test2, 1); - kMode = 2; - drawGlyph(test2, 0); - g_string_append(kResultText, "fill\n"); - g_string_append(kResultText, "%%EOF\n"); - if(type != 1) fprintf(stdout, "Content-type: application/postscript\n\n"); - fprintf(stdout, "%s", kResultText->str); - } - else{ - if(type != 1) fprintf(stdout, "Content-type: text/plain\n\n"); - fprintf(stdout, "An error occurred."); - } - } - else{ //raw(text) - - if(test2->len != 0){ - test2 = CalcSizes(test2, 1); - if(type != 1) fprintf(stdout, "Content-type: text/plain\n\n"); - fprintf(stdout, "result=%s", test2->str); - } - else{ - if(type != 1) fprintf(stdout, "Content-type: text/plain\n\n"); - fprintf(stdout, "result=nodata"); - } - } - dummy = closeDB(); - - return 0; -} - +//kagecgi.c +// + +#include "kage.h" +#include "kagecgi.h" +#include "sysdep.h" + +int main(int argc, char *argv[]){ + KGString *tmp1, *tmp2, *test1, *test2, *filename; + FILE *err; + char errbuf[errorFileSize]; + char *pos, *cur; + int dummy; + int type; + + dummy = initDB(); + + //set default + kShotai = kMincho; + //kShotai = kGothic; + kSize = 200; + kType = 0; //png + kInput = 0; //ids or direct + kResultText = kg_string_new(""); + kMode = 0; + + //confirm request + type = 0; + //GET request + if(type == 0){ + tmp1 = kg_string_new((kgchar *)getenv("QUERY_STRING")); + if(tmp1->len != 0) type = 2; + } + //argv(detect after GET request) + if(type == 0){ + tmp1 = kg_string_new((kgchar *)argv[1]); + if(tmp1->len != 0) type = 1; + } + //redirect + if(type == 0){ + tmp1 = kg_string_new((kgchar *)getenv("REDIRECT_URL")); + if(tmp1->len != 0) type = 3; + } + //error + if(type == 0){ + fprintf(stderr, "Request Error.\n"); + return 0; + } + pos = tmp1->str; + + //separate token + if(type == 1 || type == 2){ //argv or GET request + while(1){ + cur = strchr(pos, '&'); + tmp2 = kg_string_new(pos); + if(cur != NULL) kg_string_set_size(tmp2, cur - pos); + //got request string + if(strncmp(tmp2->str, "shotai=mincho", 13) == 0) kShotai = kMincho; + else if(strncmp(tmp2->str, "shotai=gothic", 13) == 0) kShotai = kGothic; + else if(strncmp(tmp2->str, "shotai=skeleton", 15) == 0) kShotai = kGothic; + else if(strncmp(tmp2->str, "type=png", 8) == 0) kType = 0; + else if(strncmp(tmp2->str, "type=svg", 8) == 0) kType = 1; + else if(strncmp(tmp2->str, "type=eps", 8) == 0) kType = 2; + else if(strncmp(tmp2->str, "type=raw", 8) == 0) kType = 3; + else if(strncmp(tmp2->str, "input=ids", 9) == 0) kInput = 0; + else if(strncmp(tmp2->str, "input=directwithadjust", 22) == 0) kInput = 2; + else if(strncmp(tmp2->str, "input=direct", 12) == 0) kInput = 1; + else if(strncmp(tmp2->str, "size=24", 7) == 0) kSize = 24; + else if(strncmp(tmp2->str, "size=200", 8) == 0) kSize = 200; + else test1 = kg_string_new(tmp2->str); + if(cur == NULL) break; + pos = cur + 1; + } + } + else{ // redirected request + kInput = 0; + while(1){ + cur = strchr(pos, '/'); + tmp2 = kg_string_new(pos); + if(cur != NULL) kg_string_set_size(tmp2, cur - pos); + //got request string + if(strncmp(tmp2->str, "mincho", 6) == 0) kShotai = kMincho; + else if(strncmp(tmp2->str, "gothic", 6) == 0) kShotai = kGothic; + else if(strncmp(tmp2->str, "skeleton", 8) == 0) kShotai = kGothic; + else if(strncmp(tmp2->str, "v0.4", 4) == 0); + else test1 = kg_string_new(tmp2->str); + if(cur == NULL) break; + pos = cur + 1; + } + if(strncmp(test1->str + test1->len - 4, ".png", 4) == 0) kType = 0; + if(strncmp(test1->str + test1->len - 4, ".svg", 4) == 0) kType = 1; + if(strncmp(test1->str + test1->len - 4, ".eps", 4) == 0) kType = 2; + if(strncmp(test1->str + test1->len - 4, ".raw", 4) == 0) kType = 3; + kg_string_set_size(test1, test1->len - 4); + } + + //clear result buffer + test2 = kg_string_new(""); + if(kType == 1){ //svg + kg_string_append(kResultText, "\n"); + kg_string_append(kResultText, "\n"); + kg_string_append(kResultText, ""); + } + else if(kType == 2){ //eps + kg_string_append(kResultText, "%!PS-Adobe-3.0 EPSF-3.0\n"); + kg_string_append(kResultText, "%%BoundingBox: 0 -208 1024 816\n"); + kg_string_append(kResultText, "%%Pages: 0\n"); + kg_string_append(kResultText, "%%Title: "); + kg_string_append(kResultText, test1->str); + kg_string_append(kResultText, "\n"); + kg_string_append(kResultText, "%%Creator: KAGE System\n"); + kg_string_append(kResultText, "%%CreationDate: 00:00 1-1-2004\n"); + kg_string_append(kResultText, "%%EndComments\n"); + kg_string_append(kResultText, "%%EndProlog\n"); + kg_string_append(kResultText, "%%Page \""); + kg_string_append(kResultText, test1->str); + kg_string_append(kResultText, "\" 1\n"); + kg_string_append(kResultText, "newpath\n"); + } + kageCanvas = initPng(canvasWidth, canvasHeight); + if(kInput == 0) generateGlyph(test1, test2); + else{ + convert99(test1, test2); + // kg_string_append(test2, test1->str); + } + + if(kType == 0){ //png(image) + if(test2->len != 0){ + if(kInput != 1){ //0 and 2 + test2 = CalcSizes(test2, 1); + } + DrawBox(); + drawGlyph(test2, 0); + //output to file + filename = kg_string_new(pngFilePath); + if(kShotai == kMincho) kg_string_append(filename, "mincho/"); + else if(kShotai == kGothic) kg_string_append(filename, "gothic/");//skeleton?? + kg_string_append(filename, test1->str); + kg_string_append(filename, ".png"); + + //skip for adjustment mode + //fp = fopen(filename->str, "w"); + //writePng(pngWidth, pngHeight, kageCanvas, fp); + //fclose(fp); + //output to stdout + if(type != 1) fprintf(stdout, "Content-type: image/png\n\n"); + writePng(pngWidth, pngHeight, kageCanvas, stdout); + //done + closePng(pngWidth, pngHeight, kageCanvas); + } + else{ + err = fopen(errorFileName, "r"); + fread(errbuf, sizeof(char), errorFileSize, err); + //printf("An error occurred.\r\n"); + if(type != 1) fprintf(stdout, "Content-type: image/png\n\n"); + fwrite(errbuf, sizeof(char), errorFileSize, stdout); + fclose(err); + } + } + else if(kType == 1){ //svg(vector graphics) + if(test2->len != 0){ + test2 = CalcSizes(test2, 1); + kMode = 1; + drawGlyph(test2, 0); + kg_string_append(kResultText, "\n"); + if(type != 1) fprintf(stdout, "Content-type: image/svg-xml\n\n"); + fprintf(stdout, "%s", kResultText->str); + } + else{ + if(type != 1) fprintf(stdout, "Content-type: text/plain\n\n"); + fprintf(stdout, "An error occurred."); + } + } + else if(kType == 2){ //eps(vector graphics) + if(test2->len != 0){ + test2 = CalcSizes(test2, 1); + kMode = 2; + drawGlyph(test2, 0); + kg_string_append(kResultText, "fill\n"); + kg_string_append(kResultText, "%%EOF\n"); + if(type != 1) fprintf(stdout, "Content-type: application/postscript\n\n"); + fprintf(stdout, "%s", kResultText->str); + } + else{ + if(type != 1) fprintf(stdout, "Content-type: text/plain\n\n"); + fprintf(stdout, "An error occurred."); + } + } + else{ //raw(text) + + if(test2->len != 0){ + test2 = CalcSizes(test2, 1); + if(type != 1) fprintf(stdout, "Content-type: text/plain\n\n"); + fprintf(stdout, "result=%s", test2->str); + } + else{ + if(type != 1) fprintf(stdout, "Content-type: text/plain\n\n"); + fprintf(stdout, "result=nodata"); + } + } + dummy = closeDB(); + + return 0; +} + diff --git a/kagecgi/kagecgi.h b/kagecgi/kagecgi.h index cf34a38..cd38a5a 100755 --- a/kagecgi/kagecgi.h +++ b/kagecgi/kagecgi.h @@ -8,7 +8,7 @@ #define _KAGECGI_H_ // define for localhost environment -#define errorFileSize 4009 +#define errorFileSize 3992 #define errorFileName "/usr/local/share/kagecgi/error.png" #define pngFilePath "/var/www/fontsjp/v0.4/" #define databaseFileName "/usr/local/share/kagecgi/kagedb" @@ -32,45 +32,45 @@ int kDesign; int kSize; int kType; int kInput; -GString *kResultText; +KGString *kResultText; int kMode; -void generateGlyph(const GString *in, GString *out); -void searchPartsData(const GString *in, GString *out); -void searchAliasData(const GString *in, GString *out); -void searchCacheData(const GString *in, GString *out); -void doCombine(const GString *in, GString *out); -void drawGlyph(const GString *in, const int mode); - -int isIDS(const GString *in); -void divideInto2(const GString *in, GString *partIDS1, GString *partIDS3); -void divideInto3(const GString *in, GString *partIDS1, GString *partIDS2, GString *partIDS3); -void addStrokeWithTransform(const GString *stroke, const int num, const int *tf, GString *out, int mode); -void convertArray(int *buf, GString *out, int size, int mode); +void generateGlyph(const KGString *in, KGString *out); +void searchPartsData(const KGString *in, KGString *out); +void searchAliasData(const KGString *in, KGString *out); +void searchCacheData(const KGString *in, KGString *out); +void doCombine(const KGString *in, KGString *out); +void drawGlyph(const KGString *in, const int mode); + +int isIDS(const KGString *in); +void divideInto2(const KGString *in, KGString *partIDS1, KGString *partIDS3); +void divideInto3(const KGString *in, KGString *partIDS1, KGString *partIDS2, KGString *partIDS3); +void addStrokeWithTransform(const KGString *stroke, const int num, const int *tf, KGString *out, int mode); +void convertArray(int *buf, KGString *out, int size, int mode); int * convertStroke(const char *in, int *a, int *size); -void convert99(const GString *in, GString *out); -void convert99calc(const char *in, GString *out); +void convert99(const KGString *in, KGString *out); +void convert99calc(const char *in, KGString *out); void DotsWidth(int *dlx, int *drx); void DotsHeight(int *dly, int *dry); -void PartsWidth(const GString *in, int *lx, int *rx); -void PartsHeight(const GString *in, int *ly, int *ry); -GString * CalcSizes(const GString *in, int mode); +void PartsWidth(const KGString *in, int *lx, int *rx); +void PartsHeight(const KGString *in, int *ly, int *ry); +KGString * CalcSizes(const KGString *in, int mode); void DrawBox(); -void CalcOptions(const GString *in, int *mitsudo, int *flag, double *yoko, double *tate); -void DoDrawParts(const GString *in, const int lx1, const double rf1, const int ly1, const double rfy1); -void DoDrawMixFont(const GString *in1, const int lx1, const double rf1, const GString *in2, const int lx2, const double rf2, const int ly1, const double rfy1, const int ly2, const double rfy2); +void CalcOptions(const KGString *in, int *mitsudo, int *flag, double *yoko, double *tate); +void DoDrawParts(const KGString *in, const int lx1, const double rf1, const int ly1, const double rfy1); +void DoDrawMixFont(const KGString *in1, const int lx1, const double rf1, const KGString *in2, const int lx2, const double rf2, const int ly1, const double rfy1, const int ly2, const double rfy2); -void combineYoko2(const GString *parts1, const GString *parts3, int *result); -void combineYoko3(const GString *parts1, const GString *parts2, const GString *parts3, int *result); -void combineTate2(const GString *parts1, const GString *parts3, int *result); -void combineTate3(const GString *parts1, const GString *parts2, const GString *parts3, int *result); -void combineHame2(const GString *parts1, const GString *parts3, int *result); +void combineYoko2(const KGString *parts1, const KGString *parts3, int *result); +void combineYoko3(const KGString *parts1, const KGString *parts2, const KGString *parts3, int *result); +void combineTate2(const KGString *parts1, const KGString *parts3, int *result); +void combineTate3(const KGString *parts1, const KGString *parts2, const KGString *parts3, int *result); +void combineHame2(const KGString *parts1, const KGString *parts3, int *result); int initDB(); int closeDB(); -void searchPartsData(const GString *in, GString *out); -void searchAliasData(const GString *in, GString *out); +void searchPartsData(const KGString *in, KGString *out); +void searchAliasData(const KGString *in, KGString *out); png_bytepp initPng(int width, int height); int closePng(int width, int height, png_bytepp canvas); diff --git a/kagecgi/kagechar.c b/kagecgi/kagechar.c index 85d3b4c..6223377 100755 --- a/kagecgi/kagechar.c +++ b/kagecgi/kagechar.c @@ -5,391 +5,391 @@ #include "kagecgi.h" #include "sysdep.h" -int isIDS(const GString *in){ - //check IDC "u2ff*" - if(strncmp(in->str, "u2ff", 4) == 0){ - //check the last char - if('0' <= (in->str)[4] && (in->str)[4] <= 'a') return TRUE; - } - return FALSE; +int isIDS(const KGString *in){ + //check IDC "u2ff*" + if(strncmp(in->str, "u2ff", 4) == 0){ + //check the last char + if('0' <= (in->str)[4] && (in->str)[4] <= 'a') return 1; //true + } + return 0; //false } -void divideInto2(const GString *in, GString *partIDS1, GString *partIDS3){ - GString *buffer[16]; - char tmp[kMaxIDCLength + 1]; - int i, counter, pointer, flag; - - g_string_set_size(partIDS1, 0); - - counter = 0; - pointer = 0; - for(i = 0; i < in->len; i++){ - if((in->str)[i] == '.'){ - strncpy(tmp, (in->str) + pointer, i - pointer); - tmp[i - pointer] = '\0'; - buffer[counter] = g_string_new(tmp); - counter++; - pointer = i + 1; - } - } - strncpy(tmp, (in->str) + pointer, i - pointer); - tmp[i - pointer] = '\0'; - buffer[counter] = g_string_new(tmp); - counter++; - - //reject over-length of IDS - if(counter > kMaxIDSSequenceLength) return; - - //1st scan - pointer = 1; - flag = 0; - while(flag >= 0 && pointer < counter){ - g_string_append(partIDS1, (buffer[pointer])->str); - g_string_append(partIDS1, "."); - if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ - switch (((buffer[pointer])->str)[4]){ - case '0': - case '1': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - flag++; - break; - case '2': - case '3': - flag = flag + 2; - break; - } - } - else flag--; - pointer++; - } - g_string_erase(partIDS1, partIDS1->len - 1, 1); - - //2nd scan - flag = 0; - while(flag >= 0 && pointer < counter){ - g_string_append(partIDS3, (buffer[pointer])->str); - g_string_append(partIDS3, "."); - if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ - switch (((buffer[pointer])->str)[4]){ - case '0': - case '1': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - flag++; - break; - case '2': - case '3': - flag = flag + 2; - break; - } - } - else flag--; - pointer++; - } - g_string_erase(partIDS3, partIDS3->len - 1, 1); +void divideInto2(const KGString *in, KGString *partIDS1, KGString *partIDS3){ + KGString *buffer[16]; + char tmp[kMaxIDCLength + 1]; + int i, counter, pointer, flag; + + kg_string_set_size(partIDS1, 0); + + counter = 0; + pointer = 0; + for(i = 0; i < in->len; i++){ + if((in->str)[i] == '.'){ + strncpy(tmp, (in->str) + pointer, i - pointer); + tmp[i - pointer] = '\0'; + buffer[counter] = kg_string_new(tmp); + counter++; + pointer = i + 1; + } + } + strncpy(tmp, (in->str) + pointer, i - pointer); + tmp[i - pointer] = '\0'; + buffer[counter] = kg_string_new(tmp); + counter++; + + //reject over-length of IDS + if(counter > kMaxIDSSequenceLength) return; + + //1st scan + pointer = 1; + flag = 0; + while(flag >= 0 && pointer < counter){ + kg_string_append(partIDS1, (buffer[pointer])->str); + kg_string_append(partIDS1, "."); + if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ + switch (((buffer[pointer])->str)[4]){ + case '0': + case '1': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'a': + case 'b': + flag++; + break; + case '2': + case '3': + flag = flag + 2; + break; + } + } + else flag--; + pointer++; + } + kg_string_erase(partIDS1, partIDS1->len - 1, 1); + + //2nd scan + flag = 0; + while(flag >= 0 && pointer < counter){ + kg_string_append(partIDS3, (buffer[pointer])->str); + kg_string_append(partIDS3, "."); + if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ + switch (((buffer[pointer])->str)[4]){ + case '0': + case '1': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'a': + case 'b': + flag++; + break; + case '2': + case '3': + flag = flag + 2; + break; + } + } + else flag--; + pointer++; + } + kg_string_erase(partIDS3, partIDS3->len - 1, 1); } -void divideInto3(const GString *in, GString *partIDS1, GString *partIDS2, GString *partIDS3){ - GString *buffer[16]; - char tmp[kMaxIDCLength + 1]; - int i, counter, pointer, flag; - - g_string_set_size(partIDS1, 0); - - counter = 0; - pointer = 0; - for(i = 0; i < in->len; i++){ - if((in->str)[i] == '.'){ - strncpy(tmp, (in->str) + pointer, i - pointer); - tmp[i - pointer] = '\0'; - buffer[counter] = g_string_new(tmp); - counter++; - pointer = i + 1; - } - } - strncpy(tmp, (in->str) + pointer, i - pointer); - tmp[i - pointer] = '\0'; - buffer[counter] = g_string_new(tmp); - counter++; - - //reject over-length of IDS - if(counter > kMaxIDSSequenceLength) return; - - //1st scan - pointer = 1; - flag = 0; - while(flag >= 0 && pointer < counter){ - g_string_append(partIDS1, (buffer[pointer])->str); - g_string_append(partIDS1, "."); - if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ - switch (((buffer[pointer])->str)[4]){ - case '0': - case '1': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - flag++; - break; - case '2': - case '3': - flag = flag + 2; - break; - } - } - else flag--; - pointer++; - } - g_string_erase(partIDS1, partIDS1->len - 1, 1); - - //2nd scan - flag = 0; - while(flag >= 0 && pointer < counter){ - g_string_append(partIDS2, (buffer[pointer])->str); - g_string_append(partIDS2, "."); - if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ - switch (((buffer[pointer])->str)[4]){ - case '0': - case '1': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - flag++; - break; - case '2': - case '3': - flag = flag + 2; - break; - } - } - else flag--; - pointer++; - } - g_string_erase(partIDS2, partIDS2->len - 1, 1); - - //3rd scan - flag = 0; - while(flag >= 0 && pointer < counter){ - g_string_append(partIDS3, (buffer[pointer])->str); - g_string_append(partIDS3, "."); - if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ - switch (((buffer[pointer])->str)[4]){ - case '0': - case '1': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - flag++; - break; - case '2': - case '3': - flag = flag + 2; - break; - } - } - else flag--; - pointer++; - } - g_string_erase(partIDS3, partIDS3->len - 1, 1); +void divideInto3(const KGString *in, KGString *partIDS1, KGString *partIDS2, KGString *partIDS3){ + KGString *buffer[16]; + char tmp[kMaxIDCLength + 1]; + int i, counter, pointer, flag; + + kg_string_set_size(partIDS1, 0); + + counter = 0; + pointer = 0; + for(i = 0; i < in->len; i++){ + if((in->str)[i] == '.'){ + strncpy(tmp, (in->str) + pointer, i - pointer); + tmp[i - pointer] = '\0'; + buffer[counter] = kg_string_new(tmp); + counter++; + pointer = i + 1; + } + } + strncpy(tmp, (in->str) + pointer, i - pointer); + tmp[i - pointer] = '\0'; + buffer[counter] = kg_string_new(tmp); + counter++; + + //reject over-length of IDS + if(counter > kMaxIDSSequenceLength) return; + + //1st scan + pointer = 1; + flag = 0; + while(flag >= 0 && pointer < counter){ + kg_string_append(partIDS1, (buffer[pointer])->str); + kg_string_append(partIDS1, "."); + if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ + switch (((buffer[pointer])->str)[4]){ + case '0': + case '1': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'a': + case 'b': + flag++; + break; + case '2': + case '3': + flag = flag + 2; + break; + } + } + else flag--; + pointer++; + } + kg_string_erase(partIDS1, partIDS1->len - 1, 1); + + //2nd scan + flag = 0; + while(flag >= 0 && pointer < counter){ + kg_string_append(partIDS2, (buffer[pointer])->str); + kg_string_append(partIDS2, "."); + if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ + switch (((buffer[pointer])->str)[4]){ + case '0': + case '1': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'a': + case 'b': + flag++; + break; + case '2': + case '3': + flag = flag + 2; + break; + } + } + else flag--; + pointer++; + } + kg_string_erase(partIDS2, partIDS2->len - 1, 1); + + //3rd scan + flag = 0; + while(flag >= 0 && pointer < counter){ + kg_string_append(partIDS3, (buffer[pointer])->str); + kg_string_append(partIDS3, "."); + if(strncmp((buffer[pointer])->str, "u2ff", 4) == 0){ + switch (((buffer[pointer])->str)[4]){ + case '0': + case '1': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'a': + case 'b': + flag++; + break; + case '2': + case '3': + flag = flag + 2; + break; + } + } + else flag--; + pointer++; + } + kg_string_erase(partIDS3, partIDS3->len - 1, 1); } -void addStrokeWithTransform(const GString *stroke, const int num, const int *tf, GString *out, int mode){ - int *buf, i, size; - GString *tmp; - - tmp = g_string_new(""); - buf = convertStroke(stroke->str, buf, &size); - - for(i = 0; i < size; i++){ - if(buf[i * 11 + 0] != 0 && buf[i * 11 + 0] != 99){ - buf[i * 11 + 3] = - tf[(num - 1) * 4 + 0] + buf[i * 11 + 3] * (tf[(num - 1) * 4 + 2] - tf[(num - 1) * 4 + 0]) / pngWidth; - buf[i * 11 + 5] = - tf[(num - 1) * 4 + 0] + buf[i * 11 + 5] * (tf[(num - 1) * 4 + 2] - tf[(num - 1) * 4 + 0]) / pngWidth; - buf[i * 11 + 7] = - tf[(num - 1) * 4 + 0] + buf[i * 11 + 7] * (tf[(num - 1) * 4 + 2] - tf[(num - 1) * 4 + 0]) / pngWidth; - buf[i * 11 + 9] = - tf[(num - 1) * 4 + 0] + buf[i * 11 + 9] * (tf[(num - 1) * 4 + 2] - tf[(num - 1) * 4 + 0]) / pngWidth; - buf[i * 11 + 4] = - tf[(num - 1) * 4 + 1] + buf[i * 11 + 4] * (tf[(num - 1) * 4 + 3] - tf[(num - 1) * 4 + 1]) / pngHeight; - buf[i * 11 + 6] = - tf[(num - 1) * 4 + 1] + buf[i * 11 + 6] * (tf[(num - 1) * 4 + 3] - tf[(num - 1) * 4 + 1]) / pngHeight; - buf[i * 11 + 8] = - tf[(num - 1) * 4 + 1] + buf[i * 11 + 8] * (tf[(num - 1) * 4 + 3] - tf[(num - 1) * 4 + 1]) / pngHeight; - buf[i * 11 + 10] = - tf[(num - 1) * 4 + 1] + buf[i * 11 + 10] * (tf[(num - 1) * 4 + 3] - tf[(num - 1) * 4 + 1]) / pngHeight; - } - } - convertArray(buf, tmp, size, mode); - if(out->len != 0) g_string_append(out, "$"); - g_string_append(out, tmp->str); - - free((void *)buf); +void addStrokeWithTransform(const KGString *stroke, const int num, const int *tf, KGString *out, int mode){ + int *buf, i, size; + KGString *tmp; + + tmp = kg_string_new(""); + buf = convertStroke(stroke->str, buf, &size); + + for(i = 0; i < size; i++){ + if(buf[i * 11 + 0] != 0 && buf[i * 11 + 0] != 99){ + buf[i * 11 + 3] = + tf[(num - 1) * 4 + 0] + buf[i * 11 + 3] * (tf[(num - 1) * 4 + 2] - tf[(num - 1) * 4 + 0]) / pngWidth; + buf[i * 11 + 5] = + tf[(num - 1) * 4 + 0] + buf[i * 11 + 5] * (tf[(num - 1) * 4 + 2] - tf[(num - 1) * 4 + 0]) / pngWidth; + buf[i * 11 + 7] = + tf[(num - 1) * 4 + 0] + buf[i * 11 + 7] * (tf[(num - 1) * 4 + 2] - tf[(num - 1) * 4 + 0]) / pngWidth; + buf[i * 11 + 9] = + tf[(num - 1) * 4 + 0] + buf[i * 11 + 9] * (tf[(num - 1) * 4 + 2] - tf[(num - 1) * 4 + 0]) / pngWidth; + buf[i * 11 + 4] = + tf[(num - 1) * 4 + 1] + buf[i * 11 + 4] * (tf[(num - 1) * 4 + 3] - tf[(num - 1) * 4 + 1]) / pngHeight; + buf[i * 11 + 6] = + tf[(num - 1) * 4 + 1] + buf[i * 11 + 6] * (tf[(num - 1) * 4 + 3] - tf[(num - 1) * 4 + 1]) / pngHeight; + buf[i * 11 + 8] = + tf[(num - 1) * 4 + 1] + buf[i * 11 + 8] * (tf[(num - 1) * 4 + 3] - tf[(num - 1) * 4 + 1]) / pngHeight; + buf[i * 11 + 10] = + tf[(num - 1) * 4 + 1] + buf[i * 11 + 10] * (tf[(num - 1) * 4 + 3] - tf[(num - 1) * 4 + 1]) / pngHeight; + } + } + convertArray(buf, tmp, size, mode); + if(out->len != 0) kg_string_append(out, "$"); + kg_string_append(out, tmp->str); + + free((void *)buf); } -void convertArray(int *buf, GString *out, int size, int mode){ - int i; - char tmp[kMaxStrokeDataLength]; - - for(i = 0; i < size; i++){ - if(!(mode == 1 && (buf[i * 11 + 0] == 0 || buf[i * 11 + 0] == 99))){ - sprintf(tmp, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d$", - buf[i * 11 + 0], - buf[i * 11 + 1], - buf[i * 11 + 2], - buf[i * 11 + 3], - buf[i * 11 + 4], - buf[i * 11 + 5], - buf[i * 11 + 6], - buf[i * 11 + 7], - buf[i * 11 + 8], - buf[i * 11 + 9], - buf[i * 11 + 10]); - g_string_append(out, tmp); - } - } - g_string_erase(out, (out->len - 1), 1); +void convertArray(int *buf, KGString *out, int size, int mode){ + int i; + char tmp[kMaxStrokeDataLength]; + + for(i = 0; i < size; i++){ + if(!(mode == 1 && (buf[i * 11 + 0] == 0 || buf[i * 11 + 0] == 99))){ + sprintf(tmp, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d$", + buf[i * 11 + 0], + buf[i * 11 + 1], + buf[i * 11 + 2], + buf[i * 11 + 3], + buf[i * 11 + 4], + buf[i * 11 + 5], + buf[i * 11 + 6], + buf[i * 11 + 7], + buf[i * 11 + 8], + buf[i * 11 + 9], + buf[i * 11 + 10]); + kg_string_append(out, tmp); + } + } + out = kg_string_erase(out, (out->len - 1), 1); } int * convertStroke(const char *in, int *a, int *size){ - int i, counter, pointer; - int a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10; - char tmp[kMaxStrokeDataLength + 1]; - - a = (int *)malloc(0); - counter = 0; - pointer = 0; - for(i = 0; i < strlen(in); i++){ - if(in[i] == '$'){ - strncpy(tmp, &in[pointer], i - pointer); - tmp[i - pointer] = '\0'; - a = (int *)realloc(a, sizeof(int) * 11 * (counter + 1)); - sscanf(tmp, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", - &a0,&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10); - a[counter * 11 + 0] = a0; - a[counter * 11 + 1] = a1; - a[counter * 11 + 2] = a2; - a[counter * 11 + 3] = a3; - a[counter * 11 + 4] = a4; - a[counter * 11 + 5] = a5; - a[counter * 11 + 6] = a6; - a[counter * 11 + 7] = a7; - a[counter * 11 + 8] = a8; - a[counter * 11 + 9] = a9; - a[counter * 11 + 10] = a10; - counter++; - pointer = i + 1; - } - } - strncpy(tmp, &in[pointer], i - pointer); - tmp[i - pointer] = '\0'; - a = (int *)realloc(a, sizeof(int) * 11 * (counter + 1)); - sscanf(tmp, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", - &a0,&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10); - a[counter * 11 + 0] = a0; - a[counter * 11 + 1] = a1; - a[counter * 11 + 2] = a2; - a[counter * 11 + 3] = a3; - a[counter * 11 + 4] = a4; - a[counter * 11 + 5] = a5; - a[counter * 11 + 6] = a6; - a[counter * 11 + 7] = a7; - a[counter * 11 + 8] = a8; - a[counter * 11 + 9] = a9; - a[counter * 11 + 10] = a10; - counter++; - *(size) = counter; - return a; + int i, counter, pointer; + int a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10; + char tmp[kMaxStrokeDataLength + 1]; + + a = (int *)malloc(0); + counter = 0; + pointer = 0; + for(i = 0; i < strlen(in); i++){ + if(in[i] == '$'){ + strncpy(tmp, &in[pointer], i - pointer); + tmp[i - pointer] = '\0'; + a = (int *)realloc(a, sizeof(int) * 11 * (counter + 1)); + sscanf(tmp, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", + &a0,&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10); + a[counter * 11 + 0] = a0; + a[counter * 11 + 1] = a1; + a[counter * 11 + 2] = a2; + a[counter * 11 + 3] = a3; + a[counter * 11 + 4] = a4; + a[counter * 11 + 5] = a5; + a[counter * 11 + 6] = a6; + a[counter * 11 + 7] = a7; + a[counter * 11 + 8] = a8; + a[counter * 11 + 9] = a9; + a[counter * 11 + 10] = a10; + counter++; + pointer = i + 1; + } + } + strncpy(tmp, &in[pointer], i - pointer); + tmp[i - pointer] = '\0'; + a = (int *)realloc(a, sizeof(int) * 11 * (counter + 1)); + sscanf(tmp, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", + &a0,&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10); + a[counter * 11 + 0] = a0; + a[counter * 11 + 1] = a1; + a[counter * 11 + 2] = a2; + a[counter * 11 + 3] = a3; + a[counter * 11 + 4] = a4; + a[counter * 11 + 5] = a5; + a[counter * 11 + 6] = a6; + a[counter * 11 + 7] = a7; + a[counter * 11 + 8] = a8; + a[counter * 11 + 9] = a9; + a[counter * 11 + 10] = a10; + counter++; + *(size) = counter; + return a; } -void convert99(const GString *in, GString *out){ - int i, pointer; - char tmp[kMaxStrokeDataLength + 1]; - GString *buf; - - g_string_set_size(out, 0); - buf = g_string_new(""); - pointer = 0; - for(i = 0; i < in->len; i++){ - if((in->str)[i] == '$'){ - strncpy(tmp, in->str + pointer, i - pointer); - tmp[i - pointer] = '\0'; - if(strncmp(tmp, "99:", 3) == 0){ - convert99calc(tmp, buf); - if(buf->len == 0){ - g_string_set_size(out, 0); - return; - } - g_string_append(out, buf->str); - } - else g_string_append(out, tmp); - g_string_append(out, "$"); - - pointer = i + 1; - } - } - strncpy(tmp, in->str + pointer, i - pointer); - tmp[i - pointer] = '\0'; - if(strncmp(tmp, "99:", 3) == 0){ - convert99calc(tmp, buf); - if(buf->len == 0){ - g_string_set_size(out, 0); - return; - } - g_string_append(out, buf->str); +void convert99(const KGString *in, KGString *out){ + int i, pointer; + char tmp[kMaxStrokeDataLength + 1]; + KGString *buf; + + kg_string_set_size(out, 0); + buf = kg_string_new(""); + pointer = 0; + for(i = 0; i < in->len; i++){ + if((in->str)[i] == '$'){ + strncpy(tmp, in->str + pointer, i - pointer); + tmp[i - pointer] = '\0'; + if(strncmp(tmp, "99:", 3) == 0){ + convert99calc(tmp, buf); + if(buf->len == 0){ + kg_string_set_size(out, 0); + return; } - else g_string_append(out, tmp); + kg_string_append(out, buf->str); + } + else kg_string_append(out, tmp); + kg_string_append(out, "$"); + + pointer = i + 1; + } + } + strncpy(tmp, in->str + pointer, i - pointer); + tmp[i - pointer] = '\0'; + if(strncmp(tmp, "99:", 3) == 0){ + convert99calc(tmp, buf); + if(buf->len == 0){ + kg_string_set_size(out, 0); + return; + } + kg_string_append(out, buf->str); + } + else kg_string_append(out, tmp); } -void convert99calc(const char *in, GString *out){ - GString *buf1, *buf2; - int a1,x1,y1,x2,y2,option,option2; - char pname[kMaxStrokeDataLength]; - int tf[12]; - - g_string_set_size(out, 0); - buf2 = g_string_new(""); - - //get parts data - sscanf(in, "%d:%d:%d:%d:%d:%d:%d:%s", - &a1,&option,&option2,&x1,&y1,&x2,&y2,pname); - //end = strchr(pname, ':'); - //*end = '\0'; - buf1 = g_string_new(pname); - generateGlyph(buf1, buf2); - if(buf2->len == 0) return; - - //convert - tf[0] = x1; - tf[1] = y1; - tf[2] = x2; - tf[3] = y2; - addStrokeWithTransform(buf2, 1, tf, out, 1); +void convert99calc(const char *in, KGString *out){ + KGString *buf1, *buf2; + int a1,x1,y1,x2,y2,option,option2; + char pname[kMaxStrokeDataLength]; + int tf[12]; + + kg_string_set_size(out, 0); + buf2 = kg_string_new(""); + + //get parts data + sscanf(in, "%d:%d:%d:%d:%d:%d:%d:%s", + &a1,&option,&option2,&x1,&y1,&x2,&y2,pname); + //end = strchr(pname, ':'); + //*end = '\0'; + buf1 = kg_string_new(pname); + generateGlyph(buf1, buf2); + if(buf2->len == 0) return; + + //convert + tf[0] = x1; + tf[1] = y1; + tf[2] = x2; + tf[3] = y2; + addStrokeWithTransform(buf2, 1, tf, out, 1); } diff --git a/kagecgi/kagecomb.c b/kagecgi/kagecomb.c index 7227d53..3b1ac74 100755 --- a/kagecgi/kagecomb.c +++ b/kagecgi/kagecomb.c @@ -5,7 +5,7 @@ #include "kagecgi.h" #include "sysdep.h" -void combineYoko2(const GString *parts1, const GString *parts3, int *result){ +void combineYoko2(const KGString *parts1, const KGString *parts3, int *result){ int f, g, h, i, j, k, l; int flg_boxL, flg_boxR; int Xside, YsideLa, YsideLb, YsideRa, YsideRb, YheightL, YnanameL, YsmallL; @@ -193,11 +193,11 @@ void combineYoko2(const GString *parts1, const GString *parts3, int *result){ kShotai = tempShotai; } -void combineYoko3(const GString *parts1, const GString *parts2, const GString *parts3, int *result){ +void combineYoko3(const KGString *parts1, const KGString *parts2, const KGString *parts3, int *result){ //not yet } -void combineTate2(const GString *parts1, const GString *parts3, int *result){ +void combineTate2(const KGString *parts1, const KGString *parts3, int *result){ int f, g, h, i, j, k, l; int flg_boxL, flg_boxR; int pxL, pxR, pyL, pyR; @@ -372,11 +372,11 @@ void combineTate2(const GString *parts1, const GString *parts3, int *result){ kShotai = tempShotai; } -void combineTate3(const GString *parts1, const GString *parts2, const GString *parts3, int *result){ +void combineTate3(const KGString *parts1, const KGString *parts2, const KGString *parts3, int *result){ //not yet } -void combineHame2(const GString *parts1, const GString *parts3, int *result){ +void combineHame2(const KGString *parts1, const KGString *parts3, int *result){ int i; int *buf, strokes; diff --git a/kagecgi/kagedb.c b/kagecgi/kagedb.c index e9c1dc5..469d833 100755 --- a/kagecgi/kagedb.c +++ b/kagecgi/kagedb.c @@ -1,126 +1,126 @@ -//kagedb.c -// - -#include "kage.h" -#include "kagecgi.h" -#include "sysdep.h" - -int initDB(){ +//kagedb.c +// + +#include "kage.h" +#include "kagecgi.h" +#include "sysdep.h" + +int initDB(){ db_create(&kDatabase, NULL, 0); - kDatabase->open(kDatabase, databaseFileName, NULL, DB_HASH, DB_RDONLY, 0644); - return 0; -} - -int closeDB(){ - kDatabase->close(kDatabase, 0); - return 0; -} - -void searchPartsData(const GString *in, GString *out){ - DBT dbkey, dbdata; - char *start, *end, *buf; - GString *temp, *temp2; - - //cut off the end '-0000' if 'in' end with it - temp = g_string_new(in->str); -// if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) g_string_set_size(temp, temp->len - 5); - if((temp->str)[0] == 'u'){ - if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) g_string_set_size(temp, temp->len - 4); - else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) g_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) g_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) g_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) g_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) g_string_set_size(temp, temp->len - 2); - } - - memset(&dbkey,0,sizeof(DBT)); - memset(&dbdata,0,sizeof(DBT)); - dbkey.data = temp->str; - dbkey.size = temp->len; - g_string_set_size(out, 0); - temp2 = g_string_new(""); - kDatabase->get(kDatabase, NULL, &dbkey, &dbdata, 0); - if(dbdata.size != 0){ + kDatabase->open(kDatabase, databaseFileName, NULL, DB_HASH, DB_RDONLY, 0644); + return 0; +} + +int closeDB(){ + kDatabase->close(kDatabase, 0); + return 0; +} + +void searchPartsData(const KGString *in, KGString *out){ + DBT dbkey, dbdata; + char *start, *end, *buf; + KGString *temp, *temp2; + + //cut off the end '-0000' if 'in' end with it + temp = kg_string_new(in->str); +// if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) kg_string_set_size(temp, temp->len - 5); + if((temp->str)[0] == 'u'){ + if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) kg_string_set_size(temp, temp->len - 4); + else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + } + + memset(&dbkey,0,sizeof(DBT)); + memset(&dbdata,0,sizeof(DBT)); + dbkey.data = temp->str; + dbkey.size = temp->len; + kg_string_set_size(out, 0); + temp2 = kg_string_new(""); + kDatabase->get(kDatabase, NULL, &dbkey, &dbdata, 0); + if(dbdata.size != 0){ buf = (char *)malloc(dbdata.size + 1); strncpy(buf, dbdata.data, dbdata.size + 1); - //first:search selected shotai - if(kShotai == kMincho) start = strstr(buf, ",mincho,"); - else start = strstr(buf, ",gothic,"); - if(start != NULL){ - start = strchr((start+8), ','); - if(start != NULL){ - start = strchr((start+1), ','); - if(start != NULL){ - end = strchr((start+1), ','); - if(end != NULL){ - g_string_append_len(temp2, (start+1), end - start - 2 + 1); - convert99(temp2, out); - return; - } - } - } - } - //second:search another shotai - if(kShotai == kMincho) start = strstr(buf, ",gothic,"); - else start = strstr(buf, ",mincho,"); - if(start != NULL){ - start = strchr((start+8), ','); - if(start != NULL){ - start = strchr((start+1), ','); - if(start != NULL){ - end = strchr((start+1), ','); - if(end != NULL){ - g_string_append_len(temp2, (start+1), end - start - 2 + 1); - convert99(temp2, out); - return; - } - } - } - } + //first:search selected shotai + if(kShotai == kMincho) start = strstr(buf, ",mincho,"); + else start = strstr(buf, ",gothic,"); + if(start != NULL){ + start = strchr((start+8), ','); + if(start != NULL){ + start = strchr((start+1), ','); + if(start != NULL){ + end = strchr((start+1), ','); + if(end != NULL){ + kg_string_append_len(temp2, (start+1), end - start - 2 + 1); + convert99(temp2, out); + return; + } + } + } + } + //second:search another shotai + if(kShotai == kMincho) start = strstr(buf, ",gothic,"); + else start = strstr(buf, ",mincho,"); + if(start != NULL){ + start = strchr((start+8), ','); + if(start != NULL){ + start = strchr((start+1), ','); + if(start != NULL){ + end = strchr((start+1), ','); + if(end != NULL){ + kg_string_append_len(temp2, (start+1), end - start - 2 + 1); + convert99(temp2, out); + return; + } + } + } + } free(buf); - } -} - -void searchAliasData(const GString *in, GString *out){ - DBT dbkey, dbdata; - char *start, *end, *buf; - GString *temp; - - //cut off the end '-0000' if 'in' end with it - temp = g_string_new(in->str); -// if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) g_string_set_size(temp, temp->len - 5); - if((temp->str)[0] == 'u'){ - if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) g_string_set_size(temp, temp->len - 4); - else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) g_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) g_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) g_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) g_string_set_size(temp, temp->len - 2); - else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) g_string_set_size(temp, temp->len - 2); - } - - memset(&dbkey,0,sizeof(DBT)); - memset(&dbdata,0,sizeof(DBT)); - dbkey.data = temp->str; - dbkey.size = temp->len; - g_string_set_size(out, 0); - kDatabase->get(kDatabase, NULL, &dbkey, &dbdata, 0); - if(dbdata.size != 0){ + } +} + +void searchAliasData(const KGString *in, KGString *out){ + DBT dbkey, dbdata; + char *start, *end, *buf; + KGString *temp; + + //cut off the end '-0000' if 'in' end with it + temp = kg_string_new(in->str); +// if(strncmp(temp->str + temp->len - 5, "-0000", 5) == 0) kg_string_set_size(temp, temp->len - 5); + if((temp->str)[0] == 'u'){ + if(strncmp(temp->str + temp->len - 4, "-j00", 4) == 0) kg_string_set_size(temp, temp->len - 4); + else if(strncmp(temp->str + temp->len - 4, "-g00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-t00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-k00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-v00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + else if(strncmp(temp->str + temp->len - 4, "-u00", 4) == 0) kg_string_set_size(temp, temp->len - 2); + } + + memset(&dbkey,0,sizeof(DBT)); + memset(&dbdata,0,sizeof(DBT)); + dbkey.data = temp->str; + dbkey.size = temp->len; + kg_string_set_size(out, 0); + kDatabase->get(kDatabase, NULL, &dbkey, &dbdata, 0); + if(dbdata.size != 0){ buf = (char *)malloc(dbdata.size + 1); strncpy(buf, dbdata.data, dbdata.size + 1); - start = strstr(buf, ",linkto,"); - if(start != NULL){ - start = strchr((start+8), ','); - if(start != NULL){ - start = strchr((start+1), ','); - if(start != NULL){ - end = strchr((start+1), ','); - if(end != NULL){ - g_string_append_len(out, (start+1), end - start - 2 + 1); - } - } - } - } + start = strstr(buf, ",linkto,"); + if(start != NULL){ + start = strchr((start+8), ','); + if(start != NULL){ + start = strchr((start+1), ','); + if(start != NULL){ + end = strchr((start+1), ','); + if(end != NULL){ + kg_string_append_len(out, (start+1), end - start - 2 + 1); + } + } + } + } free(buf); - } -} - + } +} + diff --git a/kagecgi/kageeg.c b/kagecgi/kageeg.c index 56862ba..891a67c 100755 --- a/kagecgi/kageeg.c +++ b/kagecgi/kageeg.c @@ -5,8 +5,8 @@ #include "kagecgi.h" #include "sysdep.h" -void generateGlyphByIDS(const GString *in, GString *out, int flag){ - GString *tmp1, *tmp2; +void generateGlyphByIDS(const KGString *in, KGString *out, int flag){ + KGString *tmp1, *tmp2; //pass this method if 'in' is not UCS parts if((in->str)[0] != 'u'){ @@ -19,18 +19,18 @@ void generateGlyphByIDS(const GString *in, GString *out, int flag){ return; } - tmp1 = g_string_new(in->str); - tmp2 = g_string_new(in->str); + tmp1 = kg_string_new(in->str); + tmp2 = kg_string_new(in->str); //append place flag if(1 <= flag && flag <= 7){ - if(tmp1->len != 7) g_string_append(tmp1, "-"); - if(flag == 1) g_string_append(tmp1, "01"); - else if(flag == 2) g_string_append(tmp1, "02"); - else if(flag == 3) g_string_append(tmp1, "03"); - else if(flag == 4) g_string_append(tmp1, "04"); - else if(flag == 5) g_string_append(tmp1, "05"); - else if(flag == 6) g_string_append(tmp1, "06"); + if(tmp1->len != 7) kg_string_append(tmp1, "-"); + if(flag == 1) kg_string_append(tmp1, "01"); + else if(flag == 2) kg_string_append(tmp1, "02"); + else if(flag == 3) kg_string_append(tmp1, "03"); + else if(flag == 4) kg_string_append(tmp1, "04"); + else if(flag == 5) kg_string_append(tmp1, "05"); + else if(flag == 6) kg_string_append(tmp1, "06"); } generateGlyph(tmp1, out); @@ -40,16 +40,16 @@ void generateGlyphByIDS(const GString *in, GString *out, int flag){ return; } -void generateGlyph(const GString *in, GString *out){ - GString *tmp; - tmp = g_string_new(""); - g_string_set_size(out, 0); +void generateGlyph(const KGString *in, KGString *out){ + KGString *tmp; + tmp = kg_string_new(""); + kg_string_set_size(out, 0); //search from parts searchPartsData(in, tmp); if(tmp->len != 0){ tmp = CalcSizes(tmp, 1); - g_string_assign(out, tmp->str); + out = kg_string_assign(out, tmp->str); return; } @@ -71,19 +71,19 @@ void generateGlyph(const GString *in, GString *out){ } } -void doCombine(const GString *in, GString *out){ - GString *partIDS1, *partIDS2, *partIDS3; - GString *partStroke1, *partStroke2, *partStroke3; +void doCombine(const KGString *in, KGString *out){ + KGString *partIDS1, *partIDS2, *partIDS3; + KGString *partStroke1, *partStroke2, *partStroke3; int result[12]; - partIDS1 = g_string_new(""); - partIDS2 = g_string_new(""); - partIDS3 = g_string_new(""); - partStroke1 = g_string_new(""); - partStroke2 = g_string_new(""); - partStroke3 = g_string_new(""); + partIDS1 = kg_string_new(""); + partIDS2 = kg_string_new(""); + partIDS3 = kg_string_new(""); + partStroke1 = kg_string_new(""); + partStroke2 = kg_string_new(""); + partStroke3 = kg_string_new(""); - g_string_set_size(out, 0); + kg_string_set_size(out, 0); //check first IDC if(strncmp(in->str, "u2ff", 4) != 0) return; @@ -205,7 +205,7 @@ void doCombine(const GString *in, GString *out){ } } -void drawGlyph(const GString *in, const int mode){ +void drawGlyph(const KGString *in, const int mode){ int i, j; int *buf; buf = convertStroke(in->str, buf, &j); diff --git a/kagecgi/kageic.c b/kagecgi/kageic.c index 8031ee0..ad67f0a 100755 --- a/kagecgi/kageic.c +++ b/kagecgi/kageic.c @@ -13,24 +13,24 @@ void icPolygon(kPoint *poly, int number){ } else if(kMode == 1){ //output for svg sprintf(buf, ""); - g_string_append(kResultText, buf); + kg_string_append(kResultText, buf); } else if(kMode == 2){ //output for eps sprintf(buf, "%.0f %.0f moveto\n", poly[0].X * 5, 1000 - (poly[0].Y * 5) - 200); - g_string_append(kResultText, buf); + kg_string_append(kResultText, buf); for(i = 1; i < number; i++){ sprintf(buf, " %.0f %.0f lineto\n", poly[i].X * 5, 1000 - (poly[i].Y * 5) - 200); - g_string_append(kResultText, buf); + kg_string_append(kResultText, buf); } sprintf(buf, " %.0f %.0f lineto\n", poly[0].X * 5, 1000 - (poly[0].Y * 5) - 200); - g_string_append(kResultText, buf); - g_string_append(kResultText, "closepath\n"); + kg_string_append(kResultText, buf); + kg_string_append(kResultText, "closepath\n"); } } diff --git a/kagecgi/kagetool.c b/kagecgi/kagetool.c index 9c23bc8..77a2147 100755 --- a/kagecgi/kagetool.c +++ b/kagecgi/kagetool.c @@ -53,7 +53,7 @@ void DotsHeight(int *dly, int *dry){ } } -void PartsWidth(const GString *in, int *lx, int *rx){ +void PartsWidth(const KGString *in, int *lx, int *rx){ int i; int *buf, strokes; @@ -80,7 +80,7 @@ void PartsWidth(const GString *in, int *lx, int *rx){ free(buf); } -void PartsHeight(const GString *in, int *ly, int *ry){ +void PartsHeight(const KGString *in, int *ly, int *ry){ int i; int *buf, strokes; @@ -107,7 +107,7 @@ void PartsHeight(const GString *in, int *ly, int *ry){ free(buf); } -GString * CalcSizes(const GString *in, int mode){ +KGString * CalcSizes(const KGString *in, int mode){ int i, j, k, basewidth, one_lineX, one_lineY; int dlx1, drx1, dly1, dry1; int px1, py1; @@ -119,9 +119,9 @@ GString * CalcSizes(const GString *in, int mode){ int *buf, strokes; int tf[12]; - GString *out; + KGString *out; - out = g_string_new(""); + out = kg_string_new(""); basewidth = pngWidth * 0.9; if(mode == 0){ @@ -232,7 +232,7 @@ GString * CalcSizes(const GString *in, int mode){ tf[2] = px1 + pr1 * 200; tf[3] = py1 + pry1 * 200; addStrokeWithTransform(in, 1, tf, out, 0); - return g_string_new(out->str); + return kg_string_new(out->str); } void DrawBox(){ @@ -245,7 +245,7 @@ void DrawBox(){ } } -void CalcOptions(const GString *in, int *mitsudo, int *flag, double *yoko, double *tate){ +void CalcOptions(const KGString *in, int *mitsudo, int *flag, double *yoko, double *tate){ int i, j, k, l, flg; int dlx1, drx1, dly1, dry1; int kari, mode; @@ -394,7 +394,7 @@ void CalcOptions(const GString *in, int *mitsudo, int *flag, double *yoko, doubl free(buf); } -void DoDrawParts(const GString *in, const int lx1, const double rf1, const int ly1, const double rfy1){ +void DoDrawParts(const KGString *in, const int lx1, const double rf1, const int ly1, const double rfy1){ int i; int *buf, strokes; @@ -416,10 +416,10 @@ void DoDrawParts(const GString *in, const int lx1, const double rf1, const int l free(buf); } -void DoDrawMixFont(const GString *in1, +void DoDrawMixFont(const KGString *in1, const int lx1, const double rf1, - const GString *in2, + const KGString *in2, const int lx2, const double rf2, const int ly1, diff --git a/kagecgi/sysdep.h b/kagecgi/sysdep.h index b48e08d..3b71411 100755 --- a/kagecgi/sysdep.h +++ b/kagecgi/sysdep.h @@ -8,9 +8,8 @@ #include -#include - #include #include +#include "kagestr.h" -- 1.7.10.4