frmt.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <string.h>
00018 #include <stdio.h>
00019 #include <grass/Vect.h>
00020 #include <grass/gis.h>
00021
00022
00023
00024
00025
00026
00027 int dig_read_frmt_ascii(FILE * dascii, struct Format_info *finfo)
00028 {
00029 char buff[20001], buf1[1024];
00030 char *ptr;
00031 int frmt = -1;
00032
00033 G_debug(3, "dig_read_frmt_ascii()");
00034
00035
00036 if (G_getl2(buff, 2000, dascii)) {
00037 G_chop(buff);
00038
00039 if (!(ptr = G_index(buff, ':'))) {
00040 G_warning("Vector format not recognized: %s", buff);
00041 return (-1);
00042 }
00043
00044 strcpy(buf1, buff);
00045 buf1[ptr - buff] = '\0';
00046
00047 ptr++;
00048 while (*ptr == ' ')
00049 ptr++;
00050
00051 if (strcmp(buf1, "FORMAT") == 0) {
00052 if (G_strcasecmp(ptr, "ogr") == 0) {
00053 frmt = GV_FORMAT_OGR;
00054 }
00055 }
00056 }
00057 if (frmt == -1) {
00058 G_warning("Vector format not recognized: %s", buff);
00059 return (-1);
00060 }
00061
00062
00063 #ifdef HAVE_OGR
00064 finfo->ogr.dsn = NULL;
00065 finfo->ogr.layer_name = NULL;
00066 #endif
00067
00068 while (G_getl2(buff, 2000, dascii)) {
00069 G_chop(buff);
00070
00071 if (!(ptr = G_index(buff, ':'))) {
00072 G_warning("Format definition is not correct: %s", buff);
00073 continue;
00074 }
00075
00076 strcpy(buf1, buff);
00077 buf1[ptr - buff] = '\0';
00078
00079 ptr++;
00080 while (*ptr == ' ')
00081 ptr++;
00082
00083 #ifdef HAVE_OGR
00084 if (strcmp(buf1, "DSN") == 0)
00085 finfo->ogr.dsn = G_store(ptr);
00086 if (strcmp(buf1, "LAYER") == 0)
00087 finfo->ogr.layer_name = G_store(ptr);
00088 #endif
00089 }
00090
00091 return frmt;
00092 }
00093
00094
00095
00096
00097
00098
00099
00100 int dig_write_frmt_ascii(FILE * dascii, struct Format_info *finfo, int format)
00101 {
00102 G_debug(3, "dig_write_frmt_ascii()");
00103
00104 G_fatal_error("Format not supported by dig_write_frmt_ascii()");
00105
00106 return 0;
00107 }