<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>static API</title>
		<link>http://www.allegro.cc/forums/view/590974</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 12 Apr 2007 22:41:28 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>hello everybody... I have still a question that should be easy to answer for a lot of you ... ;-P</p><p>My app is static in its way of work ( working with dll , alllegro and windows.<br />But I m using <br /><span class="source-code"><a href="http://www.delorie.com/djgpp/doc/libc/libc_92.html" target="_blank">chdir</a><span class="k2">(</span><span class="s">"C:\\my_app_name\\saves\\folder_of_particuliar_saves"</span><span class="k2">)</span><span class="k2">;</span></span></p><p>I didn t figure out how to know wich is the hard disk ( &quot;C:&quot; )and the folder (\\somewhere\\my_app_name) if I let users install it anywhere on their computer.</p><p>Could someone explain me wich syntax to use to have the resident directory of installation? And how to navigate inside of it ?</p><p>I would like for example to let users use my app from an usb-key. This app is under windows, but cant be worked from emultaor under linux because of this particuliar point.<br />( for those who will have this suggestion: my app is communicating with hardware, a compilation under linux needs to rewrite a lot of code, so first I want it purely static)</p><p>Thanks for answer!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (karistouf)</author>
		<pubDate>Thu, 12 Apr 2007 14:34:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">guillermet christoph said:</div><div class="quote"><p>
