Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:clean up some warnings
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3143e34e5113413a136a7d3ac1a945a31fcb15d1
User & Date: brandon 2016-05-27 19:08:51
Context
2016-05-27
19:25
fix more annoying warnings check-in: 3b93189a99 user: brandon tags: trunk
19:08
clean up some warnings check-in: 3143e34e51 user: brandon tags: trunk
2016-05-26
21:16
add support for new database-opening flags check-in: 70910f4055 user: brandon tags: trunk
Changes

Changes to src/zdb.c.

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
246
247
248
249
250
251
252
253
254
255
256
257
  else
    error (EXIT_FAILURE, errno, "Filename too long");
  snprintf (buckets_str, sizeof(buckets_str), "#bnum=%lu", num_buckets);
  if (strlen (dbfile) + strlen (mmap_str) < sizeof (db_str))
    strncat (db_str, buckets_str, 32);
  else
    error (EXIT_FAILURE, errno, "Filename too long");
  db = zdb_open (db_str, ZDB_CREATOR, false);
#else
  db = zdb_open (dbfile, ZDB_CREATOR, false);
  GDBM_FILE database = (GDBM_FILE)db;
  gdbm_setopt (database, GDBM_SETMAXMAPSIZE, &mmap_size, sizeof (size_t));
  gdbm_setopt (database, GDBM_SETCACHESIZE, &num_buckets, sizeof (size_t));
#endif
  return db;
}

................................................................................
int
zdb_reorganize (void *db)
{
#ifdef HAVE_KYOTOCABINET
  return 0;
#else
  GDBM_FILE database = (GDBM_FILE)db;
  if (gdbm_reorganize (db))
    return 1;
  return 0;
#endif
}







|

|







 







|




40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
246
247
248
249
250
251
252
253
254
255
256
257
  else
    error (EXIT_FAILURE, errno, "Filename too long");
  snprintf (buckets_str, sizeof(buckets_str), "#bnum=%lu", num_buckets);
  if (strlen (dbfile) + strlen (mmap_str) < sizeof (db_str))
    strncat (db_str, buckets_str, 32);
  else
    error (EXIT_FAILURE, errno, "Filename too long");
  db = zdb_open (db_str, mode, false);
#else
  db = zdb_open (dbfile, mode, false);
  GDBM_FILE database = (GDBM_FILE)db;
  gdbm_setopt (database, GDBM_SETMAXMAPSIZE, &mmap_size, sizeof (size_t));
  gdbm_setopt (database, GDBM_SETCACHESIZE, &num_buckets, sizeof (size_t));
#endif
  return db;
}

................................................................................
int
zdb_reorganize (void *db)
{
#ifdef HAVE_KYOTOCABINET
  return 0;
#else
  GDBM_FILE database = (GDBM_FILE)db;
  if (gdbm_reorganize (database))
    return 1;
  return 0;
#endif
}

Changes to src/zdbc.c.

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
  else
    exit (EXIT_SUCCESS);
}

int
main (int argc, char **argv)
{
  FILE *input;
  struct arguments arguments;
  int mode = ZDB_CREATOR;

  arguments.verbose = false;
  arguments.sync = false;
  arguments.no_lock = false;
#ifdef HAVE_GDBM







<







125
126
127
128
129
130
131

132
133
134
135
136
137
138
  else
    exit (EXIT_SUCCESS);
}

