|
From: Alex M. S. <arc...@us...> - 2004-04-01 22:44:02
|
Update of /cvsroot/nettle/nettle/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27888/c Modified Files: chardefn choices socket zapgen Log Message: Part 1 of many - let's tidy up the codebase a bit. This week: c/chardefn and friends Index: chardefn =================================================================== RCS file: /cvsroot/nettle/nettle/c/chardefn,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** chardefn 2 Feb 2002 21:30:45 -0000 1.14 --- chardefn 1 Apr 2004 22:31:59 -0000 1.15 *************** *** 1,7 **** /** * Zap font character definitions - * (C) Nettle developers 2000-2001 * ! * $Id$ */ --- 1,10 ---- /** + * * Zap font character definitions * ! * © Nettle developers 2000-2004 ! * ! * @version $Id$ ! * */ *************** *** 13,72 **** #include "zapredraw.h" ! /* Define Zap graphics characters */ ! static void copypair (char *area, int step, int height, ! const char *base, char upper, char lower) ! { ! int x, y; ! const char *ptr = base + upper * step * height; ! for (y = 0; y < height; y++) ! { ! memcpy (area, ptr, step); ! if ((height & 1) && y == height / 2) ! ptr = base + lower * step * height; ! else ! ptr += step; ! for (x = step - 1; x >= 0; x--) ! area[x] |= ptr[x]; ! if ((height & 1) == 0 && y == (height - 1) / 2) ! ptr = base + lower * step * height; ! else ! ptr += step; ! area += step; ! } ! } ! ! static void make_underline (char *area, int step, int height) ! { ! char pixels[8] = {0}; /* hmm, trouble if the font is > 64 pixels wide... */ ! int x; ! area += step * height; ! while (--height > 1) ! { ! area -= step; ! for (x = step - 1; x >= 0; --x) ! { ! area[x >> 3] |= area[(x >> 3) - 2 * step] & ~pixels[x >> 3]; ! pixels[x >> 3] |= area[x >> 3]; ! } ! } ! } ! void define_zap_chars(int *int_area, int char_size, int width, int height) { int loop; int step=char_size/height; char *area=(char *) int_area; - const char *base = area; /* define characters */ area += 0x100 * char_size; ! /* initialise extra character area (chars 0x100-<end>) to 0 */ ! memset (area, 0, EXTRA_ZAP_CHARS * char_size); /* Active Cursor 0x100 */ --- 16,74 ---- #include "zapredraw.h" ! /** ! * Takes 2 characters, puts upper in the topleft of a character, and ! * lower in the bottomright of a chracter, and stores it in area ! * ! * @param area Character to be filled in ! * @param step Step size in bytes ! * @param height Height of the character ! * @param base Base of ZapRedraw font area ! * @param upper Character to be used in upper-left corner ! * @param lower Character to be used in lower-right corner ! */ static void copypair (char *area, int step, int height, ! const char *base, char upper, char lower); ! /** ! * Takes a character area, and underlines it ! * ! * @param area Character to be filled in ! * @param step Step size in bytes ! * @param height Height of the character ! */ ! static void make_underline (char *area, int step, int height); ! /** ! * Takes an array of character data, and fills in the undefined characters ! * (ie. those not defined by the Zap font) required by Nettle ! * ! * @param int_area pointer to character data ! * @param first_char first character defined by the Zap font ! * @param last_char last character defined by the Zap font ! * @param char_size size of character in bytes ! * @param width width of character ! * @param height height of character ! */ ! static void define_undefined_characters(int *int_area, ! int first_char, ! int last_char, ! int char_size, ! int width, int height); + /* ----------------------------------------------------------------------- */ ! char *chardefn_define_cursors(int *int_area, int char_size, ! int width, int height, cursor_t cursor_type) { int loop; int step=char_size/height; char *area=(char *) int_area; /* define characters */ area += 0x100 * char_size; ! /* initialise cursor character area to 0 */ ! memset (area, 0, cursor_last * char_size); /* Active Cursor 0x100 */ *************** *** 130,133 **** --- 132,162 ---- area+=char_size; + return area; + } + + /* ----------------------------------------------------------------------- */ + + void chardefn_define_characters(int *int_area, int first_char, + int last_char, int char_size, + int width, int height, cursor_t cursor_type) + { + int loop; + int step=char_size/height; + char *area=(char *) int_area; + const char *base = area; + /* define characters */ + area += 0x100 * char_size; + + /* initialise extra character area (chars 0x100-<end>) to 0 */ + memset (area, 0, EXTRA_ZAP_CHARS * char_size); + + /* define the undefined characters */ + define_undefined_characters(int_area, first_char, last_char, char_size, + width, height); + + /* define the cursor characters */ + area = chardefn_define_cursors(int_area, char_size, width, height, + cursor_type); + /* Diamond 0x102 */ { *************** *** 339,345 **** } ! void define_zap_undef_chars(int *int_area, int first_char, int last_char, ! int char_size, int width, int height) { char *area = (char *)int_area; --- 368,421 ---- } + /* ----------------------------------------------------------------------- */ ! static void copypair (char *area, int step, int height, ! const char *base, char upper, char lower) ! { ! int x, y; ! const char *ptr = base + upper * step * height; ! for (y = 0; y < height; y++) ! { ! memcpy (area, ptr, step); ! if ((height & 1) && y == height / 2) ! ptr = base + lower * step * height; ! else ! ptr += step; ! for (x = step - 1; x >= 0; x--) ! area[x] |= ptr[x]; ! if ((height & 1) == 0 && y == (height - 1) / 2) ! ptr = base + lower * step * height; ! else ! ptr += step; ! area += step; ! } ! } ! ! /* ----------------------------------------------------------------------- */ ! ! static void make_underline (char *area, int step, int height) ! { ! char pixels[8] = {0}; /* hmm, trouble if the font is > 64 pixels wide... */ ! int x; ! ! area += step * height; ! ! while (--height > 1) ! { ! area -= step; ! for (x = step - 1; x >= 0; --x) ! { ! area[x >> 3] |= area[(x >> 3) - 2 * step] & ~pixels[x >> 3]; ! pixels[x >> 3] |= area[x >> 3]; ! } ! } ! } ! ! /* ----------------------------------------------------------------------- */ ! ! static void define_undefined_characters(int *int_area, ! int first_char, ! int last_char, int char_size, ! int width, int height) { char *area = (char *)int_area; *************** *** 391,392 **** --- 467,471 ---- } } + + /* ----------------------------------------------------------------------- */ + Index: choices =================================================================== RCS file: /cvsroot/nettle/nettle/c/choices,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** choices 13 Dec 2003 17:42:56 -0000 1.39 --- choices 1 Apr 2004 22:31:59 -0000 1.40 *************** *** 536,541 **** * stressful operation anyhow */ ! update_cursors(zap_font_area); ! update_cursors(zap_lowres_font_area); } } --- 536,541 ---- * stressful operation anyhow */ ! zapredraw_update_cursors(zap_font_area, cursor_type); ! zapredraw_update_cursors(zap_lowres_font_area, cursor_type); } } Index: socket =================================================================== RCS file: /cvsroot/nettle/nettle/c/socket,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** socket 25 Oct 2003 23:44:47 -0000 1.36 --- socket 1 Apr 2004 22:31:59 -0000 1.37 *************** *** 54,57 **** --- 54,63 ---- } + if (setsockopt(socket_handle, SOL_SOCKET, SO_OOBINLINE, (char *) &data, sizeof(data))) + { + close(socket_handle); + return -1; + } + socketwatch_register(socket_handle); Index: zapgen =================================================================== RCS file: /cvsroot/nettle/nettle/c/zapgen,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** zapgen 20 Oct 2003 23:48:19 -0000 1.37 --- zapgen 1 Apr 2004 22:31:59 -0000 1.38 *************** *** 306,325 **** ! /* ! * Description: Update the cursors in a given font_area ! * Parameters: font_area-> the area, as returned from load_font ! * Returns: none ! * Note: Will also update all the other special characters; ! * this is not intentional and should be replaced with ! * /just/ the cursors being updated. ! */ ! void update_cursors(int *font_area) { ! int width = font_area[2]; ! int height = font_area[3]; int char_size = ((width+ 7) & ~7)*height/8; /* fill in graphics chars */ ! define_zap_chars(font_area+8, char_size, width, height); } --- 306,319 ---- ! ! void zapredraw_update_cursors(int *font_area, cursor_t cursor_type) { ! int width = font_area[2]; ! int height = font_area[3]; int char_size = ((width+ 7) & ~7)*height/8; /* fill in graphics chars */ ! chardefn_define_cursors(font_area+8, char_size, width, height, ! cursor_type); } *************** *** 473,482 **** fclose(file_handle); ! /* fill in graphics chars */ ! define_zap_chars(zap_load_area+8, char_size, width, height); ! ! /* fill in some undefined characters in range 0x00-0xFF*/ ! define_zap_undef_chars (zap_load_area+8, first_char, last_char, ! char_size, width, height); zap_load_area[4]=0; --- 467,475 ---- fclose(file_handle); ! /* fill in graphics characters and undefined characters */ ! /* FIXME: cursor_type is a global here, we shouldn't have globals */ ! chardefn_define_characters(zap_load_area+8, first_char, ! last_char, char_size, width, ! height, cursor_type); zap_load_area[4]=0; |