more noisy parser error logging
authorJiri Kuthan <jiri@iptel.org>
Tue, 12 Mar 2002 23:58:26 +0000 (23:58 +0000)
committerJiri Kuthan <jiri@iptel.org>
Tue, 12 Mar 2002 23:58:26 +0000 (23:58 +0000)
msg_parser.c
parse_to.c

index 19eb876..18e144e 100644 (file)
@@ -37,6 +37,8 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
        /* int l; */
        char* end;
        char s1,s2,s3;
+       char *prn;
+       unsigned int t;
 
        /* grammar:
                request  =  method SP uri SP version CRLF
@@ -174,7 +176,16 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
 error:
        LOG(L_INFO, "ERROR:parse_first_line: bad %s first line\n",
                (fl->type==SIP_REPLY)?"reply(status)":"request");
-       LOG(L_INFO, "ERROR: at line 0 char %d\n", offset);
+
+       LOG(L_INFO, "ERROR: at line 0 char %d: \n", offset );
+       prn=pkg_malloc( offset );
+       if (prn) {
+               for (t=0; t<offset; t++)
+                       if (*(buffer+t)) *(prn+t)=*(buffer+t);
+                       else *(prn+t)='°';
+               LOG(L_INFO, "ERROR: parsed so far: %.*s\n", offset, prn );
+               pkg_free( prn );
+       };
 error1:
        fl->type=SIP_INVALID;
        LOG(L_INFO, "ERROR:parse_first_line: bad message\n");
index e0ed774..79b72ed 100644 (file)
@@ -112,7 +112,7 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to_param : "
-                                               "unexpected char [%c] in status %d .\n",*tmp,status);
+                                               "unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
                                }
                                break;
                        case '\r':
@@ -149,7 +149,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to_param : "
-                                               "unexpected char [%c] in status %d .\n",*tmp,status);
+                                               "unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "unexpected char [%c] in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -167,7 +168,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                }
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to_param : "
-                                               "unexpected char [%c] in status %d .\n",*tmp,status);
+                                               "unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "unexpected char [%c] in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -191,7 +193,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to_param :"
-                                               "unexpected char [%c] in status %d .\n",*tmp,status);
+                                               "unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "unexpected char [%c] in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -221,7 +224,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to_param :"
-                                               "unexpected char [%c] in status %d .\n",*tmp,status);
+                                               "unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "unexpected char [%c] in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -253,7 +257,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to_param :"
-                                               " unexpected char [%c] in status %d .\n",*tmp,status);
+                                               "unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* " unexpected char [%c] in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -287,7 +292,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to_param : "
-                                               "unexpected char [%c] in status %d .\n",*tmp,status);
+                                               "unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "unexpected char [%c] in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -321,7 +327,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to_param : "
-                                               "unexpected char [%c] in status %d .\n",*tmp,status);
+                                               "unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "unexpected char [%c] in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -349,7 +356,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to_param : "
-                                               "unexpected char [%c] in status %d .\n",*tmp,status);
+                                               "unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "unexpected char [%c] in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -452,7 +460,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-                                               "in status %d .\n",*tmp,status);
+                                               "in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "in status %d .\n",*tmp,status); */
                                }
                                break;
                        case '\r':
@@ -475,7 +484,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-                                               "in status %d .\n",*tmp,status);
+                                               "in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -493,7 +503,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
                                                }
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-                                               "in status %d .\n",*tmp,status);
+                                               "in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -519,7 +530,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-                                               "in status %d .\n",*tmp,status);
+                                               "in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -542,7 +554,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-                                               "in status %d .\n",*tmp,status);
+                                               "in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -563,7 +576,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-                                               "in status %d .\n",*tmp,status);
+                                               "in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;
@@ -589,7 +603,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
                                                goto endofheader;
                                        default:
                                                LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-                                               "in status %d .\n",*tmp,status);
+                                               "in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+                                               /* "in status %d .\n",*tmp,status); */
                                                goto error;
                                }
                                break;