From 634aeeb9d58b01f9de6632a014a063ef0c4cf31e Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Fri, 25 Dec 2009 05:00:31 -0500 Subject: Used the "indent" C formatting program from GNU to do some clean ups The command options used was: -nbad -bap -sc -bl -blf -bli0 -cli4 -cbi0 -di5 -nbc -bls -ip2 -nut -ts4 -bap -i4 -sob -npsl --- src/common/lock.c | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'src/common/lock.c') diff --git a/src/common/lock.c b/src/common/lock.c index 42bbff0..7409baf 100644 --- a/src/common/lock.c +++ b/src/common/lock.c @@ -8,32 +8,38 @@ // (書き込みが終わるまで、旧ファイルを保管しておく) // 新しいファイルの書き込み開始 -FILE* lock_fopen(const char* filename,int *info) { - char newfile[512]; - FILE *fp; - int no = getpid(); +FILE *lock_fopen (const char *filename, int *info) +{ + char newfile[512]; + FILE *fp; + int no = getpid (); - // 安全なファイル名を得る(手抜き) - do { - sprintf(newfile,"%s_%d.tmp",filename,no++); - } while((fp = fopen_(newfile,"r")) && fclose_(fp)); - *info = --no; - return fopen_(newfile,"w"); + // 安全なファイル名を得る(手抜き) + do + { + sprintf (newfile, "%s_%d.tmp", filename, no++); + } + while ((fp = fopen_ (newfile, "r")) && fclose_ (fp)); + *info = --no; + return fopen_ (newfile, "w"); } // 旧ファイルを削除&新ファイルをリネーム -int lock_fclose(FILE *fp,const char* filename,int *info) { - int ret = 0; - char newfile[512]; - if(fp != NULL) { - ret = fclose_(fp); - sprintf(newfile,"%s_%d.tmp",filename,*info); - remove(filename); - // このタイミングで落ちると最悪。 - rename(newfile,filename); - return ret; - } else { - return 1; - } +int lock_fclose (FILE * fp, const char *filename, int *info) +{ + int ret = 0; + char newfile[512]; + if (fp != NULL) + { + ret = fclose_ (fp); + sprintf (newfile, "%s_%d.tmp", filename, *info); + remove (filename); + // このタイミングで落ちると最悪。 + rename (newfile, filename); + return ret; + } + else + { + return 1; + } } - -- cgit v1.2.3-70-g09d2