d_openselect.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <grass/dbmi.h>
00003 #include "macros.h"
00004 #include "dbstubs.h"
00005 
00012 int
00013 db_d_open_select_cursor()
00014 {
00015     dbCursor *cursor;
00016     int stat;
00017     dbToken token;
00018     dbString select;
00019     int mode;
00020 
00021 /* get the arg(s) */
00022     db_init_string (&select);
00023     DB_RECV_STRING(&select);
00024     DB_RECV_INT(&mode);
00025 
00026 /* create a cursor */
00027     cursor = (dbCursor *) db_malloc (sizeof(dbCursor));
00028     if (cursor == NULL)
00029         return db_get_error_code();
00030     token = db_new_token ( (dbAddress) cursor);
00031     if (token < 0)
00032         return db_get_error_code();
00033     db_init_cursor(cursor);
00034 
00035 /* call the procedure */
00036     stat = db_driver_open_select_cursor (&select, cursor, mode);
00037     db_free_string (&select);
00038 
00039 /* send the return code */
00040     if (stat != DB_OK)
00041     {
00042         DB_SEND_FAILURE();
00043         return DB_OK;
00044     }
00045     DB_SEND_SUCCESS();
00046 
00047 /* mark this as a readonly cursor */
00048     db_set_cursor_type_readonly (cursor);
00049 
00050 /* add this cursor to the cursors managed by the driver state */
00051     db__add_cursor_to_driver_state(cursor);
00052 
00053 /* results */
00054     DB_SEND_TOKEN (&token);
00055     DB_SEND_INT (cursor->type);
00056     DB_SEND_INT (cursor->mode);
00057     DB_SEND_TABLE_DEFINITION (cursor->table);
00058     return DB_OK;
00059 }

Generated on Sun Apr 6 17:31:38 2008 for GRASS by  doxygen 1.5.5