projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tighten formatting rules
[oweals/gnunet.git]
/
src
/
fs
/
fs_file_information.c
diff --git
a/src/fs/fs_file_information.c
b/src/fs/fs_file_information.c
index e9d74b9c0b443b603521792551c24841cbc957cd..28bbf12dd2f5e3447392aacc904b11d047ccf22b 100644
(file)
--- a/
src/fs/fs_file_information.c
+++ b/
src/fs/fs_file_information.c
@@
-11,7
+11,12
@@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-*/
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
/**
* @file fs/fs_file_information.c
/**
* @file fs/fs_file_information.c
@@
-44,6
+49,7
@@
GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s)
return s->serialization;
}
return s->serialization;
}
+
/**
* Obtain the filename from the file information structure.
*
/**
* Obtain the filename from the file information structure.
*
@@
-92,16
+98,14
@@
GNUNET_FS_file_information_set_filename (struct GNUNET_FS_FileInformation *s,
* @return publish structure entry for the file
*/
struct GNUNET_FS_FileInformation *
* @return publish structure entry for the file
*/
struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
- void *client_info,
- const char *filename,
- const struct GNUNET_FS_Uri
- *keywords,
- const struct
- GNUNET_CONTAINER_MetaData *meta,
- int do_index,
- const struct GNUNET_FS_BlockOptions
- *bo)
+GNUNET_FS_file_information_create_from_file (
+ struct GNUNET_FS_Handle *h,
+ void *client_info,
+ const char *filename,
+ const struct GNUNET_FS_Uri *keywords,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ int do_index,
+ const struct GNUNET_FS_BlockOptions *bo)
{
struct FileInfo *fi;
uint64_t fsize;
{
struct FileInfo *fi;
uint64_t fsize;
@@
-109,12
+113,9
@@
GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
const char *fn;
const char *ss;
const char *fn;
const char *ss;
-#if WINDOWS
- char fn_conv[MAX_PATH];
-#endif
-
/* FIXME: should include_symbolic_links be GNUNET_NO or GNUNET_YES here? */
/* FIXME: should include_symbolic_links be GNUNET_NO or GNUNET_YES here? */
- if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES))
+ if (GNUNET_OK !=
+ GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES))
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
return NULL;
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
return NULL;
@@
-126,37
+127,32
@@
GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
return NULL;
}
ret =
return NULL;
}
ret =
- GNUNET_FS_file_information_create_from_reader (h, client_info,
- fsize,
- &GNUNET_FS_data_reader_file_,
- fi, keywords, meta,
- do_index, bo);
+ GNUNET_FS_file_information_create_from_reader (h,
+ client_info,
+ fsize,
+ &GNUNET_FS_data_reader_file_,
+ fi,
+ keywords,
+ meta,
+ do_index,
+ bo);
if (ret == NULL)
return NULL;
ret->h = h;
ret->filename = GNUNET_strdup (filename);
if (ret == NULL)
return NULL;
ret->h = h;
ret->filename = GNUNET_strdup (filename);
-#if !WINDOWS
fn = filename;
fn = filename;
-#else
- plibc_conv_to_win_path (filename, fn_conv);
- fn = fn_conv;
-#endif
while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR)))
fn = ss + 1;
/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
* this should be changed to EXTRACTOR_METAFORMAT_UTF8
*/
while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR)))
fn = ss + 1;
/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
* this should be changed to EXTRACTOR_METAFORMAT_UTF8
*/
-#if !WINDOWS
-
GNUNET_CONTAINER_meta_data_insert (ret->meta,
"<gnunet>",
+ GNUNET_CONTAINER_meta_data_insert (ret->meta,
+
"<gnunet>",
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
EXTRACTOR_METAFORMAT_C_STRING,
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain", fn, strlen (fn) + 1);
-#else
- GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>",
- EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", fn, strlen (fn) + 1);
-#endif
+ "text/plain",
+ fn,
+ strlen (fn) + 1);
return ret;
}
return ret;
}
@@
-178,26
+174,31
@@
GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
* @return publish structure entry for the file
*/
struct GNUNET_FS_FileInformation *
* @return publish structure entry for the file
*/
struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
- void *client_info, uint64_t length,
- void *data,
- const struct GNUNET_FS_Uri
- *keywords,
- const struct
- GNUNET_CONTAINER_MetaData *meta,
- int do_index,
- const struct GNUNET_FS_BlockOptions
- *bo)
+GNUNET_FS_file_information_create_from_data (
+ struct GNUNET_FS_Handle *h,
+ void *client_info,
+ uint64_t length,
+ void *data,
+ const struct GNUNET_FS_Uri *keywords,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ int do_index,
+ const struct GNUNET_FS_BlockOptions *bo)
{
if (GNUNET_YES == do_index)
{
GNUNET_break (0);
return NULL;
}
{
if (GNUNET_YES == do_index)
{
GNUNET_break (0);
return NULL;
}
- return GNUNET_FS_file_information_create_from_reader (h, client_info, length,
- &GNUNET_FS_data_reader_copy_,
- data, keywords, meta,
- do_index, bo);
+ return GNUNET_FS_file_information_create_from_reader (h,
+ client_info,
+ length,
+ &
+ GNUNET_FS_data_reader_copy_,
+ data,
+ keywords,
+ meta,
+ do_index,
+ bo);
}
}
@@
-218,18
+219,16
@@
GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
* @return publish structure entry for the file
*/
struct GNUNET_FS_FileInformation *
* @return publish structure entry for the file
*/
struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
- void *client_info,
- uint64_t length,
- GNUNET_FS_DataReader reader,
- void *reader_cls,
- const struct GNUNET_FS_Uri
- *keywords,
- const struct
- GNUNET_CONTAINER_MetaData *meta,
- int do_index,
- const struct
- GNUNET_FS_BlockOptions *bo)
+GNUNET_FS_file_information_create_from_reader (
+ struct GNUNET_FS_Handle *h,
+ void *client_info,
+ uint64_t length,
+ GNUNET_FS_DataReader reader,
+ void *reader_cls,
+ const struct GNUNET_FS_Uri *keywords,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ int do_index,
+ const struct GNUNET_FS_BlockOptions *bo)
{
struct GNUNET_FS_FileInformation *ret;
{
struct GNUNET_FS_FileInformation *ret;
@@
-261,8
+260,8
@@
GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
* @return #GNUNET_YES if so, #GNUNET_NO if not
*/
int
* @return #GNUNET_YES if so, #GNUNET_NO if not
*/
int
-GNUNET_FS_file_information_is_directory (
const struct GNUNET_FS_FileInformation
-
*ent)
+GNUNET_FS_file_information_is_directory (
+
const struct GNUNET_FS_FileInformation
*ent)
{
return ent->is_directory;
}
{
return ent->is_directory;
}
@@
-281,16
+280,13
@@
GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInformation
* @return publish structure entry for the directory , NULL on error
*/
struct GNUNET_FS_FileInformation *
* @return publish structure entry for the directory , NULL on error
*/
struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
- void *client_info,
- const struct GNUNET_FS_Uri
- *keywords,
- const struct
- GNUNET_CONTAINER_MetaData
- *meta,
- const struct
- GNUNET_FS_BlockOptions *bo,
- const char *filename)
+GNUNET_FS_file_information_create_empty_directory (
+ struct GNUNET_FS_Handle *h,
+ void *client_info,
+ const struct GNUNET_FS_Uri *keywords,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_BlockOptions *bo,
+ const char *filename)
{
struct GNUNET_FS_FileInformation *ret;
{
struct GNUNET_FS_FileInformation *ret;
@@
-322,7
+318,8
@@
int
GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
struct GNUNET_FS_FileInformation *ent)
{
GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
struct GNUNET_FS_FileInformation *ent)
{
- if ((ent->dir != NULL) || (ent->next != NULL) || (dir->is_directory != GNUNET_YES))
+ if ((ent->dir != NULL) || (ent->next != NULL) ||
+ (dir->is_directory != GNUNET_YES))
{
GNUNET_break (0);
return GNUNET_SYSERR;
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@
-359,10
+356,13
@@
GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
no = GNUNET_NO;
if (GNUNET_OK !=
no = GNUNET_NO;
if (GNUNET_OK !=
- proc (proc_cls, dir,
- (dir->is_directory == GNUNET_YES) ? dir->data.dir.dir_size : dir->data.
- file.file_size,
- dir->meta, &dir->keywords, &dir->bo,
+ proc (proc_cls,
+ dir,
+ (dir->is_directory == GNUNET_YES) ? dir->data.dir.dir_size
+ : dir->data.file.file_size,
+ dir->meta,
+ &dir->keywords,
+ &dir->bo,
(dir->is_directory == GNUNET_YES) ? &no : &dir->data.file.do_index,
&dir->client_info))
return;
(dir->is_directory == GNUNET_YES) ? &no : &dir->data.file.do_index,
&dir->client_info))
return;
@@
-373,10
+373,15
@@
GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir,
{
no = GNUNET_NO;
if (GNUNET_OK !=
{
no = GNUNET_NO;
if (GNUNET_OK !=
- proc (proc_cls, pos,
- (pos->is_directory == GNUNET_YES) ? pos->data.dir.dir_size : pos->data.
- file.file_size, pos->meta, &pos->keywords, &pos->bo,
- (pos->is_directory == GNUNET_YES) ? &no : &pos->data.file.do_index,
+ proc (proc_cls,
+ pos,
+ (pos->is_directory == GNUNET_YES) ? pos->data.dir.dir_size
+ : pos->data.file.file_size,
+ pos->meta,
+ &pos->keywords,
+ &pos->bo,
+ (pos->is_directory == GNUNET_YES) ? &no
+ : &pos->data.file.do_index,
&pos->client_info))
break;
pos = pos->next;
&pos->client_info))
break;
pos = pos->next;
@@
-413,8
+418,14
@@
GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
}
/* clean up client-info */
if (NULL != cleaner)
}
/* clean up client-info */
if (NULL != cleaner)
- cleaner (cleaner_cls, fi, fi->data.dir.dir_size, fi->meta, &fi->keywords,
- &fi->bo, &no, &fi->client_info);
+ cleaner (cleaner_cls,
+ fi,
+ fi->data.dir.dir_size,
+ fi->meta,
+ &fi->keywords,
+ &fi->bo,
+ &no,
+ &fi->client_info);
GNUNET_free_non_null (fi->data.dir.dir_data);
}
else
GNUNET_free_non_null (fi->data.dir.dir_data);
}
else
@@
-427,19
+438,25
@@
GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
}
/* clean up client-info */
if (NULL != cleaner)
}
/* clean up client-info */
if (NULL != cleaner)
- cleaner (cleaner_cls, fi, fi->data.file.file_size, fi->meta,
- &fi->keywords, &fi->bo, &fi->data.file.do_index,
+ cleaner (cleaner_cls,
+ fi,
+ fi->data.file.file_size,
+ fi->meta,
+ &fi->keywords,
+ &fi->bo,
+ &fi->data.file.do_index,
&fi->client_info);
}
GNUNET_free_non_null (fi->filename);
GNUNET_free_non_null (fi->emsg);
if (NULL != fi->sks_uri)
&fi->client_info);
}
GNUNET_free_non_null (fi->filename);
GNUNET_free_non_null (fi->emsg);
if (NULL != fi->sks_uri)
-
GNUNET_FS_uri_destroy (fi->sks_uri);
+ GNUNET_FS_uri_destroy (fi->sks_uri);
if (NULL != fi->chk_uri)
if (NULL != fi->chk_uri)
-
GNUNET_FS_uri_destroy (fi->chk_uri);
+ GNUNET_FS_uri_destroy (fi->chk_uri);
/* clean up serialization */
/* clean up serialization */
- if ((NULL != fi->serialization) && (0 != UNLINK (fi->serialization)))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
+ if ((NULL != fi->serialization) && (0 != unlink (fi->serialization)))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+ "unlink",
fi->serialization);
if (NULL != fi->keywords)
GNUNET_FS_uri_destroy (fi->keywords);
fi->serialization);
if (NULL != fi->keywords)
GNUNET_FS_uri_destroy (fi->keywords);