/rusxmms/librcc

To get this branch, use:
bzr branch http://suren.me/webbzr/rusxmms/librcc

« back to all changes in this revision

Viewing changes to src/engine.c

  • Committer: Suren A. Chilingaryan
  • Date: 2005-06-16 23:14:30 UTC
  • Revision ID: Arch-1:ds@dside.dyndns.org--darksoft-2004%librcc--main--0.1--base-0
Initial Import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <string.h>
 
3
 
 
4
#include "librcc.h"
 
5
 
 
6
int rccEngineInit(rcc_engine_context *engine_ctx, rcc_context *ctx) {
 
7
    if ((!ctx)||(!engine_ctx)) return -1;
 
8
    
 
9
    engine_ctx->ctx = ctx;
 
10
    engine_ctx->free_func = NULL;
 
11
    engine_ctx->func = NULL;
 
12
    return 0;
 
13
}
 
14
 
 
15
void rccFreeEngine(rcc_engine_context *engine_ctx) {
 
16
    if (!engine_ctx) return;
 
17
    
 
18
    if (engine_ctx->free_func) {
 
19
        engine_ctx->free_func(engine_ctx);
 
20
        engine_ctx->free_func = NULL;
 
21
    }
 
22
 
 
23
    engine_ctx->func = NULL;
 
24
    engine_ctx->internal = NULL;
 
25
}
 
26
 
 
27
int rccEngineConfigure(rcc_engine_context *ctx) {
 
28
    rcc_language_id language_id;
 
29
    rcc_engine_id engine_id;
 
30
    rcc_engine *engine;
 
31
 
 
32
    if ((!ctx)||(!ctx->ctx)) return -1;
 
33
 
 
34
    rccEngineFree(&ctx);
 
35
    
 
36
    language_id = rccGetCurrentLanguage(ctx->ctx);
 
37
    if (language_id<0) return -1;
 
38
 
 
39
    engine_id = rccGetCurrentEngine(ctx->ctx);
 
40
    if (engine_id<0) return -1;
 
41
    
 
42
    engine = ctx->ctx->languages[language_id]->engines[engine_id];
 
43
    
 
44
    ctx->free_func = engine->free_func;
 
45
    ctx->func = engine->func;
 
46
    ctx->language = ctx->languages[language_id];
 
47
 
 
48
    ctx->internal = engine->init_func(ctx);
 
49
    return 0;
 
50
}
 
51
 
 
52
rcc_engine_internal rccEngineGetInternal(rcc_engine_context *ctx) {
 
53
    if (!ctx) return NULL;
 
54
 
 
55
    return ctx->internal;
 
56
}