summaryrefslogtreecommitdiffstats
path: root/lib/libfetch/file.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-02-05 22:13:51 +0000
committerdes <des@FreeBSD.org>2002-02-05 22:13:51 +0000
commitec29926e4d7b6382c39d76ef0d75b6e476e13bfe (patch)
treecad86b96b05ec19f9c9eb4e26ddb8060f540c83d /lib/libfetch/file.c
parent98e34f92cb576f8096793659805327afe5ceaef3 (diff)
downloadFreeBSD-src-ec29926e4d7b6382c39d76ef0d75b6e476e13bfe.zip
FreeBSD-src-ec29926e4d7b6382c39d76ef0d75b6e476e13bfe.tar.gz
Reindent, and add parentheses to return statements. Some functions in
ftp.c and http.c now have exceedingly long lines due to deep nesting; this will be corrected by reorganizing the code in a later revision.
Diffstat (limited to 'lib/libfetch/file.c')
-rw-r--r--lib/libfetch/file.c152
1 files changed, 76 insertions, 76 deletions
diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c
index 73ff4d2..085f232 100644
--- a/lib/libfetch/file.c
+++ b/lib/libfetch/file.c
@@ -42,105 +42,105 @@ __FBSDID("$FreeBSD$");
FILE *
fetchXGetFile(struct url *u, struct url_stat *us, const char *flags)
{
- FILE *f;
-
- if (us && fetchStatFile(u, us, flags) == -1)
- return NULL;
-
- f = fopen(u->doc, "r");
-
- if (f == NULL)
- _fetch_syserr();
-
- if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
- fclose(f);
- _fetch_syserr();
- }
-
- return f;
+ FILE *f;
+
+ if (us && fetchStatFile(u, us, flags) == -1)
+ return (NULL);
+
+ f = fopen(u->doc, "r");
+
+ if (f == NULL)
+ _fetch_syserr();
+
+ if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
+ fclose(f);
+ _fetch_syserr();
+ }
+
+ return (f);
}
FILE *
fetchGetFile(struct url *u, const char *flags)
{
- return fetchXGetFile(u, NULL, flags);
+ return (fetchXGetFile(u, NULL, flags));
}
FILE *
fetchPutFile(struct url *u, const char *flags)
{
- FILE *f;
-
- if (CHECK_FLAG('a'))
- f = fopen(u->doc, "a");
- else
- f = fopen(u->doc, "w+");
-
- if (f == NULL)
- _fetch_syserr();
-
- if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
- fclose(f);
- _fetch_syserr();
- }
-
- return f;
+ FILE *f;
+
+ if (CHECK_FLAG('a'))
+ f = fopen(u->doc, "a");
+ else
+ f = fopen(u->doc, "w+");
+
+ if (f == NULL)
+ _fetch_syserr();
+
+ if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
+ fclose(f);
+ _fetch_syserr();
+ }
+
+ return (f);
}
static int
_fetch_stat_file(const char *fn, struct url_stat *us)
{
- struct stat sb;
-
- us->size = -1;
- us->atime = us->mtime = 0;
- if (stat(fn, &sb) == -1) {
- _fetch_syserr();
- return -1;
- }
- us->size = sb.st_size;
- us->atime = sb.st_atime;
- us->mtime = sb.st_mtime;
- return 0;
+ struct stat sb;
+
+ us->size = -1;
+ us->atime = us->mtime = 0;
+ if (stat(fn, &sb) == -1) {
+ _fetch_syserr();
+ return (-1);
+ }
+ us->size = sb.st_size;
+ us->atime = sb.st_atime;
+ us->mtime = sb.st_mtime;
+ return (0);
}
int
fetchStatFile(struct url *u, struct url_stat *us, const char *flags __unused)
{
- return _fetch_stat_file(u->doc, us);
+ return (_fetch_stat_file(u->doc, us));
}
struct url_ent *
fetchListFile(struct url *u, const char *flags __unused)
{
- DIR *dir;
- struct dirent *de;
- struct url_stat us;
- struct url_ent *ue;
- int size, len;
- char fn[PATH_MAX], *p;
- int l;
-
- if ((dir = opendir(u->doc)) == NULL) {
- _fetch_syserr();
- return NULL;
- }
-
- ue = NULL;
- strncpy(fn, u->doc, sizeof fn - 2);
- fn[sizeof fn - 2] = 0;
- strcat(fn, "/");
- p = strchr(fn, 0);
- l = sizeof fn - strlen(fn) - 1;
-
- while ((de = readdir(dir)) != NULL) {
- strncpy(p, de->d_name, l - 1);
- p[l - 1] = 0;
- if (_fetch_stat_file(fn, &us) == -1)
- /* should I return a partial result, or abort? */
- break;
- _fetch_add_entry(&ue, &size, &len, de->d_name, &us);
- }
-
- return ue;
+ struct dirent *de;
+ struct url_stat us;
+ struct url_ent *ue;
+ int size, len;
+ char fn[PATH_MAX], *p;
+ DIR *dir;
+ int l;
+
+ if ((dir = opendir(u->doc)) == NULL) {
+ _fetch_syserr();
+ return (NULL);
+ }
+
+ ue = NULL;
+ strncpy(fn, u->doc, sizeof fn - 2);
+ fn[sizeof fn - 2] = 0;
+ strcat(fn, "/");
+ p = strchr(fn, 0);
+ l = sizeof fn - strlen(fn) - 1;
+
+ while ((de = readdir(dir)) != NULL) {
+ strncpy(p, de->d_name, l - 1);
+ p[l - 1] = 0;
+ if (_fetch_stat_file(fn, &us) == -1)
+ /* should I return a partial result, or abort? */
+ break;
+ _fetch_add_entry(&ue, &size, &len, de->d_name, &us);
+ }
+
+ return (ue);
}
OpenPOWER on IntegriCloud