Skip to content

Commit 52e0b70

Browse files
committed
feat: initial implementation of STRAP C library
- Add core library functions for safe string manipulation and time utilities - Implement afgets, afread, strjoin, strjoin_va, strtrim functions - Add struct timeval helper functions (add, sub, to_seconds) - Include comprehensive unit tests - Set up CI/CD with GitHub Actions for multi-platform testing - Add documentation, examples, and contribution guidelines - MIT licensed
0 parents  commit 52e0b70

File tree

12 files changed

+801
-0
lines changed

12 files changed

+801
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ""
5+
labels: ""
6+
assignees: ""
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Environment (please complete the following information):**
27+
28+
- OS: [e.g. Ubuntu 20.04]
29+
- Compiler: [e.g. gcc 9.3]
30+
- Version: [e.g. v0.1]
31+
32+
**Additional context**
33+
Add any other context about the problem here.

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Build on Linux/macOS
20+
if: runner.os != 'Windows'
21+
run: |
22+
make
23+
24+
- name: Build on Windows
25+
if: runner.os == 'Windows'
26+
run: |
27+
gcc -Wall -Wextra -O2 -c strap.c -o strap.o
28+
ar rcs libstrap.a strap.o
29+
30+
- name: Run tests on Linux/macOS
31+
if: runner.os != 'Windows'
32+
run: |
33+
cd tests
34+
gcc -I.. -L.. -o test_strap test_strap.c -lstrap
35+
./test_strap
36+
37+
- name: Run tests on Windows
38+
if: runner.os == 'Windows'
39+
run: |
40+
cd tests
41+
gcc -I.. -L.. -o test_strap.exe test_strap.c -lstrap
42+
./test_strap.exe

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Object files
2+
*.o
3+
*.obj
4+
5+
# Libraries
6+
*.lib
7+
*.a
8+
*.la
9+
*.lo
10+
11+
# Executables
12+
*.exe
13+
*.out
14+
*.app
15+
16+
# Build directories
17+
build/
18+
dist/
19+
20+
# IDE files
21+
.vscode/
22+
.idea/
23+
*.swp
24+
*.swo
25+
26+
# OS files
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Test executables
31+
tests/test_strap
32+
tests/test_strap.exe

CONTRIBUTING.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Contributing to STRAP
2+
3+
Thank you for your interest in contributing to STRAP! We welcome contributions from the community.
4+
5+
## How to Contribute
6+
7+
1. Fork the repository
8+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
9+
3. Make your changes
10+
4. Add tests for new functionality
11+
5. Ensure all tests pass
12+
6. Commit your changes (`git commit -m 'Add some amazing feature'`)
13+
7. Push to the branch (`git push origin feature/amazing-feature`)
14+
8. Open a Pull Request
15+
16+
## Development Setup
17+
18+
```bash
19+
git clone https://github.com/murapadev/strap.git
20+
cd strap
21+
make
22+
# Run tests
23+
cd tests
24+
gcc -I.. -L.. -o test_strap test_strap.c -lstrap
25+
./test_strap
26+
```
27+
28+
## Code Style
29+
30+
- Use consistent indentation (4 spaces)
31+
- Add comments for complex logic
32+
- Follow C99 standards where possible
33+
- Write clear, descriptive function and variable names
34+
35+
## Reporting Issues
36+
37+
Please use the bug report template when creating issues. Include as much detail as possible to help us reproduce and fix the issue.
38+
39+
## License
40+
41+
By contributing, you agree that your contributions will be licensed under the MIT License.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 murapadev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CC = gcc
2+
CFLAGS = -Wall -Wextra -O2
3+
AR = ar
4+
ARFLAGS = rcs
5+
6+
TARGET = libstrap.a
7+
SOURCES = strap.c
8+
OBJECTS = $(SOURCES:.c=.o)
9+
10+
PREFIX = /usr/local
11+
12+
.PHONY: all clean install
13+
14+
all: $(TARGET)
15+
16+
$(TARGET): $(OBJECTS)
17+
$(AR) $(ARFLAGS) $@ $^
18+
19+
%.o: %.c
20+
$(CC) $(CFLAGS) -c $< -o $@
21+
22+
clean:
23+
rm -f $(OBJECTS) $(TARGET)
24+
25+
install: $(TARGET)
26+
install -d $(PREFIX)/lib
27+
install -m 644 $(TARGET) $(PREFIX)/lib
28+
install -d $(PREFIX)/include
29+
install -m 644 strap.h $(PREFIX)/include

0 commit comments

Comments
 (0)