diff options
author | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2012-09-19 20:51:34 -0700 |
---|---|---|
committer | Laxmikant Rashinkar <LK.Rashinkar@gmail.com> | 2012-09-19 20:51:34 -0700 |
commit | 1123323fda6d128fb98b0427e0ea5f6a2dc9e632 (patch) | |
tree | 3407a3771a069f812554312ce7c36db625139cc2 /xrdp/xrdp_font.c | |
parent | 3cedfae76a2351bc8b1e5bd2ee33bbf8630dbacf (diff) | |
download | xrdp-proprietary-1123323fda6d128fb98b0427e0ea5f6a2dc9e632.tar.gz xrdp-proprietary-1123323fda6d128fb98b0427e0ea5f6a2dc9e632.zip |
o moved from GNU General Public License to Apache License, Version 2.0
o applied new coding standards to all .c files
o moved some files around
Diffstat (limited to 'xrdp/xrdp_font.c')
-rw-r--r-- | xrdp/xrdp_font.c | 359 |
1 files changed, 189 insertions, 170 deletions
diff --git a/xrdp/xrdp_font.c b/xrdp/xrdp_font.c index e1c4257b..91734807 100644 --- a/xrdp/xrdp_font.c +++ b/xrdp/xrdp_font.c @@ -1,26 +1,24 @@ +/** + * xrdp: A Remote Desktop Protocol server. + * + * Copyright (C) Jay Sorg 2004-2012 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * fonts + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - xrdp: A Remote Desktop Protocol server. - Copyright (C) Jay Sorg 2004-2010 - - fonts - -*/ -/* The fv1 files contain Font File Header (just one) FNT1 4 bytes @@ -43,176 +41,197 @@ #if 0 /* not used */ static char w_char[] = { - 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, - 0x08, 0x20, 0x80, - 0x08, 0x50, 0x80, - 0x04, 0x51, 0x00, - 0x04, 0x51, 0x00, - 0x04, 0x51, 0x00, - 0x02, 0x8a, 0x00, - 0x02, 0x8a, 0x00, - 0x02, 0x8a, 0x00, - 0x01, 0x04, 0x00, - 0x01, 0x04, 0x00, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x08, 0x20, 0x80, + 0x08, 0x50, 0x80, + 0x04, 0x51, 0x00, + 0x04, 0x51, 0x00, + 0x04, 0x51, 0x00, + 0x02, 0x8a, 0x00, + 0x02, 0x8a, 0x00, + 0x02, 0x8a, 0x00, + 0x01, 0x04, 0x00, + 0x01, 0x04, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, }; #endif /*****************************************************************************/ -struct xrdp_font* APP_CC -xrdp_font_create(struct xrdp_wm* wm) +struct xrdp_font *APP_CC +xrdp_font_create(struct xrdp_wm *wm) { - struct xrdp_font* self; - struct stream* s; - int fd; - int b; - int i; - int index; - int datasize; - int file_size; - struct xrdp_font_char* f; - char file_path[256]; - - DEBUG(("in xrdp_font_create")); - g_snprintf(file_path, 255, "%s/%s", XRDP_SHARE_PATH, DEFAULT_FONT_NAME); - if (!g_file_exist(file_path)) - { - g_writeln("xrdp_font_create: error font file [%s] does not exist", - file_path); - return 0; - } - file_size = g_file_get_size(file_path); - if (file_size < 1) - { - g_writeln("xrdp_font_create: error reading font from file [%s]", - file_path); - return 0; - } - self = (struct xrdp_font*)g_malloc(sizeof(struct xrdp_font), 1); - self->wm = wm; - make_stream(s); - init_stream(s, file_size + 1024); - fd = g_file_open(file_path); - if (fd != -1) - { - b = g_file_read(fd, s->data, file_size + 1024); - g_file_close(fd); - if (b > 0) + struct xrdp_font *self; + struct stream *s; + int fd; + int b; + int i; + int index; + int datasize; + int file_size; + struct xrdp_font_char *f; + char file_path[256]; + + DEBUG(("in xrdp_font_create")); + g_snprintf(file_path, 255, "%s/%s", XRDP_SHARE_PATH, DEFAULT_FONT_NAME); + + if (!g_file_exist(file_path)) { - s->end = s->data + b; - in_uint8s(s, 4); - in_uint8a(s, self->name, 32); - in_uint16_le(s, self->size); - in_uint16_le(s, self->style); - in_uint8s(s, 8); - index = 32; - while (s_check_rem(s, 16)) - { - f = self->font_items + index; - in_sint16_le(s, i); - f->width = i; - in_sint16_le(s, i); - f->height = i; - in_sint16_le(s, i); - f->baseline = i; - in_sint16_le(s, i); - f->offset = i; - in_sint16_le(s, i); - f->incby = i; - in_uint8s(s, 6); - datasize = FONT_DATASIZE(f); - if (datasize < 0 || datasize > 512) - { - /* shouldn't happen */ - g_writeln("error in xrdp_font_create, datasize wrong"); - g_writeln("width %d height %d datasize %d index %d", - f->width, f->height, datasize, index); - break; - } - if (s_check_rem(s, datasize)) - { - f->data = (char*)g_malloc(datasize, 0); - in_uint8a(s, f->data, datasize); - } - else + g_writeln("xrdp_font_create: error font file [%s] does not exist", + file_path); + return 0; + } + + file_size = g_file_get_size(file_path); + + if (file_size < 1) + { + g_writeln("xrdp_font_create: error reading font from file [%s]", + file_path); + return 0; + } + + self = (struct xrdp_font *)g_malloc(sizeof(struct xrdp_font), 1); + self->wm = wm; + make_stream(s); + init_stream(s, file_size + 1024); + fd = g_file_open(file_path); + + if (fd != -1) + { + b = g_file_read(fd, s->data, file_size + 1024); + g_file_close(fd); + + if (b > 0) { - g_writeln("error in xrdp_font_create"); + s->end = s->data + b; + in_uint8s(s, 4); + in_uint8a(s, self->name, 32); + in_uint16_le(s, self->size); + in_uint16_le(s, self->style); + in_uint8s(s, 8); + index = 32; + + while (s_check_rem(s, 16)) + { + f = self->font_items + index; + in_sint16_le(s, i); + f->width = i; + in_sint16_le(s, i); + f->height = i; + in_sint16_le(s, i); + f->baseline = i; + in_sint16_le(s, i); + f->offset = i; + in_sint16_le(s, i); + f->incby = i; + in_uint8s(s, 6); + datasize = FONT_DATASIZE(f); + + if (datasize < 0 || datasize > 512) + { + /* shouldn't happen */ + g_writeln("error in xrdp_font_create, datasize wrong"); + g_writeln("width %d height %d datasize %d index %d", + f->width, f->height, datasize, index); + break; + } + + if (s_check_rem(s, datasize)) + { + f->data = (char *)g_malloc(datasize, 0); + in_uint8a(s, f->data, datasize); + } + else + { + g_writeln("error in xrdp_font_create"); + } + + index++; + } } - index++; - } } - } - free_stream(s); -/* - self->font_items[0].offset = -4; - self->font_items[0].baseline = -16; - self->font_items[0].width = 24; - self->font_items[0].height = 16; - self->font_items[0].data = g_malloc(3 * 16, 0); - g_memcpy(self->font_items[0].data, w_char, 3 * 16); -*/ - DEBUG(("out xrdp_font_create")); - return self; + + free_stream(s); + /* + self->font_items[0].offset = -4; + self->font_items[0].baseline = -16; + self->font_items[0].width = 24; + self->font_items[0].height = 16; + self->font_items[0].data = g_malloc(3 * 16, 0); + g_memcpy(self->font_items[0].data, w_char, 3 * 16); + */ + DEBUG(("out xrdp_font_create")); + return self; } /*****************************************************************************/ /* free the font and all the items */ void APP_CC -xrdp_font_delete(struct xrdp_font* self) +xrdp_font_delete(struct xrdp_font *self) { - int i; - - if (self == 0) - { - return; - } - for (i = 0; i < NUM_FONTS; i++) - { - g_free(self->font_items[i].data); - } - g_free(self); + int i; + + if (self == 0) + { + return; + } + + for (i = 0; i < NUM_FONTS; i++) + { + g_free(self->font_items[i].data); + } + + g_free(self); } /*****************************************************************************/ /* compare the two font items returns 1 if they match */ int APP_CC -xrdp_font_item_compare(struct xrdp_font_char* font1, - struct xrdp_font_char* font2) +xrdp_font_item_compare(struct xrdp_font_char *font1, + struct xrdp_font_char *font2) { - int datasize; + int datasize; + + if (font1 == 0) + { + return 0; + } + + if (font2 == 0) + { + return 0; + } + + if (font1->offset != font2->offset) + { + return 0; + } + + if (font1->baseline != font2->baseline) + { + return 0; + } + + if (font1->width != font2->width) + { + return 0; + } + + if (font1->height != font2->height) + { + return 0; + } + + datasize = FONT_DATASIZE(font1); + + if (g_memcmp(font1->data, font2->data, datasize) == 0) + { + return 1; + } - if (font1 == 0) - { - return 0; - } - if (font2 == 0) - { - return 0; - } - if (font1->offset != font2->offset) - { - return 0; - } - if (font1->baseline != font2->baseline) - { - return 0; - } - if (font1->width != font2->width) - { - return 0; - } - if (font1->height != font2->height) - { return 0; - } - datasize = FONT_DATASIZE(font1); - if (g_memcmp(font1->data, font2->data, datasize) == 0) - { - return 1; - } - return 0; } |