From b98848664a60ea7fa6cab951c45f9d2bf5ba11f7 Mon Sep 17 00:00:00 2001 From: Eric Harris-Braun Date: Thu, 3 Mar 2016 12:04:39 -0500 Subject: [PATCH] wip #109: scaffold transcoder for Content-Type --- src/base_defs | 12 +++++++++--- src/base_defs.c | 2 +- web/sysdefs.json | 26 +++++++++++++++++++------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/base_defs b/src/base_defs index 95ef4a02..291df91a 100644 --- a/src/base_defs +++ b/src/base_defs @@ -634,10 +634,16 @@ Symbol: PLAIN_TEXT_MEDIA_SUBTYPE,NULL_STRUCTURE; Symbol: CEPTR_TEXT_MEDIA_SUBTYPE,NULL_STRUCTURE; Data: content_type_2_line_proc, (CONCAT_STR (RESULT_SYMBOL:LINE) - (LINE:"Content-type") (ASCII_CHAR:':') - (TRANSCODE (TRANSCODE_TO:LINE) (PARAM_REF:/2/1/1)) + (LINE:"Content-Type") (ASCII_CHAR:':') (ASCII_CHAR:' ') + (IF (EQ_SYM (PARAM_REF:/2/1/1) (TEST_SYMBOL_SYMBOL:TEXT_MEDIA_TYPE)) + (LINE:"text") + (LINE:"unknown")) (ASCII_CHAR:'/') - (TRANSCODE (TRANSCODE_TO:LINE) (PARAM_REF:/2/1/2)) + (IF (EQ_SYM (PARAM_REF:/2/1/2) (TEST_SYMBOL_SYMBOL:HTML_TEXT_MEDIA_SUBTYPE)) + (LINE:"html") + (IF (EQ_SYM (PARAM_REF:/2/1/2) (TEST_SYMBOL_SYMBOL:PLAIN_TEXT_MEDIA_SUBTYPE)) + (LINE:"plain") + (LINE:"ceptr")))) ); Process: content_type_2_line,content_type_2_line_proc,"content type transcoder","output",SIGNATURE_SYMBOL,LINE,"input",SIGNATURE_SYMBOL,CONTENT_TYPE,0; diff --git a/src/base_defs.c b/src/base_defs.c index 0a625dbe..28a12ff2 100644 --- a/src/base_defs.c +++ b/src/base_defs.c @@ -1118,7 +1118,7 @@ void base_defs(SemTable *sem) { sY(INTERNET_CONTEXT,HTML_TEXT_MEDIA_SUBTYPE,NULL_STRUCTURE); sY(INTERNET_CONTEXT,PLAIN_TEXT_MEDIA_SUBTYPE,NULL_STRUCTURE); sY(INTERNET_CONTEXT,CEPTR_TEXT_MEDIA_SUBTYPE,NULL_STRUCTURE); - sData(INTERNET_CONTEXT,content_type_2_line_proc,STX_OP,CONCAT_STR,STX_OP,RESULT_SYMBOL,LINE,STX_CP,STX_OP,LINE,"Content-type",STX_CP,STX_OP,ASCII_CHAR,':',STX_CP,STX_OP,TRANSCODE,STX_OP,TRANSCODE_TO,LINE,STX_CP,STX_OP,PARAM_REF,2,1,1,TREE_PATH_TERMINATOR,STX_CP,STX_CP,STX_OP,ASCII_CHAR,'/',STX_CP,STX_OP,TRANSCODE,STX_OP,TRANSCODE_TO,LINE,STX_CP,STX_OP,PARAM_REF,2,1,2,TREE_PATH_TERMINATOR,STX_CP,STX_CP,STX_CP); + sData(INTERNET_CONTEXT,content_type_2_line_proc,STX_OP,CONCAT_STR,STX_OP,RESULT_SYMBOL,LINE,STX_CP,STX_OP,LINE,"Content-Type",STX_CP,STX_OP,ASCII_CHAR,':',STX_CP,STX_OP,ASCII_CHAR,' ',STX_CP,STX_OP,IF,STX_OP,EQ_SYM,STX_OP,PARAM_REF,2,1,1,TREE_PATH_TERMINATOR,STX_CP,STX_OP,TEST_SYMBOL_SYMBOL,TEXT_MEDIA_TYPE,STX_CP,STX_CP,STX_OP,LINE,"text",STX_CP,STX_OP,LINE,"unknown",STX_CP,STX_CP,STX_OP,ASCII_CHAR,'/',STX_CP,STX_OP,IF,STX_OP,EQ_SYM,STX_OP,PARAM_REF,2,1,2,TREE_PATH_TERMINATOR,STX_CP,STX_OP,TEST_SYMBOL_SYMBOL,HTML_TEXT_MEDIA_SUBTYPE,STX_CP,STX_CP,STX_OP,LINE,"html",STX_CP,STX_OP,IF,STX_OP,EQ_SYM,STX_OP,PARAM_REF,2,1,2,TREE_PATH_TERMINATOR,STX_CP,STX_OP,TEST_SYMBOL_SYMBOL,PLAIN_TEXT_MEDIA_SUBTYPE,STX_CP,STX_CP,STX_OP,LINE,"plain",STX_CP,STX_OP,LINE,"ceptr",STX_CP,STX_CP,STX_CP,STX_CP,STX_CP); sP(INTERNET_CONTEXT,content_type_2_line,content_type_2_line_proc,"content type transcoder","output",SIGNATURE_SYMBOL,LINE,"input",SIGNATURE_SYMBOL,CONTENT_TYPE,0); sY(INTERNET_CONTEXT,CONTENT_ENCODING,CSTRING); sY(INTERNET_CONTEXT,HTTP_REQUEST_METHOD,CSTRING); diff --git a/web/sysdefs.json b/web/sysdefs.json index 766718a4..3fa372d0 100644 --- a/web/sysdefs.json +++ b/web/sysdefs.json @@ -2857,15 +2857,27 @@ {"sem":{ "ctx":0,"type":2,"id":93 },"surface":"content type transcoder"}, {"sem":{ "ctx":0,"type":3,"id":23 },"children":[ {"sem":{ "ctx":0,"type":2,"id":122 },"surface":{ "ctx":2,"type":2,"id":14 }}, - {"sem":{ "ctx":2,"type":2,"id":14 },"surface":"Content-type"}, + {"sem":{ "ctx":2,"type":2,"id":14 },"surface":"Content-Type"}, {"sem":{ "ctx":0,"type":2,"id":45 },"surface":":"}, - {"sem":{ "ctx":0,"type":3,"id":6 },"children":[ - {"sem":{ "ctx":0,"type":2,"id":203 },"surface":{ "ctx":2,"type":2,"id":14 }}, - {"sem":{ "ctx":0,"type":2,"id":120 },"surface":"/2/1/1"}]}, + {"sem":{ "ctx":0,"type":2,"id":45 },"surface":" "}, + {"sem":{ "ctx":0,"type":3,"id":8 },"children":[ + {"sem":{ "ctx":0,"type":3,"id":26 },"children":[ + {"sem":{ "ctx":0,"type":2,"id":120 },"surface":"/2/1/1"}, + {"sem":{ "ctx":3,"type":2,"id":11 },"surface":{ "ctx":6,"type":2,"id":20 }}]}, + {"sem":{ "ctx":2,"type":2,"id":14 },"surface":"text"}, + {"sem":{ "ctx":2,"type":2,"id":14 },"surface":"unknown"}]}, {"sem":{ "ctx":0,"type":2,"id":45 },"surface":"/"}, - {"sem":{ "ctx":0,"type":3,"id":6 },"children":[ - {"sem":{ "ctx":0,"type":2,"id":203 },"surface":{ "ctx":2,"type":2,"id":14 }}, - {"sem":{ "ctx":0,"type":2,"id":120 },"surface":"/2/1/2"}]}]}, + {"sem":{ "ctx":0,"type":3,"id":8 },"children":[ + {"sem":{ "ctx":0,"type":3,"id":26 },"children":[ + {"sem":{ "ctx":0,"type":2,"id":120 },"surface":"/2/1/2"}, + {"sem":{ "ctx":3,"type":2,"id":11 },"surface":{ "ctx":6,"type":2,"id":21 }}]}, + {"sem":{ "ctx":2,"type":2,"id":14 },"surface":"html"}, + {"sem":{ "ctx":0,"type":3,"id":8 },"children":[ + {"sem":{ "ctx":0,"type":3,"id":26 },"children":[ + {"sem":{ "ctx":0,"type":2,"id":120 },"surface":"/2/1/2"}, + {"sem":{ "ctx":3,"type":2,"id":11 },"surface":{ "ctx":6,"type":2,"id":22 }}]}, + {"sem":{ "ctx":2,"type":2,"id":14 },"surface":"plain"}, + {"sem":{ "ctx":2,"type":2,"id":14 },"surface":"ceptr"}]}]}]}, {"sem":{ "ctx":0,"type":2,"id":94 },"children":[ {"sem":{ "ctx":0,"type":2,"id":116 },"children":[ {"sem":{ "ctx":0,"type":2,"id":106 },"surface":"output"},