mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 11:41:44 +08:00
整理优化代码
This commit is contained in:
32
src/Common/Parser.cpp
Normal file
32
src/Common/Parser.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by xzl on 2019/6/28.
|
||||
//
|
||||
|
||||
#include "Parser.h"
|
||||
|
||||
namespace mediakit{
|
||||
|
||||
string FindField(const char* buf, const char* start, const char *end ,int bufSize) {
|
||||
if(bufSize <=0 ){
|
||||
bufSize = strlen(buf);
|
||||
}
|
||||
const char *msg_start = buf, *msg_end = buf + bufSize;
|
||||
int len = 0;
|
||||
if (start != NULL) {
|
||||
len = strlen(start);
|
||||
msg_start = strstr(buf, start);
|
||||
}
|
||||
if (msg_start == NULL) {
|
||||
return "";
|
||||
}
|
||||
msg_start += len;
|
||||
if (end != NULL) {
|
||||
msg_end = strstr(msg_start, end);
|
||||
if (msg_end == NULL) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return string(msg_start, msg_end);
|
||||
}
|
||||
|
||||
}//namespace mediakit
|
||||
Reference in New Issue
Block a user