format
git-svn-id: file:///raid/svn-personal/okuu/trunk@11 7d206d2a-66c2-044b-96de-ba755a9b3ba8
This commit is contained in:
parent
376c2bbac6
commit
b39a1d1f9d
15
.clang-format
Normal file
15
.clang-format
Normal 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
|
19
Bot/bot.c
19
Bot/bot.c
|
@ -42,9 +42,7 @@ extern int ircport;
|
||||||
int ok_sock;
|
int ok_sock;
|
||||||
struct sockaddr_in ok_addr;
|
struct sockaddr_in ok_addr;
|
||||||
|
|
||||||
void ok_close(int sock){
|
void ok_close(int sock) { close(sock); }
|
||||||
close(sock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ok_bot_kill(int sig) {
|
void ok_bot_kill(int sig) {
|
||||||
fprintf(stderr, "Shutdown\n");
|
fprintf(stderr, "Shutdown\n");
|
||||||
|
@ -60,9 +58,7 @@ bool ok_is_number(const char* str) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ok_null(const char* str){
|
char* ok_null(const char* str) { return str == NULL ? "(null)" : (char*)str; }
|
||||||
return str == NULL ? "(null)" : (char*)str;
|
|
||||||
}
|
|
||||||
|
|
||||||
int namesort(const struct dirent** a_, const struct dirent** b_) {
|
int namesort(const struct dirent** a_, const struct dirent** b_) {
|
||||||
const struct dirent* a = *a_;
|
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);
|
return atoi(a->d_name) - atoi(b->d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nodots(const struct dirent* d){
|
int nodots(const struct dirent* d) { return (strcmp(d->d_name, "..") == 0 || strcmp(d->d_name, ".") == 0) ? 0 : 1; }
|
||||||
return (strcmp(d->d_name, "..") == 0 || strcmp(d->d_name, ".") == 0) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ok_bot(void) {
|
void ok_bot(void) {
|
||||||
if((ok_sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
|
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);
|
sprintf(construct, "%s/%s", nntppath, list[i]->d_name);
|
||||||
if(ok_news_read(construct) == 0) {
|
if(ok_news_read(construct) == 0) {
|
||||||
if(strcmp(news_entry.from, nntpfrom) != 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 ");
|
char* temp = ok_strcat3(tmp, news_entry.from, "\x03 ");
|
||||||
free(tmp);
|
free(tmp);
|
||||||
int j;
|
int j;
|
||||||
|
@ -222,7 +218,8 @@ void ok_bot(void){
|
||||||
int len = 0;
|
int len = 0;
|
||||||
if(params != NULL) {
|
if(params != NULL) {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; params[i] != NULL; i++);
|
for(i = 0; params[i] != NULL; i++)
|
||||||
|
;
|
||||||
len = i;
|
len = i;
|
||||||
}
|
}
|
||||||
if(prefix != NULL && len == 2) {
|
if(prefix != NULL && len == 2) {
|
||||||
|
|
|
@ -105,7 +105,8 @@ int ok_news_read(const char* path){
|
||||||
if(strcasecmp(ln, "Content-Type") == 0) {
|
if(strcasecmp(ln, "Content-Type") == 0) {
|
||||||
ignore = false;
|
ignore = false;
|
||||||
j++;
|
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) {
|
if(ln[j] != 0) {
|
||||||
char* v = ln + j;
|
char* v = ln + j;
|
||||||
int k;
|
int k;
|
||||||
|
@ -160,7 +161,8 @@ int ok_news_read(const char* path){
|
||||||
char* value = "";
|
char* value = "";
|
||||||
ln[j] = 0;
|
ln[j] = 0;
|
||||||
j++;
|
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(ln[j] != 0) value = ln + j;
|
||||||
if(strcasecmp(key, "From") == 0) {
|
if(strcasecmp(key, "From") == 0) {
|
||||||
if(news_entry.from != NULL) free(news_entry.from);
|
if(news_entry.from != NULL) free(news_entry.from);
|
||||||
|
@ -191,7 +193,8 @@ int ok_news_read(const char* path){
|
||||||
|
|
||||||
free(attr);
|
free(attr);
|
||||||
k++;
|
k++;
|
||||||
for(; value[k] != 0 && (value[k] == ' ' || value[k] == '\t'); k++);
|
for(; value[k] != 0 && (value[k] == ' ' || value[k] == '\t'); k++)
|
||||||
|
;
|
||||||
incr2 = k;
|
incr2 = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,4 @@ char* ok_strcat3(const char* a, const char* b, const char* c){
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ok_strdup(const char* a){
|
char* ok_strdup(const char* a) { return ok_strcat(a, ""); }
|
||||||
return ok_strcat(a, "");
|
|
||||||
}
|
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -5,10 +5,13 @@ PWD = `pwd`
|
||||||
|
|
||||||
FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM)
|
FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM)
|
||||||
|
|
||||||
.PHONY: all clean ./Bot
|
.PHONY: all format clean ./Bot
|
||||||
|
|
||||||
./Bot::
|
./Bot::
|
||||||
$(MAKE) -C $@ $(FLAGS)
|
$(MAKE) -C $@ $(FLAGS)
|
||||||
|
|
||||||
|
format:
|
||||||
|
clang-format -i --verbose `find . -name "*.c" -or -name "*.h"`
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -C ./Bot $(FLAGS) clean
|
$(MAKE) -C ./Bot $(FLAGS) clean
|
||||||
|
|
Loading…
Reference in New Issue
Block a user