予定通り、日記をdiary.stricter.orgに移動しました。
花鳥諷詠 〜 たまゆらの四季を買った。
diary.stricter.org多分、日記のURIをhttp://diary.stricter.org/に変えます。
latest.cgilatest.cgiをC言語で書き直してみました。妙なデータを出力しているのを発見した場合は教えてくれると助かります。
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
void itoa_(int val,char *buf){
int a = 1,count = 0;
while(val >= a){
a = a*10;
count++;
}
if(!count){
count = 1;
}
*(buf+count) = '\0';
while(count--){
*(buf+count) = '0'+val%10;
val = val/10;
}
}
int main(void){
DIR *dir;
struct dirent *file;
int year = 0;
int month = 0;
char buf[64];
if((dir = opendir(".")) == NULL){
goto error;
}
while(1){
file = readdir(dir);
if(file == NULL){
break;
}
else if(year<atoi(file->d_name)){
year = atoi(file->d_name);
}
}
closedir(dir);
if(!year){
goto error;
}
itoa_(year,buf);
if((dir = opendir(buf)) == NULL){
goto error;
}
while(1){
file = readdir(dir);
if(file == NULL){
break;
}
else if(month<atoi(file->d_name)){
month = atoi(file->d_name);
}
}
closedir(dir);
if(!month){
goto error;
}
fputs("Status: 302 Found\n",stdout);
fputs("Location: http://stricter.org/other/diary/",stdout);
fputc('0'+year/1000%10,stdout);
fputc('0'+year/100%10,stdout);
fputc('0'+year/10%10,stdout);
fputc('0'+year%10,stdout);
fputc('/',stdout);
fputc('0'+month/10%10,stdout);
fputc('0'+month%10,stdout);
fputs("\n\n",stdout);
return 0;
error:
fputs("Content-type: text/plain; charset=utf-8\n\n",stdout);
fputs("Error.\n",stdout);
return 0;
}
printf関数を使いたくないからってfputs関数とかfputc関数とかを大量に使うのはどうなのかな、とは自分でも思っている。
#include <stdio.h>
struct point{
long x;
long y;
} point[10];
int main(void)
{
long x;
long y = 1;
long getf;
long goal = fgetc(stdin)-'0';
long num = 0;
while(fgetc(stdin) != '\n');
while(y != 11){
x = 1;
do{
getf = fgetc(stdin);
if('0' <= getf && getf <= '9'){
point[getf-'0'].x = x;
point[getf-'0'].y = y;
}
x++;
}while(getf != '\n');
y++;
}
while(num != goal){
if(point[num].x == point[num+1].x && point[num].y > point[num+1].y){
fputs("top\n",stdout);
}
else if(point[num].x == point[num+1].x && point[num].y < point[num+1].y){
fputs("bottom\n",stdout);
}
else if(point[num].y == point[num+1].y && point[num].x > point[num+1].x){
fputs("left\n",stdout);
}
else if(point[num].y == point[num+1].y && point[num].x < point[num+1].x){
fputs("right\n",stdout);
}
else{
fputs("Error!\n",stderr);
break;
}
num++;
}
return 0;
}
#include <stdio.h>
int main(void)
{
int count = 1;
while(count < 101){
if(count%3 && count%5){
printf("%d",count);
}
if(!(count%3)){
fputs("Fizz",stdout);
}
if(!(count%5)){
fputs("Buzz",stdout);
}
putchar('\n');
count++;
}
return 0;
}
リダイレクト忘れていそうで怖い。
リストのレンダリングが改善したように見えます。あと、速度が速くなりました。多分。
無断リンク禁止には従う必要は無いので、無断リンクを禁止しても何の意味も無い。出来るのは、リンクする時には連絡して欲しいというお願いをする程度だと思う。
"お願いだと何の意味も無い"と言う人も居るかも知れませんが、少なくとも私なら連絡すると思います。連絡する暇が無かったり面倒だったりしたらしないだろうけど。
あと、開発環境として、新しいコンピューターが欲しい(出来れば10万円くらいの)。でも、金が無い。どうしよう。