<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[http programm]]></title><description><![CDATA[<p>Hi,<br />
ich hätte gerne ein Programm, dass z.b. an Google schickt, dass ein button gedrückt wurde<br />
also benutzung des htt Protokolls</p>
<p>ein code snippet, das es an google schickt und das response in einer datei speichert, würde mich sehr glücklich machen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>[wegen des protokolls:]<br />
ich weiß nicht, ob es notwendig ist,<br />
alles aus diesem P. zu benutzen, wie z.b.<br />
Referer:...<br />
Cookie-Set:...</p>
<p>oder ob man einfach nur:<br />
button=click&amp;text=hallo&amp;...&quot; schreiben muss</p>
<p>Danke..</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/179115/http-programm</link><generator>RSS for Node</generator><lastBuildDate>Sat, 04 Jul 2026 08:08:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/179115.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Apr 2007 16:24:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to http programm on Wed, 18 Apr 2007 16:24:45 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich hätte gerne ein Programm, dass z.b. an Google schickt, dass ein button gedrückt wurde<br />
also benutzung des htt Protokolls</p>
<p>ein code snippet, das es an google schickt und das response in einer datei speichert, würde mich sehr glücklich machen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>[wegen des protokolls:]<br />
ich weiß nicht, ob es notwendig ist,<br />
alles aus diesem P. zu benutzen, wie z.b.<br />
Referer:...<br />
Cookie-Set:...</p>
<p>oder ob man einfach nur:<br />
button=click&amp;text=hallo&amp;...&quot; schreiben muss</p>
<p>Danke..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1268632</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1268632</guid><dc:creator><![CDATA[INERT]]></dc:creator><pubDate>Wed, 18 Apr 2007 16:24:45 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Wed, 18 Apr 2007 17:02:25 GMT]]></title><description><![CDATA[<p>Ok kein Problem. Zahlst du bar? Macht dann 30 Euro pro angefangener Stunde, ich schätze mal, um alles vernünftig zu programmieren und zu testen, dürfte es so 5-7 Stunden dauern. Als Anzahlung, bevor ich überhaupt anfange nehme ich 100 Euro.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1268650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1268650</guid><dc:creator><![CDATA[feigling]]></dc:creator><pubDate>Wed, 18 Apr 2007 17:02:25 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Wed, 18 Apr 2007 18:55:34 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">URLDownloadToFile(0, url, file, 0, 0);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1268739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1268739</guid><dc:creator><![CDATA[keksekekse]]></dc:creator><pubDate>Wed, 18 Apr 2007 18:55:34 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Wed, 18 Apr 2007 19:07:23 GMT]]></title><description><![CDATA[<p>INERT schrieb:</p>
<blockquote>
<p>[wegen des protokolls:]<br />
ich weiß nicht, ob es notwendig ist,<br />
alles aus diesem P. zu benutzen, wie z.b.<br />
Referer:...<br />
Cookie-Set:...<br />
oder ob man einfach nur:<br />
button=click&amp;text=hallo&amp;...&quot; schreiben muss</p>
</blockquote>
<p>im einfachsten fall musst du ein &quot;GET / HTTP/1.0\r\n\r\n&quot;<br />
zum server schicken, dann bekommst du die startseite...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1268746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1268746</guid><dc:creator><![CDATA[vista]]></dc:creator><pubDate>Wed, 18 Apr 2007 19:07:23 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Thu, 19 Apr 2007 11:39:53 GMT]]></title><description><![CDATA[<p>Kennt ihr den Webclient, aus dem .NET Framework?<br />
an so etwas hatte ich gedacht.</p>
<p>Was braucht man da alles für?<br />
ein Socket, solch eine serveraddr_in Struktur.<br />
Dann die Funktion connect, send und recv benutzen, das reicht doch, oder nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1269173</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1269173</guid><dc:creator><![CDATA[inert]]></dc:creator><pubDate>Thu, 19 Apr 2007 11:39:53 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Thu, 19 Apr 2007 21:17:23 GMT]]></title><description><![CDATA[<p>...<a href="mailto:google@google.com" rel="nofollow">mailto:google@google.com</a>klick mich&lt;/p&gt;&lt;/html&gt; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1269646</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1269646</guid><dc:creator><![CDATA[haha]]></dc:creator><pubDate>Thu, 19 Apr 2007 21:17:23 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Thu, 19 Apr 2007 21:22:54 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-14811.html" rel="nofollow">TactX</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-10.html" rel="nofollow">ANSI C</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-8.html" rel="nofollow">Rund um die Programmierung</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1269648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1269648</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Thu, 19 Apr 2007 21:22:54 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Thu, 19 Apr 2007 21:22:55 GMT]]></title><description><![CDATA[<p>...du bist aber eh schnelllller als der Asterix im Zaubertrankrausch... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1269649</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1269649</guid><dc:creator><![CDATA[@feigling]]></dc:creator><pubDate>Thu, 19 Apr 2007 21:22:55 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Thu, 19 Apr 2007 22:20:02 GMT]]></title><description><![CDATA[<p>schau dir libcurl an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1269659</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1269659</guid><dc:creator><![CDATA[rüdiger]]></dc:creator><pubDate>Thu, 19 Apr 2007 22:20:02 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Fri, 20 Apr 2007 20:07:03 GMT]]></title><description><![CDATA[<p>INERT schrieb:</p>
<blockquote>
<p>ein code snippet, das es an google schickt und das response in einer datei speichert, würde mich sehr glücklich machen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<pre><code class="language-cpp">struct tCookie
{ char *pcname;
  char *pcvalue;
  char *pcpath;
  char *pcdomain;
};

struct tb
{ char *pc;
  int cnt;
};

struct tE
{ char *pcpath;
  char *pchost;
  char *pcsend;
  char *pcpost;
  struct tb recv;
  char *pchtml;
  char *pclocation;
  struct tCookie *Cookie;
  int CookieAnzahl;
};

static void MakeLoginCplusplusPost(struct tE *e, char *username,
                                                 char *password)
{
  e-&gt;pcpost = realloc(e-&gt;pcpost, SIZEOF0);
  e-&gt;pcpost[0] = 0;

  StringCat(&amp;e-&gt;pcpost, &quot;username=%s&quot;, username);
  StringCat(&amp;e-&gt;pcpost, &quot;&amp;password=%s&quot;, password);
  StringCat(&amp;e-&gt;pcpost, &quot;&amp;login=Login&quot;);
}

static int cplusplus(struct tE *pe)
{
  int ifehler;
  char *url = &quot;http://www.c-plusplus.net/forum/login-var-.html&quot;;

  a_UrlUrlToHostPath(url, pe);
  printf(&quot;%s%s\n&quot;, pe-&gt;pchost, pe-&gt;pcpath);
  MakeLoginCplusplusPost(pe, &quot;&lt;username&gt;&quot;, &quot;&lt;password&gt;&quot;);
  MakeSendHeader(pe, pe-&gt;pcpost);
  if ((ifehler = DoDownLoad(pe)) == 0)
	  ifehler = Loop302(pe);
  printf(&quot;ifehler %i\n&quot;, ifehler);
  return ifehler;
}

static int google(struct tE *pe)
{
  char *url = &quot;http://www.google.de&quot;;
  int ifehler;

  a_UrlUrlToHostPath(url, pe);
  printf(&quot;%s%s\n&quot;, pe-&gt;pchost, pe-&gt;pcpath);
  MakeSendHeader(pe, HEADERTYPE_GET);
  if ((ifehler = DoDownLoad(pe)) == 0)
	  ifehler = Loop302(pe);
  printf(&quot;ifehler %i\n&quot;, ifehler);
  return ifehler;
}

static int google2(struct tE *pe)
{
  int ifehler;
  char *url = &quot;http://www.google.de&quot;
			  &quot;/search?hl=de&quot;
			  &quot;&amp;q=Schweine%20im%20Weltall&quot;
			  &quot;&amp;btnG=Google-Suche&quot;
			  &quot;&amp;meta=&quot;;

  a_UrlUrlToHostPath(url, pe);
  printf(&quot;%s%s\n&quot;, pe-&gt;pchost, pe-&gt;pcpath);
  MakeSendHeader(pe, HEADERTYPE_GET);
  if ((ifehler = DoDownLoad(pe)) == 0)
	  ifehler = Loop302(pe);
  printf(&quot;ifehler %i\n&quot;, ifehler);
  return ifehler;
}

int main()
{
  WSADATA ws;
  struct tE *pe;

  WSAStartup(0x101, &amp;ws);
  pe = calloc(1, sizeof(struct tE));

  cplusplus(pe);
  /*google2(pe);*/
  /*google(pe);*/
  /*freenet(pe);*/

  FreeVars(pe);
  WSACleanup();

  printf(&quot;fertig&quot;);
  getch();
  return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1270246</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270246</guid><dc:creator><![CDATA[keksekekse]]></dc:creator><pubDate>Fri, 20 Apr 2007 20:07:03 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Sat, 21 Apr 2007 09:39:34 GMT]]></title><description><![CDATA[<p>Vielen Dank euch allen.</p>
<p>Ich werde mir das mal anschauen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1270434</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270434</guid><dc:creator><![CDATA[INERT]]></dc:creator><pubDate>Sat, 21 Apr 2007 09:39:34 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Sat, 21 Apr 2007 10:43:14 GMT]]></title><description><![CDATA[<p>keksekekse schrieb:</p>
<blockquote>
<p>INERT schrieb:</p>
<blockquote>
<p>ein code snippet, das es an google schickt und das response in einer datei speichert, würde mich sehr glücklich machen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<pre><code class="language-cpp">/* etwas Code */
</code></pre>
</blockquote>
<p>hi keksekekse.<br />
wieso sind da soviele return values static?<br />
überhaupt komm ich bei C89 bzw. C99 mit dem static immer durcheinander, wieso das z.B. wie hier für return values benutzt wird. mir ist ja klar, dass es, wenn es in einem functionbody steht, dass es heißt, dass der wert zwischen den aufrufen erhalten bleibt. aber hier erschließt sich mir nicht ganz der sinn und nutzen, wenn so viele variablen und vorallem die return values static sind. habe das komischerweiße auch in sehr vielen selfmade-httpds gesehen. kannst du das bitte näher erläutern? vielleicht hats ja auch was mit der netzwerkprogrammierung an sich zutun.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1270480</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270480</guid><dc:creator><![CDATA[static]]></dc:creator><pubDate>Sat, 21 Apr 2007 10:43:14 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Sat, 21 Apr 2007 13:58:29 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">static int a;	       /* Auf das Modul beschränkte Variable = 0 */

static void b(void)	 /* Auf das Modul beschränkte Funktion */
{
  int c;		        /* Flüchtige Variable auf dem Stack */
  static int d;		 /* Statische Variable im Datenbereich = 0 */
  static int e = 8888;  /* Statische Variable im Datenbereich = 8888 */

  e++;			      /* Nach jedem Aufruf von b() ist e um 1 größer */
} /* &lt;- Zeile 10 */

int main()
{
  return 0;
}
/* &lt;- Zeile 16 */
</code></pre>
<pre><code>Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
src\main.c:
Warning W8004 src\main.c 10: 'd' is assigned a value that is never used in function b
Warning W8080 src\main.c 10: 'c' is declared but never used in function b
Warning W8080 src\main.c 16: 'a' is declared but never used
Warning W8080 src\main.c 16: 'b()' is declared but never used
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1270607</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270607</guid><dc:creator><![CDATA[keksekekse]]></dc:creator><pubDate>Sat, 21 Apr 2007 13:58:29 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Sat, 21 Apr 2007 14:06:19 GMT]]></title><description><![CDATA[<p>keksekekse schrieb:</p>
<blockquote>
<p>INERT schrieb:</p>
<blockquote>
<p>ein code snippet, das es an google schickt und das response in einer datei speichert, würde mich sehr glücklich machen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<pre><code class="language-cpp">selfmade wget
</code></pre>
</blockquote>
<p>fehlt da nicht die hälfte?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1270613</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270613</guid><dc:creator><![CDATA[vista]]></dc:creator><pubDate>Sat, 21 Apr 2007 14:06:19 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Sat, 21 Apr 2007 14:25:25 GMT]]></title><description><![CDATA[<p>also kann ich durch static nameclashes verhindern und ich kann verhindern, dass jemand von außerhalb auf die funktion zugreift. hat es auch einen optimierungstechnischen grund bzw. wird es gerade wegen den aufgezählten gründen vom compiler optimiert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1270620</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270620</guid><dc:creator><![CDATA[static]]></dc:creator><pubDate>Sat, 21 Apr 2007 14:25:25 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Sat, 21 Apr 2007 14:43:51 GMT]]></title><description><![CDATA[<p>Der Grund ist, daß der *Compiler* static-Variablennamen und static-Funkionsnamen in die *.obj-Datei nicht oder nicht als gültige Bezeichner einträgt, d.h. der *Linker* kommt dadurch nicht in die Verlegenheit, sich zwischen zwei gleichen Namen mit unterschiedlicher Bedeutung entscheiden zu müssen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1270627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270627</guid><dc:creator><![CDATA[keksekekse]]></dc:creator><pubDate>Sat, 21 Apr 2007 14:43:51 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Sat, 21 Apr 2007 14:48:23 GMT]]></title><description><![CDATA[<p>vista schrieb:</p>
<blockquote>
<p>fehlt da nicht die hälfte?</p>
</blockquote>
<p>mal sehen, wieviel Code das Forum pro Post verträgt...</p>
<p><strong>main.c</strong> Teil 1:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;conio.h&gt;
#include &lt;stdio.h&gt;

#include &quot;globals.h&quot;
#include &quot;cookie.h&quot;
#include &quot;url.h&quot;

#define SENDNOSOCKET    1
#define SENDNOCONNECT   2
#define SENDNOSEND      3
#define SENDNOTCOMPLETE 4
#define RECVERRRECV     5
#define RECVCLOSED      6
#define NOHOST          7
#define OUTNOTWRITE     8
#define HTTPERR0        9
#define HTTPERR1       10
#define HTTPERR2       11
#define HTTPERR3       12
#define HTTPERR4       13

static int CopyRecvToHtml(struct tE *e)
{
  char *pc;
  int inewblkcnt, ihtmllen;

  e-&gt;pchtml = realloc(e-&gt;pchtml, SIZEOF0);
  e-&gt;pchtml[0] = 0;

  pc = strstr(e-&gt;recv.pc, &quot;\r\n\r\n&quot;);
  if (pc == 0)
      return HTTPERR0;
  pc += 2;

  ihtmllen = 0;
  while(1)
    { if (strncmp(pc, &quot;\r\n&quot;, 2) != 0)
          return HTTPERR1;
      pc += 2;
      inewblkcnt = strtoul(pc, 0, 0x10);
      pc = strchr(pc, '\r');
      if (pc == 0)
          return HTTPERR2;

	  if (inewblkcnt == 0 &amp;&amp; strcmp(pc, &quot;\r\n\r\n&quot;) == 0)
	      break;				 /* last block ending ok &quot;\r\n0\r\n\r\n&quot; */
      if (inewblkcnt == 0)
	      return HTTPERR3;
      if (strncmp(pc, &quot;\r\n&quot;, 2) != 0)
	      return HTTPERR4;
      pc += 2;

	  e-&gt;pchtml = realloc(e-&gt;pchtml, ihtmllen+inewblkcnt+SIZEOF0);

	  memmove(e-&gt;pchtml+ihtmllen, pc, inewblkcnt);
	  e-&gt;pchtml[ihtmllen+inewblkcnt] = 0;

      ihtmllen += inewblkcnt;
	  pc       += inewblkcnt;
    }

  return 0;
}

static int filecnt; 

static void WriteToFile(int ifnum, char *pcinouterr, char *pcext,
                                               char *s, int slen)
{
  char fname[80];
  FILE *fp;

  _snprintf(fname, sizeof(fname), &quot;f%i%s.%s&quot;, ifnum, pcinouterr, pcext);
  if ((fp = fopen(fname, &quot;wb&quot;)) == 0)
	  return;
  fwrite(s, 1, slen, fp);
  fclose(fp);
} 

static int DnLoad(long host, short port, struct tE *e)
{
  SOCKET s;
  struct sockaddr_in A;
  int iretconn, iretsend, isendbytes;
  static char pctmpbuf[2000];
  int itmpbufcnt;
  long content_length;
  long content_offset;
  char *tmpptr;

  s = socket(AF_INET, SOCK_STREAM, 0);
  if (s == INVALID_SOCKET)
      return SENDNOSOCKET;

  A.sin_family = AF_INET;
  A.sin_port = htons(port);
  A.sin_addr.s_addr = host;
  iretconn = connect(s, (struct sockaddr *)&amp;A, sizeof(A));
  if (iretconn == SOCKET_ERROR)
    { closesocket(s);
      return SENDNOCONNECT;
    }

  isendbytes = strlen(e-&gt;pcsend);
  iretsend = send(s, e-&gt;pcsend, isendbytes, 0);
  if (iretsend == SOCKET_ERROR)
    { closesocket(s);
      return SENDNOSEND;
    }
  if (iretsend &lt; isendbytes)
    { closesocket(s);
      return SENDNOTCOMPLETE;
    }

  content_offset = 0;
  content_length = -1;
  e-&gt;recv.pc = realloc(e-&gt;recv.pc, SIZEOF0);
  e-&gt;recv.pc[0] = 0;
  e-&gt;recv.cnt = 0;
  while(1)
    { itmpbufcnt = recv(s, pctmpbuf, sizeof(pctmpbuf), 0);
      if (itmpbufcnt == SOCKET_ERROR)
		{ closesocket(s);
          return RECVERRRECV; 
        } 
      if (itmpbufcnt == 0)
		{ closesocket(s);
		  return RECVCLOSED;
	    }
	  e-&gt;recv.pc = realloc(e-&gt;recv.pc, e-&gt;recv.cnt+itmpbufcnt+SIZEOF0);

	  memmove(e-&gt;recv.pc+e-&gt;recv.cnt, pctmpbuf, itmpbufcnt);
	  e-&gt;recv.pc[e-&gt;recv.cnt+itmpbufcnt] = 0;

	  e-&gt;recv.cnt += itmpbufcnt;

      if (content_length == -1 &amp;&amp; e-&gt;recv.cnt &gt;= 17)
	      if ((tmpptr = strstr(e-&gt;recv.pc, &quot;Content-length: &quot;)) != 0 ||
	          (tmpptr = strstr(e-&gt;recv.pc, &quot;Content-Length: &quot;)) != 0)
	          content_length = strtoul(tmpptr+16, 0, 10);
      if (!content_offset &amp;&amp; e-&gt;recv.cnt &gt;= 4)
	      if ((tmpptr = strstr(e-&gt;recv.pc, &quot;\r\n\r\n&quot;)) != 0)
			  content_offset = (tmpptr-e-&gt;recv.pc)+4;

      if (content_offset &amp;&amp; content_length != -1)
	      if (e-&gt;recv.cnt &gt;= content_offset + content_length)
	          break;

	  if (content_length == -1 &amp;&amp;
		  e-&gt;recv.cnt &gt;= 5 &amp;&amp;
		  strcmp(e-&gt;recv.pc+e-&gt;recv.cnt-5, &quot;\r\n\r\n &quot;) == 0)
	      break;

	  if (content_length == -1 &amp;&amp;
		  e-&gt;recv.cnt &gt;= 7 &amp;&amp;
		  strcmp(e-&gt;recv.pc+e-&gt;recv.cnt-7, &quot;\r\n0\r\n\r\n&quot;) == 0)
	    { closesocket(s);
		  return CopyRecvToHtml(e);
	    }
    }
  closesocket(s);
  return 0;
}

static int DownLoad(struct tE *e)
{
  HOSTENT *he;

  if ((he = gethostbyname(e-&gt;pchost)) == 0)
      return NOHOST;
  return DnLoad(*((long *)he-&gt;h_addr_list[0]), 80, e);
}

static int DoDownLoad(struct tE *e)
{
  WriteToFile(filecnt++, &quot;in&quot;, &quot;txt&quot;, e-&gt;pcsend, strlen(e-&gt;pcsend));
  return DownLoad(e);
}

static void FreeVars(struct tE *e)
{
  int i;

  free(e-&gt;pcpath);
  free(e-&gt;pchost);
  free(e-&gt;pcsend);
  free(e-&gt;pcpost);
  free(e-&gt;recv.pc);
  free(e-&gt;pchtml);
  for (i = 0; i &lt; e-&gt;CookieAnzahl; i++)
	{ free(e-&gt;Cookie[i].pcname);
	  free(e-&gt;Cookie[i].pcvalue);
	  free(e-&gt;Cookie[i].pcpath);
      free(e-&gt;Cookie[i].pcdomain);
	}
  free(e-&gt;Cookie);
  memset(e, 0, sizeof(struct tE));
}

static void StringCat(char **S, char *format, ...)
{
  char o[1000];

  _vsnprintf(o, sizeof(o), format, &amp;format+1);
  *S = realloc(*S, strlen(*S)+strlen(o)+SIZEOF0);
  strcat(*S, o);
}

static void MakeSendHeader(struct tE *e, char *pcpost)
{
  e-&gt;pcsend = realloc(e-&gt;pcsend, SIZEOF0);
  e-&gt;pcsend[0] = 0;

  if (pcpost)
	{ StringCat(&amp;e-&gt;pcsend, &quot;POST %s HTTP/1.1\r\n&quot;, e-&gt;pcpath);
	  StringCat(&amp;e-&gt;pcsend, &quot;Content-Type: application&quot;
	                        &quot;/x-www-form-urlencoded\r\n&quot;);
	  StringCat(&amp;e-&gt;pcsend, &quot;Host: %s\r\n&quot;, e-&gt;pchost);
	  StringCat(&amp;e-&gt;pcsend, &quot;Content-Length: %u\r\n&quot;, strlen(pcpost));
      a_CookieSetCookies(e);
      StringCat(&amp;e-&gt;pcsend, &quot;\r\n&quot;);
	  StringCat(&amp;e-&gt;pcsend, &quot;%s&quot;, pcpost);
	}
	else /* HEADERTYPE_GET */
	{ StringCat(&amp;e-&gt;pcsend, &quot;GET %s HTTP/1.1\r\n&quot;, e-&gt;pcpath);
	  StringCat(&amp;e-&gt;pcsend, &quot;Accept: image/gif, image/x-xbitmap, &quot;
									&quot;image/jpeg, image/pjpeg, &quot;
									&quot;application/x-shockwave-flash, &quot;
									&quot;*/*\r\n&quot;);
	  StringCat(&amp;e-&gt;pcsend, &quot;Accept-Language: de\r\n&quot;);
	  StringCat(&amp;e-&gt;pcsend, &quot;User-Agent: Mozilla/4.0 (compatible; &quot;
	                        &quot;MSIE 6.0; Windows 98; .NET CLR 1.1.4322)\r\n&quot;);
	  StringCat(&amp;e-&gt;pcsend, &quot;Host: %s\r\n&quot;, e-&gt;pchost);
	  StringCat(&amp;e-&gt;pcsend, &quot;Connection: Keep-Alive\r\n&quot;);
      a_CookieSetCookies(e);
      StringCat(&amp;e-&gt;pcsend, &quot;\r\n&quot;);
	}
}

#define HEADERTYPE_GET 0

static int Loop302(struct tE *e)
{
  int ifehler;

  while(1)
	{ a_CookieParseCookies(e);
	  if (strnicmp(e-&gt;recv.pc, &quot;HTTP/1.0 302 Found&quot;,             18) != 0 &amp;&amp;
          strnicmp(e-&gt;recv.pc, &quot;HTTP/1.1 302 Found&quot;,             18) != 0 &amp;&amp;
	      strnicmp(e-&gt;recv.pc, &quot;HTTP/1.1 301 Moved Permanently&quot;, 30) != 0)
		{ WriteToFile(filecnt++, &quot;out&quot;, &quot;htm&quot;, e-&gt;recv.pc, e-&gt;recv.cnt);
		  return 0;
        }
      WriteToFile(filecnt++, &quot;out&quot;, &quot;txt&quot;, e-&gt;recv.pc, e-&gt;recv.cnt);
      a_UrlParseLocation(e);
      a_UrlUrlToHostPath(e-&gt;pclocation, e);
      printf(&quot;%s%s\n&quot;, e-&gt;pchost, e-&gt;pcpath);
	  MakeSendHeader(e, HEADERTYPE_GET);
      if ((ifehler = DoDownLoad(e)) != 0)
		  break;
	}
  WriteToFile(filecnt++, &quot;err&quot;, &quot;txt&quot;, e-&gt;recv.pc, e-&gt;recv.cnt);
  return ifehler;
}

static void MakeLoginFreenetPost(struct tE *e, char *callback,
                                               char *world,
											   char *profile,
											   char *password)
{
  e-&gt;pcpost = realloc(e-&gt;pcpost, SIZEOF0);
  e-&gt;pcpost[0] = 0;

  StringCat(&amp;e-&gt;pcpost, &quot;callback=%s&quot;,  callback);
  StringCat(&amp;e-&gt;pcpost, &quot;&amp;world=%s&quot;,    world);
  StringCat(&amp;e-&gt;pcpost, &quot;&amp;username=%s&quot;, profile);
  StringCat(&amp;e-&gt;pcpost, &quot;&amp;password=%s&quot;, password);
}

static int freenet(struct tE *pe)
{
  char *url = &quot;http://e-tools.freenet.de/login.php3&quot;;
  int ifehler;

  a_UrlUrlToHostPath(url, pe);
  printf(&quot;%s%s\n&quot;, pe-&gt;pchost, pe-&gt;pcpath);
  MakeLoginFreenetPost(pe, &quot;http%3A%2F%2Fcommunity.freenet.de&quot;
						   &quot;%2Ffreunde-finden&quot;
						   &quot;%2Findex.html&quot;,
						   &quot;frn_DE&quot;, &quot;&lt;profile&gt;&quot;, &quot;&lt;password&gt;&quot;);
  MakeSendHeader(pe, pe-&gt;pcpost);
  if ((ifehler = DoDownLoad(pe)) == 0)
	  ifehler = Loop302(pe);
  printf(&quot;ifehler %i\n&quot;, ifehler);
  if (ifehler)
      return ifehler;

  url = &quot;http://logout.freenet.de&quot;;
  a_UrlUrlToHostPath(url, pe);
  printf(&quot;%s%s\n&quot;, pe-&gt;pchost, pe-&gt;pcpath);
  MakeSendHeader(pe, HEADERTYPE_GET);
  if ((ifehler = DoDownLoad(pe)) == 0)
	  ifehler = Loop302(pe);
  printf(&quot;ifehler %i\n&quot;, ifehler);
  return ifehler;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1270629</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270629</guid><dc:creator><![CDATA[keksekekse]]></dc:creator><pubDate>Sat, 21 Apr 2007 14:48:23 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Sat, 21 Apr 2007 14:50:27 GMT]]></title><description><![CDATA[<p><strong>cookie.c</strong></p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;

#include &quot;globals.h&quot;
#include &quot;cookie.h&quot;

static void DelCookie(struct tE *e, char *pcname)
{
  int i;

  for (i = 0; i &lt; e-&gt;CookieAnzahl; i++)
	{ if (strcmp(e-&gt;Cookie[i].pcname, pcname) == 0)
		{ free(e-&gt;Cookie[i].pcname);
		  free(e-&gt;Cookie[i].pcvalue);
		  free(e-&gt;Cookie[i].pcpath);
          free(e-&gt;Cookie[i].pcdomain);
		  memmove(e-&gt;Cookie+i, e-&gt;Cookie+i+1,
				 (e-&gt;CookieAnzahl-i-1)*sizeof(struct tCookie));
	      e-&gt;CookieAnzahl--;
          return;
        }
    }
}

static int IsCookie(struct tE *e, char *pcname)
{
  int i;

  for (i = 0; i &lt; e-&gt;CookieAnzahl; i++)
	  if (strcmp(e-&gt;Cookie[i].pcname, pcname) == 0)
		  return 1;
  return 0;
}

static void SetCookie(struct tE *e, char *pcname, char *pcvalue,
									char *pcpath, char *pcdomain)
{
  if (stricmp(pcvalue, &quot;deleted&quot;) == 0)
    { DelCookie(e, pcname);
      return;
    }
  if (IsCookie(e, pcname))
	  DelCookie(e, pcname);

  e-&gt;Cookie = realloc(e-&gt;Cookie, (e-&gt;CookieAnzahl+1)*sizeof(struct tCookie));
  memset(e-&gt;Cookie+e-&gt;CookieAnzahl, 0, sizeof(struct tCookie));

  if (pcname)   e-&gt;Cookie[e-&gt;CookieAnzahl].pcname   = strdup(pcname);
  if (pcvalue)  e-&gt;Cookie[e-&gt;CookieAnzahl].pcvalue  = strdup(pcvalue); 
  if (pcpath)   e-&gt;Cookie[e-&gt;CookieAnzahl].pcpath   = strdup(pcpath);
  if (pcdomain) e-&gt;Cookie[e-&gt;CookieAnzahl].pcdomain = strdup(pcdomain);
  e-&gt;CookieAnzahl++;
}

struct tNameValue
{ char *pcname;
  char *pcvalue;
};
struct tbNameValue
{ struct tNameValue *pnv;
  int nvcnt;
};

static char *DupNameOrValue(char *s, char *e)
{
  char *p;

  p = malloc(e-s+SIZEOF0);
  memmove(p, s, e-s);
  p[e-s] = 0;
  return p;
}

static void FreeNameValue(struct tbNameValue *pb)
{
  int i;

  for (i = 0; i &lt; pb-&gt;nvcnt; i++)
	{ free(pb-&gt;pnv[i].pcname);
	  free(pb-&gt;pnv[i].pcvalue);
	}
  free(pb-&gt;pnv);
  free(pb);
}

static struct tbNameValue *ParseNameValue(char *s)
{
  char *n, *v;
  struct tbNameValue *pret;

  pret = calloc(1, sizeof(struct tbNameValue));
  while(1)
	{ while(1)
		{ while(*s == ' ' || *s == '\t') /* Leerzeichen überlesen */
			  s++;
		  if (*s == '\r' || *s == 0) /* Zeilen-/Textende */
			  return pret;			 /* ==&gt; fertig */

		  /* Name parsen */
          n = s;
		  while(*s &amp;&amp; *s != '=' &amp;&amp; *s != ';' &amp;&amp; *s != '\r')
			  s++;

		  /* neues Name/Wert-Paar anlegen und auf null setzen */
		  pret-&gt;nvcnt++;
		  pret-&gt;pnv = realloc(pret-&gt;pnv, pret-&gt;nvcnt*sizeof(struct tNameValue));
		  memset(pret-&gt;pnv+pret-&gt;nvcnt-1, 0, sizeof(struct tNameValue));

          /* Name speichern */
		  pret-&gt;pnv[pret-&gt;nvcnt-1].pcname = DupNameOrValue(n, s);

		  if (*s == '=') /* Wert folgt */
			  break;
		  if (*s == ';') /* nur Name */
              s++;
		} /* while(1) */

      /* Name=... */
	  s++;	/* *s == '=' */
	  if (*s == '&quot;')
		{ s++; /* *s == '&quot;' */

          /* Wert-String parsen */
		  while(*s == ' ' || *s == '\t') /* Leerzeichen überlesen */
			  s++;
          v = s;
		  while(*s &amp;&amp; *s != '&quot;' &amp;&amp; *s != '\r')
			  s++;

		  /* Wert speichern */
		  pret-&gt;pnv[pret-&gt;nvcnt-1].pcvalue = DupNameOrValue(v, s);

		  if (*s == '&quot;') /* *s == '&quot;' */
			  s++;
		  while(*s == ' ' || *s == '\t') /* Leerzeichen überlesen */
			  s++;
		  while(*s &amp;&amp; *s != ';' &amp;&amp; *s != '\r') /* nach ';' suchen */
			  s++;
		}
		else
		{ /* Wert parsen */
		  v = s;
		  while(*s &amp;&amp; *s != ';' &amp;&amp; *s != '\r')
			  s++;
		  /* Wert speichern */
		  pret-&gt;pnv[pret-&gt;nvcnt-1].pcvalue = DupNameOrValue(v, s);
		}
	  if (*s == ';')
		  s++;
	} /* while(1) */
}

void a_CookieParseCookies(struct tE *e)
{
  char *pcfound;
  char *pcname, *pcvalue, *pcpath, *pcdomain;
  char *s;
  struct tbNameValue *px;
  int i;

  if (e-&gt;recv.pc == 0)
	  return;

  s = e-&gt;recv.pc;
  while((pcfound = strstr(s, &quot;\r\nSet-Cookie: &quot;)) != 0)
	{ px = ParseNameValue(pcfound+14);

	  pcname  = px-&gt;pnv[0].pcname;
      pcvalue = px-&gt;pnv[0].pcvalue;
	  pcpath = pcdomain = 0;
	  for (i = 1; i &lt; px-&gt;nvcnt; i++)
		{ if (stricmp(px-&gt;pnv[i].pcname, &quot;path&quot;) == 0)
			  pcpath = px-&gt;pnv[i].pcvalue;
			else
		  if (stricmp(px-&gt;pnv[i].pcname, &quot;domain&quot;) == 0)
		      pcdomain = px-&gt;pnv[i].pcvalue; 
        }
	  if (pcdomain == 0)
		  pcdomain = e-&gt;pchost;
	  SetCookie(e, pcname, pcvalue, pcpath, pcdomain);

	  FreeNameValue(px);
	  s = pcfound+14;
	}
}

static int IsRightCookie(char *pchost, char *pcdomain)
{
  int idomainlen, ihostlen;

  idomainlen = strlen(pcdomain);
  ihostlen   = strlen(pchost);

  if (ihostlen &gt;= idomainlen)
      if (strncmp(pcdomain, pchost+(ihostlen-idomainlen), idomainlen) == 0)
          return 1;
  return 0;
}

static void StringCat(char **S, char *format, ...)
{
  char o[1000];

  _vsnprintf(o, sizeof(o), format, &amp;format+1);
  *S = realloc(*S, strlen(*S)+strlen(o)+SIZEOF0);
  strcat(*S, o);
}

void a_CookieSetCookies(struct tE *e)
{
  int i;
  int cookiesetflag;

  cookiesetflag = 0;
  for (i = 0; i &lt; e-&gt;CookieAnzahl; i++)
	{ if (IsRightCookie(e-&gt;pchost, e-&gt;Cookie[i].pcdomain))
		{ if (!cookiesetflag)
			  StringCat(&amp;e-&gt;pcsend, &quot;Cookie: &quot;);
		  if (cookiesetflag)
			  StringCat(&amp;e-&gt;pcsend, &quot;; &quot;);
		  cookiesetflag = 1;
		  StringCat(&amp;e-&gt;pcsend, &quot;%s=%s&quot;, e-&gt;Cookie[i].pcname,
		                                 e-&gt;Cookie[i].pcvalue);
		}
    }

  if (cookiesetflag)
	  StringCat(&amp;e-&gt;pcsend, &quot;\r\n&quot;);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1270631</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270631</guid><dc:creator><![CDATA[keksekekse]]></dc:creator><pubDate>Sat, 21 Apr 2007 14:50:27 GMT</pubDate></item><item><title><![CDATA[Reply to http programm on Sat, 21 Apr 2007 15:01:21 GMT]]></title><description><![CDATA[<p><strong>url.c</strong></p>
<pre><code class="language-cpp">#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;

#include &quot;globals.h&quot;
#include &quot;url.h&quot;

void a_UrlUrlToHostPath(char *url, struct tE *e)
{
  char *pcprotoend, *host, *path;

  if ((pcprotoend = strstr(url, &quot;://&quot;)) != 0)
    { host = pcprotoend+3;
      if ((path = strchr(host, '/')) == 0)
		  path = strchr(host, 0);

	  e-&gt;pchost = realloc(e-&gt;pchost, path-host+SIZEOF0);
	  memmove(e-&gt;pchost, host, path-host);
      e-&gt;pchost[path-host] = 0;
	}
    else
	  path = url;

  e-&gt;pcpath = realloc(e-&gt;pcpath, (path[0] != '/')+strlen(path)+SIZEOF0);
  e-&gt;pcpath[0] = 0;
  if (*path != '/')
      strcat(e-&gt;pcpath, &quot;/&quot;);
  strcat(e-&gt;pcpath, path);
}

void a_UrlParseLocation(struct tE *e)
{
  char *pcs, *pce;

  if (e-&gt;recv.pc == 0)
	  return;
  pcs = strstr(e-&gt;recv.pc, &quot;\r\nLocation: &quot;);
  if (pcs == 0)
	  return;
  pcs += 2;
  pcs += 10;
  pce = strchr(pcs, '\r');
  e-&gt;pclocation = realloc(e-&gt;pclocation, pce-pcs+SIZEOF0);
  memmove(e-&gt;pclocation, pcs, pce-pcs);
  e-&gt;pclocation[pce-pcs] = 0;
}
</code></pre>
<p><strong>ur.h</strong></p>
<pre><code class="language-cpp">#ifndef __URL_H__
#define __URL_H__

void a_UrlUrlToHostPath(char *url, struct tE *e);
void a_UrlParseLocation(struct tE *e);

#endif /* __URL_H__ */
</code></pre>
<p><strong>cookie.h</strong></p>
<pre><code class="language-cpp">#ifndef __COOKIE_H__
#define __COOKIE_H__

void a_CookieParseCookies(struct tE *e);
void a_CookieSetCookies(struct tE *e);

#endif /* __COOKIE_H__ */
</code></pre>
<p><strong>globals.h</strong></p>
<pre><code class="language-cpp">#ifndef __GLOBALS_H__
#define __GLOBALS_H__

struct tCookie
{ char *pcname;
  char *pcvalue;
  char *pcpath;
  char *pcdomain;
};

struct tb
{ char *pc;
  int cnt;
};

struct tE
{ char *pcpath;
  char *pchost;
  char *pcsend;
  char *pcpost;
  struct tb recv;
  char *pchtml;
  char *pclocation;
  struct tCookie *Cookie;
  int CookieAnzahl;
};

#define SIZEOF0 1

#endif /* __GLOBALS_H__ */
</code></pre>
<p><strong>M.bat</strong></p>
<pre><code>@d:\borland\tcc55\bin\make -fm.mak
</code></pre>
<p><strong>m.mak</strong></p>
<pre><code>COMPILER=d:\borland\tcc55\bin\bcc32
LINKER=d:\borland\tcc55\bin\ilink32

output\main.exe: output\main.obj \
		         output\cookie.obj \
		         output\url.obj
 @$(LINKER) /Gn/c/x/ap/Tpe -Ioutput -joutput c0x32 main cookie url, output\main,, import32 cw32
 @copy output\main.exe

output\main.obj: src\main.c src\globals.h src\cookie.h src\url.h
 @$(COMPILER) -c -w -noutput src\main.c

output\cookie.obj: src\cookie.c src\cookie.h src\globals.h
 @$(COMPILER) -c -w -noutput src\cookie.c

output\url.obj: src\url.c src\url.h src\globals.h
 @$(COMPILER) -c -w -noutput src\url.c
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1270633</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1270633</guid><dc:creator><![CDATA[keksekekse]]></dc:creator><pubDate>Sat, 21 Apr 2007 15:01:21 GMT</pubDate></item></channel></rss>