int
main (int argc, char **argv)
{

  struct arguments arguments;
  int mode = ZDB_CREATOR;

  arguments.verbose = false;
  arguments.sync = false;
  arguments.no_lock = false;
#ifdef HAVE_GDBM

Changes to src/zdbf.c.

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
{
  /*
   * This function fetches records from the database from queries
   * in a file object.
   */

  size_t linelen = 512;
  ssize_t chars_read;
  char *lineptr = (char *) malloc (linelen);
  char *value_str;
  char *key_str;
  size_t key_size;

  /* query the database for each line of input */
  while (getline (&lineptr, &linelen, input) != EOF)
    {
      key_size = strlen (lineptr);







<

<







114
115
116
117
118
119
120

121

122
123
124
125
126
127
128
{
  /*
   * This function fetches records from the database from queries
   * in a file object.
   */

  size_t linelen = 512;

  char *lineptr = (char *) malloc (linelen);

  char *key_str;
  size_t key_size;

  /* query the database for each line of input */
  while (getline (&lineptr, &linelen, input) != EOF)
    {
      key_size = strlen (lineptr);

Changes to src/zdbr.c.

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
{
  /*
   * This function removes records from the database from queries
   * in a file object.
   */

  size_t linelen = 512;
  size_t key_size, query_size;
  char *lineptr = (char *) malloc (linelen);
  char *key_str;
  int res;

  /* query the database for each line of input */
  while (getline (&lineptr, &linelen, input) != EOF)
    {
      key_size = strlen (lineptr);
      if (lineptr[key_size - 1] == '\n')
        key_size -= 1;
................................................................................
int
main (int argc, char **argv)
{
  void *database;
  FILE *input;
  struct arguments arguments;
  int mode = ZDB_WRITER;
  int res;

  arguments.verbose = false;
  arguments.sync = false;
  arguments.no_lock = false;
#ifdef HAVE_GDBM
  arguments.no_mmap = false;
#endif







|


<







 







<







110
111
112
113
114
115
116
117
118
119

120
121
122
123
124
125
126
...
156
157
158
159
160
161
162

163
164
165
166
167
168
169
{
  /*
   * This function removes records from the database from queries
   * in a file object.
   */

  size_t linelen = 512;
  size_t key_size;
  char *lineptr = (char *) malloc (linelen);
  char *key_str;


  /* query the database for each line of input */
  while (getline (&lineptr, &linelen, input) != EOF)
    {
      key_size = strlen (lineptr);
      if (lineptr[key_size - 1] == '\n')
        key_size -= 1;
................................................................................
int
main (int argc, char **argv)
{
  void *database;
  FILE *input;
  struct arguments arguments;
  int mode = ZDB_WRITER;


  arguments.verbose = false;
  arguments.sync = false;
  arguments.no_lock = false;
#ifdef HAVE_GDBM
  arguments.no_mmap = false;
#endif

Changes to src/zdbs.c.

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
addrecords (void *db, FILE *input, const char *delim, bool verbose)
{
  size_t linelen = 512;
  char *lineptr = (char *) malloc (linelen);
  char *linecpy;
  char *key_str, *value_str;
  size_t line_size, key_size, value_size;
  ssize_t chars_read = 0;
  int value_trimmed = 0;
  long int count = 1;

  /* add each line of the input to the database */
  while (getline (&lineptr, &linelen, input) != EOF)
    {
      line_size = strlen (lineptr);
      if (lineptr[line_size - 1] == '\n')
................................................................................
        {
          error (0, errno, "Invalid record format (key%svalue)", delim);
          continue;
        }
      value_size = strlen (value_str);
      key_size = strlen (key_str);
      if (verbose)
        printf ("%d: ", count);
      if (zdb_store (db, key_str, key_size, value_str, value_size, verbose))
        error (0, errno, "Could not store record in database: %s", key_str);
      count++;
      free (linecpy);
    }
  free (lineptr);
  return (0);







<
<







 







|







109
110
111
112
113
114
115


116
117
118
119
120
121
122
...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
addrecords (void *db, FILE *input, const char *delim, bool verbose)
{
  size_t linelen = 512;
  char *lineptr = (char *) malloc (linelen);
  char *linecpy;
  char *key_str, *value_str;
  size_t line_size, key_size, value_size;


  long int count = 1;

  /* add each line of the input to the database */
  while (getline (&lineptr, &linelen, input) != EOF)
    {
      line_size = strlen (lineptr);
      if (lineptr[line_size - 1] == '\n')
................................................................................
        {
          error (0, errno, "Invalid record format (key%svalue)", delim);
          continue;
        }
      value_size = strlen (value_str);
      key_size = strlen (key_str);
      if (verbose)
        printf ("%ld: ", count);
      if (zdb_store (db, key_str, key_size, value_str, value_size, verbose))
        error (0, errno, "Could not store record in database: %s", key_str);
      count++;
      free (linecpy);
    }
  free (lineptr);
  return (0);