litespeedtech / litespeedtech/lsquic

open_memstream and regex on WIN32

Open
#684 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.9k
Forks
397
Avg merge
2d 22h
Merged PRs (30d)
8

Description

By default, the http_server cannot run on Windows because of open_memstream and regex not found by the Cmake

However, thanks to [vcpkg](https://vcpkg.io/en/), one can
vcpkg install fmem
vcpkg install pcre

This was useful anyway to get a GETOPT_INCLUDE_DIR/GETOPT_LIB_DIR
vcpkg install getopt

But there are a few problems :

The Cmake won't handle `CHECK_FUNCTION_EXISTS(open_memstream HAVE_OPEN_MEMSTREAM)` correctly, because :
it does not allow any OPENMEMSTREAM_INCLUDE_DIR
the vcpkg fmem does not declare `open_memstream()` function, there is a fmem abstraction

But it can be fixed easily
```
FILE* open_memstream(char** dstBuf, size_t* dstSize) {
FILE* result = NULL;
fmem stream_info;
fmem_init(&stream_info);
result = fmem_open(&stream_info, "w+");
fmem_mem(&stream_info, dstBuf, dstSize);
return result;
}
```

Then I had to force
```
#define HAVE_OPEN_MEMSTREAM 1
#define HAVE_REGEX 1
```

in test_config.h

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the CMake logic around CHECK_FUNCTION_EXISTS(open_memstream...) and test_config.h, then trace how the http_server uses these feature definitions on WIN32. Reproduce the vcpkg setup for fmem, pcre, and getopt; done means the http_server builds and runs on Windows without manually forcing HAVE_OPEN_MEMSTREAM or HAVE_REGEX.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.