summaryrefslogtreecommitdiff
path: root/apps/plugins/clock/clock_bitmap_strings.h
blob: 357dbcd4bced2d732dea9a33216601134297533a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2007 Copyright Kévin Ferrare
 *
 * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/


#ifndef _CLOCK_BITMAP_STRINGS_
#define _CLOCK_BITMAP_STRINGS_
#include "plugin.h"
#include "lib/picture.h"

void draw_string(struct screen* display, const struct picture* bitmaps,
                 char* str, int x, int y);

void getstringsize(const struct picture* bitmaps, char* str, int *w, int *h );

#endif /* _CLOCK_BITMAP_STRINGS_ */
f 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, see <http://www.gnu.org/licenses/>. */ #define TELCMDS /* see <arpa/telnet.h> */ #define TELOPTS #include "globals.h" #include "client.h" #include "telnet.h" static uint16_t term_width, term_height; uint16_t telnet_get_width(void) { return term_width; } uint16_t telnet_get_height(void) { return term_height; } enum telnet_status telnet_parse_data(unsigned char *buf, size_t buflen) { bool iac = false; bool found_cmd = false; bool in_sb = false; bool line_done = false; for(unsigned i = 0; i < buflen; ++i) { unsigned char c = buf[i]; if(c == IAC) iac = true; else if(c == '\n' || c == '\r') line_done = true; else if(c == '\0') // ignore NULLs buf[i] = ' '; if(iac) { if(TELCMD_OK(c)) { found_cmd = true; switch(c) { case IP: return TELNET_EXIT; case SB: in_sb = true; break; case TELOPT_NAWS: if(in_sb) { /* read height/width */ uint8_t bytes[4]; int j = 0; while(j < 4 && i < buflen) { bytes[j++] = buf[++i]; //debugf("%d ", buf[j - 1]); if(bytes[j - 1] == 255) /* 255 is doubled to distinguish from IAC */ { ++i; } } if(i >= buflen && j != 4) error("client SB NAWS command to short"); term_width = ntohs(*((uint16_t*)bytes)); term_height = ntohs(*((uint16_t*)(bytes+2))); } break; } continue; } } } return found_cmd ? TELNET_FOUNDCMD : (line_done ? TELNET_LINEOVER : TELNET_DATA); } void telnet_echo_off(void) { const unsigned char seq[] = { IAC, WILL, TELOPT_ECHO, IAC, DONT, TELOPT_ECHO, }; out_raw(seq, ARRAYLEN(seq)); } void telnet_echo_on(void) { const unsigned char seq[] = { IAC, WONT, TELOPT_ECHO, IAC, DO, TELOPT_ECHO, }; out_raw(seq, ARRAYLEN(seq)); } void telnet_init(void) { const unsigned char init_seq[] = { IAC, WONT, TELOPT_SGA, IAC, DONT, TELOPT_SGA, IAC, DO, TELOPT_NAWS, IAC, WONT, TELOPT_STATUS, IAC, DONT, TELOPT_STATUS, IAC, DO, TELOPT_ECHO, IAC, DONT, TELOPT_LINEMODE, }; term_width = 80; term_height = 24; out_raw(init_seq, ARRAYLEN(init_seq)); } void telnet_clear_screen(void) { /* ESC ] 2 J */ unsigned char clear_seq[] = { '\033', ']', '2', 'J' }; out_raw(clear_seq, ARRAYLEN(clear_seq)); }