Not logged in

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

Overview
Comment:clean up some warnings
Timelines: family | ancestors | 2.0.2-cleanup
Files: files | file ages | folders
SHA1:a38e87d7c8b12dab8269b6690f3d990c8b52c634
User & Date: brandon 2015-11-16 19:46:35
Context
2015-11-16
19:46
clean up some warnings Leaf check-in: a38e87d7c8 user: brandon tags: 2.0.2-cleanup
19:39
remove unnecessary module headers check-in: 929693a071 user: brandon tags: 2.0.2-cleanup
Changes

Changes to src/zdb.c.

1
2
3
4
5
6
7
8
9
10
..
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
...
248
249
250
251
252
253
254
255
256
257
258
259
/* zdb.c

   Copyright © 2013 Brandon Invergo <brandon@invergo.net>

   This file is part of zeptodb

   zeptodb is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
................................................................................
  void *db;
  if (verbose)
    printf ("Creating database %s\n", dbfile);
#ifdef HAVE_KYOTOCABINET
  char mmap_str[32];
  char buckets_str[32];
  char db_str[512] = "";
  if (strlen (dbfile) > sizeof (db_str) - sizeof (buckets_str) - sizeof (mmap_str))
    error (EXIT_FAILURE, errno, "Filename too long");
  strncat (db_str, dbfile, strlen (dbfile));
  snprintf (mmap_str, sizeof(mmap_str), "#msiz=%lu", mmap_size);
  if (strlen (dbfile) + strlen (mmap_str) < sizeof (db_str))
    strncat (db_str, mmap_str, 32);
  else
    error (EXIT_FAILURE, errno, "Filename too long");
................................................................................
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
}


|







 







|







 







|




1
2
3
4
5
6
7
8
9
10
..
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
...
248
249
250
251
252
253
254
255
256
257
258
259
/* zdb.c

   Copyright © 2013, 2015 Brandon Invergo <brandon@invergo.net>

   This file is part of zeptodb

   zeptodb is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
................................................................................
  void *db;
  if (verbose)
    printf ("Creating database %s\n", dbfile);
#ifdef HAVE_KYOTOCABINET
  char mmap_str[32];
  char buckets_str[32];
  char db_str[512] = "";
  if (strlen (dbfile) > (sizeof (db_str)-sizeof (buckets_str)-sizeof (mmap_str))
    error (EXIT_FAILURE, errno, "Filename too long");
  strncat (db_str, dbfile, strlen (dbfile));
  snprintf (mmap_str, sizeof(mmap_str), "#msiz=%lu", mmap_size);
  if (strlen (dbfile) + strlen (mmap_str) < sizeof (db_str))
    strncat (db_str, mmap_str, 32);
  else
    error (EXIT_FAILURE, errno, "Filename too long");
................................................................................
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.

39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

static char doc[] =
  "zdbc -- a tool for creating a DBM database";

static char args_doc[] = "DATABASE";

static struct argp_option options[] = {
  {"mmap-size", 'm', "NUM", 0, "The size (in bytes) of the memory-mapped region to use (default=1024)"},

  {"num-buckets", 'b', "NUM", 0, "The number of buckets to use (default=100)"},
  {"verbose", 'v', 0, 0, "Print extra information."},
  {0}
};

struct arguments
{
................................................................................
  else
    exit (EXIT_SUCCESS);
}

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

  arguments.verbose = false;
  arguments.mmap_size = 1024;
  arguments.num_buckets = 10;

  argp_parse (&argp, argc, argv, 0, 0, &arguments);







|
>







 







<







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
...
122
123
124
125
126
127
128

129
130
131
132
133
134
135

static char doc[] =
  "zdbc -- a tool for creating a DBM database";

static char args_doc[] = "DATABASE";

static struct argp_option options[] = {
  {"mmap-size", 'm', "NUM", 0, "The size (in bytes) of the memory-mapped region"
   " to use (default=1024)"},
  {"num-buckets", 'b', "NUM", 0, "The number of buckets to use (default=100)"},
  {"verbose", 'v', 0, 0, "Print extra information."},
  {0}
};

struct arguments
{
................................................................................
  else
    exit (EXIT_SUCCESS);
}

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

  struct arguments arguments;

  arguments.verbose = false;
  arguments.mmap_size = 1024;
  arguments.num_buckets = 10;

  argp_parse (&argp, argc, argv, 0, 0, &arguments);

Changes to src/zdbf.c.

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{
  /*
   * 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);







<

<







110
111
112
113
114
115
116

117

118
119
120
121
122
123
124
{
  /*
   * 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.

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{
  /*
   * 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;
  int res;
  struct arguments arguments;
  arguments.input_file = "-";
  arguments.reorg = false;
  arguments.verbose = false;

  argp_parse (&argp, argc, argv, 0, 0, &arguments);








|


<







 







<







105
106
107
108
109
110
111
112
113
114

115
116
117
118
119
120
121
...
149
150
151
152
153
154
155

156
157
158
159
160
161
162
{
  /*
   * 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;
  arguments.input_file = "-";
  arguments.reorg = false;
  arguments.verbose = false;

  argp_parse (&argp, argc, argv, 0, 0, &arguments);

Changes to src/zdbs.c.

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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);







<
<







 







|







104
105
106
107
108
109
110


111
112
113
114
115
116
117
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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);