file.c (d74a913b68131656f4e2dbd1a87d52d31fcfaa47) | file.c (38c7e4a631ce968b02e4a08944aabad9b57844e8) |
---|---|
1/*- 2 * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 25 unchanged lines hidden (view full) --- 34#include <dirent.h> 35#include <stdio.h> 36#include <string.h> 37 38#include "fetch.h" 39#include "common.h" 40 41FILE * | 1/*- 2 * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 25 unchanged lines hidden (view full) --- 34#include <dirent.h> 35#include <stdio.h> 36#include <string.h> 37 38#include "fetch.h" 39#include "common.h" 40 41FILE * |
42fetchXGetFile(struct url *u, struct url_stat *us, char *flags) | 42fetchXGetFile(struct url *u, struct url_stat *us, const char *flags) |
43{ 44 FILE *f; 45 46 if (us && fetchStatFile(u, us, flags) == -1) 47 return NULL; 48 49 f = fopen(u->doc, "r"); 50 --- 4 unchanged lines hidden (view full) --- 55 fclose(f); 56 _fetch_syserr(); 57 } 58 59 return f; 60} 61 62FILE * | 43{ 44 FILE *f; 45 46 if (us && fetchStatFile(u, us, flags) == -1) 47 return NULL; 48 49 f = fopen(u->doc, "r"); 50 --- 4 unchanged lines hidden (view full) --- 55 fclose(f); 56 _fetch_syserr(); 57 } 58 59 return f; 60} 61 62FILE * |
63fetchGetFile(struct url *u, char *flags) | 63fetchGetFile(struct url *u, const char *flags) |
64{ 65 return fetchXGetFile(u, NULL, flags); 66} 67 68FILE * | 64{ 65 return fetchXGetFile(u, NULL, flags); 66} 67 68FILE * |
69fetchPutFile(struct url *u, char *flags) | 69fetchPutFile(struct url *u, const char *flags) |
70{ 71 FILE *f; 72 73 if (CHECK_FLAG('a')) 74 f = fopen(u->doc, "a"); 75 else 76 f = fopen(u->doc, "w+"); 77 --- 4 unchanged lines hidden (view full) --- 82 fclose(f); 83 _fetch_syserr(); 84 } 85 86 return f; 87} 88 89static int | 70{ 71 FILE *f; 72 73 if (CHECK_FLAG('a')) 74 f = fopen(u->doc, "a"); 75 else 76 f = fopen(u->doc, "w+"); 77 --- 4 unchanged lines hidden (view full) --- 82 fclose(f); 83 _fetch_syserr(); 84 } 85 86 return f; 87} 88 89static int |
90_fetch_stat_file(char *fn, struct url_stat *us) | 90_fetch_stat_file(const char *fn, struct url_stat *us) |
91{ 92 struct stat sb; 93 94 us->size = -1; 95 us->atime = us->mtime = 0; 96 if (stat(fn, &sb) == -1) { 97 _fetch_syserr(); 98 return -1; 99 } 100 us->size = sb.st_size; 101 us->atime = sb.st_atime; 102 us->mtime = sb.st_mtime; 103 return 0; 104} 105 106int | 91{ 92 struct stat sb; 93 94 us->size = -1; 95 us->atime = us->mtime = 0; 96 if (stat(fn, &sb) == -1) { 97 _fetch_syserr(); 98 return -1; 99 } 100 us->size = sb.st_size; 101 us->atime = sb.st_atime; 102 us->mtime = sb.st_mtime; 103 return 0; 104} 105 106int |
107fetchStatFile(struct url *u, struct url_stat *us, char *flags) | 107fetchStatFile(struct url *u, struct url_stat *us, const char *flags) |
108{ 109 return _fetch_stat_file(u->doc, us); 110} 111 112struct url_ent * | 108{ 109 return _fetch_stat_file(u->doc, us); 110} 111 112struct url_ent * |
113fetchListFile(struct url *u, char *flags) | 113fetchListFile(struct url *u, const char *flags) |
114{ 115 DIR *dir; 116 struct dirent *de; 117 struct url_stat us; 118 struct url_ent *ue; 119 int size, len; 120 char fn[MAXPATHLEN], *p; 121 int l; --- 24 unchanged lines hidden --- | 114{ 115 DIR *dir; 116 struct dirent *de; 117 struct url_stat us; 118 struct url_ent *ue; 119 int size, len; 120 char fn[MAXPATHLEN], *p; 121 int l; --- 24 unchanged lines hidden --- |