git-svn-id: file:///raid/svn-personal/okuu/trunk@11 7d206d2a-66c2-044b-96de-ba755a9b3ba8
This commit is contained in:
Nishi 2024-09-11 10:24:20 +00:00
parent 376c2bbac6
commit b39a1d1f9d
6 changed files with 152 additions and 136 deletions

15
.clang-format Normal file
View File

@ -0,0 +1,15 @@
---
# $Id$
Language: Cpp
UseTab: Always
TabWidth: 8
IndentWidth: 8
PointerAlignment: Left
ColumnLimit: 1024
AllowShortIfStatementsOnASingleLine: Always
AllowShortBlocksOnASingleLine: Never
AllowShortLoopsOnASingleLine: true
SpaceBeforeParens: Never
AlignEscapedNewlines: DontAlign
SortIncludes: false
AllowShortEnumsOnASingleLine: false

View File

@ -42,9 +42,7 @@ extern int ircport;
int ok_sock;
struct sockaddr_in ok_addr;
void ok_close(int sock){
close(sock);
}
void ok_close(int sock) { close(sock); }
void ok_bot_kill(int sig) {
fprintf(stderr, "Shutdown\n");
@ -60,9 +58,7 @@ bool ok_is_number(const char* str) {
return true;
}
char* ok_null(const char* str){
return str == NULL ? "(null)" : (char*)str;
}
char* ok_null(const char* str) { return str == NULL ? "(null)" : (char*)str; }
int namesort(const struct dirent** a_, const struct dirent** b_) {
const struct dirent* a = *a_;
@ -70,9 +66,7 @@ int namesort(const struct dirent** a_, const struct dirent** b_){
return atoi(a->d_name) - atoi(b->d_name);
}
int nodots(const struct dirent* d){
return (strcmp(d->d_name, "..") == 0 || strcmp(d->d_name, ".") == 0) ? 0 : 1;
}
int nodots(const struct dirent* d) { return (strcmp(d->d_name, "..") == 0 || strcmp(d->d_name, ".") == 0) ? 0 : 1; }
void ok_bot(void) {
if((ok_sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
@ -145,7 +139,9 @@ void ok_bot(void){
sprintf(construct, "%s/%s", nntppath, list[i]->d_name);
if(ok_news_read(construct) == 0) {
if(strcmp(news_entry.from, nntpfrom) != 0) {
char* tmp = ok_strcat3("PRIVMSG ", ircchan, " :\x03" "07[USENET] ~ ");
char* tmp = ok_strcat3("PRIVMSG ", ircchan,
" :\x03"
"07[USENET] ~ ");
char* temp = ok_strcat3(tmp, news_entry.from, "\x03 ");
free(tmp);
int j;
@ -222,7 +218,8 @@ void ok_bot(void){
int len = 0;
if(params != NULL) {
int i;
for(i = 0; params[i] != NULL; i++);
for(i = 0; params[i] != NULL; i++)
;
len = i;
}
if(prefix != NULL && len == 2) {

View File

@ -105,7 +105,8 @@ int ok_news_read(const char* path){
if(strcasecmp(ln, "Content-Type") == 0) {
ignore = false;
j++;
for(; ln[j] != 0 && (ln[j] == ' ' || ln[j] == '\t'); j++);
for(; ln[j] != 0 && (ln[j] == ' ' || ln[j] == '\t'); j++)
;
if(ln[j] != 0) {
char* v = ln + j;
int k;
@ -160,7 +161,8 @@ int ok_news_read(const char* path){
char* value = "";
ln[j] = 0;
j++;
for(; ln[j] != 0 && (ln[j] == '\t' || ln[j] == ' '); j++);
for(; ln[j] != 0 && (ln[j] == '\t' || ln[j] == ' '); j++)
;
if(ln[j] != 0) value = ln + j;
if(strcasecmp(key, "From") == 0) {
if(news_entry.from != NULL) free(news_entry.from);
@ -191,7 +193,8 @@ int ok_news_read(const char* path){
free(attr);
k++;
for(; value[k] != 0 && (value[k] == ' ' || value[k] == '\t'); k++);
for(; value[k] != 0 && (value[k] == ' ' || value[k] == '\t'); k++)
;
incr2 = k;
}
}

View File

@ -20,6 +20,4 @@ char* ok_strcat3(const char* a, const char* b, const char* c){
return str;
}
char* ok_strdup(const char* a){
return ok_strcat(a, "");
}
char* ok_strdup(const char* a) { return ok_strcat(a, ""); }

View File

@ -5,10 +5,13 @@ PWD = `pwd`
FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM)
.PHONY: all clean ./Bot
.PHONY: all format clean ./Bot
./Bot::
$(MAKE) -C $@ $(FLAGS)
format:
clang-format -i --verbose `find . -name "*.c" -or -name "*.h"`
clean:
$(MAKE) -C ./Bot $(FLAGS) clean