Ejemplo n.º 1
0
char *pretty_html( int c )
{
  static struct {
     int code;
     char *name;
  } table[4] = { { 60, "<" }
, { 62, ">" }
, { 34, """ }
, { 38, "&" }
 };
  static char buf[30];
  char *src = LYKeycodeToString( c, ebp_52 );
  if ( src == 0 )
  {
    return 0;
  }
{
  char *dst = buf;
  int adj = 0;
  unsigned int n;
  BOOLEAN found;
  while ( c = src[0], src++, ( c != 0 ) & 255 )
  {
    found = 0;
    n = 0;
    for ( ; n <= 3; n++ )
    {
      if ( table[ n ].code == c )
      {
        found = 1;
        strcpy( dst, table[ n ].name );
        adj = adj + strlen( dst ) + -1;
        dst += strlen( dst );
        break;
      }
      else
      {
        // n++;
      }
    }
    if ( found == 0 )
    {
      dst[0] = c;
      dst++;
    }
  }
  adj += buf[11] - dst;
  while ( adj += -1, ( adj > 0 ) & 255 )
  {
    dst[0] = ' ';
    dst++;
  }
  dst[0] = 0;
  return buf;
}
}
Ejemplo n.º 2
0
char *fmt_keys( int lkc_first, int lkc_second )
{
  char *buf = 0;
  BOOLEAN quotes = 0;
  char *fmt_first;
  char *fmt_second;
  if ( lkc_first < 0 )
  {
    return 0;
  }
  fmt_first = LYKeycodeToString( lkc_first, 1 );
  if ( fmt_first && strlen( fmt_first ) == 1 && fmt_first[0] != '\'' )
    quotes = 1;
  if ( quotes )
  {
    if ( lkc_second < 0 )
    {
      HTSprintf0( &buf, "'%s'", fmt_first );
      return buf;
    }
    HTSprintf0( &buf, "'%s", fmt_first );
  }
  else
    HTSACopy( &buf, fmt_first );
  if ( lkc_second >= 0 )
  {
    fmt_second = LYKeycodeToString( lkc_second, 1 );
    if ( fmt_second == 0 )
    {
      if ( buf )
      {
        free( buf );
        buf = 0;
      }
      return 0;
    }
    else
    {
      HTSprintf( &buf, "%s%s%s", "", fmt_second, "" );
    }
  }
  return buf;
}
Ejemplo n.º 3
0
static char *pretty_html(int c)
{
    char *src = LYKeycodeToString(c, TRUE);

    if (src != 0) {
	/* *INDENT-OFF* */
	static const struct {
	    int	code;
	    const char *name;
	} table[] = {
	    { '<',	"&lt;" },
	    { '>',	"&gt;" },
	    { '"',	"&quot;" },
	    { '&',	"&amp;" }
	};
	/* *INDENT-ON* */

	static char buf[30];
	char *dst = buf;
	int adj = 0;
	unsigned n;
	BOOLEAN found;

	while ((c = *src++) != 0) {
	    found = FALSE;
	    for (n = 0; n < TABLESIZE(table); n++) {
		if (c == table[n].code) {
		    found = TRUE;
		    LYStrNCpy(dst, table[n].name, sizeof(dst) - 1);
		    adj += (int) strlen(dst) - 1;
		    dst += (int) strlen(dst);
		    break;
		}
	    }
	    if (!found) {
		*dst++ = (char) c;
	    }
	}
	adj -= (int) (dst - buf) - PRETTY_LEN;
	while (adj-- > 0)
	    *dst++ = ' ';
	*dst = 0;
	return buf;
    }

    return 0;
}
Ejemplo n.º 4
0
char *key_for_func( int func )
{
  static char *buf;
  int i = LYReverseKeymap( func );
  char *formatted;
  if ( i >= 0 )
  {
    formatted = LYKeycodeToString( i, 1 );
    HTSACopy( &buf, "?" );
  }
  else
  if ( buf == 0 )
  {
    HTSACopy( &buf, "" );
  }
  return buf;
}