Browse code

getHeader:support content spanning multipe headers

Patch by Robert Szokovacs

Stefan Sayer authored on 01/07/2010 12:48:17
Showing 27 changed files
... ...
@@ -112,7 +112,7 @@ void AnnounceTransferDialog::onSessionStart(const AmSipRequest& req)
112 112
     status = Announcing;
113 113
     callee_uri = get_session_param(req.hdrs, "Refer-To");
114 114
     if (!callee_uri.length()) {
115
-      callee_uri = getHeader(req.hdrs, "P-Refer-To");
115
+      callee_uri = getHeader(req.hdrs, "P-Refer-To", true);
116 116
       if (callee_uri.length()) {
117 117
 	INFO("Use of P-Refer-To header is deprecated. "
118 118
 	     "Use '%s: Refer-To=<uri>' instead.\n",PARAM_HDR);
... ...
@@ -140,7 +140,7 @@ void AnnounceTransferDialog::onSipRequest(const AmSipRequest& req)
140 140
      (req.method == "NOTIFY")) {
141 141
     try {
142 142
 
143
-      if (strip_header_params(getHeader(req.hdrs,"Event", "o")) != "refer") 
143
+      if (strip_header_params(getHeader(req.hdrs,"Event", "o", true)) != "refer") 
144 144
 	throw AmSession::Exception(481, "Subscription does not exist");
145 145
 
146 146
       if ((strip_header_params(req.content_type) != "message/sipfrag"))
... ...
@@ -142,7 +142,7 @@ void AnnRecorderFactory::getAppParams(const AmSipRequest& req, map<string, strin
142 142
     typ = DEFAULT_TYPE;
143 143
   }
144 144
   else {
145
-    string iptel_app_param = getHeader(req.hdrs, PARAM_HDR);
145
+    string iptel_app_param = getHeader(req.hdrs, PARAM_HDR, true);
146 146
     
147 147
     if (!iptel_app_param.length()) {
148 148
       throw AmSession::Exception(500, MOD_NAME ": parameters not found");
... ...
@@ -113,7 +113,7 @@ void AuthB2BDialog::onInvite(const AmSipRequest& req)
113 113
   setInOut(NULL,NULL); 
114 114
 
115 115
   if (AuthB2BFactory::user.empty()) {
116
-    string app_param = getHeader(req.hdrs, PARAM_HDR);
116
+    string app_param = getHeader(req.hdrs, PARAM_HDR, true);
117 117
 
118 118
     if (!app_param.length()) {
119 119
       AmSession::Exception(500, "auth_b2b: parameters not found");
... ...
@@ -88,7 +88,7 @@ AmSession* CallTimerFactory::onInvite(const AmSipRequest& req)
88 88
      throw AmSession::Exception(500,"could not get a user timer reference");
89 89
   }
90 90
 
91
-  string app_param = getHeader(req.hdrs, PARAM_HDR);
91
+  string app_param = getHeader(req.hdrs, PARAM_HDR, true);
92 92
 
93 93
   unsigned int call_time = CallTimerFactory::DefaultCallTimer;
94 94
 
... ...
@@ -379,22 +379,22 @@ void ConferenceDialog::onSessionStart(const AmSipRequest& req)
379 379
   int i, len;
380 380
   string lonely_user_file;
381 381
 
382
-  string app_param_hdr = getHeader(req.hdrs, PARAM_HDR);
382
+  string app_param_hdr = getHeader(req.hdrs, PARAM_HDR, true);
383 383
   if (app_param_hdr.length()) {
384 384
     from_header = get_header_keyvalue(app_param_hdr, "Dialout-From");
385 385
     extra_headers = get_header_keyvalue(app_param_hdr, "Dialout-Extra");
386 386
     dialout_suffix = get_header_keyvalue(app_param_hdr, "Dialout-Suffix");      
387 387
     language = get_header_keyvalue(app_param_hdr, "Language");      
388 388
   } else {
389
-    from_header = getHeader(req.hdrs, "P-Dialout-From");
390
-    extra_headers = getHeader(req.hdrs, "P-Dialout-Extra");
391
-    dialout_suffix = getHeader(req.hdrs, "P-Dialout-Suffix");
389
+    from_header = getHeader(req.hdrs, "P-Dialout-From", true);
390
+    extra_headers = getHeader(req.hdrs, "P-Dialout-Extra", true);
391
+    dialout_suffix = getHeader(req.hdrs, "P-Dialout-Suffix", true);
392 392
     if (from_header.length() || extra_headers.length() 
393 393
 	|| dialout_suffix.length()) {
394 394
       DBG("Warning: P-Dialout- style headers are deprecated."
395 395
 	  " Please use P-App-Param header instead.\n");
396 396
     }
397
-    language = getHeader(req.hdrs, "P-Language");
397
+    language = getHeader(req.hdrs, "P-Language", true);
398 398
     if (language.length()) {
399 399
       DBG("Warning: P-Language header is deprecated."
400 400
 	  " Please use P-App-Param header instead.\n");
... ...
@@ -837,14 +837,14 @@ void ConferenceDialog::onSipRequest(const AmSipRequest& req)
837 837
   dlg.remote_tag = "";
838 838
 
839 839
   // get route set and next hop
840
-  string iptel_app_param = getHeader(req.hdrs, PARAM_HDR);
840
+  string iptel_app_param = getHeader(req.hdrs, PARAM_HDR, true);
841 841
   if (iptel_app_param.length()) {
842 842
     dlg.route = get_header_keyvalue(iptel_app_param,"Transfer-RR");
843 843
   } else {
844 844
     INFO("Use of P-Transfer-RR/P-Transfer-NH is deprecated. "
845 845
 	 "Use '%s: Transfer-RR=<rr>;Transfer-NH=<nh>' instead.\n",PARAM_HDR);
846 846
 
847
-    dlg.route = getHeader(req.hdrs,"P-Transfer-RR");
847
+    dlg.route = getHeader(req.hdrs,"P-Transfer-RR", true);
848 848
   }
849 849
 
850 850
   DBG("ConferenceDialog::onSipRequest: local_party = %s\n",dlg.local_party.c_str());
... ...
@@ -457,7 +457,7 @@ void DSMFactory::addVariables(DSMCall* s, const string& prefix,
457 457
 void DSMFactory::addParams(DSMCall* s, const string& hdrs) {
458 458
   // TODO: use real parser with quoting and optimize
459 459
   map<string, string> params;
460
-  vector<string> items = explode(getHeader(hdrs, PARAM_HDR), ";");
460
+  vector<string> items = explode(getHeader(hdrs, PARAM_HDR, true), ";");
461 461
   for (vector<string>::iterator it=items.begin(); 
462 462
        it != items.end(); it++) {
463 463
     vector<string> kv = explode(*it, "=");
... ...
@@ -510,7 +510,7 @@ void DSMFactory::runMonitorAppSelect(const AmSipRequest& req, string& start_diag
510 510
 	  from_parser.uri = req.from_uri;
511 511
 	else {
512 512
 	  size_t end;
513
-	  string pai = getHeader(req.hdrs, SIP_HDR_P_ASSERTED_IDENTITY);
513
+	  string pai = getHeader(req.hdrs, SIP_HDR_P_ASSERTED_IDENTITY, true);
514 514
 	  if (!from_parser.parse_contact(pai, 0, end)) {
515 515
 	    WARN("Failed to parse " SIP_HDR_P_ASSERTED_IDENTITY " '%s'\n",
516 516
 		  pai.c_str());
... ...
@@ -81,7 +81,7 @@ EXEC_ACTION_START(URIGetHeaderAction) {
81 81
   string hname  = resolveVars(par1, sess, sc_sess, event_params);
82 82
   string dstname = resolveVars(par2, sess, sc_sess, event_params);
83 83
 
84
-  sc_sess->var[dstname] = getHeader(sc_sess->var["hdrs"], hname);  
84
+  sc_sess->var[dstname] = getHeader(sc_sess->var["hdrs"], hname, true);  
85 85
   DBG("got header '%s' value '%s' as $%s\n", 
86 86
       hname.c_str(), sc_sess->var[dstname].c_str(), dstname.c_str());
87 87
 
... ...
@@ -298,7 +298,7 @@ AmSession* EarlyAnnounceFactory::onInvite(const AmSipRequest& req)
298 298
 
299 299
 #ifdef USE_MYSQL
300 300
 
301
-    string iptel_app_param = getHeader(req.hdrs, PARAM_HDR);
301
+    string iptel_app_param = getHeader(req.hdrs, PARAM_HDR, true);
302 302
     string language = get_header_keyvalue(iptel_app_param,"Language");
303 303
     string announce_file = "";
304 304
 
... ...
@@ -385,11 +385,11 @@ void EarlyAnnounceDialog::process(AmEvent* event)
385 385
 	continue_b2b = true;
386 386
       } else if (EarlyAnnounceFactory::ContinueB2B == 
387 387
 		 EarlyAnnounceFactory::AppParam) {
388
-	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR);
388
+	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR, true);
389 389
 	if (iptel_app_param.length()) {
390 390
 	  continue_b2b = get_header_keyvalue(iptel_app_param,"B2B")=="yes";
391 391
 	} else {
392
-	  continue_b2b = getHeader(invite_req.hdrs,"P-B2B")=="yes";
392
+	  continue_b2b = getHeader(invite_req.hdrs,"P-B2B", true)=="yes";
393 393
 	}
394 394
       }
395 395
       DBG("determined: continue_b2b = %s\n", continue_b2b?"true":"false");
... ...
@@ -398,7 +398,7 @@ void EarlyAnnounceDialog::process(AmEvent* event)
398 398
 	unsigned int code_i = 404;
399 399
 	string reason = "Not Found";
400 400
 	
401
-	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR);
401
+	string iptel_app_param = getHeader(invite_req.hdrs, PARAM_HDR, true);
402 402
 	if (iptel_app_param.length()) {
403 403
 	  string code = get_header_keyvalue(iptel_app_param,"Final-Reply-Code");
404 404
 	  if (code.length() && str2i(code, code_i)) {
... ...
@@ -408,11 +408,11 @@ void EarlyAnnounceDialog::process(AmEvent* event)
408 408
 	  if (!reason.length())
409 409
 	    reason = "Not Found";
410 410
 	} else {
411
-	  string code = getHeader(invite_req.hdrs,"P-Final-Reply-Code");
411
+	  string code = getHeader(invite_req.hdrs,"P-Final-Reply-Code", true);
412 412
 	  if (code.length() && str2i(code, code_i)) {
413 413
 	    ERROR("while parsing P-Final-Reply-Code\n");
414 414
 	  }
415
-	  string h_reason =  getHeader(invite_req.hdrs,"P-Final-Reply-Reason");
415
+	  string h_reason =  getHeader(invite_req.hdrs,"P-Final-Reply-Reason", true);
416 416
 	  if (h_reason.length()) {
417 417
 	    INFO("Use of P-Final-Reply-Code/P-Final-Reply-Reason is deprecated. ");
418 418
 	    INFO("Use '%s: Final-Reply-Code=<code>;"
... ...
@@ -78,7 +78,7 @@ AmSession* b2b_connectFactory::onInvite(const AmSipRequest& req)
78 78
 //     throw AmSession::Exception(500,"could not get a user timer reference");
79 79
 //   }
80 80
 
81
-  string app_param = getHeader(req.hdrs, PARAM_HDR);
81
+  string app_param = getHeader(req.hdrs, PARAM_HDR, true);
82 82
 
83 83
   if (!app_param.length()) {
84 84
     throw  AmSession::Exception(500, "b2b_connect: parameters not found");
... ...
@@ -108,7 +108,7 @@ void b2b_connectDialog::onInvite(const AmSipRequest& req)
108 108
     return;
109 109
   }
110 110
 
111
-  string app_param = getHeader(req.hdrs, PARAM_HDR);
111
+  string app_param = getHeader(req.hdrs, PARAM_HDR, true);
112 112
   string remote_party, remote_uri;
113 113
 
114 114
   if (!app_param.length()) {
... ...
@@ -90,7 +90,7 @@ extern "C" {
90 90
     if(!PyArg_ParseTuple(args,"ss",&headers,&header_name))
91 91
       return NULL;
92 92
 
93
-    string res = getHeader(headers,header_name);
93
+    string res = getHeader(headers,header_name, true);
94 94
     return PyString_FromString(res.c_str());
95 95
   }
96 96
 
... ...
@@ -115,14 +115,14 @@ extern "C" {
115 115
       return NULL;
116 116
 
117 117
     string res;
118
-    string iptel_app_param = getHeader(headers, PARAM_HDR);
118
+    string iptel_app_param = getHeader(headers, PARAM_HDR, true);
119 119
     if (iptel_app_param.length()) {
120 120
       res = get_header_keyvalue(iptel_app_param,header_name);
121 121
     } else {
122 122
       INFO("Use of P-%s is deprecated. \n", header_name);
123 123
       INFO("Use '%s: %s=<addr>' instead.\n", PARAM_HDR, header_name);
124 124
 
125
-      res = getHeader(headers,string("P-") + header_name);
125
+      res = getHeader(headers,string("P-") + header_name, true);
126 126
     }
127 127
 
128 128
 	 
... ...
@@ -128,7 +128,7 @@ extern "C" {
128 128
     if(!PyArg_ParseTuple(args,"ss",&headers,&header_name))
129 129
       return NULL;
130 130
 
131
-    string res = getHeader(headers,header_name);
131
+    string res = getHeader(headers,header_name, true);
132 132
     return PyString_FromString(res.c_str());
133 133
   }
134 134
 
... ...
@@ -383,7 +383,7 @@ void SIPRegistration::onSipReply(const AmSipReply& reply, int old_dlg_status)
383 383
 
384 384
     string contacts = reply.contact;
385 385
     if (contacts.empty()) 
386
-      contacts = getHeader(reply.hdrs, "Contact", "m");
386
+      contacts = getHeader(reply.hdrs, "Contact", "m", true);
387 387
     bool found = false;
388 388
 
389 389
     if (!contacts.length()) {
... ...
@@ -121,25 +121,25 @@ void SWPrepaidSIPDialog::onInvite(const AmSipRequest& req)
121 121
   // this will prevent us from being added to media processor
122 122
   setInOut(NULL,NULL);
123 123
 
124
-  m_uuid = getHeader(req.hdrs,"P-Caller-Uuid");
124
+  m_uuid = getHeader(req.hdrs,"P-Caller-Uuid", true);
125 125
   if(!m_uuid.length()) {
126 126
     ERROR("Application header P-Caller-Uuid not found\n");
127 127
     throw AmSession::Exception(500, "could not get UUID parameter");
128 128
   }
129 129
 
130
-  m_proxy = getHeader(req.hdrs,"P-Proxy");
130
+  m_proxy = getHeader(req.hdrs,"P-Proxy", true);
131 131
   if(!m_proxy.length()) {
132 132
     ERROR("Application header P-Proxy not found\n");
133 133
     throw AmSession::Exception(500, "could not get PROXY parameter");
134 134
   }
135 135
 
136
-  m_ruri = getHeader(req.hdrs,"P-R-Uri");
136
+  m_ruri = getHeader(req.hdrs,"P-R-Uri", true);
137 137
   if(!m_ruri.length()) {
138 138
     ERROR("Application header P-R-Uri not found\n");
139 139
     throw AmSession::Exception(500, "could not get RURI parameter");
140 140
   }
141 141
 
142
-  m_dest = getHeader(req.hdrs,"P-Acc-Dest");
142
+  m_dest = getHeader(req.hdrs,"P-Acc-Dest", true);
143 143
 
144 144
   if(!m_dest.length()) {
145 145
     ERROR("Application header P-Acc-Dest not found\n");
... ...
@@ -312,7 +312,7 @@ AmSession* VoiceboxFactory::onInvite(const AmSipRequest& req)
312 312
     domain = "default";
313 313
   }
314 314
   else {
315
-    string iptel_app_param = getHeader(req.hdrs, PARAM_HDR);
315
+    string iptel_app_param = getHeader(req.hdrs, PARAM_HDR, true);
316 316
   
317 317
     if (!iptel_app_param.length()) {
318 318
       throw AmSession::Exception(500, APP_NAME ": parameters not found");
... ...
@@ -529,7 +529,7 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req)
529 529
   }
530 530
   else {
531 531
   
532
-    iptel_app_param = getHeader(req.hdrs, PARAM_HDR);
532
+    iptel_app_param = getHeader(req.hdrs, PARAM_HDR, true);
533 533
     mode = get_header_keyvalue(iptel_app_param,"mod", "Mode");
534 534
     
535 535
     if (!EmailAddress.length()) {
... ...
@@ -851,7 +851,7 @@ AmSessionFactory* AmPlugIn::findSessionFactory(AmSipRequest& req)
851 851
       req.cmd = req.user; 
852 852
       break;
853 853
     case AmConfig::App_APPHDR: 
854
-      req.cmd = getHeader(req.hdrs, APPNAME_HDR); 
854
+      req.cmd = getHeader(req.hdrs, APPNAME_HDR, true); 
855 855
       break;      
856 856
     case AmConfig::App_RURIPARAM: 
857 857
       req.cmd = get_header_param(req.r_uri, "app");
... ...
@@ -851,7 +851,7 @@ int AmSession::acceptAudio(const string& body,
851 851
   try {
852 852
     try {
853 853
       // handle codec and send reply
854
-      string str_msg_flags = getHeader(hdrs,"P-MsgFlags");
854
+      string str_msg_flags = getHeader(hdrs,"P-MsgFlags", true);
855 855
       unsigned int msg_flags = 0;
856 856
       if(reverse_hex2int(str_msg_flags,msg_flags)){
857 857
 	ERROR("while parsing 'P-MsgFlags' header\n");
... ...
@@ -4,34 +4,43 @@
4 4
 #include "AmSipMsg.h"
5 5
 
6 6
 
7
-string getHeader(const string& hdrs,const string& hdr_name)
7
+string getHeader(const string& hdrs,const string& hdr_name, bool single)
8 8
 {
9 9
   size_t pos1; 
10 10
   size_t pos2;
11 11
   size_t pos_s;
12
-  if (findHeader(hdrs,hdr_name, pos1, pos2, pos_s)) 
13
-    return hdrs.substr(pos1,pos2-pos1);
12
+  size_t skip = 0;
13
+  string ret = "";
14
+  while(findHeader(hdrs, hdr_name, skip, pos1, pos2, pos_s)) 
15
+  {
16
+    if(skip)
17
+      ret.append(", ");
14 18
   else
15
-    return "";
19
+      if(single) return hdrs.substr(pos1,pos2-pos1);
20
+    ret.append(hdrs.substr(pos1,pos2-pos1));
21
+    skip = pos2+1;
22
+  }
23
+  return ret;
16 24
 }
17 25
 
18 26
 string getHeader(const string& hdrs,const string& hdr_name, 
19
-		 const string& compact_hdr_name)
27
+		 const string& compact_hdr_name, bool single)
20 28
 {
21
-  string res = getHeader(hdrs, hdr_name);
29
+  string res = getHeader(hdrs, hdr_name, single);
22 30
   if (!res.length())
23
-    return getHeader(hdrs, compact_hdr_name);
31
+    return getHeader(hdrs, compact_hdr_name, single);
24 32
   return res;
25 33
 }
26 34
 
27
-bool findHeader(const string& hdrs,const string& hdr_name, 
35
+bool findHeader(const string& hdrs,const string& hdr_name, const size_t skip, 
28 36
 		size_t& pos1, size_t& pos2, size_t& hdr_start)
29 37
 {
30 38
   unsigned int p;
31 39
   char* hdr = strdup(hdr_name.c_str());
32
-  const char* hdrs_c = hdrs.c_str();
40
+  if(skip >= hdrs.length()) return false;
41
+  const char* hdrs_c = hdrs.c_str() + skip;
33 42
   char* hdr_c = hdr;
34
-  const char* hdrs_end = hdrs_c + hdrs.length();
43
+  const char* hdrs_end = hdrs.c_str() + hdrs.length();
35 44
   const char* hdr_end = hdr_c + hdr_name.length(); 
36 45
 
37 46
   while(hdr_c != hdr_end){
... ...
@@ -101,19 +110,19 @@ bool findHeader(const string& hdrs,const string& hdr_name,
101 110
 
102 111
 bool removeHeader(string& hdrs, const string& hdr_name) {
103 112
   size_t pos1, pos2, hdr_start;
113
+  bool found = false;
104 114
 
105
-  if (findHeader(hdrs,hdr_name, pos1, pos2, 
106
-		 hdr_start)) {
115
+  while (findHeader(hdrs, hdr_name, 0, pos1, pos2, hdr_start)) {
107 116
     while (pos2 < hdrs.length() && 
108 117
 	   (hdrs[pos2]=='\r' || hdrs[pos2]=='\n'))
109 118
       pos2++;
110 119
 
111 120
     hdr_start -= hdr_name.length(); 
112 121
     hdrs.erase(hdr_start, pos2 - hdr_start);
113
-    return true;
122
+    found = true;
114 123
   }
115 124
 
116
-  return false;
125
+  return found;
117 126
 }
118 127
 
119 128
 /* Print Member */
... ...
@@ -70,16 +70,16 @@ class AmSipRequest : public _AmSipMsgInDlg
70 70
   string print();
71 71
 };
72 72
 
73
-string getHeader(const string& hdrs,const string& hdr_name);
73
+string getHeader(const string& hdrs,const string& hdr_name, bool single = false);
74 74
 
75 75
 string getHeader(const string& hdrs,const string& hdr_name, 
76
-		 const string& compact_hdr_name);
76
+		 const string& compact_hdr_name, bool single = false);
77 77
 
78
-/** find a header, 
78
+/** find a header, starting from char skip
79 79
     if found, value is between pos1 and pos2 
80 80
     and hdr start is the start of the header 
81 81
     @return true if found */
82
-bool findHeader(const string& hdrs,const string& hdr_name, 
82
+bool findHeader(const string& hdrs,const string& hdr_name, const size_t skip, 
83 83
 		size_t& pos1, size_t& pos2, 
84 84
 		size_t& hdr_start);
85 85
 
... ...
@@ -788,6 +788,18 @@ string get_header_keyvalue(const string& param_hdr, const string& short_name, co
788 788
  * while skipping escaped values
789 789
  */
790 790
 string get_header_keyvalue(const string& param_hdr, const string& name) {
791
+  vector <string> parts = explode(param_hdr, ",");
792
+  vector<string>::iterator vit;
793
+  string part;
794
+  for ( vit=parts.begin() ; vit < parts.end(); vit++ )
795
+  {
796
+    part = get_header_keyvalue_single(*vit, name);
797
+    if(!part.empty()) break;
798
+  }
799
+  return part;
800
+}
801
+
802
+string get_header_keyvalue_single(const string& param_hdr, const string& name) {
791 803
   // ugly, but we need escaping
792 804
 #define ST_FINDKEY  0
793 805
 #define ST_FK_ESC   1
... ...
@@ -902,7 +914,7 @@ string get_header_keyvalue(const string& param_hdr, const string& name) {
902 914
 
903 915
 /** get the value of key @param name from \ref PARAM_HDR header in hdrs */
904 916
 string get_session_param(const string& hdrs, const string& name) {
905
-  string iptel_app_param = getHeader(hdrs, PARAM_HDR);
917
+  string iptel_app_param = getHeader(hdrs, PARAM_HDR, true);
906 918
   if (!iptel_app_param.length()) {
907 919
     //      DBG("call parameters header PARAM_HDR not found "
908 920
     // 	 "(need to configure ser's tw_append?).\n");
... ...
@@ -268,6 +268,9 @@ string get_header_param(const string& hdr_string, const string& param_name);
268 268
 /** get the value of key @param name from the list param_hdr*/
269 269
 string get_header_keyvalue(const string& param_hdr, const string& name);
270 270
 
271
+/** get the value of key @param name from the list param_hdr, no comma separated values*/
272
+string get_header_keyvalue_single(const string& param_hdr, const string& name);
273
+
271 274
 /** get the value of key @param short_name or @param name or from the list param_hdr*/
272 275
 string get_header_keyvalue(const string& param_hdr, const string& short_name, const string& name);
273 276
 
274 277
deleted file mode 100644
... ...
@@ -1,333 +0,0 @@
1
-/*
2
- * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
3
- * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
4
- * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
5
- */
6
-
7
-/* $Header: /cvsroot/sems/answer_machine/plug-in/gsm/gsm-1.0-pl10/src/toast_alaw.c.orig,v 1.1 2003/02/03 15:04:56 rco Exp $ */
8
-
9
-#include	"toast.h"
10
-
11
-/*  toast_alaw.c -- manipulate A-law encoded sound.
12
- */
13
-
14
-extern FILE	* in, * out;
15
-
16
-#define	A2S(x)	(a2s[  (unsigned char )(x)       ])
17
-#define	S2A(x)	(s2a[ ((unsigned short)(x)) >> 4 ])
18
-
19
-static unsigned short a2s[] = {
20
-
21
- 	 5120,60160,  320,65200,20480,44032, 1280,64192,
22
-	 2560,62848,   64,65456,10240,54784,  640,64864,
23
-	 7168,58112,  448,65072,28672,35840, 1792,63680,
24
-	 3584,61824,  192,65328,14336,50688,  896,64608,
25
-	 4096,61184,  256,65264,16384,48128, 1024,64448,
26
-	 2048,63360,    0,65520, 8192,56832,  512,64992,
27
-	 6144,59136,  384,65136,24576,39936, 1536,63936,
28
-	 3072,62336,  128,65392,12288,52736,  768,64736,
29
-	 5632,59648,  352,65168,22528,41984, 1408,64064,
30
-	 2816,62592,   96,65424,11264,53760,  704,64800,
31
-	 7680,57600,  480,65040,30720,33792, 1920,63552,
32
-	 3840,61568,  224,65296,15360,49664,  960,64544,
33
-	 4608,60672,  288,65232,18432,46080, 1152,64320,
34
-	 2304,63104,   32,65488, 9216,55808,  576,64928,
35
-	 6656,58624,  416,65104,26624,37888, 1664,63808,
36
-	 3328,62080,  160,65360,13312,51712,  832,64672,
37
-	 5376,59904,  336,65184,21504,43008, 1344,64128,
38
-	 2688,62720,   80,65440,10752,54272,  672,64832,
39
-	 7424,57856,  464,65056,29696,34816, 1856,63616,
40
-	 3712,61696,  208,65312,14848,50176,  928,64576,
41
-	 4352,60928,  272,65248,17408,47104, 1088,64384,
42
-	 2176,63232,   16,65504, 8704,56320,  544,64960,
43
-	 6400,58880,  400,65120,25600,38912, 1600,63872,
44
-	 3200,62208,  144,65376,12800,52224,  800,64704,
45
-	 5888,59392,  368,65152,23552,40960, 1472,64000,
46
-	 2944,62464,  112,65408,11776,53248,  736,64768,
47
-	 7936,57344,  496,65024,31744,32768, 1984,63488,
48
-	 3968,61440,  240,65280,15872,49152,  992,64512,
49
-	 4864,60416,  304,65216,19456,45056, 1216,64256,
50
-	 2432,62976,   48,65472, 9728,55296,  608,64896,
51
-	 6912,58368,  432,65088,27648,36864, 1728,63744,
52
-	 3456,61952,  176,65344,13824,51200,  864,64640
53
-};
54
-
55
-
56
-static unsigned char  s2a[] = {
57
-
58
-	170, 42,234,106,138, 10,202, 74,186, 58,250,122,154, 26,218, 90,
59
-	162, 34,226, 98,130,  2,194, 66,178, 50,242,114,146, 18,210, 82,
60
-	174, 46, 46,238,238,110,110,142,142, 14, 14,206,206, 78, 78,190,
61
-	190, 62, 62,254,254,126,126,158,158, 30, 30,222,222, 94, 94,166,
62
-	166, 38, 38, 38, 38,230,230,230,230,102,102,102,102,134,134,134,
63
-	134,  6,  6,  6,  6,198,198,198,198, 70, 70, 70, 70,182,182,182,
64
-	182, 54, 54, 54, 54,246,246,246,246,118,118,118,118,150,150,150,
65
-	150, 22, 22, 22, 22,214,214,214,214, 86, 86, 86, 86,168,168,168,
66
-	168, 40, 40, 40, 40, 40, 40, 40, 40,232,232,232,232,232,232,232,
67
-	232,104,104,104,104,104,104,104,104,136,136,136,136,136,136,136,
68
-	136,  8,  8,  8,  8,  8,  8,  8,  8,200,200,200,200,200,200,200,
69
-	200, 72, 72, 72, 72, 72, 72, 72, 72,184,184,184,184,184,184,184,
70
-	184, 56, 56, 56, 56, 56, 56, 56, 56,248,248,248,248,248,248,248,
71
-	248,120,120,120,120,120,120,120,120,152,152,152,152,152,152,152,
72
-	152, 24, 24, 24, 24, 24, 24, 24, 24,216,216,216,216,216,216,216,
73
-	216, 88, 88, 88, 88, 88, 88, 88, 88,160,160,160,160,160,160,160,
74
-	160, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
75
-	 32,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,
76
-	224, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96,
77
-	 96,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,
78
-	128,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
79
-	  0,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
80
-	192, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
81
-	 64,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
82
-	176, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
83
-	 48,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
84
-	240,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,
85
-	112,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
86
-	144, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
87
-	 16,208,208,208,208,208,208,208,208,208,208,208,208,208,208,208,
88
-	208, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
89
-	 80,172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,
90
-	172, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
91
-	 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
92
-	 44,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,
93
-	236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,
94
-	236,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,
95
-	108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,
96
-	108,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,
97
-	140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,
98
-	140, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
99
-	 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
100
-	 12,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,
101
-	204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,
102
-	204, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
103
-	 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
104
-	 76,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,
105
-	188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,
106
-	188, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
107
-	 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
108
-	 60,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,
109
-	252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,
110
-	252,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
111
-	124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
112
-	124,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
113
-	156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
114
-	156, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
115
-	 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
116
-	 28,220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,
117
-	220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,220,
118
-	220, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
119
-	 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
120
-	 92,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
121
-	164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,
122
-	164, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
123
-	 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
124
-	 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
125
-	 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
126
-	 36,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
127
-	228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
128
-	228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
129
-	228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,228,
130
-	228,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
131
-	100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
132
-	100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
133
-	100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
134
-	100,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
135
-	132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
136
-	132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
137
-	132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
138
-	132,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
139
-	  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
140
-	  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
141
-	  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
142
-	  4,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
143
-	196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
144
-	196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
145
-	196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,
146
-	196, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
147
-	 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
148
-	 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
149
-	 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
150
-	 68,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
151
-	180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
152
-	180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
153
-	180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
154
-	180, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
155
-	 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
156
-	 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
157
-	 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
158
-	 52,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
159
-	244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
160
-	244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
161
-	244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,
162
-	244,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
163
-	116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
164
-	116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
165
-	116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,116,
166
-	116,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
167
-	148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
168
-	148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
169
-	148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,
170
-	148, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
171
-	 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
172
-	 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
173
-	 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
174
-	 20,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
175
-	212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
176
-	212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
177
-	212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,
178
-	212, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
179
-	 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
180
-	 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
181
-	 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
182
-	 84, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
183
-	 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
184
-	 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
185
-	 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
186
-	 85,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
187
-	213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
188
-	213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
189
-	213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,213,
190
-	213, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
191
-	 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
192
-	 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
193
-	 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
194
-	 21,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
195
-	149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
196
-	149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
197
-	149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,149,
198
-	149,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
199
-	117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
200
-	117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
201
-	117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,117,
202
-	117,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
203
-	245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
204
-	245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
205
-	245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,
206
-	245, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
207
-	 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
208
-	 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
209
-	 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
210
-	 53,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
211
-	181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
212
-	181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
213
-	181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,
214
-	181, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
215
-	 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
216
-	 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
217
-	 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
218
-	 69,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
219
-	197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
220
-	197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
221
-	197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,
222
-	197,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
223
-	  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
224
-	  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
225
-	  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
226
-	  5,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
227
-	133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
228
-	133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
229
-	133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,
230
-	133,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
231
-	101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
232
-	101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
233
-	101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,
234
-	101,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
235
-	229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
236
-	229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
237
-	229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,229,
238
-	229, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
239
-	 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
240
-	 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
241
-	 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
242
-	 37,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
243
-	165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
244
-	165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
245
-	165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,
246
-	165, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
247
-	 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
248
-	 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
249
-	 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
250
-	 93,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,
251
-	221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,221,
252
-	221, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
253
-	 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
254
-	 29,157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,
255
-	157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,157,
256
-	157,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,
257
-	125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,
258
-	125,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,
259
-	253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,
260
-	253, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
261
-	 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
262
-	 61,189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,
263
-	189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,
264
-	189, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
265
-	 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
266
-	 77,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,
267
-	205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,
268
-	205, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
269
-	 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
270
-	 13,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,
271
-	141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,
272
-	141,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,
273
-	109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,
274
-	109,237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,
275
-	237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,237,
276
-	237, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
277
-	 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
278
-	 45,173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,
279
-	173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,
280
-	173, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
281
-	 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
282
-	 81,209,209,209,209,209,209,209,209,209,209,209,209,209,209,209,
283
-	209, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
284
-	 17,145,145,145,145,145,145,145,145,145,145,145,145,145,145,145,
285
-	145,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,
286
-	113,241,241,241,241,241,241,241,241,241,241,241,241,241,241,241,
287
-	241, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
288
-	 49,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,
289
-	177, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
290
-	 65,193,193,193,193,193,193,193,193,193,193,193,193,193,193,193,
291
-	193,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
292
-	  1,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,
293
-	129, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
294
-	 97,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,
295
-	225, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
296
-	 33,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,
297
-	161, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
298
-	 89,217,217,217,217,217,217,217,217, 25, 25, 25, 25, 25, 25, 25,
299
-	 25,153,153,153,153,153,153,153,153,121,121,121,121,121,121,121,
300
-	121,249,249,249,249,249,249,249,249, 57, 57, 57, 57, 57, 57, 57,
301
-	 57,185,185,185,185,185,185,185,185, 73, 73, 73, 73, 73, 73, 73,
302
-	 73,201,201,201,201,201,201,201,201,  9,  9,  9,  9,  9,  9,  9,
303
-	  9,137,137,137,137,137,137,137,137,105,105,105,105,105,105,105,
304
-	105,233,233,233,233,233,233,233,233, 41, 41, 41, 41, 41, 41, 41,
305
-	 41,169,169,169,169,169,169,169,169, 87, 87, 87, 87, 87, 87, 87,
306
-	 87,215,215,215,215, 23, 23, 23, 23,151,151,151,151,119,119,119,
307
-	119,247,247,247,247, 55, 55, 55, 55,183,183,183,183, 71, 71, 71,
308
-	 71,199,199,199,199,  7,  7,  7,  7,135,135,135,135,103,103,103,
309
-	103,231,231,231,231, 39, 39, 39, 39,167,167,167,167, 95, 95, 95,
310
-	 95,223,223, 31, 31,159,159,127,127,255,255, 63, 63,191,191, 79,
311
-	 79,207,207, 15, 15,143,143,111,111,239,239, 47, 47,175,175, 83,
312
-	 83,211, 19,147,115,243, 51,179, 67,195,  3,131, 99,227, 35,163,
313
-	 91,219, 27,155,123,251, 59,187, 75,203, 11,139,107,235, 43,171
314
-};
315
-
316
-int alaw_input P1((buf), gsm_signal * buf) 
317
-{
318
-	int  i, c;
319
-
320
-	for (i = 0; i < 160 && (c = fgetc(in)) != EOF; i++) buf[i] = A2S( c );
321
-	if (c == EOF && ferror(in)) return -1;
322
-	return i;
323
-}
324
-
325
-int alaw_output P1((buf), gsm_signal * buf) 
326
-{
327
-	int  i;
328
-
329
-	for (i = 0; i < 160; i++, buf++)
330
-		if (fputc( S2A( *buf ), out) == EOF) return -1;
331
-	return 0;
332
-}
333
-
... ...
@@ -152,7 +152,7 @@ int  SessionTimer::configure(AmConfigReader& conf)
152 152
  */
153 153
 bool SessionTimerFactory::checkSessionExpires(const AmSipRequest& req) 
154 154
 {
155
-  string session_expires = getHeader(req.hdrs, "Session-Expires", "x");
155
+  string session_expires = getHeader(req.hdrs, "Session-Expires", "x", true);
156 156
 
157 157
   if (session_expires.length()) {
158 158
     unsigned int i_se;
... ...
@@ -174,10 +174,10 @@ void SessionTimer::updateTimer(AmSession* s, const AmSipRequest& req) {
174 174
   if((req.method == "INVITE")||(req.method == "UPDATE")){
175 175
     
176 176
     remote_timer_aware = 
177
-      key_in_list(getHeader(req.hdrs, SIP_HDR_SUPPORTED),"timer");
177
+      key_in_list(getHeader(req.hdrs, SIP_HDR_SUPPORTED),"timer", true);
178 178
     
179 179
     // determine session interval
180
-    string sess_expires_hdr = getHeader(req.hdrs, "Session-Expires", "x");
180
+    string sess_expires_hdr = getHeader(req.hdrs, "Session-Expires", "x", true);
181 181
     
182 182
     bool rem_has_sess_expires = false;
183 183
     unsigned int rem_sess_expires=0; 
... ...
@@ -193,7 +193,7 @@ void SessionTimer::updateTimer(AmSession* s, const AmSipRequest& req) {
193 193
 
194 194
     // get Min-SE
195 195
     unsigned int i_minse = min_se;
196
-    string min_se_hdr = getHeader(req.hdrs, "Min-SE");
196
+    string min_se_hdr = getHeader(req.hdrs, "Min-SE", true);
197 197
     if (!min_se_hdr.empty()) {
198 198
       if (str2i(strip_header_params(min_se_hdr),
199 199
 		i_minse)) {
... ...
@@ -251,9 +251,9 @@ void SessionTimer::updateTimer(AmSession* s, const AmSipReply& reply)
251 251
     return;
252 252
   
253 253
   // determine session interval
254
-  string sess_expires_hdr = getHeader(reply.hdrs, "Session-Expires");
254
+  string sess_expires_hdr = getHeader(reply.hdrs, "Session-Expires", true);
255 255
   if (sess_expires_hdr.empty())
256
-    sess_expires_hdr = getHeader(reply.hdrs, "x"); // compact form
256
+    sess_expires_hdr = getHeader(reply.hdrs, "x", true); // compact form
257 257
   
258 258
   session_refresher = refresh_local;
259 259
   session_refresher_role = UAC;
... ...
@@ -134,13 +134,14 @@ bool UACAuth::onSipReply(const AmSipReply& reply)
134 134
 	// 				credential->user.c_str(),
135 135
 	// 				credential->pwd.c_str());
136 136
 	if (((reply.code == 401) && 
137
-	     getHeader(ri->second.hdrs, "Authorization").length()) ||
137
+	     getHeader(ri->second.hdrs, "Authorization", true).length()) ||
138 138
 	    ((reply.code == 407) && 
139
-	     getHeader(ri->second.hdrs, "Proxy-Authorization").length())) {
139
+	     getHeader(ri->second.hdrs, "Proxy-Authorization", true).length())) {
140 140
 	  DBG("Authorization failed!\n");
141 141
 	} else {
142
-	  string auth_hdr = (reply.code==407) ? getHeader(reply.hdrs, "Proxy-Authenticate") : 
143
-	    getHeader(reply.hdrs, "WWW-Authenticate");
142
+	  string auth_hdr = (reply.code==407) ? 
143
+      getHeader(reply.hdrs, "Proxy-Authenticate", true) : 
144
+	    getHeader(reply.hdrs, "WWW-Authenticate", true);
144 145
 	  string result; 
145 146
 			
146 147
 	  string auth_uri; 
147 148
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+sems_tests
... ...
@@ -18,7 +18,11 @@
18 18
 #include "fct.h"
19 19
 
20 20
 FCT_BGN() {
21
-    FCTMF_SUITE_CALL(test_headers);
21
+  init_logging();
22
+  log_stderr = true;
23
+  log_level = 3;
24
+
25
+  FCTMF_SUITE_CALL(test_headers);
22 26
 } FCT_END();
23 27
 
24 28
 
... ...
@@ -1,5 +1,7 @@
1 1
 #include "fct.h"
2 2
 
3
+#include "log.h"
4
+
3 5
 #include "AmSipHeaders.h"
4 6
 #include "AmSipMsg.h"
5 7
 
... ...
@@ -9,7 +11,9 @@ FCTMF_SUITE_BGN(test_headers) {
9 11
         fct_chk( getHeader("P-My-Test: myval" CRLF, "P-My-Test") == "myval");
10 12
     } FCT_TEST_END();
11 13
     FCT_TEST_BGN(getHeader_multi) {
12
-        fct_chk( getHeader("P-My-Test: myval" CRLF "P-My-Test: myval2" CRLF , "P-My-Test") == "myval");
14
+      fct_chk( getHeader("P-My-Test: myval" CRLF "P-My-Test: myval2" CRLF , "P-My-Test", true) == "myval" );
15
+      fct_chk( getHeader("P-My-Test: myval" CRLF "P-My-Test: myval2" CRLF , "P-My-Test", false) == "myval, myval2" );
16
+      fct_chk( getHeader("P-My-Test: myval" CRLF "P-My-Otherheader: myval2" CRLF "P-My-Test: myval2" CRLF , "P-My-Test", false) == "myval, myval2" );
13 17
     } FCT_TEST_END();
14 18
 
15 19
 } FCTMF_SUITE_END();