diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-02-17 17:25:57 +0000 |
---|---|---|
committer | <> | 2015-03-17 16:26:24 +0000 |
commit | 780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch) | |
tree | 598f8b9fa431b228d29897e798de4ac0c1d3d970 /docs/gsg/C/CoreCursorUsage.html | |
parent | 7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff) | |
download | berkeleydb-master.tar.gz |
Diffstat (limited to 'docs/gsg/C/CoreCursorUsage.html')
-rw-r--r-- | docs/gsg/C/CoreCursorUsage.html | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/docs/gsg/C/CoreCursorUsage.html b/docs/gsg/C/CoreCursorUsage.html index 0d681396..a04474d2 100644 --- a/docs/gsg/C/CoreCursorUsage.html +++ b/docs/gsg/C/CoreCursorUsage.html @@ -14,7 +14,7 @@ <body> <div xmlns="" class="navheader"> <div class="libver"> - <p>Library Version 11.2.5.3</p> + <p>Library Version 12.1.6.1</p> </div> <table width="100%" summary="Navigation header"> <tr> @@ -94,7 +94,7 @@ Remember that you can find the complete implementation of this application in: </p> - <pre class="programlisting"><span class="emphasis"><em>DB_INSTALL</em></span>/examples_c/getting_started</pre> + <pre class="programlisting"><span class="emphasis"><em>DB_INSTALL</em></span>/examples/c/getting_started</pre> <p> where <code class="literal"><span class="emphasis"><em>DB_INSTALL</em></span></code> is the location where you placed your DB distribution. @@ -126,7 +126,12 @@ int show_vendor_record(char *, DB *); </pre> </p> <a id="c_cursor11"></a> <pre class="programlisting">/* - * Displays all inventory items and the associated vendor record. + * Searches for an inventory item based on that item's name. The search is + * performed using the item name secondary database. Displays all + * inventory items that use the specified name, as well as the vendor + * associated with that inventory item. + * + * If no item name is provided, then all inventory items are displayed. */ int main(int argc, char *argv[]) @@ -176,7 +181,7 @@ main(int argc, char *argv[]) <a id="c_cursor12"></a> <pre class="programlisting">int show_all_records(STOCK_DBS *my_stock) { - DBC *cursorp; + DBC *inventory_cursorp; DBT key, data; char *the_vendor; int exit_value, ret; @@ -187,7 +192,7 @@ main(int argc, char *argv[]) /* Get a cursor to the itemname db */ my_stock->inventory_dbp->cursor(my_stock->inventory_dbp, NULL, - &cursorp, 0); + &inventory_cursorp, 0); /* * Iterate over the inventory database, from the first record @@ -195,7 +200,7 @@ main(int argc, char *argv[]) */ exit_value = 0; while ((ret = - cursorp->get(cursorp, &key, &data, DB_NEXT)) + inventory_cursorp->get(inventory_cursorp, &key, &data, DB_NEXT)) == 0) { the_vendor = show_inventory_item(data.data); @@ -207,7 +212,7 @@ main(int argc, char *argv[]) } /* Close the cursor */ - cursorp->close(cursorp); + inventory_cursorp->close(inventory_cursorp); return(exit_value); } </pre> <p> @@ -224,13 +229,18 @@ main(int argc, char *argv[]) </p> <a id="c_cursor13"></a> <pre class="programlisting">/* - * Shows an inventory item. + * Shows an inventory item. How we retrieve the inventory + * item values from the provided buffer is strictly dependent + * on the order that those items were originally stored in the + * DBT. See load_inventory_database in example_database_load + * for how this was done. */ char * show_inventory_item(void *vBuf) { float price; - int buf_pos, quantity; + int quantity; + size_t buf_pos; char *category, *name, *sku, *vendor_name; char *buf = (char *)vBuf; @@ -298,7 +308,7 @@ show_vendor_record(char *vendor_name, DB *vendor_dbp) /* Set the search key to the vendor's name */ key.data = vendor_name; - key.size = strlen(vendor_name) + 1; + key.size = (u_int32_t)strlen(vendor_name) + 1; /* * Make sure we use the memory we set aside for the VENDOR @@ -312,7 +322,7 @@ show_vendor_record(char *vendor_name, DB *vendor_dbp) data.flags = DB_DBT_USERMEM; /* Get the record */ - ret = vendor_dbp->get(vendor_dbp, 0, &key, &data, 0); + ret = vendor_dbp->get(vendor_dbp, NULL, &key, &data, 0); if (ret != 0) { vendor_dbp->err(vendor_dbp, ret, "Error searching for vendor: '%s'", vendor_name); |