《Node.js+MongoDB+AngularJS Web开发》源代码


书中源代码,nodejs-mongodb-angularjs-web-development-master
资源截图
代码片段和文件信息
/**
 * Copyright (c) 2006-2008 Apple Inc. All rights reserved.
 *
 * Licensed under the Apache License Version 2.0 (the “License“);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing software
 * distributed under the License is distributed on an “AS IS“ BASIS
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/

#include “base64.h“

#include 
#include 

// base64 tables
static char basis_64[] =
    “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/“;
static signed char index_64[128] =
{
    -1-1-1-1 -1-1-1-1 -1-1-1-1 -1-1-1-1
    -1-1-1-1 -1-1-1-1 -1-1-1-1 -1-1-1-1
    -1-1-1-1 -1-1-1-1 -1-1-162 -1-1-163
    52535455 56575859 6061-1-1 -1-1-1-1
    -1 0 1 2  3 4 5 6  7 8 910 11121314
    15161718 19202122 232425-1 -1-1-1-1
    -1262728 29303132 33343536 37383940
    41424344 45464748 495051-1 -1-1-1-1
};
#define CHAR64(c)  (((c) < 0 || (c) > 127) ? -1 : index_64[(c)])

// base64_encode    :    base64 encode
//
// value            :    data to encode
// vlen             :    length of data
// (result)         :    new char[] - c-str of result
char *base64_encode(const unsigned char *value int vlen)
{
    char *result = (char *)malloc((vlen * 4) / 3 + 5);
    char *out = result;
    while (vlen >= 3)
    {
        *out++ = basis_64[value[0] >> 2];
        *out++ = basis_64[((value[0] << 4) & 0x30) | (value[1] >> 4)];
        *out++ = basis_64[((value[1] << 2) & 0x3C) | (value[2] >> 6)];
        *out++ = basis_64[value[2] & 0x3F];
        value += 3;
        vlen -= 3;
    }
    if (vlen > 0)
    {
        *out++ = basis_64[value[0] >> 2];
        unsigned char oval = (value[0] << 4) & 0x30;
        if (vlen > 1) oval |= value[1] >> 4;
        *out++ = basis_64[oval];
        *out++ = (vlen < 2) ? ‘=‘ : basis_64[(value[1] << 2) & 0x3C];
        *out++ = ‘=‘;
    }
    *out = ‘‘;

    return result;
}

// base64_decode    :    base64 decode
//
// value            :    c-str to decode
// rlen             :    length of decoded result
// (result)         :    new unsigned char[] - decoded result
unsigned char *base64_decode(const char *value int *rlen)
{
    *rlen = 0;
    int c1 c2 c3 c4;

    int vlen = strlen(value);
    unsigned char *result =(unsigned char *)malloc((vlen * 3) / 4 + 1);
    unsigned char *out = result;

    while (1)
    {
        if (value[0]==0)
            return result;
        c1 = value[0];
        if (CHAR64(c1) == -1)
            goto base64_decode_error;;
        c2 = value[1];
        if (CHAR64(c2) == -1)
            goto base64_decode_error;;
     

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-master
     文件         143  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterREADME.md
     目录           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03
     目录           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03censorify
     文件           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03censorifyREADME.md
     文件         571  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03censorifycensortext.js
     文件         204  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03censorifypackage.json
     文件         369  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03censorifypublish_package.json
     目录           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03
eadwords
     目录           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03
eadwords
ode_modules
     目录           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03
eadwords
ode_modulescensorify
     文件           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03
eadwords
ode_modulescensorifyREADME.md
     文件         571  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03
eadwords
ode_modulescensorifycensortext.js
     文件         472  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03
eadwords
ode_modulescensorifypackage.json
     文件         369  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03
eadwords
ode_modulescensorifypublish_package.json
     文件         262  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch03
eadwords
eadwords.js
     目录           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch04
     文件         353  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch04callback_chain.js
     文件         469  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch04callback_closure.js
     文件         694  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch04callback_parameter.js
     文件         933  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch04emmiter_listener.js
     文件         415  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch04
exttick.js
     文件         288  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch04simple_interval.js
     文件         374  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch04simple_timer.js
     目录           0  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch05
     文件         248  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch05uffer_concat.js
     文件         730  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch05uffer_copy.js
     文件         376  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch05uffer_read.js
     文件         272  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch05uffer_slice.js
     文件         218  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch05uffer_write.js
     文件        1201  2014-11-10 22:12  nodejs-mongodb-angularjs-web-development-masterch05uffered_data.js
............此处省略2566个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)