/* $Id$ */ /* * Copyright (c) 2005 Dimitri Sokolyuk * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include char allowed[] = " 0123456789:;.,-ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char *seg[][3] = { [' '] = { " ", " ", " " }, ['0'] = { " _ ", "| |", "|_|" }, ['1'] = { " ", " |", " |" }, ['2'] = { " _ ", " _|", "|_ " }, ['3'] = { " _ ", " _|", " _|" }, ['4'] = { " ", "|_|", " |" }, ['5'] = { " _ ", "|_ ", " _|" }, ['6'] = { " _ ", "|_ ", "|_|" }, ['7'] = { " _ ", " |", " |" }, ['8'] = { " _ ", "|_|", "|_|" }, ['9'] = { " _ ", "|_|", " _|" }, [':'] = { " ", " * ", " * " }, [';'] = { " ", " * ", " / " }, ['.'] = { " ", " ", " * " }, [','] = { " ", " ", " / " }, ['-'] = { " ", " _ ", " " }, ['A'] = { " _ ", "|_|", "| |" }, ['B'] = { " ", "|_ ", "|_|" }, ['C'] = { " _ ", "| ", "|_ " }, ['D'] = { " ", " _|", "|_|" }, ['E'] = { " _ ", "|_ ", "|_ " }, ['F'] = { " _ ", "|_ ", "| " }, ['G'] = { " _ ", "| ", "|_|" }, ['H'] = { " ", "|_ ", "| |" }, ['I'] = { " ", " ", " |" }, ['J'] = { " ", " |", "|_|" }, ['K'] = { " _ ", "|_ ", "| |" }, ['L'] = { " ", "| ", "|_ " }, ['M'] = { " _ ", "| |", "| |" }, ['N'] = { " ", " _ ", "| |" }, ['O'] = { " ", " _ ", "|_|" }, ['P'] = { " _ ", "|_|", "| " }, ['Q'] = { " _ ", "|_|", " |" }, ['R'] = { " ", " _ ", "| " }, ['S'] = { " ", "|_ ", " _|" }, ['T'] = { " ", "|_ ", "|_ " }, ['U'] = { " ", " ", "|_|" }, ['V'] = { " ", "| |", "|_|" }, ['W'] = { " ", "| |", " _ " }, ['X'] = { " ", "|_|", "| |" }, ['Y'] = { " ", "|_|", " _|" }, ['Z'] = { " _ ", " |", "|_ " }, }; char ** sevenseg(char *s) { size_t sz; char **t, *p; int i, c; sz = 3 * strlen(s) + 1; t = calloc(3, sizeof(char *)); for (i = 0; i < 3; i++) { t[i] = calloc(sz, sizeof(char)); for (p = s; *p; p++) { c = toupper(*p); if (strchr(allowed, c) != NULL) strlcat(t[i], seg[c][i], sz); } } return t; } int main(int argc, char **argv) { int i; char **s; if (argc < 2) return(-1); s = sevenseg(argv[1]); for (i = 0; i < 3; i++) { puts(s[i]); free(s[i]); } puts(""); return(0); }