]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/moduleloadtest.c
Fix various typos, repeated words, align some spelling to LDP.
[thirdparty/openssl.git] / test / moduleloadtest.c
CommitLineData
527eb8d2 1/*
3c2bdd7d 2 * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
527eb8d2
RL
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10/*
11 * Extremely simple dynamic loader, must never be linked with anything other
12 * than the standard C library. Its purpose is to try to load a dynamic module
13 * and verify the presence of one symbol, if that's given.
14 */
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <openssl/core.h>
19#include "simpledynamic.h"
20
21static int test_load(const char *path, const char *symbol)
22{
23#ifdef SD_INIT
24 SD sd = SD_INIT;
25 SD_SYM sym;
9b0f76e1
P
26 int ret;
27
28 if (!sd_load(path, &sd, SD_MODULE))
29 return 0;
30 ret = symbol == NULL || sd_sym(sd, symbol, &sym);
31 if (!sd_close(sd))
32 ret = 0;
33 return ret;
527eb8d2
RL
34#else
35 fprintf(stderr, "No dynamic loader\n");
36 return 0;
37#endif
38}
39
40int main(int argc, char *argv[])
41{
42 const char *m, *s;
43
44 if (argc != 2 && argc != 3) {
45 fprintf(stderr, "Usage: %s sharedobject [ entrypoint ]\n", argv[0]);
46 return 1;
47 }
48
49 m = argv[1];
50 s = argc == 3 ? argv[2] : NULL;
51
52 return test_load(m, s) ? 0 : 1;
53}