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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/*******************************************************************************
* Project: ePOST/Open 2 *
* *
* File Name: ms_rmb_parser.l *
* *
* Subsystem: Mail Server *
* Module: Receive Mailbags (RMB) *
* *
* Description: This module contains the LEX specification for EPL file. *
* It used for parsing EPL Letters files from VM Mailbag *
* *
* Author: Paola Vinassa *
* *
* Created: *
********************************************************************************
* *
* Modification History *
* *
* Revision Date Who Modified Description *
* *
* 1.1 21 Jan 1998 EF Add storechone (TRC) *
*******************************************************************************/
%{
#include <stdio.h>
#include <ms_rmb.h>
#include <ms_rmb_parser.h>
#include "__parser__tab.h"
static void store_conv(void);
static void storechone(void);
static void store_afp(void);
static int store_channel(void);
static int store_eplb(char);
%}
%%
^\x5a..\xd3\xaf\x5f { store_afp(); return(t_IPS); }
^\x5a { store_afp(); return(t_AFP); }
^\xc5\xd7\xd3\xf1..........\xf0.* \
{ store_conv(); return(t_EPL1_S_E); }
^\xc5\xd7\xd3\xf1..........\xf2.* \
{ store_conv(); return(t_EPL1_M_E); }
^\xc5\xd7\xd3\xf2.* { store_conv(); return(t_EPL2_E); }
^\xc5\xd7\xd3\xd7.* { store_conv(); return(t_EPLP_E); }
^\xc5\xd7\xd3\xd4.* { store_conv(); return(t_EPLM_E); }
^\xf1.* { storechone(); return(t_CH1_E); }
^[\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xc1\xc2\xc3].* \
{ return( store_channel() ); }
^[\x40\xF0\x60\x4e].* \
{ storechone(); return(t_CH_NEUTRAL_E); }
^\xc5\xd7\xd3\xf4.* { store_conv(); return(t_EPL4_E); }
^\xc5\xd7\xd3\xf7.* { store_conv(); return(t_EPL7_E); }
^\xc5\xd7\xd3\xd1\x40\xd4\xc2\xc7\xd3\xc5\xe3.* \
{ store_conv(); return(t_EPLJMBGLET_E); }
^\xc5\xd7\xd3\xd1\x40\xd4\xc2\xc7\xc6\xc9\xd3\xc5.* \
{ store_conv(); return(t_EPLJMBGFILE_E); }
^\xc5\xd7\xd3\xd1\x40\xd4\xc2\xc7\xe2\xc5\xd9\xe5.* \
{ store_conv(); return(t_EPLJMBGSERV_E); }
^\xc5\xd7\xd3\xd1\x40\xd4\xc2\xc7\xd7\xc1\xc7\xc5.* \
{ store_conv(); return(t_EPLJMBGPAGE_E); }
\n { return(t_NL); }
. { printf("%X len %d\n", yytext[0], yyleng);
if (yytext[0] == 0x5a)
{ store_afp();
return (t_AFP);
} else return(t_ERR); }
%%
/* Removed rule EF 21/1/1998
^\xf1.* { storechone(); return(t_CH1_E); }
*/
static void storechone(void)
{
char c;
if(yyleng!=1)
{
memcpy(lineBuffer, yytext, yyleng);
lineBuffer[yyleng]='\0';
}
else
{
/* '\0' has been met */
memcpy(lineBuffer, yytext, yyleng);
while((c=input())!='\n')
{
lineBuffer[yyleng++]=c;
}
unput(c);
lineBuffer[yyleng]='\0';
}
mleng=yyleng;
}
static void store_conv(void)
{
char ascii_rec[1024];
memcpy(lineBuffer, yytext, yyleng);
lineBuffer[yyleng]='\0';
mleng=yyleng;
Convert_to_ASCII(yytext,ascii_rec,mleng);
ascii_rec[mleng] = NULL;
#ifdef DEBUG
printf("lineBuffer: #%s#\n", lineBuffer);
printf("ascii: #%s#\n", ascii_rec);
printf("mleng: %d\n", mleng);
#endif
}
/* AFP block management */
static void store_afp(void)
{
unsigned int i, nchar;
char c;
memcpy(lineBuffer, yytext, yyleng);
for ( ;yyleng < 6; yyleng++)
{
lineBuffer[yyleng]=input();
}
/*
lineBuffer[yyleng]=input();
yyleng++;
lineBuffer[yyleng]=input();
yyleng++;
*/
/* The bytes [1-2] contain the lenght of the record afp; */
/* the byte [1] is the most significant byte */
nchar = ((unsigned char)lineBuffer[1])*256 + (unsigned char)lineBuffer[2];
for( i=yyleng-1; i<nchar; i++)
{
c=input();
lineBuffer[yyleng]=c;
yyleng++;
}
mleng=yyleng;
#ifdef DEBUG
printf("lineBuffer: #%s#\n", lineBuffer);
printf("mleng: %d\n", mleng);
#endif
}
/* Channels management */
/* the recipient channel is 2 or the one in the customer profile */
int store_channel(void)
{
char ascii_rec[1024];
char c;
/* memcpy(lineBuffer, yytext, yyleng);
lineBuffer[yyleng]='\0';
mleng=yyleng;
Convert_to_ASCII(yytext,ascii_rec,mleng);
ascii_rec[mleng] = NULL;
*/
if(yyleng!=1)
{
memcpy(lineBuffer, yytext, yyleng);
lineBuffer[yyleng]='\0';
}
else
{
/* '\0' has been met */
memcpy(lineBuffer, yytext, yyleng);
while((c=input())!='\n')
{
lineBuffer[yyleng++]=c;
}
unput(c);
lineBuffer[yyleng]='\0';
}
mleng=yyleng;
#ifdef DEBUG
printf("lineBuffer: #%s#\n", lineBuffer);
printf("ascii: #%s#\n", ascii_rec);
printf("mleng: %d\n", mleng);
#endif
if(lineBuffer[0] == 0xF2)
return (t_CHX_REC_E);
else
return (t_CHX_NOREC_E);
} |
Partager