{\r
NyLPC_TcHttpStream_t* inst=(NyLPC_TcHttpStream_t*)i_inst;\r
NyLPC_TUInt16 s,free_size;\r
- NyLPC_TUInt16 l;\r
+ NyLPC_TUInt32 l;\r
const char* src=(const char*)i_data;\r
- l=(NyLPC_TUInt16)(i_length<0?strlen(src):i_length);\r
- if(l>=NyLPC_TUInt16_MAX){\r
- return NyLPC_TBool_FALSE;\r
- }\r
+ l=(i_length<0?strlen(src):i_length);\r
while(l>0){\r
//送信バッファがNULLなら、割り当て。\r
if(inst->txb==NULL){\r
}\r
//書き込み可能サイズの計算\r
free_size=inst->txb_size-inst->tx_len;\r
- if(free_size>l){\r
+ if((NyLPC_TInt32)free_size>l){\r
//書き込み可能サイズがi_length未満なら、バッファに貯めるだけ。\r
memcpy(inst->txb+inst->tx_len,src,l);\r
inst->tx_len+=(NyLPC_TUInt16)l;\r
--- /dev/null
+#include <stdio.h>\r
+#include "NyLPC_cMimeType.h"\r
+struct TMimeTypeTable{\r
+ const char* ext;\r
+ const char* mimetype;\r
+};\r
+const static struct TMimeTypeTable table[]=\r
+{\r
+ {"zip" ,"application/zip"},\r
+ {"js" ,"application/x-javascript"},\r
+ {"txt" ,"text/plain"},\r
+ {"html","text/html"},\r
+ {"htm","text/html"},\r
+ {"css" ,"text/css"},\r
+ {"jpeg","image/jpeg"},\r
+ {"jpg" ,"image/jpeg"},\r
+ {"png" ,"image/png"},\r
+ {"gif" ,"image/gif"},\r
+ {NULL,NULL}\r
+};\r
+const static char* default_mimetype="application/octet-stream";\r
+\r
+const char* NyLPC_cMiMeType_getFileName2MimeType(const char* i_file_name)\r
+{\r
+ int i;\r
+ const char* p=strrchr(i_file_name,'.');\r
+ if(p==NULL){\r
+ return default_mimetype;\r
+ }\r
+ for(i=0;table[i].ext!=NULL;i++){\r
+ if(strcmp(table[i].ext,p+1)==0){\r
+ return table[i].mimetype;\r
+ }\r
+ }\r
+ return default_mimetype;\r
+}\r
--- /dev/null
+/*********************************************************************************\r
+ * PROJECT: MiMic\r
+ * --------------------------------------------------------------------------------\r
+ *\r
+ * This file is part of MiMic\r
+ * Copyright (C)2011 Ryo Iizuka\r
+ *\r
+ * MiMic is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU Lesser General Public License as published\r
+ * by the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ *\r
+ * For further information please contact.\r
+ * http://nyatla.jp/\r
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
+ *\r
+ *********************************************************************************/\r
+#ifndef NyLPC_TcMimeType_H_\r
+#define NyLPC_TcMimeType_H_\r
+\r
+/**********************************************************************\r
+ *\r
+ * NyLPC_TiHttpPtrStream class\r
+ *\r
+ **********************************************************************/\r
+#include "NyLPC_stdlib.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif /* __cplusplus */\r
+const char* NyLPC_cMiMeType_getFileName2MimeType(const char* i_file_name);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif /* __cplusplus */\r
+\r
+#endif\r