Go to the documentation of this file.00001
00016 #include <grass/gis.h>
00017
00029 int G_write_key_value_file(const char *file,
00030 const struct Key_Value *kv, int *stat)
00031 {
00032 FILE *fd;
00033
00034 *stat = 0;
00035 fd = fopen(file, "w");
00036 if (fd == NULL)
00037 *stat = -3;
00038 else if (G_fwrite_key_value(fd, kv) != 0 || fclose(fd) == EOF)
00039 *stat = -4;
00040 return (*stat != 0);
00041 }
00042
00054 struct Key_Value *G_read_key_value_file(const char *file, int *stat)
00055 {
00056 FILE *fd;
00057 struct Key_Value *kv;
00058
00059 *stat = 0;
00060 fd = fopen(file, "r");
00061 if (fd == NULL) {
00062 *stat = -1;
00063 return NULL;
00064 }
00065 kv = G_fread_key_value(fd);
00066 fclose(fd);
00067 if (kv == NULL)
00068 *stat = -2;
00069 return kv;
00070 }