最初コミット

このコミットが含まれているのは:
守矢諏訪子 2024-04-22 15:38:35 +09:00
コミット b5a68057e5
6個のファイルの変更238行の追加0行の削除

2
.gitignore vendored ノーマルファイル
ファイルの表示

@ -0,0 +1,2 @@
odl
release

2
CHANGELOG.md ノーマルファイル
ファイルの表示

@ -0,0 +1,2 @@
# 0.1.0
* 最初リリース

14
LICENSE.txt ノーマルファイル
ファイルの表示

@ -0,0 +1,14 @@
Copyright © 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
Copyright © 2018-2024 by 076.moe
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

87
Makefile ノーマルファイル
ファイルの表示

@ -0,0 +1,87 @@
UNAME_S!=uname -s
NAME!=cat main.c | grep "const char\* sofname" | awk '{print $$5}' | \
sed "s/\"//g" | sed "s/;//"
VERSION!=cat main.c | grep "const char\* version" | awk '{print $$5}' | \
sed "s/\"//g" | sed "s/;//"
PREFIX=/usr/local
MANPREFIX=${PREFIX}/man
CFLAGS=-Wall -Wextra -g -I/usr/include -I/usr/local/include
LDFLAGS=-L/usr/lib -L/usr/local/lib
.if ${UNAME_S} == "FreeBSD"
MANPREFIX=${PREFIX}/share/man
.elif ${UNAME_S} == "OpenBSD"
.elif ${UNAME_S} == "Linux"
PREFIX=/usr
MANPREFIX=${PREFIX}/share/man
.elif ${UNAME_S} == "NetBSD"
PREFIX=/usr/pkg
CFLAGS+= -I/usr/pkg/include
LDFLAGS+= -L/usr/pkg/lib
MANPREFIX=${PREFIX}/share/man
.endif
CC=cc
FILES=main.c
LIBS=-lcurl
all:
${CC} ${CFLAGS} -o ${NAME} ${FILES} ${LDFLAGS} ${LIBS}
strip ${NAME}
clean:
rm -f ${NAME}
release-openbsd: clean
mkdir -p release/bin
${CC} ${CFLAGS} -o release/bin/${NAME}-${VERSION}-openbsd-amd64 ${FILES} ${LDFLAGS} \
-static -lcurl -lc -lnghttp3 -lngtcp2_crypto_quictls -lngtcp2 -lssl \
-lcrypto -lnghttp2 -lz -lpthread
strip release/bin/${NAME}-${VERSION}-openbsd-amd64
release-netbsd: clean
mkdir -p release/bin
${CC} ${CFLAGS} -o release/bin/${NAME}-${VERSION}-netbsd-amd64 ${FILES} ${LDFLAGS} \
-static -lcurl -lnghttp2 -lc -lidn2 -lunistring -lgssapi -lkrb5 -lhx509 -lintl \
-lssl -lcrypto -lcrypt -lasn1 -lcom_err -lroken -lutil -lwind -lheimbase \
-lheimntlm -lz -lpthread
strip release/bin/${NAME}-${VERSION}-netbsd-amd64
release-freebsd: clean
mkdir -p release/bin
${CC} ${CFLAGS} -o release/bin/${NAME}-${VERSION}-freebsd-amd64 ${FILES} ${LDFLAGS} \
-static -lcurl -lnghttp2 -lssh2 -lpsl -lssl -lheimntlm \
-lhx509 -lcom_err -lcrypto -lasn1 -lwind -lheimbase \
-lroken -lcrypt -lz -lkrb5 -lgssapi -lgssapi_krb5 -lthr \
-lidn2 -lunistring -lprivateheimipcc
strip release/bin/${NAME}-${VERSION}-freebsd-amd64
release-linux: clean
mkdir -p release/bin
${CC} ${CFLAGS} -o release/bin/${NAME}-${VERSION}-linux-amd64 ${FILES} ${LDFLAGS} \
-static -lcurl -lc -lnghttp2 -lidn2 -lssh2 -lpsl -lssl -lcrypto -lzstd -lz \
-lunistring
strip release/bin/${NAME}-${VERSION}-linux-amd64
dist: clean
mkdir -p ${NAME}-${VERSION} release/src
cp -R LICENSE.txt Makefile README.md CHANGELOG.md \
*.c ${NAME}-${VERSION}
tar zcfv ${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}
mv ${NAME}-${VERSION}.tar.gz release/src
rm -rf ${NAME}-${VERSION}
upload:
rsync -rtvzP release/bin/* 192.168.0.143:/zroot/repo/bin/odl
rsync -rtvzP release/src/* 192.168.0.143:/zroot/repo/src/odl
install: all
mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f ${NAME} ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/${NAME}
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/${NAME}
.PHONY: all clean install uninstall

52
README.md ノーマルファイル
ファイルの表示

@ -0,0 +1,52 @@
# curconv
## インストールする方法
### OpenBSD
```sh
doas pkg_add curl brotli
make LIBS=-static -lcurl -lc -lnghttp3 -lngtcp2_crypto_quictls -lngtcp2 -lssl -lcrypto -lnghttp2 -lz -lpthread
doas make install
```
### Void Linux (muslのみ)
```sh
doas xbps-install libunistring brotli icu libidn2
cd ~/.local/src
git clone https://github.com/google/brotli.git
mkdir -p ~/.local/src/brotli/out
cd ~/.local/src/brotli/out
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF .. -DCMAKE_INSTALL_PREFIX=./installed ..
cmake --build . --config Release --target install
doas mv installed/lib64/libbrotli* /usr/lib
make LIBS=-static -lcurl -lc -lnghttp2 -lidn2 -lssh2 -lpsl -lssl -lcrypto -lzstd -lz -lunistring PREFIX=/usr
doas make install PREFIX=/usr
```
### FreeBSD
書込中・・・
### NetBSD
書込中・・・
### CRUX Linux, Artix Linux, Devuan GNU/Linux等 (glibcの場合)
CRUXの場合
```sh
doas prt-get depinst curl
```
Artixの場合
```sh
doas pacman -S curl
```
Devuanの場合
```sh
doas apt install curl
```
```sh
make LIBS=-lcurl PREFIX=/usr
doas make install PREFIX=/usr
```

81
main.c ノーマルファイル
ファイルの表示

@ -0,0 +1,81 @@
#include <stdio.h>
#include <stdlib.h>
#include <libgen.h>
#include <curl/curl.h>
const char* sofname = "odl";
const char* version = "0.1.0";
char* filename;
int progress_callback(void *cp, double dt, double dn, double ut, double un) {
(void)cp;
(void)ut;
(void)un;
double progress = (dn / dt) * 100.0;
char* status = "ダウンロード中";
if (progress == 100.0) status = "ダウンロード済み";
printf("\r[");
int barw = 50;
int pos = (int)(progress * barw / 100.0);
for (int i = 0; i < barw; ++i) {
if (i < pos) printf("=");
else if (i == pos) printf(">");
else printf(" ");
}
printf("] %.2f%% %s, %s", progress, filename, status);
fflush(stdout);
return 0;
}
int main(int argc, char* argv[]) {
if (argc < 2) {
printf("usage: %s [url ...]\n", sofname);
return 1;
}
CURL* curl = curl_easy_init();
if (!curl) {
perror("curlを初期設置に失敗。");
return -1;
}
for (int i = 1; i < argc; i++) {
const char* url = argv[i];
filename = basename((char*)url);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
FILE* file = fopen(filename, "wb");
if (!file) {
curl_easy_cleanup(curl);
perror("ファイルを開けません。");
return -1;
}
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
CURLcode res = curl_easy_perform(curl);
fclose(file);
if (res != CURLE_OK) {
curl_easy_cleanup(curl);
fprintf(stderr, "ダウンロードに失敗: %s\n", curl_easy_strerror(res));
return -1;
}
printf("\n");
}
curl_easy_cleanup(curl);
printf("\nダウンロードに完了しました。\n");
return 0;
}