Fossil

Check-in [e94605b5]
Login

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

Overview
Comment:implemented /json/logout.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | json
Files: files | file ages | folders
SHA1: e94605b54fa0b7ad9d53de29e2609b879274bc17
User & Date: stephan 2011-09-16 19:27:27
Context
2011-09-16
21:39
restructured /json/cap output. check-in: 7e3902d1 user: stephan tags: json
19:27
implemented /json/logout. check-in: e94605b5 user: stephan tags: json
18:57
Merged trunk [693ab93b7d] to quiet down -Wall. Removed a trailing comma from an enum (-Wall mode). check-in: 98cdd410 user: stephan tags: json
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/json.c.

541
542
543
544
545
546
547


548
549

550








551
552
553
554
555
556
557
...
752
753
754
755
756
757
758












759
760
761
762
763
764
765
...
879
880
881
882
883
884
885

886
887
888
889
890
891
892
    goto cleanup; \
  }while(0)

  tmp = cson_value_new_string(MANIFEST_UUID,strlen(MANIFEST_UUID));
  SET("fossil");
 
  {/* "timestamp" */


    time_t const t = (time_t)time(0);
    struct tm gt = *gmtime(&t);

    cson_int_t jsTime = (cson_int_t)mktime(&gt);








    tmp = cson_value_new_integer(jsTime);
    SET("timestamp");
  }
  if( 0 != resultCode ){
    if( ! pMsg ) pMsg = json_err_str(resultCode);
    tmp = json_rc_string(resultCode);
    SET("resultCode");
................................................................................
    char * cookie = NULL;
    login_set_user_cookie(name, uid, &cookie);
    payload = cson_value_new_string( cookie, strlen(cookie) );
    free(cookie);
  }
  return payload;
}













/*
** Implementation of the /json/stat page/command.
**
*/
cson_value * json_page_stat(void){
  i64 t, fsize;
................................................................................
** /json (in CGI mode) or a subcommand of the json command in CLI mode
*/
static const JsonPageDef JsonPageDefs[] = {
/* please keep alphabetically sorted (case-insensitive) for maintenance reasons. */
{"cap", json_page_cap, 0},
{"HAI",json_page_version,0},
{"login",json_page_login,1/*should be >0. Only 0 for dev/testing purposes.*/},

{"stat",json_page_stat,0},
{"version",json_page_version,0},
{"wiki",json_page_wiki,0},
/* Last entry MUST have a NULL name. */
{NULL,NULL}
};








>
>


>
|
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>







 







>







541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
...
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
...
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
    goto cleanup; \
  }while(0)

  tmp = cson_value_new_string(MANIFEST_UUID,strlen(MANIFEST_UUID));
  SET("fossil");
 
  {/* "timestamp" */
    cson_int_t jsTime;
#if 1
    time_t const t = (time_t)time(0);
    struct tm gt = *gmtime(&t);
    gt.tm_isdst = -1;
    jsTime = (cson_int_t)mktime(&gt);
#else
    /* i'm not 100% sure that the above actually does what i expect,
       but we can't use the following because this function can be
       called in response to error handling if the db cannot be opened
       (or before that).
    */
    jsTime = (cson_int_t)db_int64(0, "SELECT strftime('%%s','now')");
#endif
    tmp = cson_value_new_integer(jsTime);
    SET("timestamp");
  }
  if( 0 != resultCode ){
    if( ! pMsg ) pMsg = json_err_str(resultCode);
    tmp = json_rc_string(resultCode);
    SET("resultCode");
................................................................................
    char * cookie = NULL;
    login_set_user_cookie(name, uid, &cookie);
    payload = cson_value_new_string( cookie, strlen(cookie) );
    free(cookie);
  }
  return payload;
}

/*
** Impl of /json/logout.
**
** Shortcomings: this never reports failure, as we don't go through
** the trouble of actually checking whether the user is logged in or
** not.
*/
cson_value * json_page_logout(void){
  login_clear_login_data();
  return NULL;
}

/*
** Implementation of the /json/stat page/command.
**
*/
cson_value * json_page_stat(void){
  i64 t, fsize;
................................................................................
** /json (in CGI mode) or a subcommand of the json command in CLI mode
*/
static const JsonPageDef JsonPageDefs[] = {
/* please keep alphabetically sorted (case-insensitive) for maintenance reasons. */
{"cap", json_page_cap, 0},
{"HAI",json_page_version,0},
{"login",json_page_login,1/*should be >0. Only 0 for dev/testing purposes.*/},
{"logout",json_page_logout,1/*should be >0. Only 0 for dev/testing purposes.*/},
{"stat",json_page_stat,0},
{"version",json_page_version,0},
{"wiki",json_page_wiki,0},
/* Last entry MUST have a NULL name. */
{NULL,NULL}
};