00001 /* 00002 PROJETO USPDesigner 00003 MODULO: GPH (Interface Grafica) 00004 Copyright (C) 1989 a 2008, Marcos Tsuzuki, All rights reserved 00005 Universidade de Sao Paulo, EPUSP-PMR 00006 00007 NOME DO ARQUIVO: gphprint.cpp 00008 Coded by Marcos Tsuzuki 00009 00010 Redistribution and use in source and binary forms, with or without 00011 modification, are permitted provided that the following conditions 00012 are met: 00013 00014 1. Redistributions of source code must retain the above copyright 00015 notice, this list of conditions and the following disclaimer. 00016 00017 2. Redistributions in binary form must reproduce the above copyright 00018 notice, this list of conditions and the following disclaimer in the 00019 documentation and/or other materials provided with the distribution. 00020 00021 3. The names of its contributors may not be used to endorse or promote 00022 products derived from this software without specific prior written 00023 permission. 00024 00025 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00026 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00027 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00028 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00029 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 00037 00038 Any feedback is very welcome. 00039 email: mtsuzuki at usp.br (remove space) 00040 */ 00041 #include <stdio.h> 00042 #include "mancommd.h" 00043 #include "gphgraph.h" 00044 00045 void MSD_execPrint(void) 00046 { 00047 MSD_highPrint(stdout, restbuf); 00048 } 00049 00050 void MSD_highPrint(FILE *fptr, char *mens) 00051 { 00052 char buf[256]; 00053 00054 MSD_lowPrint(buf, mens); 00055 fprintf(fptr, "%s", buf); 00056 } 00057 00058 void MSD_lowPrint(char *to, char *from) 00059 { 00060 char *sp, *dp, hexbuf[3]; 00061 int hex; 00062 00063 for (sp = from, dp = to; *sp && *sp != '\n'; ++sp, ++dp) 00064 { 00065 if (*sp & 0x80) 00066 { 00067 *dp++ = *sp++; 00068 *dp = *sp; 00069 continue; 00070 } 00071 if (*sp == '\\') 00072 { 00073 switch (*++sp) 00074 { 00075 case 'n': 00076 *dp = '\n'; 00077 break; 00078 00079 case '^': 00080 *dp = '^'; 00081 break; 00082 00083 case '\\': 00084 *dp = '\\'; 00085 break; 00086 00087 case 'x': 00088 hexbuf[0] = *++sp; 00089 hexbuf[1] = *++sp; 00090 hexbuf[2] = 0; 00091 if (1 != sscanf(hexbuf, "%x", &hex)) 00092 { 00093 break; 00094 } 00095 *dp = hex; 00096 break; 00097 00098 default: 00099 *dp = *sp; 00100 } 00101 continue; 00102 } 00103 if (*sp == '^') 00104 { 00105 ++sp; 00106 *dp = (*sp < 0 && 0x40 < *sp) ? *sp : *sp - 0x40; 00107 continue; 00108 } 00109 *dp = *sp; 00110 } 00111 *dp = '\0'; 00112 }