Skip to content

Instantly share code, notes, and snippets.

@silentrob
Created January 29, 2010 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silentrob/290103 to your computer and use it in GitHub Desktop.
Save silentrob/290103 to your computer and use it in GitHub Desktop.
var sys = require('sys');
var posix = require('posix');
var ini = {'global':{}};
var parseINI = function(d) {
var section = 'global';
var lines = d.split('\n');
for (var i=0; i<lines.length; i++) {
var re = /(.*)=(.*)|\[([a-z:\.0-9]+)\]/i;
var match = lines[i].match(re);
if (match != null) {
if (match[3] != undefined) {
section = match[3];
ini[section] = {};
} else {
var key = match[1];
var value = match[2];
ini[section][key] = value;
}
}
}
sys.puts(ini.global.extensions);
};
posix.cat("rsp.conf").addCallback(parseINI);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment