60

Well, no, but I will surely think about it.

61

hum

Tinilib cheeky
avatar
Proud to be CAKE©®™


GCC4TI importe qui a problème en Autriche, pour l'UE plus et une encore de correspours nucléaire, ce n'est pas ytre d'instérier. L'état très même contraire, toujours reconstruire un pouvoir une choyer d'aucrée de compris le plus mite de genre, ce n'est pas moins)
Stalin est l'élection de la langie.

62

Since the goal is to handle configuration data, I think 'datalib' or 'conflib' would be more logical
avatar

63

About the API : isn't it a bit heavy (in terms of caller code size) to always pass the file name and section ? Perhaps it might be a good idea to put them in a global variable...

And what calling convention do you intend to use ?

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

64

pass the file name and section ? Perhaps it might be a good idea to put them in a global variable.

file name, might be in a global variable, yes, in my opinion : how many people would use more than one conf file ?

but for the section, you could want to get data from many sections, or even put only 2 or 3 keys in each section... using a global variable, you would have to set it at each time you want to get a key/value (if you have many sections and use keys from many sections at any time)
I, personnaly, prefer the ability to choose the section in each function call... (but that's only my point of view, naturally)
avatar
Tutorial C (TI-89/92+/v200) - Articles Développement Web (PHP, Javascript, ...)
« What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against? » - Larry Wall

65

to pass the file name and section takes 8 bytes à each call.
Global variable is a bad idea, since any lib called by the main program can use my lib
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

66

Flanker
: to pass the file name and section takes 8 bytes à each call.

I find it a bit large (and it doesn't account for the increased register usage : instead of being able to use a2-a6, the program can only use a4-a6 or a5-a6, which is rather constraining), but...
Global variable is a bad idea, since any lib called by the main program can use my lib

You might use "push_file(char *)" and "pop_file()" to overcome this problem smile

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

67

where do you see an increased register usage ?
A typical call like this one :
 pea     buf_value(pc)
 moveq   #40,d0
 move.l  d0,-(a7)
 pea     result_value(pc)
 pea     buf_key(pc)
 pea     buf_section(pc)
 pea     buf_file(pc)
 jsr     reglib@0003
 lea     24(a7),a7
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

68

OK, so you use stack parameter passing ^^

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

69

oui
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

70

A first public version is avalaible on ti-fr : www.ti-fr.com
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

71

Then I move the topic to the release section happy
avatar
Que cache le pays des Dieux ? - Forum Ghibli - Forum Littéraire

La fin d'un monde souillé est venue. L'oiseau blanc plane dans le ciel annonçant le début d'une longue ère de purification. Détachons-nous à jamais de notre vie dans ce monde de souffrance. Ô toi l'oiseau blanc, l'être vêtu de bleu, guide nous vers ce monde de pureté. - Sutra originel dork.

72

thx hehe
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

73

A few "bug" reports, from the C header file :
(The way it is, it's impossible to compile a program using it)
three things :
- you can't use '::' in C. you have to use confilb__function and not conflib::function
- you can't use the word 'default' as a variable name (default is a C keyword) ; I've corrected this by using 'defaut', the french word for 'default'
- you have to put a semi-colon at the end of the prototypes

I don't know if using the library will work (but it should), my program is not enough developed to allow me to test that, but after correction of these three kind of mistakes, the C file which includes Conflib_C's header compiles just fine.
Here's a diff between the Header you provide, and the one I got after corrections :
--- ./ConfLib_C.h       2004-11-09 13:27:02.000000000 +0100
+++ /home/squale/developpement/prog_ti/KryptonII/v2/v2.1.01/sources/libs/ConfLib_C.h    2004-11-15 21:36:11.000000000 +0100
@@ -10 +10 @@
-long conflib::get_num_key(const char *file, const char *section, const char *key, long default, const short *error)
+long conflib__get_num_key(const char *file, const char *section, const char *key, long defaut, const short *error);
@@ -22 +22 @@
-short conflib__add_num_key(const char *file, const char *section, const char *key, long value)
+short conflib__add_num_key(const char *file, const char *section, const char *key, long value);
@@ -33 +33 @@
-short conflib::remove_key(const char *file, const char *section, const char *key)
+short conflib__remove_key(const char *file, const char *section, const char *key);
@@ -45 +45 @@
-short conflib__get_string_key(const char *file, const char *section, const char *key, const char *value, long max_length, const char *default)
+short conflib__get_string_key(const char *file, const char *section, const char *key, const char *value, long max_length, const char *defaut);
@@ -59 +59 @@
-short conflib__add_string_key(const char *file, const char *section, const char *key, const char *value)
+short conflib__add_string_key(const char *file, const char *section, const char *key, const char *value);


[edit] thanks to StoopidGuy for correcting two mistakes of english which were changing the meaning of my sentences.
avatar
Tutorial C (TI-89/92+/v200) - Articles Développement Web (PHP, Javascript, ...)
« What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against? » - Larry Wall

74

I must say I still don't understand the purpose of this library. This is not a troll, I have a few serious questions:
* Why would you want to use this library rather than simple binary config files, which are much smaller? In a well-done program, you'll need a GUI for configuration editing anyway, so what's the point of using a text-based format?
* What's so new about this? You can easily parse an INI-format config file using fscanf.
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

75

The advantage of using a _test_ config file instead of a _binary_ one is that anyone can easily edit the text file, to change some settings;
Yes, in a dame, for instance, you would provide a nice GUI to allow users to edit the settings, ok
but, suppose you have many options that are usefull only for debugging purpose. As theses options are created only for Beta-versions of your program, you do not want to lose much time to design a nice GUI (which would not be in the final version of the program, as the corresponding options will not be in the final version of the program)... but you still want users to be able to change the values of the options easily
a text config file is perfect for this : you don't have to lose time to design a GUI useful only for Beta versions, and anyone can edit the settings, as if there were a GUI

Personnaly, I don't think I would use such a library for a final version of my program
But I use it for beta version : for instance, if O want the tester to be able to start at any level he wants instead of the first one, he can change this in the INI file... and for the final version, I will suppress this functionnality (juste a #define to remove)

avatar
Tutorial C (TI-89/92+/v200) - Articles Développement Web (PHP, Javascript, ...)
« What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against? » - Larry Wall

76

In addition to what squale said (it sure would be great if beta-testers could modify options without having to recompile or design a GUI for that purpose!):
* it easily ensures backwards compatibility as new features are introduced; it allows common configuration parameters to be shared across several programs
* if you impose the order in which you parse, yes; but conflib allows sections and definitions to be moved around within the file, just as it allows you to keep unchanged keys that you can't handle (think of this config file :
[DefaultApplications]
TextViewer = "AMSTextEdit"
TextEditor = "AMSTextEdit"

- your favourite text viewer could modify the default text viewer, even though it doesn't even know about the TextEditor key! thus it also provides some form of forward compatibility)

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

77

Pollux :
* if you impose the order in which you parse, yes; but conflib allows sections and definitions to be moved around within the file, just as it allows you to keep unchanged keys that you can't handle (think of this config file :
[DefaultApplications]
TextViewer = "AMSTextEdit"
TextEditor = "AMSTextEdit"

- your favourite text viewer could modify the default text viewer, even though it doesn't even know about the TextEditor key! thus it also provides some form of forward compatibility)

All this can be done with fscanf too. Just use it in a loop. smile
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

78

short conflib__get_string_key(const char *file, const char *section, const char *key, const char *value, long max_length, const char *defaut)
{
  FILE *f=fopen(file,"r");
  if (!f) return FAIL;
  char sechead[strlen(section)+3];
  sprintf(sechead,"[%s]",section);
  int r;
  do {
    r=fscanf(f,sechead);
    if (r>0) goto secfound; else if (!r) r=fscanf(f,"%*s");
  } while (r!=EOF);
 notfound:
  strncpy(value,defaut,max_length);
  value[max_length+1]=0;
  goto valfound;
 secfound:;
  char valhead[strlen(value)+11];
  sprintf(valhead,"%s = %%%ds",section,max_length);
  do {
    if (fscanf(f,"[%*s]")) goto notfound;
    r=fscanf(f,valhead);
    if (r>0) goto valfound; else if (!r) r=fscanf(f,"%*s");
  } while (r!=EOF);
  goto notfound;
 valfound:
  fclose(f);
  return SUCCESS;
}
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

79

This seems interesting.
but I'm wondering which size is each implementation : is one approach biggest than the other ?
(independantly of the fact that la dynamic library may take less space than a static one, or more, depending on the point of view, but it's not the debate here)
avatar
Tutorial C (TI-89/92+/v200) - Articles Développement Web (PHP, Javascript, ...)
« What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against? » - Larry Wall

80

Hmm, you're leaving out integer parsing and writing (implying (un)archival, moving around pieces of text...), yet I see that with TIGCC 0.95 and an empty _main(), the 89z takes 2745 bytes...

That's not what I would call an optimization roll And you see the evils of static linking : would you have suspected that this small piece of code could generate nearly 3 kb of code ???

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

81

The *scanf core is 1.5 KB, and the stdio stuff also takes some space, so I'd estimate around 2-2.5 KB in total.

(EDIT: cross-post - looks like my estimate was not too far off - add the in-use bit to my estimate and you're almost there.)
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

82

why would the in-use bit patch be necessary here ?

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

83

Pollux
: Hmm, you're leaving out the integer parsing

That's done by fscanf too, you just need a %i parameter. No extra size, it is already linked in as soon as you use fscanf (because there is no way the needed parts of code can be determined at compile time the way things work now).
and the writing

Sure, writing is harder than reading. But for the application suggested by squale92, you need reading only.
That's not what I would call an optimization roll

My implementation is not intended to be optimized for anything other than quick writing. I did it in 15 minutes, so that goal was achieved. I just wanted to show how easy it is using fscanf.
That's not what I would call an optimization roll And you see the evils of static linking : would you have suspected that this small piece of code could generate nearly 3 kb of code ???

Yes, see my cross-posted estimate.
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

84

Pollux
: why would the in-use bit patch be necessary here ?

Imported by fopen at 3 places. Many of the VAT routines have it set. I don't know why exactly. Sebastian's callgraph analysis tools claimed it was required, so he has set it.
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

85

Anyway, I really can't see your point: yes, his library can be reimplemented so that it will take more than 4 kb for *each* program that uses it; but it takes much less, and is needed only once... And the library could be later extended to deal with more complicated types (or include a mechanism for string escapes), without worrying about old conflib versions that could trash the data ^^

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

86

./78:
k.c: In function `conflib__get_string_key':
k.c:20: warning: passing arg 1 of `strncpy' discards qualifiers from pointer target type
k.c:21: warning: assignment of read-only location
k.c:25: warning: int format, long int arg (arg 4)
k.c:8: warning: unused parameter `key'

A few buggy this function neutral

87

Yes, I saw it was buggy too (it also misses the quotes surrounding the string...) but even if it wasn't, it would still be useless because conflib does it better...

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)

88

why this lib ?
- for some reasons, I wanted an external lib to manage config files (for reading and writing). Using external lib allows to save some RAM when I'm not using the lib
-> for this purpose, kernel libs are perfect
- such a format is perfect for sharing config files between applications. The lib is common to all applications which want to use the config file, so we can easily share the config file. If 2 applications A and B uses the same config file for one key, and if a new version of A must use differents keys, the config file remain unchanged, and B needn't to be changed
- in your example, you don't take care of file searching (you must create the file when it doesn't exist, you must search in a single system folder, you must unarchive when you write it, ....).

In my lib, a great part of the code is for writing, so your solution will have a 5-6kB -lib sick
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

89

Kevin> The purpose of this library is to provide high level functions to manage config files.
avatar
« Quand le dernier arbre sera abattu, la dernière rivière empoisonnée, le dernier poisson capturé, alors vous découvrirez que l'argent ne se mange pas. »

90

PpHd :
./78:
k.c: In function `conflib__get_string_key':
k.c:20: warning: passing arg 1 of `strncpy' discards qualifiers from pointer target type
k.c:21: warning: assignment of read-only location
k.c:25: warning: int format, long int arg (arg 4)
k.c:8: warning: unused parameter `key'

A few buggy this function neutral

True, I didn't try to compile my code. grin There are certainly a few typos in it, and I don't guarantee it works as is.
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité