~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/ruby/app_templates/kapp/app.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <ruby.h>
 
2
 
 
3
#include <qstring.h>
 
4
#include <qfileinfo.h>
 
5
#include <kinstance.h>
 
6
#include <kstandarddirs.h>
 
7
 
 
8
int main(int argc, char **argv) {
 
9
    KInstance * instance = new KInstance("%{APPNAMELC}");
 
10
    QString appdir = ::locate("data", "%{APPNAMELC}/main.rb", instance);
 
11
    delete instance;
 
12
    if (appdir.isNull()) {
 
13
        qFatal("Error: Can't find \"%{APPNAMELC}/main.rb\"\n");
 
14
    }
 
15
    QFileInfo program(appdir);
 
16
     
 
17
    char ** rubyargs = (char **) calloc(argc+4, sizeof(char *));
 
18
    rubyargs[0] = strdup(argv[0]);
 
19
    rubyargs[1] = strdup("-KU");
 
20
    rubyargs[2] = strdup(QString("-C%1").arg(program.dirPath()).latin1());
 
21
    rubyargs[3] = strdup(QString("-I%1").arg(program.dirPath()).latin1());
 
22
    rubyargs[4] = strdup(program.fileName().latin1());
 
23
    for (int i = 1; i < argc; i++) {
 
24
        rubyargs[i+4] = argv[i];
 
25
    }
 
26
 
 
27
    ruby_init();
 
28
    ruby_options(argc+4, rubyargs); 
 
29
    ruby_run();
 
30
}