HEADER := $(S) $(HEADER)
# ¥½¡¼¥¹¥Õ¥¡¥¤¥ë
-SRC = main.c cache.c parser.c layout.c window.c retriever.c tadlib.c confirm.c poptray.c postres.c http.c submit.c sjisstring.c parselib.c submitutil.c bchan_vobj.c tadurl.c bchan_panels.c bchan_menus.c residhash.c resindexhash.c tadimf.c layoutarray.c array.c render.c layoutstyle.c
+SRC = main.c cache.c parser.c layout.c window.c retriever.c tadlib.c confirm.c poptray.c postres.c http.c submit.c sjisstring.c parselib.c submitutil.c bchan_vobj.c tadurl.c bchan_panels.c bchan_menus.c residhash.c resindexhash.c tadimf.c layoutarray.c array.c render.c layoutstyle.c traydata.c
# ¥Ç¡¼¥¿¥Ü¥Ã¥¯¥¹¥½¡¼¥¹¥Õ¥¡¥¤¥ë
DBSRC =
datlayoutarray_t *boxarray;
};
-LOCAL TC dec[] = {TK_0,TK_1,TK_2,TK_3,TK_4,TK_5,TK_6,TK_7,TK_8,TK_9};
-
-LOCAL W datlayout_res_UW_to_str(UW num, TC *dest)
-{
- W i = 0, digit, draw = 0;
- TC dummy_str[10];
-
- if (dest == NULL) {
- dest = dummy_str;
- }
-
- digit = num / 1000 % 10;
- if ((digit != 0)||(draw != 0)) {
- dest[i++] = dec[digit];
- draw = 1;
- }
- digit = num / 100 % 10;
- if ((digit != 0)||(draw != 0)) {
- dest[i++] = dec[digit];
- draw = 1;
- }
- digit = num / 10 % 10;
- if ((digit != 0)||(draw != 0)) {
- dest[i++] = dec[digit];
- draw = 1;
- }
- digit = num % 10;
- if ((digit != 0)||(draw != 0)) {
- dest[i++] = dec[digit];
- draw = 1;
- }
-
- return i;
-}
-
-LOCAL W datlayout_res_totraytextdata_write_zenkaku(TC *str)
-{
- TADSEG *seg = (TADSEG*)str;
-
- if (str == NULL) {
- return 10;
- }
-
- seg->id = 0xFF00|TS_TFONT;
- seg->len = 6;
- *(UH*)(str + 2) = 3 << 8;
- *(RATIO*)(str + 3) = 0x0101;
- *(RATIO*)(str + 4) = 0x0101;
-
- return 10;
-}
-
-LOCAL W datlayout_res_totraytextdata(datlayout_res_t *res, B *data, W data_len)
-{
- W i = 0, num, digit, draw = 0;
- TC *str = (TC*)data;
-
- if (data != NULL) {
- num = res->index + 1;
- i += datlayout_res_totraytextdata_write_zenkaku(str + i) / 2;
- digit = num / 1000 % 10;
- if ((digit != 0)||(draw != 0)) {
- str[i++] = dec[digit];
- draw = 1;
- }
- digit = num / 100 % 10;
- if ((digit != 0)||(draw != 0)) {
- str[i++] = dec[digit];
- draw = 1;
- }
- digit = num / 10 % 10;
- if ((digit != 0)||(draw != 0)) {
- str[i++] = dec[digit];
- draw = 1;
- }
- digit = num % 10;
- if ((digit != 0)||(draw != 0)) {
- str[i++] = dec[digit];
- draw = 1;
- }
- str[i++] = TK_KSP;
- i += tadlib_remove_TA_APPL(res->parser_res->name, res->parser_res->name_len, str + i, data_len - i / 2) / 2;
- str[i++] = TK_KSP;
- i += datlayout_res_totraytextdata_write_zenkaku(str + i) / 2;
- str[i++] = TK_LABR;
- i += tadlib_remove_TA_APPL(res->parser_res->mail, res->parser_res->mail_len, str + i, data_len - i / 2) / 2;
- i += datlayout_res_totraytextdata_write_zenkaku(str + i) / 2;
- str[i++] = TK_RABR;
- str[i++] = TK_KSP;
- i += tadlib_remove_TA_APPL(res->parser_res->date, res->parser_res->date_len, str + i, data_len - i / 2) / 2;
- str[i++] = TK_NL;
- i += datlayout_res_totraytextdata_write_zenkaku(str + i) / 2;
- i += tadlib_remove_TA_APPL(res->parser_res->body, res->parser_res->body_len, str + i, data_len - i / 2) / 2;
- str[i++] = TK_NL;
- } else {
- num = res->index + 1;
- i += datlayout_res_totraytextdata_write_zenkaku(NULL) / 2;
- if ((0 <= num)&&(num < 10)) {
- i += 1;
- } else if ((10 <= num)&&(num < 100)) {
- i += 2;
- } else if ((100 <= num)&&(num < 1000)) {
- i += 3;
- } else if (1000 <= num) {
- i += 4;
- }
- i++; /* TK_KSP */
- i += tadlib_remove_TA_APPL_calcsize(res->parser_res->name, res->parser_res->name_len) / 2;
- i++; /* TK_KSP */
- i += datlayout_res_totraytextdata_write_zenkaku(NULL) / 2;
- i++; /* TO_LABR */
- i += tadlib_remove_TA_APPL_calcsize(res->parser_res->mail, res->parser_res->mail_len) / 2;
- i += datlayout_res_totraytextdata_write_zenkaku(NULL) / 2;
- i++; /* TO_RABR */
- i++; /* TK_KSP */
- i += tadlib_remove_TA_APPL_calcsize(res->parser_res->date, res->parser_res->date_len) / 2;
- i++; /* TK_NL */
- i += datlayout_res_totraytextdata_write_zenkaku(NULL) / 2;
- i += tadlib_remove_TA_APPL_calcsize(res->parser_res->body, res->parser_res->body_len) / 2;
- i++; /* TK_NL */
- }
-
- return i * sizeof(TC);
-}
-
LOCAL W datlayout_res_calcresheaderdrawsize(datlayout_res_t *layout_res, GID gid, SIZE *sz)
{
SIZE sz_number = {0,0}, sz_name = {0,0}, sz_mail = {0,0}, sz_date = {0,0}, sz_id = {0,0}, sz_beid = {0,0};
W numstr_len, chwidth;
H id_left = 0;
- numstr_len = datlayout_res_UW_to_str(layout_res->index + 1, numstr);
+ numstr_len = tadlib_UW_to_str(layout_res->index + 1, numstr, 10);
layoutstyle_resetgenvfont(gid);
tadlib_calcdrawsize(numstr, numstr_len, gid, &sz_number, &alist_tmp);
return err;
}
-EXPORT W datlayout_resindextotraytextdata(datlayout_t *layout, W n, B *data, W data_len)
-{
- datlayout_res_t *res;
- Bool exist;
- exist = datlayoutarray_getresbyindex(layout->boxarray, n, &res);
- if (exist == False) {
- return -1; /* TODO */
- }
- return datlayout_res_totraytextdata(res, data, data_len);
-}
-
-EXPORT W datlayout_idtotraytextdata(datlayout_t *layout, TC *id, W id_len, B *data, W data_len)
-{
- W i, len, result, sum = 0;
- Bool haveid;
- datlayout_res_t *res;
-
- len = datlayoutarray_length(layout->boxarray);
- for (i = 0; i < len; i++) {
- datlayoutarray_getresbyindex(layout->boxarray, i, &res);
-
- haveid = datlayout_res_issameid(res, id, id_len);
- if (haveid == True) {
- if (data == NULL) {
- result = datlayout_res_totraytextdata(res, NULL, 0);
- if (result < 0) {
- return result;
- }
- } else {
- result = datlayout_res_totraytextdata(res, data + sum, data_len - sum);
- if (result < 0) {
- return result;
- }
- }
- sum += result;
- }
- }
-
- return sum;
-}
-
EXPORT W datlayout_appendres(datlayout_t *layout, datparser_res_t *parser_res)
{
datlayout_res_t *layout_res;
IMPORT W datlayout_gettitlelen(datlayout_t *layout);
IMPORT VOID datlayout_clear(datlayout_t *layout);
IMPORT W datlayout_getthreadviewrectbyindex(datlayout_t *layout, W n, W *l, W *t, W *r, W *b);
-IMPORT W datlayout_resindextotraytextdata(datlayout_t *layout, W n, B *data, W data_len);
-IMPORT W datlayout_idtotraytextdata(datlayout_t *layout, TC *id, W id_len, B *data, W data_len);
#endif
#include "layoutstyle.h"
#include "layout.h"
#include "render.h"
+#include "traydata.h"
#include "retriever.h"
#include "submit.h"
#include "tadurl.h"
datlayoutstyle_t style;
datlayout_t *layout;
datrender_t *render;
+ dattraydata_t *traydata;
datwindow_t *window;
ressubmit_t *submit;
cfrmwindow_t *confirm;
gcnv_abs(bchan->gid, &pos);
err = bchan_resnumbermenu_select(&bchan->resnumbermenu, pos);
if (err == BCHAN_RESNUMBERMENU_SELECT_PUSHTRAY) {
- size = datlayout_resindextotraytextdata(bchan->layout, resindex, NULL, 0);
+ size = dattraydata_resindextotraytextdata(bchan->traydata, resindex, NULL, 0);
data = malloc(size);
if (data == NULL) {
return;
}
- datlayout_resindextotraytextdata(bchan->layout, resindex, data, size);
+ dattraydata_resindextotraytextdata(bchan->traydata, resindex, data, size);
bchan_pushstringtotray((TC*)data, size/2);
free(data);
} if (err == BCHAN_RESNUMBERMENU_SELECT_NG) {
gcnv_abs(bchan->gid, &pos);
err = bchan_residmenu_select(&bchan->residmenu, pos);
if (err == BCHAN_RESIDMENU_SELECT_PUSHTRAY) {
- size = datlayout_idtotraytextdata(bchan->layout, id, id_len, NULL, 0);
+ size = dattraydata_idtotraytextdata(bchan->traydata, id, id_len, NULL, 0);
data = malloc(size);
if (data == NULL) {
return;
}
- datlayout_idtotraytextdata(bchan->layout, id, id_len, data, size);
+ dattraydata_idtotraytextdata(bchan->traydata, id, id_len, data, size);
bchan_pushstringtotray((TC*)data, size/2);
free(data);
} if (err == BCHAN_RESIDMENU_SELECT_NG) {
datlayoutarray_t *layoutarray;
datlayout_t *layout;
datrender_t *render;
+ dattraydata_t *traydata;
datwindow_t *window;
datretriever_t *retriever;
ressubmit_t *submit;
DP_ER("datrender_new error", 0);
goto error_render;
}
+ traydata = dattraydata_new(layoutarray);
+ if (traydata == NULL) {
+ DP_ER("dattraydata_new error", 0);
+ goto error_traydata;
+ }
window = datwindow_new(wid, bchan_scroll, bchan_draw, bchan_resize, bchan_close, bchan_butdn, bchan_paste, bchan);
if (window == NULL) {
DP_ER("datwindow_new error", 0);
bchan->layoutarray = layoutarray;
bchan->layout = layout;
bchan->render = render;
+ bchan->traydata = traydata;
bchan->window = window;
bchan->retriever = retriever;
bchan->submit = submit;
error_retriever:
datwindow_delete(window);
error_window:
+ dattraydata_delete(traydata);
+error_traydata:
datrender_delete(render);
error_render:
datlayout_delete(layout);
#endif
}
-LOCAL TC dec[] = {TK_0,TK_1,TK_2,TK_3,TK_4,TK_5,TK_6,TK_7,TK_8,TK_9}; /* TODO: layout.c */
-
LOCAL W datrender_entrydraw_resnumber(datlayout_res_t *entry, W resnum, GID target)
{
- W err,digit,draw = 0;
+ W err,numstr_len;
+ TC numstr[10];
- digit = resnum / 1000 % 10;
- if ((digit != 0)||(draw != 0)) {
- err = gdra_chr(target, dec[digit], G_STORE);
- if (err < 0) {
- return err;
- }
- draw = 1;
- }
- digit = resnum / 100 % 10;
- if ((digit != 0)||(draw != 0)) {
- err = gdra_chr(target, dec[digit], G_STORE);
- if (err < 0) {
- return err;
- }
- draw = 1;
- }
- digit = resnum / 10 % 10;
- if ((digit != 0)||(draw != 0)) {
- err = gdra_chr(target, dec[digit], G_STORE);
- if (err < 0) {
- return err;
- }
- draw = 1;
- }
- digit = resnum % 10;
- if ((digit != 0)||(draw != 0)) {
- err = gdra_chr(target, dec[digit], G_STORE);
- if (err < 0) {
- return err;
- }
- draw = 1;
+ numstr_len = tadlib_UW_to_str(resnum, numstr, 10);
+ err = gdra_str(target, numstr, numstr_len, G_STORE);
+ if (err < 0) {
+ return err;
}
return 0;
return i;
}
+LOCAL TC dec[] = {TK_0,TK_1,TK_2,TK_3,TK_4,TK_5,TK_6,TK_7,TK_8,TK_9};
+
+EXPORT W tadlib_UW_to_str(UW val, TC *dest, W dest_len)
+{
+ W i = 0, digit, draw = 0;
+ TC dummy_str[10];
+
+ if (dest == NULL) {
+ dest = dummy_str;
+ }
+
+ digit = val / 1000 % 10;
+ if ((digit != 0)||(draw != 0)) {
+ dest[i++] = dec[digit];
+ draw = 1;
+ }
+ digit = val / 100 % 10;
+ if ((digit != 0)||(draw != 0)) {
+ dest[i++] = dec[digit];
+ draw = 1;
+ }
+ digit = val / 10 % 10;
+ if ((digit != 0)||(draw != 0)) {
+ dest[i++] = dec[digit];
+ draw = 1;
+ }
+ digit = val % 10;
+ if ((digit != 0)||(draw != 0)) {
+ dest[i++] = dec[digit];
+ draw = 1;
+ }
+
+ return i;
+}
+
EXPORT VOID tadlib_separete_datepart(TC *str, W len, TC **date, W *date_len, TC **id, W *id_len, TC **beid, W *beid_len)
{
taditerator_t iter;
IMPORT W tadlib_drawtext(TC *str, W len, GID gid, W dh, W dv);
IMPORT W tadlib_remove_TA_APPL_calcsize(TC *str, W len);
IMPORT W tadlib_remove_TA_APPL(TC *str, W len, TC *dest, W dest_len);
+IMPORT W tadlib_UW_to_str(UW val, TC *dest, W dest_len);
IMPORT VOID tadlib_separete_datepart(TC *str, W len, TC **date, W *date_len, TC **id, W *id_len, TC **beid, W *beid_len);
struct taditerator_t_ {
--- /dev/null
+/*
+ * traydata.c
+ *
+ * Copyright (c) 2010 project bchan
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source
+ * distribution.
+ *
+ */
+
+#include "traydata.h"
+#include "layoutarray.h"
+#include "tadlib.h"
+
+#include <basic.h>
+#include <bstdlib.h>
+#include <bstdio.h>
+#include <tcode.h>
+
+#ifdef BCHAN_CONFIG_DEBUG
+# define DP(arg) printf arg
+# define DP_ER(msg, err) printf("%s (%d/%x)\n", msg, err>>16, err)
+#else
+# define DP(arg) /**/
+# define DP_ER(msg, err) /**/
+#endif
+
+struct dattraydata_t_ {
+ datlayoutarray_t *layoutarray;
+};
+
+LOCAL W datlayout_res_totraytextdata_write_zenkaku(TC *str)
+{
+ TADSEG *seg = (TADSEG*)str;
+
+ if (str == NULL) {
+ return 10;
+ }
+
+ seg->id = 0xFF00|TS_TFONT;
+ seg->len = 6;
+ *(UH*)(str + 2) = 3 << 8;
+ *(RATIO*)(str + 3) = 0x0101;
+ *(RATIO*)(str + 4) = 0x0101;
+
+ return 10;
+}
+
+LOCAL W datlayout_res_totraytextdata(datlayout_res_t *res, B *data, W data_len)
+{
+ W i = 0, num;
+ TC *str = (TC*)data;
+
+ if (data != NULL) {
+ num = res->index + 1;
+ i += datlayout_res_totraytextdata_write_zenkaku(str + i) / 2;
+ i += tadlib_UW_to_str(num, str + i, data_len - i / 2);
+ str[i++] = TK_KSP;
+ i += tadlib_remove_TA_APPL(res->parser_res->name, res->parser_res->name_len, str + i, data_len - i / 2) / 2;
+ str[i++] = TK_KSP;
+ i += datlayout_res_totraytextdata_write_zenkaku(str + i) / 2;
+ str[i++] = TK_LABR;
+ i += tadlib_remove_TA_APPL(res->parser_res->mail, res->parser_res->mail_len, str + i, data_len - i / 2) / 2;
+ i += datlayout_res_totraytextdata_write_zenkaku(str + i) / 2;
+ str[i++] = TK_RABR;
+ str[i++] = TK_KSP;
+ i += tadlib_remove_TA_APPL(res->parser_res->date, res->parser_res->date_len, str + i, data_len - i / 2) / 2;
+ str[i++] = TK_NL;
+ i += datlayout_res_totraytextdata_write_zenkaku(str + i) / 2;
+ i += tadlib_remove_TA_APPL(res->parser_res->body, res->parser_res->body_len, str + i, data_len - i / 2) / 2;
+ str[i++] = TK_NL;
+ } else {
+ num = res->index + 1;
+ i += datlayout_res_totraytextdata_write_zenkaku(NULL) / 2;
+ i += tadlib_UW_to_str(num, NULL, 0);
+ i++; /* TK_KSP */
+ i += tadlib_remove_TA_APPL_calcsize(res->parser_res->name, res->parser_res->name_len) / 2;
+ i++; /* TK_KSP */
+ i += datlayout_res_totraytextdata_write_zenkaku(NULL) / 2;
+ i++; /* TO_LABR */
+ i += tadlib_remove_TA_APPL_calcsize(res->parser_res->mail, res->parser_res->mail_len) / 2;
+ i += datlayout_res_totraytextdata_write_zenkaku(NULL) / 2;
+ i++; /* TO_RABR */
+ i++; /* TK_KSP */
+ i += tadlib_remove_TA_APPL_calcsize(res->parser_res->date, res->parser_res->date_len) / 2;
+ i++; /* TK_NL */
+ i += datlayout_res_totraytextdata_write_zenkaku(NULL) / 2;
+ i += tadlib_remove_TA_APPL_calcsize(res->parser_res->body, res->parser_res->body_len) / 2;
+ i++; /* TK_NL */
+ }
+
+ return i * sizeof(TC);
+}
+
+EXPORT W dattraydata_resindextotraytextdata(dattraydata_t *traydata, W n, B *data, W data_len)
+{
+ datlayout_res_t *res;
+ Bool exist;
+ exist = datlayoutarray_getresbyindex(traydata->layoutarray, n, &res);
+ if (exist == False) {
+ return -1; /* TODO */
+ }
+ return datlayout_res_totraytextdata(res, data, data_len);
+}
+
+EXPORT W dattraydata_idtotraytextdata(dattraydata_t *traydata, TC *id, W id_len, B *data, W data_len)
+{
+ W i, len, result, sum = 0;
+ Bool haveid;
+ datlayout_res_t *res;
+
+ len = datlayoutarray_length(traydata->layoutarray);
+ for (i = 0; i < len; i++) {
+ datlayoutarray_getresbyindex(traydata->layoutarray, i, &res);
+
+ haveid = datlayout_res_issameid(res, id, id_len);
+ if (haveid == True) {
+ if (data == NULL) {
+ result = datlayout_res_totraytextdata(res, NULL, 0);
+ if (result < 0) {
+ return result;
+ }
+ } else {
+ result = datlayout_res_totraytextdata(res, data + sum, data_len - sum);
+ if (result < 0) {
+ return result;
+ }
+ }
+ sum += result;
+ }
+ }
+
+ return sum;
+}
+
+EXPORT dattraydata_t* dattraydata_new(datlayoutarray_t *layoutarray)
+{
+ dattraydata_t *traydata;
+
+ traydata = (dattraydata_t *)malloc(sizeof(dattraydata_t));
+ if (traydata == NULL) {
+ return NULL;
+ }
+ traydata->layoutarray = layoutarray;
+
+ return traydata;
+}
+
+EXPORT VOID dattraydata_delete(dattraydata_t *traydata)
+{
+ free(traydata);
+}
--- /dev/null
+/*
+ * traydata.h
+ *
+ * Copyright (c) 2010 project bchan
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source
+ * distribution.
+ *
+ */
+
+#include <basic.h>
+
+#include "layoutarray.h"
+
+#ifndef __TRAYDATA_H__
+#define __TRAYDATA_H__
+
+typedef struct dattraydata_t_ dattraydata_t;
+
+IMPORT dattraydata_t* dattraydata_new(datlayoutarray_t *layoutarray);
+IMPORT VOID dattraydata_delete(dattraydata_t *traydata);
+IMPORT W dattraydata_resindextotraytextdata(dattraydata_t *traydata, W n, B *data, W data_len);
+IMPORT W dattraydata_idtotraytextdata(dattraydata_t *traydata, TC *id, W id_len, B *data, W data_len);
+
+#endif