Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new services fails #65

Open
dishkakrauch opened this issue Apr 22, 2024 · 0 comments
Open

Adding new services fails #65

dishkakrauch opened this issue Apr 22, 2024 · 0 comments

Comments

@dishkakrauch
Copy link

Hello there!

Has anybody complied C code as custom service for c-icap-server ever? I didn't find any suggestion how to do it correctly.
Just trying to use this simple function for saving data which ICAP server gets:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

int save_to_disk(char *data, int length) {
    time_t current_time;
    struct tm *local_time;
    char filename[100];
    FILE *file;

    time(&current_time);
    local_time = localtime(&current_time);

    snprintf(filename, 100, "output_%02d%02d%02d.txt", local_time->tm_hour, local_time->tm_min, local_time->tm_sec);

    file = fopen(filename, "w");
    if (file == NULL) {
        return -1;
    }

    fwrite(data, 1, length, file);

    fclose(file);

    return 0;
}

I've build this code with gcc and placed to the right place as svc_echo.so service.

gcc -shared -o /usr/local/c-icap/lib/c_icap/save_data.so -fPIC save_data.c
But c-icap-server can't start with my own service which was added to c-icap.conf:

Service save_data save_data.so

It throws an error:

Loading service: save_data path save_data.so
Found handler C_handler for service with extension: .so
Not found symbol "service" in library, unload it
Error while loading service save_data.so
Error loading service save_data.so
Fatal error while parsing config file: "/usr/local/c-icap/etc/c-icap.conf" line: 868
The line is: Service save_data save_data.so

I understand that my code doesn't have all neccessary method but I can't find template for doing custom services in this repo.
My task is really simple - to create a custom service that will be saving each message from ICAP server to anywhere (local storage or S3).

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant