Fossil

Check-in [5a9e5679]
Login

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

Overview
Comment:Doc changes only
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | json
Files: files | file ages | folders
SHA1:5a9e567966c25502bbc77573263d4933a237ed8b
User & Date: stephan 2011-09-17 23:14:53
Context
2011-09-18
04:31
Factored out cson_cgi bits - now using fossil's CGI bits. Removed cson_cgi from cson_amalgamation (cuts its size considerably). Seems to still work, and this removes some discrepancies in how CGI/server modes are handled. check-in: 4cf96814 user: stephan tags: json
2011-09-17
23:14
Doc changes only check-in: 5a9e5679 user: stephan tags: json
20:25
added a missing assert() (Thanks, Joe M.) check-in: a67c6744 user: stephan tags: json
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/json.c.

11
12
13
14
15
16
17
18
19
20
21
22
23







24
25
26
27
28
29
30
...
342
343
344
345
346
347
348






349
350
351
352
353
354
355
...
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487

488
489
490
491
492
493
494
**
** Author contact information:
**   drh@hwaci.com
**   http://www.hwaci.com/drh/
**
*******************************************************************************
**  
** Code for the JSON/REST API.
**
** For notes regarding the public JSON interface, please see:
**
** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit
**







*/
#include "config.h"
#include "VERSION.h"
#include "json.h"
#include <assert.h>
#include <time.h>

................................................................................
/*
** Returns the ndx'th item in the "command path", where index 0 is the
** position of the "json" part of the path. Returns NULL if ndx is out
** of bounds or there is no "json" path element.
**
** In CLI mode the "path" is the list of arguments (skipping argv[0]).
** In server/CGI modes the path is taken from PATH_INFO.






*/
static char const * json_command_arg(unsigned char ndx){
  cson_array * ar = cson_value_get_array(
                      cson_cgi_getenv(&g.json.cgiCx,
                                      "a",
                                      FossilJsonKeys.commandPath));
  assert((NULL!=ar) && "Internal error. Was json_mode_bootstrap() called?");
................................................................................
#if 0
static unsigned int json_timestamp(){

}
#endif

/*
** Creates a new Fossil/REST response envelope skeleton.  It is owned
** by the caller, who must eventually free it using cson_value_free(),
** or add it to a cson container to transfer ownership. Returns NULL
** on error.
**
** If payload is not NULL and resultCode is 0 then it is set as the
** "payload" property of the returned object. If resultCode is non-0
** then this function will destroy payload if it is not NULL.

**
** pMsg is an optional message string (resultText) property of the
** response. If resultCode is non-0 and pMsg is NULL then
** json_err_str() is used to get the error string. The caller may
** provide his own or may use an empty string to suppress the
** resultText property.
**







|





>
>
>
>
>
>
>







 







>
>
>
>
>
>







 







|






|
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
...
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
**
** Author contact information:
**   drh@hwaci.com
**   http://www.hwaci.com/drh/
**
*******************************************************************************
**  
** Code for the JSON API.
**
** For notes regarding the public JSON interface, please see:
**
** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/edit
**
**
** Notable FIXMEs:
**
** - The overlap between cson_cgi and fossil needs to be gotten rid
** of because cson_cgi cannot get all the environment info it needs
** when fossil is running in server mode. The goal is to remove all
** of the cson_cgi bits.
*/
#include "config.h"
#include "VERSION.h"
#include "json.h"
#include <assert.h>
#include <time.h>

................................................................................
/*
** Returns the ndx'th item in the "command path", where index 0 is the
** position of the "json" part of the path. Returns NULL if ndx is out
** of bounds or there is no "json" path element.
**
** In CLI mode the "path" is the list of arguments (skipping argv[0]).
** In server/CGI modes the path is taken from PATH_INFO.
**
**
** Reminder to self: this breaks in CLI mode when called with an
** abbreviated name because we rely on the full name "json" here. The
** g object probably has the short form which we can use for our
** purposes, but i haven't yet looked for it.
*/
static char const * json_command_arg(unsigned char ndx){
  cson_array * ar = cson_value_get_array(
                      cson_cgi_getenv(&g.json.cgiCx,
                                      "a",
                                      FossilJsonKeys.commandPath));
  assert((NULL!=ar) && "Internal error. Was json_mode_bootstrap() called?");
................................................................................
#if 0
static unsigned int json_timestamp(){

}
#endif

/*
** Creates a new Fossil/JSON response envelope skeleton.  It is owned
** by the caller, who must eventually free it using cson_value_free(),
** or add it to a cson container to transfer ownership. Returns NULL
** on error.
**
** If payload is not NULL and resultCode is 0 then it is set as the
** "payload" property of the returned object. If resultCode is non-0
** then this function will destroy payload if it is not NULL. i.e.
** onwership of payload is transfered to this function.
**
** pMsg is an optional message string (resultText) property of the
** response. If resultCode is non-0 and pMsg is NULL then
** json_err_str() is used to get the error string. The caller may
** provide his own or may use an empty string to suppress the
** resultText property.
**