| 563 | | <a name="l00574"></a>00574 <span class="comment">/*</span> |
|---|
| 564 | | <a name="l00575"></a>00575 <span class="comment"> ** Process and POST data</span> |
|---|
| 565 | | <a name="l00576"></a>00576 <span class="comment"> */</span> |
|---|
| 566 | | <a name="l00577"></a>00577 <span class="preprocessor">#if 0</span> |
|---|
| 567 | | <a name="l00578"></a>00578 <span class="preprocessor"></span> <span class="keywordflow">if</span> (r-><a class="code" href="structrequest.html#1e25aac8f9b3f8d3a2a89f58fb12bb65">request</a>.<a class="code" href="structhttpReq.html#c311d136dc194681da926737a9ce0f98">contentLength</a> > 0) |
|---|
| 568 | | <a name="l00579"></a>00579 { |
|---|
| 569 | | <a name="l00580"></a>00580 bzero(buf, HTTP_MAX_LEN); |
|---|
| 570 | | <a name="l00581"></a>00581 _httpd_readBuf(r, buf, r-><a class="code" href="structrequest.html#1e25aac8f9b3f8d3a2a89f58fb12bb65">request</a>.<a class="code" href="structhttpReq.html#c311d136dc194681da926737a9ce0f98">contentLength</a>); |
|---|
| 571 | | <a name="l00582"></a>00582 _httpd_storeData(r, buf); |
|---|
| 572 | | <a name="l00583"></a>00583 |
|---|
| 573 | | <a name="l00584"></a>00584 } |
|---|
| 574 | | <a name="l00585"></a>00585 <span class="preprocessor">#endif</span> |
|---|
| 575 | | <a name="l00586"></a>00586 <span class="preprocessor"></span> |
|---|
| 576 | | <a name="l00587"></a>00587 <span class="comment">/*</span> |
|---|
| 577 | | <a name="l00588"></a>00588 <span class="comment"> ** Process any URL data</span> |
|---|
| 578 | | <a name="l00589"></a>00589 <span class="comment"> */</span> |
|---|
| 579 | | <a name="l00590"></a>00590 cp = index(r-><a class="code" href="structrequest.html#1e25aac8f9b3f8d3a2a89f58fb12bb65">request</a>.<a class="code" href="structhttpReq.html#e99c9c116c2bb6f0c79d0bde882592d0">path</a>,<span class="charliteral">'?'</span>); |
|---|
| 580 | | <a name="l00591"></a>00591 <span class="keywordflow">if</span> (cp != NULL) |
|---|
| 581 | | <a name="l00592"></a>00592 { |
|---|
| 582 | | <a name="l00593"></a>00593 *cp = 0; |
|---|
| 583 | | <a name="l00594"></a>00594 cp++; |
|---|
| 584 | | <a name="l00595"></a>00595 _httpd_storeData(r, cp); |
|---|
| 585 | | <a name="l00596"></a>00596 } |
|---|
| 586 | | <a name="l00597"></a>00597 <span class="keywordflow">return</span>(0); |
|---|
| 587 | | <a name="l00598"></a>00598 } |
|---|
| 588 | | <a name="l00599"></a>00599 |
|---|
| 589 | | <a name="l00600"></a>00600 |
|---|
| 590 | | <a name="l00601"></a>00601 <span class="keywordtype">void</span> httpdEndRequest(request *r) |
|---|
| 591 | | <a name="l00602"></a>00602 { |
|---|
| 592 | | <a name="l00603"></a>00603 _httpd_freeVariables(r-><a class="code" href="structrequest.html#a6cf396396d895f2a515c4fc00bf6c6b">variables</a>); |
|---|
| 593 | | <a name="l00604"></a>00604 shutdown(r-><a class="code" href="structrequest.html#761166d41596f6cfe9efc2ed1024ece1">clientSock</a>,2); |
|---|
| 594 | | <a name="l00605"></a>00605 close(r-><a class="code" href="structrequest.html#761166d41596f6cfe9efc2ed1024ece1">clientSock</a>); |
|---|
| 595 | | <a name="l00606"></a>00606 free(r); |
|---|
| 596 | | <a name="l00607"></a>00607 } |
|---|
| 597 | | <a name="l00608"></a>00608 |
|---|
| 598 | | <a name="l00609"></a>00609 |
|---|
| 599 | | <a name="l00610"></a>00610 <span class="keywordtype">void</span> httpdFreeVariables(request *r) |
|---|
| 600 | | <a name="l00611"></a>00611 { |
|---|
| 601 | | <a name="l00612"></a>00612 _httpd_freeVariables(r-><a class="code" href="structrequest.html#a6cf396396d895f2a515c4fc00bf6c6b">variables</a>); |
|---|
| 602 | | <a name="l00613"></a>00613 } |
|---|
| | 563 | <a name="l00574"></a>00574 |
|---|
| | 564 | <a name="l00575"></a>00575 <span class="preprocessor">#if 0</span> |
|---|
| | 565 | <a name="l00576"></a>00576 <span class="preprocessor"></span> <span class="comment">/* XXX: For WifiDog, we only process the query string parameters</span> |
|---|
| | 566 | <a name="l00577"></a>00577 <span class="comment"> but keep the GET variables in the request.query!</span> |
|---|
| | 567 | <a name="l00578"></a>00578 <span class="comment"> */</span> |
|---|
| | 568 | <a name="l00579"></a>00579 <span class="comment">/*</span> |
|---|
| | 569 | <a name="l00580"></a>00580 <span class="comment"> ** Process and POST data</span> |
|---|
| | 570 | <a name="l00581"></a>00581 <span class="comment"> */</span> |
|---|
| | 571 | <a name="l00582"></a>00582 <span class="keywordflow">if</span> (r-><a class="code" href="structrequest.html#1e25aac8f9b3f8d3a2a89f58fb12bb65">request</a>.<a class="code" href="structhttpReq.html#c311d136dc194681da926737a9ce0f98">contentLength</a> > 0) |
|---|
| | 572 | <a name="l00583"></a>00583 { |
|---|
| | 573 | <a name="l00584"></a>00584 bzero(buf, HTTP_MAX_LEN); |
|---|
| | 574 | <a name="l00585"></a>00585 _httpd_readBuf(r, buf, r-><a class="code" href="structrequest.html#1e25aac8f9b3f8d3a2a89f58fb12bb65">request</a>.<a class="code" href="structhttpReq.html#c311d136dc194681da926737a9ce0f98">contentLength</a>); |
|---|
| | 575 | <a name="l00586"></a>00586 _httpd_storeData(r, buf); |
|---|
| | 576 | <a name="l00587"></a>00587 |
|---|
| | 577 | <a name="l00588"></a>00588 } |
|---|
| | 578 | <a name="l00589"></a>00589 <span class="preprocessor">#endif</span> |
|---|
| | 579 | <a name="l00590"></a>00590 <span class="preprocessor"></span> |
|---|
| | 580 | <a name="l00591"></a>00591 <span class="comment">/*</span> |
|---|
| | 581 | <a name="l00592"></a>00592 <span class="comment"> ** Process any URL data</span> |
|---|
| | 582 | <a name="l00593"></a>00593 <span class="comment"> */</span> |
|---|
| | 583 | <a name="l00594"></a>00594 cp = index(r-><a class="code" href="structrequest.html#1e25aac8f9b3f8d3a2a89f58fb12bb65">request</a>.<a class="code" href="structhttpReq.html#e99c9c116c2bb6f0c79d0bde882592d0">path</a>,<span class="charliteral">'?'</span>); |
|---|
| | 584 | <a name="l00595"></a>00595 <span class="keywordflow">if</span> (cp != NULL) |
|---|
| | 585 | <a name="l00596"></a>00596 { |
|---|
| | 586 | <a name="l00597"></a>00597 *cp++ = 0; |
|---|
| | 587 | <a name="l00598"></a>00598 strncpy(r-><a class="code" href="structrequest.html#1e25aac8f9b3f8d3a2a89f58fb12bb65">request</a>.<a class="code" href="structhttpReq.html#baa78e58c13224512d41c25afe79146e">query</a>, cp, <span class="keyword">sizeof</span>(r-><a class="code" href="structrequest.html#1e25aac8f9b3f8d3a2a89f58fb12bb65">request</a>.<a class="code" href="structhttpReq.html#baa78e58c13224512d41c25afe79146e">query</a>)); |
|---|
| | 588 | <a name="l00599"></a>00599 _httpd_storeData(r, cp); |
|---|
| | 589 | <a name="l00600"></a>00600 } |
|---|
| | 590 | <a name="l00601"></a>00601 |
|---|
| | 591 | <a name="l00602"></a>00602 <span class="keywordflow">return</span>(0); |
|---|
| | 592 | <a name="l00603"></a>00603 } |
|---|
| | 593 | <a name="l00604"></a>00604 |
|---|
| | 594 | <a name="l00605"></a>00605 |
|---|
| | 595 | <a name="l00606"></a>00606 <span class="keywordtype">void</span> httpdEndRequest(request *r) |
|---|
| | 596 | <a name="l00607"></a>00607 { |
|---|
| | 597 | <a name="l00608"></a>00608 _httpd_freeVariables(r-><a class="code" href="structrequest.html#a6cf396396d895f2a515c4fc00bf6c6b">variables</a>); |
|---|
| | 598 | <a name="l00609"></a>00609 shutdown(r-><a class="code" href="structrequest.html#761166d41596f6cfe9efc2ed1024ece1">clientSock</a>,2); |
|---|
| | 599 | <a name="l00610"></a>00610 close(r-><a class="code" href="structrequest.html#761166d41596f6cfe9efc2ed1024ece1">clientSock</a>); |
|---|
| | 600 | <a name="l00611"></a>00611 free(r); |
|---|
| | 601 | <a name="l00612"></a>00612 } |
|---|
| | 602 | <a name="l00613"></a>00613 |
|---|
| 611 | | <a name="l00622"></a>00622 curVar = r-><a class="code" href="structrequest.html#a6cf396396d895f2a515c4fc00bf6c6b">variables</a>; |
|---|
| 612 | | <a name="l00623"></a>00623 <span class="keywordflow">while</span>(curVar) |
|---|
| 613 | | <a name="l00624"></a>00624 { |
|---|
| 614 | | <a name="l00625"></a>00625 printf(<span class="stringliteral">"Variable '%s'\n"</span>, curVar-><a class="code" href="struct__httpd__var.html#77d3c22c1b1257aeea66ef2f5af322a7">name</a>); |
|---|
| 615 | | <a name="l00626"></a>00626 curVal = curVar; |
|---|
| 616 | | <a name="l00627"></a>00627 <span class="keywordflow">while</span>(curVal) |
|---|
| 617 | | <a name="l00628"></a>00628 { |
|---|
| 618 | | <a name="l00629"></a>00629 printf(<span class="stringliteral">"\t= '%s'\n"</span>,curVal-><a class="code" href="struct__httpd__var.html#6c0032e6d6809bdcf5ceb67410b34703">value</a>); |
|---|
| 619 | | <a name="l00630"></a>00630 curVal = curVal-><a class="code" href="struct__httpd__var.html#df637dd294167ab2d01599e39d857ac4">nextValue</a>; |
|---|
| 620 | | <a name="l00631"></a>00631 } |
|---|
| 621 | | <a name="l00632"></a>00632 curVar = curVar-><a class="code" href="struct__httpd__var.html#7ae681e829e56cfa116bf85449182093">nextVariable</a>; |
|---|
| 622 | | <a name="l00633"></a>00633 } |
|---|
| 623 | | <a name="l00634"></a>00634 } |
|---|
| 624 | | <a name="l00635"></a>00635 |
|---|
| 625 | | <a name="l00636"></a>00636 <span class="keywordtype">void</span> httpdSetFileBase(server, path) |
|---|
| 626 | | <a name="l00637"></a>00637 <a class="code" href="structhttpd.html">httpd</a> *server; |
|---|
| 627 | | <a name="l00638"></a>00638 <span class="keywordtype">char</span> *path; |
|---|
| 628 | | <a name="l00639"></a>00639 { |
|---|
| 629 | | <a name="l00640"></a>00640 strncpy(server->fileBasePath, path, HTTP_MAX_URL); |
|---|
| 630 | | <a name="l00641"></a>00641 } |
|---|
| 631 | | <a name="l00642"></a>00642 |
|---|
| 632 | | <a name="l00643"></a>00643 |
|---|
| 633 | | <a name="l00644"></a>00644 <span class="keywordtype">int</span> httpdAddFileContent(server, dir, name, indexFlag, preload, path) |
|---|
| 634 | | <a name="l00645"></a>00645 <a class="code" href="structhttpd.html">httpd</a> *server; |
|---|
| 635 | | <a name="l00646"></a>00646 <span class="keywordtype">char</span> *dir, |
|---|
| 636 | | <a name="l00647"></a>00647 *name; |
|---|
| 637 | | <a name="l00648"></a>00648 <span class="keywordtype">int</span> (*preload)(); |
|---|
| 638 | | <a name="l00649"></a>00649 <span class="keywordtype">int</span> indexFlag; |
|---|
| 639 | | <a name="l00650"></a>00650 <span class="keywordtype">char</span> *path; |
|---|
| 640 | | <a name="l00651"></a>00651 { |
|---|
| 641 | | <a name="l00652"></a>00652 httpDir *dirPtr; |
|---|
| 642 | | <a name="l00653"></a>00653 <a class="code" href="struct__httpd__content.html">httpContent</a> *newEntry; |
|---|
| 643 | | <a name="l00654"></a>00654 |
|---|
| 644 | | <a name="l00655"></a>00655 dirPtr = _httpd_findContentDir(server, dir, HTTP_TRUE); |
|---|
| 645 | | <a name="l00656"></a>00656 newEntry = malloc(<span class="keyword">sizeof</span>(<a class="code" href="struct__httpd__content.html">httpContent</a>)); |
|---|
| 646 | | <a name="l00657"></a>00657 <span class="keywordflow">if</span> (newEntry == NULL) |
|---|
| 647 | | <a name="l00658"></a>00658 <span class="keywordflow">return</span>(-1); |
|---|
| 648 | | <a name="l00659"></a>00659 bzero(newEntry,<span class="keyword">sizeof</span>(<a class="code" href="struct__httpd__content.html">httpContent</a>)); |
|---|
| 649 | | <a name="l00660"></a>00660 newEntry-><a class="code" href="struct__httpd__content.html#5f20e383abe7d05a315f02d7d37c7291">name</a> = strdup(name); |
|---|
| 650 | | <a name="l00661"></a>00661 newEntry-><a class="code" href="struct__httpd__content.html#84dfed3d65d2f07d27442cdfb94f56a4">type</a> = HTTP_FILE; |
|---|
| 651 | | <a name="l00662"></a>00662 newEntry-><a class="code" href="struct__httpd__content.html#02878770ba8b1143e08e678f0ca0da12">indexFlag</a> = indexFlag; |
|---|
| 652 | | <a name="l00663"></a>00663 newEntry-><a class="code" href="struct__httpd__content.html#70cfe712fd72d9138f8cda732d34d097">preload</a> = preload; |
|---|
| 653 | | <a name="l00664"></a>00664 newEntry-><a class="code" href="struct__httpd__content.html#aabc5e64c334e035d4ddb9e46487ee7b">next</a> = dirPtr-><a class="code" href="struct__httpd__dir.html#7456ca7da5e890d2e85a07396394b77f">entries</a>; |
|---|
| 654 | | <a name="l00665"></a>00665 dirPtr-><a class="code" href="struct__httpd__dir.html#7456ca7da5e890d2e85a07396394b77f">entries</a> = newEntry; |
|---|
| 655 | | <a name="l00666"></a>00666 <span class="keywordflow">if</span> (*path == <span class="charliteral">'/'</span>) |
|---|
| 656 | | <a name="l00667"></a>00667 { |
|---|
| 657 | | <a name="l00668"></a>00668 <span class="comment">/* Absolute path */</span> |
|---|
| 658 | | <a name="l00669"></a>00669 newEntry-><a class="code" href="struct__httpd__content.html#d36079509c38ff3d00c53c87e20f22a5">path</a> = strdup(path); |
|---|
| 659 | | <a name="l00670"></a>00670 } |
|---|
| 660 | | <a name="l00671"></a>00671 <span class="keywordflow">else</span> |
|---|
| | 611 | <a name="l00622"></a>00622 <span class="keywordtype">void</span> httpdDumpVariables(request *r) |
|---|
| | 612 | <a name="l00623"></a>00623 { |
|---|
| | 613 | <a name="l00624"></a>00624 <a class="code" href="struct__httpd__var.html">httpVar</a> *curVar, |
|---|
| | 614 | <a name="l00625"></a>00625 *curVal; |
|---|
| | 615 | <a name="l00626"></a>00626 |
|---|
| | 616 | <a name="l00627"></a>00627 curVar = r-><a class="code" href="structrequest.html#a6cf396396d895f2a515c4fc00bf6c6b">variables</a>; |
|---|
| | 617 | <a name="l00628"></a>00628 <span class="keywordflow">while</span>(curVar) |
|---|
| | 618 | <a name="l00629"></a>00629 { |
|---|
| | 619 | <a name="l00630"></a>00630 printf(<span class="stringliteral">"Variable '%s'\n"</span>, curVar-><a class="code" href="struct__httpd__var.html#77d3c22c1b1257aeea66ef2f5af322a7">name</a>); |
|---|
| | 620 | <a name="l00631"></a>00631 curVal = curVar; |
|---|
| | 621 | <a name="l00632"></a>00632 <span class="keywordflow">while</span>(curVal) |
|---|
| | 622 | <a name="l00633"></a>00633 { |
|---|
| | 623 | <a name="l00634"></a>00634 printf(<span class="stringliteral">"\t= '%s'\n"</span>,curVal-><a class="code" href="struct__httpd__var.html#6c0032e6d6809bdcf5ceb67410b34703">value</a>); |
|---|
| | 624 | <a name="l00635"></a>00635 curVal = curVal-><a class="code" href="struct__httpd__var.html#df637dd294167ab2d01599e39d857ac4">nextValue</a>; |
|---|
| | 625 | <a name="l00636"></a>00636 } |
|---|
| | 626 | <a name="l00637"></a>00637 curVar = curVar-><a class="code" href="struct__httpd__var.html#7ae681e829e56cfa116bf85449182093">nextVariable</a>; |
|---|
| | 627 | <a name="l00638"></a>00638 } |
|---|
| | 628 | <a name="l00639"></a>00639 } |
|---|
| | 629 | <a name="l00640"></a>00640 |
|---|
| | 630 | <a name="l00641"></a>00641 <span class="keywordtype">void</span> httpdSetFileBase(server, path) |
|---|
| | 631 | <a name="l00642"></a>00642 <a class="code" href="structhttpd.html">httpd</a> *server; |
|---|
| | 632 | <a name="l00643"></a>00643 <span class="keywordtype">char</span> *path; |
|---|
| | 633 | <a name="l00644"></a>00644 { |
|---|
| | 634 | <a name="l00645"></a>00645 strncpy(server->fileBasePath, path, HTTP_MAX_URL); |
|---|
| | 635 | <a name="l00646"></a>00646 } |
|---|
| | 636 | <a name="l00647"></a>00647 |
|---|
| | 637 | <a name="l00648"></a>00648 |
|---|
| | 638 | <a name="l00649"></a>00649 <span class="keywordtype">int</span> httpdAddFileContent(server, dir, name, indexFlag, preload, path) |
|---|
| | 639 | <a name="l00650"></a>00650 <a class="code" href="structhttpd.html">httpd</a> *server; |
|---|
| | 640 | <a name="l00651"></a>00651 <span class="keywordtype">char</span> *dir, |
|---|
| | 641 | <a name="l00652"></a>00652 *name; |
|---|
| | 642 | <a name="l00653"></a>00653 <span class="keywordtype">int</span> (*preload)(); |
|---|
| | 643 | <a name="l00654"></a>00654 <span class="keywordtype">int</span> indexFlag; |
|---|
| | 644 | <a name="l00655"></a>00655 <span class="keywordtype">char</span> *path; |
|---|
| | 645 | <a name="l00656"></a>00656 { |
|---|
| | 646 | <a name="l00657"></a>00657 httpDir *dirPtr; |
|---|
| | 647 | <a name="l00658"></a>00658 <a class="code" href="struct__httpd__content.html">httpContent</a> *newEntry; |
|---|
| | 648 | <a name="l00659"></a>00659 |
|---|
| | 649 | <a name="l00660"></a>00660 dirPtr = _httpd_findContentDir(server, dir, HTTP_TRUE); |
|---|
| | 650 | <a name="l00661"></a>00661 newEntry = malloc(<span class="keyword">sizeof</span>(<a class="code" href="struct__httpd__content.html">httpContent</a>)); |
|---|
| | 651 | <a name="l00662"></a>00662 <span class="keywordflow">if</span> (newEntry == NULL) |
|---|
| | 652 | <a name="l00663"></a>00663 <span class="keywordflow">return</span>(-1); |
|---|
| | 653 | <a name="l00664"></a>00664 bzero(newEntry,<span class="keyword">sizeof</span>(<a class="code" href="struct__httpd__content.html">httpContent</a>)); |
|---|
| | 654 | <a name="l00665"></a>00665 newEntry-><a class="code" href="struct__httpd__content.html#5f20e383abe7d05a315f02d7d37c7291">name</a> = strdup(name); |
|---|
| | 655 | <a name="l00666"></a>00666 newEntry-><a class="code" href="struct__httpd__content.html#84dfed3d65d2f07d27442cdfb94f56a4">type</a> = HTTP_FILE; |
|---|
| | 656 | <a name="l00667"></a>00667 newEntry-><a class="code" href="struct__httpd__content.html#02878770ba8b1143e08e678f0ca0da12">indexFlag</a> = indexFlag; |
|---|
| | 657 | <a name="l00668"></a>00668 newEntry-><a class="code" href="struct__httpd__content.html#70cfe712fd72d9138f8cda732d34d097">preload</a> = preload; |
|---|
| | 658 | <a name="l00669"></a>00669 newEntry-><a class="code" href="struct__httpd__content.html#aabc5e64c334e035d4ddb9e46487ee7b">next</a> = dirPtr-><a class="code" href="struct__httpd__dir.html#7456ca7da5e890d2e85a07396394b77f">entries</a>; |
|---|
| | 659 | <a name="l00670"></a>00670 dirPtr-><a class="code" href="struct__httpd__dir.html#7456ca7da5e890d2e85a07396394b77f">entries</a> = newEntry; |
|---|
| | 660 | <a name="l00671"></a>00671 <span class="keywordflow">if</span> (*path == <span class="charliteral">'/'</span>) |
|---|
| 662 | | <a name="l00673"></a>00673 <span class="comment">/* Path relative to base path */</span> |
|---|
| 663 | | <a name="l00674"></a>00674 newEntry-><a class="code" href="struct__httpd__content.html#d36079509c38ff3d00c53c87e20f22a5">path</a> = malloc(strlen(server->fileBasePath) + |
|---|
| 664 | | <a name="l00675"></a>00675 strlen(path) + 2); |
|---|
| 665 | | <a name="l00676"></a>00676 snprintf(newEntry-><a class="code" href="struct__httpd__content.html#d36079509c38ff3d00c53c87e20f22a5">path</a>, HTTP_MAX_URL, <span class="stringliteral">"%s/%s"</span>, |
|---|
| 666 | | <a name="l00677"></a>00677 server->fileBasePath, path); |
|---|
| 667 | | <a name="l00678"></a>00678 } |
|---|
| 668 | | <a name="l00679"></a>00679 <span class="keywordflow">return</span>(0); |
|---|
| 669 | | <a name="l00680"></a>00680 } |
|---|
| 670 | | <a name="l00681"></a>00681 |
|---|
| 671 | | <a name="l00682"></a>00682 |
|---|
| 672 | | <a name="l00683"></a>00683 |
|---|
| 673 | | <a name="l00684"></a>00684 <span class="keywordtype">int</span> httpdAddWildcardContent(server, dir, preload, path) |
|---|
| 674 | | <a name="l00685"></a>00685 <a class="code" href="structhttpd.html">httpd</a> *server; |
|---|
| 675 | | <a name="l00686"></a>00686 <span class="keywordtype">char</span> *dir; |
|---|
| 676 | | <a name="l00687"></a>00687 <span class="keywordtype">int</span> (*preload)(); |
|---|
| 677 | | <a name="l00688"></a>00688 <span class="keywordtype">char</span> *path; |
|---|
| 678 | | <a name="l00689"></a>00689 { |
|---|
| 679 | | <a name="l00690"></a>00690 httpDir *dirPtr; |
|---|
| 680 | | <a name="l00691"></a>00691 <a class="code" href="struct__httpd__content.html">httpContent</a> *newEntry; |
|---|
| 681 | | <a name="l00692"></a>00692 |
|---|
| 682 | | <a name="l00693"></a>00693 dirPtr = _httpd_findContentDir(server, dir, HTTP_TRUE); |
|---|
| 683 | | <a name="l00694"></a>00694 newEntry = malloc(<span class="keyword">sizeof</span>(<a class="code" href="struct__httpd__content.html">httpContent</a>)); |
|---|
| 684 | | <a name="l00695"></a>00695 <span class="keywordflow">if</span> (newEntry == NULL) |
|---|
| 685 | | <a name="l00696"></a>00696 <span class="keywordflow">return</span>(-1); |
|---|
| 686 | | <a name="l00697"></a>00697 bzero(newEntry,<span class="keyword">sizeof</span>(<a class="code" href="struct__httpd__content.html">httpContent</a>)); |
|---|
| 687 | | <a name="l00698"></a>00698 newEntry-><a class="code" href="struct__httpd__content.html#5f20e383abe7d05a315f02d7d37c7291">name</a> = NULL; |
|---|
| 688 | | <a name="l00699"></a>00699 newEntry-><a class="code" href="struct__httpd__content.html#84dfed3d65d2f07d27442cdfb94f56a4">type</a> = HTTP_WILDCARD; |
|---|
| 689 | | <a name="l00700"></a>00700 newEntry-><a class="code" href="struct__httpd__content.html#02878770ba8b1143e08e678f0ca0da12">indexFlag</a> = HTTP_FALSE; |
|---|
| 690 | | <a name="l00701"></a>00701 newEntry-><a class="code" href="struct__httpd__content.html#70cfe712fd72d9138f8cda732d34d097">preload</a> = preload; |
|---|
| 691 | | <a name="l00702"></a>00702 newEntry-><a class="code" href="struct__httpd__content.html#aabc5e64c334e035d4ddb9e46487ee7b">next</a> = dirPtr-><a class="code" href="struct__httpd__dir.html#7456ca7da5e890d2e85a07396394b77f">entries</a>; |
|---|
| 692 | | <a name="l00703"></a>00703 dirPtr-><a class="code" href="struct__httpd__dir.html#7456ca7da5e890d2e85a07396394b77f">entries</a> = newEntry; |
|---|
| 693 | | <a name="l00704"></a>00704 <span class="keywordflow">if</span> (*path == <span class="charliteral">'/'</span>) |
|---|
| 694 | | <a name="l00705"></a>00705 { |
|---|
| 695 | | <a name="l00706"></a>00706 <span class="comment">/* Absolute path */</span> |
|---|
| 696 | | <a name="l00707"></a>00707 newEntry-><a class="code" href="struct__httpd__content.html#d36079509c38ff3d00c53c87e20f22a5">path</a> = strdup(path); |
|---|
| 697 | | <a name="l00708"></a>00708 } |
|---|
| 698 | | <a name="l00709"></a>00709 <span class="keywordflow">else</span> |
|---|
| | 662 | <a name="l00673"></a>00673 <span class="comment">/* Absolute path */</span> |
|---|
| | 663 | <a name="l00674"></a>00674 newEntry-><a class="code" href="struct__httpd__content.html#d36079509c38ff3d00c53c87e20f22a5">path</a> = strdup(path); |
|---|
| | 664 | <a name="l00675"></a>00675 } |
|---|
| | 665 | <a name="l00676"></a>00676 <span class="keywordflow">else</span> |
|---|
| | 666 | <a name="l00677"></a>00677 { |
|---|
| | 667 | <a name="l00678"></a>00678 <span class="comment">/* Path relative to base path */</span> |
|---|
| | 668 | <a name="l00679"></a>00679 newEntry-><a class="code" href="struct__httpd__content.html#d36079509c38ff3d00c53c87e20f22a5">path</a> = malloc(strlen(server->fileBasePath) + |
|---|
| | 669 | <a name="l00680"></a>00680 strlen(path) + 2); |
|---|
| | 670 | <a name="l00681"></a>00681 snprintf(newEntry-><a class="code" href="struct__httpd__content.html#d36079509c38ff3d00c53c87e20f22a5">path</a>, HTTP_MAX_URL, <span class="stringliteral">"%s/%s"</span>, |
|---|
| | 671 | <a name="l00682"></a>00682 server->fileBasePath, path); |
|---|
| | 672 | <a name="l00683"></a>00683 } |
|---|
| | 673 | <a name="l00684"></a>00684 <span class="keywordflow">return</span>(0); |
|---|
| | 674 | <a name="l00685"></a>00685 } |
|---|
| | 675 | <a name="l00686"></a>00686 |
|---|
| | 676 | <a name="l00687"></a>00687 |
|---|
| | 677 | <a name="l00688"></a>00688 |
|---|
| | 678 | <a name="l00689"></a>00689 <span class="keywordtype">int</span> httpdAddWildcardContent(server, dir, preload, path) |
|---|
| | 679 | <a name="l00690"></a>00690 <a class="code" href="structhttpd.html">httpd</a> *server; |
|---|
| | 680 | <a name="l00691"></a>00691 <span class="keywordtype">char</span> *dir; |
|---|
| | 681 | <a name="l00692"></a>00692 <span class="keywordtype">int</span> (*preload)(); |
|---|
| | 682 | <a name="l00693"></a>00693 <span class="keywordtype">char</span> *path; |
|---|
| | 683 | <a name="l00694"></a>00694 { |
|---|
| | 684 | <a name="l00695"></a>00695 httpDir *dirPtr; |
|---|
| | 685 | <a name="l00696"></a>00696 <a class="code" href="struct__httpd__content.html">httpContent</a> *newEntry; |
|---|
| | 686 | <a name="l00697"></a>00697 |
|---|
| | 687 | <a name="l00698"></a>00698 dirPtr = _httpd_findContentDir(server, dir, HTTP_TRUE); |
|---|
| | 688 | <a name="l00699"></a>00699 newEntry = malloc(<span class="keyword">sizeof</span>(<a class="code" href="struct__httpd__content.html">httpContent</a>)); |
|---|
| | 689 | <a name="l00700"></a>00700 <span class="keywordflow">if</span> (newEntry == NULL) |
|---|
| | 690 | <a name="l00701"></a>00701 <span class="keywordflow">return</span>(-1); |
|---|
| | 691 | <a name="l00702"></a>00702 bzero(newEntry,<span class="keyword">sizeof</span>(<a class="code" href="struct__httpd__content.html">httpContent</a>)); |
|---|
| | 692 | <a name="l00703"></a>00703 newEntry-><a class="code" href="struct__httpd__content.html#5f20e383abe7d05a315f02d7d37c7291">name</a> = NULL; |
|---|
| | 693 | <a name="l00704"></a>00704 newEntry-><a class="code" href="struct__httpd__content.html#84dfed3d65d2f07d27442cdfb94f56a4">type</a> = HTTP_WILDCARD; |
|---|
| | 694 | <a name="l00705"></a>00705 newEntry-><a class="code" href="struct__httpd__content.html#02878770ba8b1143e08e678f0ca0da12">indexFlag</a> = HTTP_FALSE; |
|---|
| | 695 | <a name="l00706"></a>00706 newEntry-><a class="code" href="struct__httpd__content.html#70cfe712fd72d9138f8cda732d34d097">preload</a> = preload; |
|---|
| | 696 | <a name="l00707"></a>00707 newEntry-><a class="code" href="struct__httpd__content.html#aabc5e64c334e035d4ddb9e46487ee7b">next</a> = dirPtr-><a class="code" href="struct__httpd__dir.html#7456ca7da5e890d2e85a07396394b77f">entries</a>; |
|---|
| | 697 | <a name="l00708"></a>00708 dirPtr-><a class="code" href="struct__httpd__dir.html#7456ca7da5e890d2e85a07396394b77f">entries</a> = newEntry; |
|---|
| | 698 | <a name="l00709"></a>00709 <span class="keywordflow">if</span> (*path == <span class="charliteral">'/'</span>) |
|---|
| 700 | | <a name="l00711"></a>00711 <span class="comment">/* Path relative to base path */</span> |
|---|
| 701 | | <a name="l00712"></a>00712 newEntry-><a class="code" href="struct__httpd__content.html#d36079509c38ff3d00c53c87e20f22a5">path</a> = malloc(strlen(server->fileBasePath) + |
|---|
| 702 | | <a name="l00713"></a>00713 strlen(path) + 2); |
|---|
| 703 | | <a name="l00714"></a>00714 snprintf(newEntry-><a class="code" href="struct__httpd__content.html#d36079509c38ff3d00c53c87e20f22a5">path</a>, HTTP_MAX_URL, <span class="stringliteral">"%s/%s"</span>, |
|---|
| 704 | | <a name="l00715"></a>00715 server->fileBasePath, path); |
|---|
| 705 | | <a name="l00716"></a>00716 } |
|---|
| 706 | | <a name="l00717"></a>00717 <span class="keywordflow">return</span>(0); |
|---|
| 707 | | <a name="l00718"></a>00718 } |
|---|
| 708 | | <a name="l00719"></a>00719 |
|---|
| 709 | | <a name="l00720"></a>00720 |
|---|
| 710 | | <a name="l00721"></a>00721 |
|---|
| 711 | | <a name="l00722"></a>00722 |
|---|
| 712 | | <a name="l00723"></a>00723 <span class="keywordtype">int</span> httpdAddC404Content(server, function) |
|---|
| 713 | | <a name="l00724"></a>00724 <a class="code" href="structhttpd.html">httpd</a> *server; |
|---|
| 714 | | <a name="l00725"></a>00725 <span class="keywordtype">void</span> (*function)(); |
|---|
| 715 | | <a name="l00726"></a>00726 { |
|---|
| 716 | | <a name="l00727"></a>00727 <span class="keywordflow">if</span> (!server->handle404) { |
|---|
| 717 | | <a name="l00728"></a>00728 server->handle404 = (<a class="code" href="struct__httpd__404.html">http404</a>*)malloc(<span class="keyword">sizeof</span>(<a class="code" href="struct__httpd__404.html">http404</a>)); |
|---|
| 718 | | <a name="l00729"></a>00729 } |
|---|
| 719 | | <a name="l00730"></a>00730 |
|---|
| 720 | | <a name="l00731"></a>00731 <span class="keywordflow">if</span> (!server->handle404) { |
|---|
| 721 | | <a name="l00732"></a>00732 <span class="keywordflow">return</span>(-1); |
|---|
| 722 | | <a name="l00733"></a>00733 } |
|---|
| 723 | | <a name="l00734"></a>00734 |
|---|
| 724 | | <a name="l00735"></a>00735 server->handle404->function = function; |
|---|
| 725 | | <a name="l00736"></a>00736 <span class="keywordflow">return</span>(0); |
|---|
| 726 | | <a name="l00737"></a>00737 } |
|---|
| 727 | | <a name="l00738"></a>00738 |
|---|
| 728 | | <a name="l00739"></a>00739 <span class="keywordtype">int</span> httpdAddCContent(server, dir, name, indexFlag, preload, function) |
|---|
| 729 | | <a name="l00740"></a>00740 <a class="code" href="structhttpd.html">httpd</a> *server; |
|---|
| 730 | | <a name="l00741"></a>00741 &nb |
|---|