Wregistry

Check-in [f676e3ddbc]
Login

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

Overview
Comment:Fix error in WrDeleteSection() when trying to delete non-existent section.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f676e3ddbc0c6205fc5c7f25e9219377cc94c7bd
User & Date: wbp 2016-01-20 20:13:27
Context
2017-06-24
19:54
Add explicit return type to main() in test program. check-in: c0c5027c01 user: wbp tags: trunk
2016-01-20
20:13
Fix error in WrDeleteSection() when trying to delete non-existent section. check-in: f676e3ddbc user: wbp tags: trunk
2016-01-18
19:55
Add function WrDeleteSection(). check-in: 3965c0bcc6 user: wbp tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to testwreg.c.

25
26
27
28
29
30
31










32
33
34
35

    string = WrReadStringEntry("Settings", "section", "default value");
    printf("value read: %s\n", string);

    /* test of WrDeleteSection() */
    code = WrDeleteSection("Settings" );
    printf("WrDeleteSection() %s\n", code ? "succeeded" : "failed");










    string = WrReadStringEntry("Settings", "section", "no value");
    printf("value read: %s\n", string);
    exit(0);
}







>
>
>
>
>
>
>
>
>
>




25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

    string = WrReadStringEntry("Settings", "section", "default value");
    printf("value read: %s\n", string);

    /* test of WrDeleteSection() */
    code = WrDeleteSection("Settings" );
    printf("WrDeleteSection() %s\n", code ? "succeeded" : "failed");
    string = WrReadStringEntry("Settings", "section", "no value");
    printf("value read: %s\n", string);

    /* test of WrDeleteSection() when section doesn't exist */
    code = WrDeleteSection("Settings" );
    if (!code)
    {
        fprintf(stderr, "WrDeleteSection() failed\n");
        exit(1);
    }
    string = WrReadStringEntry("Settings", "section", "no value");
    printf("value read: %s\n", string);
    exit(0);
}

Changes to wregistry.c.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|  ---------------------------------------------------------
|  WrDeleteSection
|  WrOpen
|  WrReadStringEntry
|  WrWriteStringEntry
|  (insert_key_value)
|
|  Last modified:  18-Jan-2016  Wm. Parsons
|=============================================================================*/
#include <sqlite3.h>    	/* for sqlite3 functions */
#include <stdio.h>      	/* for snprintf() */
#include <stdlib.h>     	/* for getenv() */
#include <string.h>     	/* for strncpy() */

#include "wregistry.h"
................................................................................
 *============================================================================*/
{
    char sql[256];

    if (Db == NULL)
        return 0;

    snprintf(sql, sizeof sql, "drop table \"%s\"", section);
    return sqlite3_exec(Db, sql, NULL, NULL, NULL) == SQLITE_OK;
}

int
WrOpen(char const *app_key, char const *vendor_key)
/*=============================================================================
 *







|







 







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|  ---------------------------------------------------------
|  WrDeleteSection
|  WrOpen
|  WrReadStringEntry
|  WrWriteStringEntry
|  (insert_key_value)
|
|  Last modified:  20-Jan-2016  Wm. Parsons
|=============================================================================*/
#include <sqlite3.h>    	/* for sqlite3 functions */
#include <stdio.h>      	/* for snprintf() */
#include <stdlib.h>     	/* for getenv() */
#include <string.h>     	/* for strncpy() */

#include "wregistry.h"
................................................................................
 *============================================================================*/
{
    char sql[256];

    if (Db == NULL)
        return 0;

    snprintf(sql, sizeof sql, "drop table if exists \"%s\"", section);
    return sqlite3_exec(Db, sql, NULL, NULL, NULL) == SQLITE_OK;
}

int
WrOpen(char const *app_key, char const *vendor_key)
/*=============================================================================
 *