Fossil

Check-in [ea8d28ac]
Login

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

Overview
Comment:s/unlink/remove/ for Windows build (thanks again to Robert Engelhardt).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | json
Files: files | file ages | folders
SHA1: ea8d28acf3b33fb8cfa09170e54bcc1f36e6c403
User & Date: stephan 2011-09-16 13:34:15
Context
2011-09-16
13:39
more cson portability fixes, thanks to Robert Engelhardt and Joe Mistachkin. check-in: afd36e98 user: stephan tags: json
13:34
s/unlink/remove/ for Windows build (thanks again to Robert Engelhardt). check-in: ea8d28ac user: stephan tags: json
11:48
compile fix for mingw (thanks to Robert Engelhardt). check-in: 58d41564 user: stephan tags: json
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/cson_amalgamation.c.

5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282

5283
5284







5285
5286
5287
5288
5289
5290
5291
....
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
....
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
....
5501
5502
5503
5504
5505
5506
5507

5508
5509
5510
5511
5512
5513
5514
        names[i] = r->name[0] ? r->name : NULL;
    }
    names[i] = NULL;
    return names;
}
/* end file ./cson_session.c */
/* begin file ./cson_session_file.c */
#if !defined(_WIN32)
#  if !defined(_POSIX_VERSION)
#    define _POSIX_VERSION 200112L /* chmod(), unlink() */
#  endif
#  define ENABLE_POSIX_FILE_OPS 1
#else
#  define ENABLE_POSIX_FILE_OPS 0
#endif

#include <stdlib.h>
#include <string.h>
#include <assert.h>
#if ENABLE_POSIX_FILE_OPS

#  include <unistd.h> /* unlink() */
#  include <sys/stat.h> /* chmod() */







#endif

static int cson_session_file_load( cson_sessmgr * self, cson_value ** tgt, char const * id );
static int cson_session_file_save( cson_sessmgr * self, cson_value const * root, char const * id );
static int cson_session_file_remove( cson_sessmgr * self, char const * id );
static void cson_session_file_finalize( cson_sessmgr * self );

................................................................................
    fh = fopen( fname, "w" );
    if( ! fh ) return cson_rc.IOError;
#if ENABLE_POSIX_FILE_OPS
    chmod( fname, 0600 );
#endif
    rc = cson_output_FILE( root, fh, NULL );
    fclose( fh );
#if ENABLE_POSIX_FILE_OPS
    if( rc )
    {
        unlink( fname );
    }
#endif
    return rc;
}

void cson_session_file_finalize( cson_sessmgr * self )
{
    if( self && (self->api == &cson_sessmgr_api_file) )
    {
................................................................................
    char fname[BufSize];
    int rc;
    IMPL_DECL(cson_rc.ArgError);
    if( !id || !*id ) return cson_rc.ArgError;
    memset( fname, 0, BufSize );
    rc = cson_session_file_name( impl, id, fname, BufSize );
    if( 0 != rc ) return rc;
#if ENABLE_POSIX_FILE_OPS
    rc = unlink( fname );
#else
#  error "unlink not implemented for this platform."
#endif
    return (0==rc) ? 0 : cson_rc.IOError;
}


int cson_sessmgr_file( cson_sessmgr ** tgt, cson_object const * opt )
{
    int rc;
................................................................................
    error_clean:
    m->api->finalize( m );
    return rc;
}

#undef IMPL_DECL
#undef ENABLE_POSIX_FILE_OPS

/* end file ./cson_session_file.c */
/* begin file ./cson_sqlite3.c */
/** @file cson_sqlite3.c

This file contains the implementation code for the cson
sqlite3-to-JSON API.








|












>


>
>
>
>
>
>
>







 







<


|

<







 







<
|
<
<
<







 







>







5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
....
5410
5411
5412
5413
5414
5415
5416

5417
5418
5419
5420

5421
5422
5423
5424
5425
5426
5427
....
5441
5442
5443
5444
5445
5446
5447

5448



5449
5450
5451
5452
5453
5454
5455
....
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
        names[i] = r->name[0] ? r->name : NULL;
    }
    names[i] = NULL;
    return names;
}
/* end file ./cson_session.c */
/* begin file ./cson_session_file.c */
#if !defined(_WIN32) && !defined(_WIN64)
#  if !defined(_POSIX_VERSION)
#    define _POSIX_VERSION 200112L /* chmod(), unlink() */
#  endif
#  define ENABLE_POSIX_FILE_OPS 1
#else
#  define ENABLE_POSIX_FILE_OPS 0
#endif

#include <stdlib.h>
#include <string.h>
#include <assert.h>
#if ENABLE_POSIX_FILE_OPS
#  define UNLINK_FILE unlink
#  include <unistd.h> /* unlink() */
#  include <sys/stat.h> /* chmod() */
#else
/* http://msdn.microsoft.com/en-us/library/1c3tczd6(v=vs.80).aspx
  #  define UNLINK_FILE _unlink
  #  include <io.h>
*/
#  define UNLINK_FILE remove
#  include <stdio.h> /* remove(), _unlink() */
#endif

static int cson_session_file_load( cson_sessmgr * self, cson_value ** tgt, char const * id );
static int cson_session_file_save( cson_sessmgr * self, cson_value const * root, char const * id );
static int cson_session_file_remove( cson_sessmgr * self, char const * id );
static void cson_session_file_finalize( cson_sessmgr * self );

................................................................................
    fh = fopen( fname, "w" );
    if( ! fh ) return cson_rc.IOError;
#if ENABLE_POSIX_FILE_OPS
    chmod( fname, 0600 );
#endif
    rc = cson_output_FILE( root, fh, NULL );
    fclose( fh );

    if( rc )
    {
        UNLINK_FILE( fname );
    }

    return rc;
}

void cson_session_file_finalize( cson_sessmgr * self )
{
    if( self && (self->api == &cson_sessmgr_api_file) )
    {
................................................................................
    char fname[BufSize];
    int rc;
    IMPL_DECL(cson_rc.ArgError);
    if( !id || !*id ) return cson_rc.ArgError;
    memset( fname, 0, BufSize );
    rc = cson_session_file_name( impl, id, fname, BufSize );
    if( 0 != rc ) return rc;

    rc = UNLINK_FILE( fname );



    return (0==rc) ? 0 : cson_rc.IOError;
}


int cson_sessmgr_file( cson_sessmgr ** tgt, cson_object const * opt )
{
    int rc;
................................................................................
    error_clean:
    m->api->finalize( m );
    return rc;
}

#undef IMPL_DECL
#undef ENABLE_POSIX_FILE_OPS
#undef UNLINK_FILE
/* end file ./cson_session_file.c */
/* begin file ./cson_sqlite3.c */
/** @file cson_sqlite3.c

This file contains the implementation code for the cson
sqlite3-to-JSON API.