diff options
author | Chuck Miller <shadowmil@gmail.com> | 2009-12-25 05:00:31 -0500 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-12-26 00:40:11 -0700 |
commit | 634aeeb9d58b01f9de6632a014a063ef0c4cf31e (patch) | |
tree | 70023dd2bcc12a3f96ec6f118d80e27411920531 /src/common/lock.c | |
parent | 113fcc4f0a7a0921e94bc415515dd4b393a29d60 (diff) | |
download | tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.tar.gz tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.tar.bz2 tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.tar.xz tmwa-634aeeb9d58b01f9de6632a014a063ef0c4cf31e.zip |
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
Diffstat (limited to 'src/common/lock.c')
-rw-r--r-- | src/common/lock.c | 54 |
1 files changed, 30 insertions, 24 deletions
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; + } } - |