00001 #include <grass/gis.h> 00002 00003 int G_write_key_value_file ( 00004 char *file, 00005 struct Key_Value *kv, 00006 int *stat) 00007 { 00008 FILE *fd; 00009 00010 *stat = 0; 00011 fd = fopen(file, "w"); 00012 if (fd == NULL) 00013 *stat = -3; 00014 else if(G_fwrite_key_value(fd, kv) != 0 || fclose(fd) == EOF) 00015 *stat = -4; 00016 return (*stat != 0); 00017 } 00018 00019 struct Key_Value *G_read_key_value_file(char *file, int *stat) 00020 { 00021 FILE *fd; 00022 struct Key_Value *kv; 00023 00024 *stat = 0; 00025 fd = fopen (file, "r"); 00026 if (fd == NULL) 00027 { 00028 *stat = -1; 00029 return NULL; 00030 } 00031 kv = G_fread_key_value (fd); 00032 fclose (fd); 00033 if (kv == NULL) 00034 *stat = -2; 00035 return kv; 00036 }