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