My app is static in its way of work
</p></div></div><p>
You keep using that word. I do not think it means what you think it means. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><div class="quote_container"><div class="title">guillermet christoph said:</div><div class="quote"><p>
Could someone explain me wich syntax to use to have the resident directory of installation?
</p></div></div><p>
Just using a relative path works in itself (no chdirs are required), if the user starts the program by double-clicking the executable:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/load_bitmap" target="_blank"><span class="a">load_bitmap</span></a><span class="k2">(</span><span class="s">"foo.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span> <span class="c">//load "foo.bmp" in the same directory as the exe</span>
<a href="http://www.allegro.cc/manual/load_bitmap" target="_blank"><span class="a">load_bitmap</span></a><span class="k2">(</span><span class="s">"bar/foo.bmp"</span>, NULL<span class="k2">)</span><span class="k2">;</span> <span class="c">//load "foo.bmp" in the subdirectory "bar"</span>
</pre></div></div><p>
(I&#39;m using forward slashes here as they work in <i>both</i> Windows and UNIX)</p><p>But to be completely sure, you can combine <span class="source-code"><a href="http://www.allegro.cc/manual/get_executable_name" target="_blank"><span class="a">get_executable_name</span></a><span class="k2">(</span><span class="k1">char</span> <span class="k3">*</span>buf, <span class="k1">int</span> size<span class="k2">)</span><span class="k2">;</span></span><br />with <span class="source-code"><span class="k1">char</span> <span class="k3">*</span><a href="http://www.allegro.cc/manual/replace_filename" target="_blank"><span class="a">replace_filename</span></a><span class="k2">(</span><span class="k1">char</span> <span class="k3">*</span>dest, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>path, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>filename, <span class="k1">int</span> size<span class="k2">)</span><span class="k2">;</span></span></p><p>E.g.:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">char</span> path<span class="k2">[</span><span class="n">512</span><span class="k2">]</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/get_executable_name" target="_blank"><span class="a">get_executable_name</span></a><span class="k2">(</span>path, <span class="k1">sizeof</span><span class="k2">(</span>path<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/replace_filename" target="_blank"><span class="a">replace_filename</span></a><span class="k2">(</span>path, path, <span class="s">"foo.bmp"</span>, <span class="k1">sizeof</span><span class="k2">(</span>path<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>

<a href="http://www.allegro.cc/manual/load_bitmap" target="_blank"><span class="a">load_bitmap</span></a><span class="k2">(</span>path, NULL<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

[EDIT]<br />Someone must have lobotomized me in my sleep. Fixed the load_bitmap() call.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Thu, 12 Apr 2007 15:22:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I believe the last row of code in gnolam&#39;s post should be
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/load_bitmap" target="_blank"><span class="a">load_bitmap</span></a><span class="k2">(</span>path,NULL<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Maybe that was obvious to the OP though <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ixilom)</author>
		<pubDate>Thu, 12 Apr 2007 15:54:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok... interresting...</p><p>on static definition: for me Blender ( on linux and win) is a static api: it has all the dll and drivers it needs to work. A program that need external library installed on the system is not static. But perhaps Im wrong ?</p><p>get_executable_name is good, is there any split function to navigate easely  from folder up to folder down ?</p><p>my app is there : /MY_APP_FOLDER/BIN/my_app.exe<br />my bitmap are there: <i>MY_APP_FOLDER/IMAGES</i></p><p>so i need to navigate easely...</p><p>thanks !!!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (karistouf)</author>
		<pubDate>Thu, 12 Apr 2007 16:14:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Static to me is something that doesn&#39;t change, the opposite of dynamic.<br />A program that comes with its own DLL&#39;s and such I&#39;d call &quot;stand alone&quot; rather than static.</p><p>As for getting different directory &quot;levels&quot;, there is no such magic function AFAIK.<br />Shouldn&#39;t be too hard to make one though. Just some simple string management <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ixilom)</author>
		<pubDate>Thu, 12 Apr 2007 16:28:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>i hate string management .... nostring minded am I...;D</p><p>is there any function in mingw that do a replacement in a string of a certain keyword ( replace /bin by /saves ) ?</p><p>but thanks... really!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (karistouf)</author>
		<pubDate>Thu, 12 Apr 2007 16:33:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry to post for no apparent reason, but...</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
You keep using that word. I do not think it means what you think it means. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div></div><p>

I laughed. A lot.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Thu, 12 Apr 2007 17:46:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>we agree that static is the good term when you do not install libraries on the system to run your app??????????????????????????<br />i have done some linuxing during two years and some apps were said static...<br /><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (karistouf)</author>
		<pubDate>Thu, 12 Apr 2007 18:01:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I believe they mean static as in the libraries were built into the executable itself, not requiring any external libraries. <br />However, if they deliver a bunch of libraries (located where the executable is), its not a static build. Merely a &quot;stand alone&quot;.</p><p>The normal way of running Linux applications is to require the user to install the libraries that are needed, sharing the libraries with a bunch of other software.<br />This has been avoided in the most recent games(and some applications) and thus they come with their own libraries it should &quot;just work&quot; &lt;tm&gt;. No need for the gamer to hunt down a plethora of libraries he/she has never heard of. <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ixilom)</author>
		<pubDate>Thu, 12 Apr 2007 18:36:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
we agree that static is the good term when you do not install libraries on the system to run your app
</p></div></div><p>
No. Static is the opposite of dynamic, and refers to how you use libraries. So I guess you think of applications that are statically linked, so there are no runtime dependencies to other libraries which may have to be installed as well. This would not be called &#39;static&#39; however, but stand-alone or independent, or self-contained or whatever. </p><p>Edit: I also don&#39;t get why you use the term API. It&#39;s the shorthand for Application Programming Interface, and doesn&#39;t make sense the way you&#39;re using it...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Thu, 12 Apr 2007 18:37:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The way you compile your program does not affect its path.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul whoknows)</author>
		<pubDate>Thu, 12 Apr 2007 18:50:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok lets stay statically linked.<br />i didn t know it was so important...<br />thanks for precision about api. I m in france and on forums we do not use with the same meanings english terms. There is always a kind of deformation...;D
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (karistouf)</author>
		<pubDate>Thu, 12 Apr 2007 18:54:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
is there any function in mingw that do a replacement in a string of a certain keyword ( replace /bin by /saves ) ?
</p></div></div><p>

No, there isn&#39;t*. But you can use <tt>strstr()</tt> to find the first occurance of the substring you want to replace, then copy all of the proceeding string to a buffer, then <tt>strcat()</tt> what you want to replace it with, then copy the rest of the original string to the buffer.</p><p><sup>* Not in C anyway. I don&#39;t know about C++.</sup></p><p>edit:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
ok lets stay statically linked.
</p></div></div><p>

If you&#39;re using the Allegro dll, which I assume you are, since you mentined dlls in your original post, then you are dynamically linking, not statically linking (dll == Dynamic Link Library).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 12 Apr 2007 19:03:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code"><a href="http://www.allegro.cc/manual/replace_filename" target="_blank"><span class="a">replace_filename</span></a></span>replace_filename will change /bin to /saves, assuming the last component of the path name is /bin.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Thu, 12 Apr 2007 19:11:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
replace_filename will change /bin to /saves, assuming the last component of the path name is /bin.
</p></div></div><p>
That&#39;s not a MinGW (GCC)  function though. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 12 Apr 2007 19:23:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sure, but this is obviously an Allegro question. See the second post in the thread <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Thu, 12 Apr 2007 19:24:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
See the second post in the thread
</p></div></div><p>

Nah, I&#39;m busy looking at this part now:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
get_executable_name is good, is there any split function to navigate easely from folder up to folder down ?</p><p>my app is there : /MY_APP_FOLDER/BIN/my_app.exe<br />my bitmap are there: <i>MY_APP_FOLDER/IMAGES</i>
</p></div></div><p>

In DOS/Windows, &quot;..&quot; represents the parent directory, does this hold true for other OSes?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 12 Apr 2007 19:28:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, it does. But you can&#39;t do <i>MY_APP_FOLDER/BIN/my_app.exe/../../IMAGES</i>, you have to get the directory name twice, then append the IMAGES part. I suppose you could get away with getting the directory name <i>without a trailing slash</i> and then calling replace_filename.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Thu, 12 Apr 2007 19:30:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>strstr used and used with strncat.<br />i arrived to this point but still little troubles with mingw and its way to access with &quot;\\&quot; .<br />and of course &quot;\&quot; is a special very special caracter...<br />so now i let this down and will try the magic &quot;..&quot;::)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (karistouf)</author>
		<pubDate>Thu, 12 Apr 2007 19:33:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Use / not \\. / will work on all platforms, plus you don&#39;t have to escape it. It also looks better because you don&#39;t have toe scape it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 12 Apr 2007 19:51:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>sorry but / is not working on my dev cpp + mingw32. Its like this...</p><p>But on the &quot;..&quot; I can say that simplest solutions are the best. It works now, I just have to adapt some few things....<br />so now its ok !!!</p><p>thank you<br /><img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (karistouf)</author>
		<pubDate>Thu, 12 Apr 2007 19:59:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
sorry but / is not working on my dev cpp + mingw32. Its like this...
</p></div></div><p>

How did you use it? It should work fine.</p><p>eg:</p><p><span class="source-code">output <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_337.html" target="_blank">fopen</a><span class="k2">(</span><span class="s">"../output.txt"</span>, <span class="s">"w"</span><span class="k2">)</span><span class="k2">;</span></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 12 Apr 2007 20:07:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>chdir (&quot;..&quot;) <br />and I do not have to handle string funct...</p><p>what a pity that in mingw32 the main interresting function in libc are missing...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (karistouf)</author>
		<pubDate>Thu, 12 Apr 2007 20:11:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
chdir (&quot;..&quot;) <br />and I do not have to handle string funct...
</p></div></div><p>

The following code worked perfectly for me with MinGW:</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#include &lt;stdio.h&gt;</span>
<span class="p">#include &lt;unistd.h&gt;</span>

<span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span>
  
  FILE <span class="k3">*</span>output<span class="k2">;</span>
  
  <a href="http://www.delorie.com/djgpp/doc/libc/libc_92.html" target="_blank">chdir</a><span class="k2">(</span><span class="s">"../files"</span><span class="k2">)</span><span class="k2">;</span>
  output <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_337.html" target="_blank">fopen</a><span class="k2">(</span><span class="s">"test.txt"</span>, <span class="s">"w"</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>output, <span class="s">"Hello World!"</span><span class="k2">)</span><span class="k2">;</span>
  
  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
  
<span class="k2">}</span>
</pre></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
what a pity that in mingw32 the main interresting function in libc are missing...
</p></div></div><p>
Such as?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 12 Apr 2007 20:18:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>&#39;/&#39; works perfectly in Mingw32. There are no missing libc functions in mingw32 that I&#39;m aware of...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Thu, 12 Apr 2007 20:48:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>To be honest the reason I clicked the thread was cause it said &#39;<i>Static</i> API&#39;.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Thu, 12 Apr 2007 22:39:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What version of mingw do you have? You must have broken something to be missing libc functions and having / not work. <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (BAF)</author>
		<pubDate>Thu, 12 Apr 2007 22:41:28 +0000</pubDate>
	</item>
</rss>
