暇な俺が>>307のサンプル作りましたよ。鵜呑みにはするなよ。
こういうの初めてな人には数字読取のところで「??」ってなるかもしれんが、たぶん定石なので覚えるべし。

bool get_message(const char* in,int id,char* out)
{
 const char* p=in;
 char* q=out;
 int c,n;
 //
 while(p=strstr(p,":msg")){
  //数字までシーク
  p+=4;
  //数字読取
  n=0;
  while(*p>='0' && *p<='9'){ n*=10; n+=*p-'0'; p++; }
  //メッセージ
  if(n==id){
   //メッセージ先頭までシーク
   while(*p=='\n')p++;
   //メッセージ読取
   while(*p!='\n'){
    *q++=*p++;
   }
   *q++='\0';
   //成功
   return true;
  }
 }
 //失敗
 return false;
}