Annotation of sbbs/src/sbbs3/js_xtrn_area.c, revision 1.1.1.2

1.1       root        1: /* js_xtrn_area.c */
                      2: 
                      3: /* Synchronet JavaScript "External Program Area" Object */
                      4: 
1.1.1.2 ! root        5: /* $Id: js_xtrn_area.c,v 1.27 2009/03/20 00:39:46 rswindell Exp $ */
1.1       root        6: 
                      7: /****************************************************************************
                      8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
                      9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
                     10:  *                                                                                                                                                     *
1.1.1.2 ! root       11:  * Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html         *
1.1       root       12:  *                                                                                                                                                     *
                     13:  * This program is free software; you can redistribute it and/or                       *
                     14:  * modify it under the terms of the GNU General Public License                         *
                     15:  * as published by the Free Software Foundation; either version 2                      *
                     16:  * of the License, or (at your option) any later version.                                      *
                     17:  * See the GNU General Public License for more details: gpl.txt or                     *
                     18:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
                     19:  *                                                                                                                                                     *
                     20:  * Anonymous FTP access to the most recent released source is available at     *
                     21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
                     22:  *                                                                                                                                                     *
                     23:  * Anonymous CVS access to the development source and modification history     *
                     24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
                     25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
                     26:  *     (just hit return, no password is necessary)                                                     *
                     27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
                     28:  *                                                                                                                                                     *
                     29:  * For Synchronet coding style and modification guidelines, see                                *
                     30:  * http://www.synchro.net/source.html                                                                          *
                     31:  *                                                                                                                                                     *
                     32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
                     33:  * format) via e-mail to [email protected]                                                                      *
                     34:  *                                                                                                                                                     *
                     35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
                     36:  ****************************************************************************/
                     37: 
                     38: #include "sbbs.h"
                     39: 
                     40: #ifdef JAVASCRIPT
                     41: 
                     42: #ifdef BUILD_JSDOCS
                     43: 
                     44: static char* xtrn_sec_prop_desc[] = {
                     45: 
                     46:         "index into sec_list array (or -1 if not in index) <i>(introduced in v3.12)</i>"
                     47:        ,"unique number for this external program section"
                     48:        ,"external program section internal code"
                     49:        ,"external program section name"
                     50:        ,"external program section access requirements"
1.1.1.2 ! root       51:        ,"user has sufficient access to enter this section <i>(introduced in v3.15)</i>"
1.1       root       52:        ,NULL
                     53: };
                     54: 
                     55: static char* xtrn_prog_prop_desc[] = {
                     56: 
                     57:         "index into prog_list array (or -1 if not in index) <i>(introduced in v3.12)</i>"
                     58:        ,"program number"
                     59:        ,"program section index <i>(introduced in v3.12)</i>"
                     60:        ,"program section number"
                     61:        ,"program section internal code <i>(introduced in v3.12)</i>"
                     62:        ,"internal code"
                     63:        ,"name"
                     64:        ,"command-line"
                     65:        ,"clean-up command-line"
                     66:        ,"startup directory"
                     67:        ,"access requirements"
                     68:        ,"execution requirements"
                     69:        ,"toggle options (bitfield)"
                     70:        ,"drop file type"
                     71:        ,"event type (0=none)"
                     72:        ,"extra time given to users running this program"
                     73:        ,"maximum time allowed in program"
                     74:        ,"execution cost (credits to run this program)"
                     75:        /* Insert here */
1.1.1.2 ! root       76:        ,"user has sufficient access to see this program"
1.1       root       77:        ,"user has sufficient access to run this program"
                     78:        ,NULL
                     79: };
                     80: 
                     81: static char* event_prop_desc[] = {
                     82: 
                     83:         "command-line"
                     84:        ,"startup directory"
                     85:        ,"node number"
                     86:        ,"time to execute"
                     87:        ,"frequency to execute"
                     88:        ,"days of week to execute (bitfield)"
                     89:        ,"days of month to execute (bitfield)"
                     90:        ,"date/time last run (in time_t format)"
                     91:        ,"toggle options (bitfield)"
                     92:        ,NULL
                     93: };
                     94: 
                     95: static char* xedit_prop_desc[] = {
                     96: 
                     97:         "name"
                     98:        ,"command-line"
                     99:        ,"access requirements"
                    100:        ,"toggle options (bitfield)"
                    101:        ,"drop file type"
                    102:        ,NULL
                    103: };
                    104: 
                    105: #endif
                    106: 
                    107: BOOL DLLCALL js_CreateXtrnProgProperties(JSContext* cx, JSObject* obj, xtrn_t* xtrn)
                    108: {
                    109:        JSString* js_str;
                    110: 
                    111:        if((js_str=JS_NewStringCopyZ(cx, xtrn->code))==NULL)
                    112:                return(FALSE);
                    113:        if(!JS_DefineProperty(cx, obj, "code", STRING_TO_JSVAL(js_str)
                    114:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    115:                return(FALSE);
                    116: 
                    117:        if((js_str=JS_NewStringCopyZ(cx, xtrn->name))==NULL)
                    118:                return(FALSE);
                    119:        if(!JS_DefineProperty(cx, obj, "name", STRING_TO_JSVAL(js_str)
                    120:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    121:                return(FALSE);
                    122: 
                    123:        if((js_str=JS_NewStringCopyZ(cx, xtrn->cmd))==NULL)
                    124:                return(FALSE);
                    125:        if(!JS_DefineProperty(cx, obj, "cmd", STRING_TO_JSVAL(js_str)
                    126:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    127:                return(FALSE);
                    128: 
                    129:        if((js_str=JS_NewStringCopyZ(cx, xtrn->clean))==NULL)
                    130:                return(FALSE);
                    131:        if(!JS_DefineProperty(cx, obj, "clean_cmd", STRING_TO_JSVAL(js_str)
                    132:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    133:                return(FALSE);
                    134: 
                    135:        if((js_str=JS_NewStringCopyZ(cx, xtrn->path))==NULL)
                    136:                return(FALSE);
                    137:        if(!JS_DefineProperty(cx, obj, "startup_dir", STRING_TO_JSVAL(js_str)
                    138:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    139:                return(FALSE);
                    140: 
                    141:        if((js_str=JS_NewStringCopyZ(cx, xtrn->arstr))==NULL)
                    142:                return(FALSE);
                    143:        if(!JS_DefineProperty(cx, obj, "ars", STRING_TO_JSVAL(js_str)
                    144:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    145:                return(FALSE);
                    146: 
                    147:        if((js_str=JS_NewStringCopyZ(cx, xtrn->run_arstr))==NULL)
                    148:                return(FALSE);
                    149:        if(!JS_DefineProperty(cx, obj, "execution_ars", STRING_TO_JSVAL(js_str)
                    150:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    151:                return(FALSE);
                    152: 
                    153:        if(!JS_DefineProperty(cx, obj, "settings", INT_TO_JSVAL(xtrn->misc)
                    154:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    155:                return(FALSE);
                    156: 
                    157:        if(!JS_DefineProperty(cx, obj, "type", INT_TO_JSVAL(xtrn->type)
                    158:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    159:                return(FALSE);
                    160: 
                    161:        if(!JS_DefineProperty(cx, obj, "event", INT_TO_JSVAL(xtrn->event)
                    162:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    163:                return(FALSE);
                    164: 
                    165:        if(!JS_DefineProperty(cx, obj, "textra", INT_TO_JSVAL(xtrn->textra)
                    166:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    167:                return(FALSE);
                    168: 
                    169:        if(!JS_DefineProperty(cx, obj, "max_time", INT_TO_JSVAL(xtrn->maxtime)
                    170:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    171:                return(FALSE);
                    172: 
                    173:        if(!JS_DefineProperty(cx, obj, "cost", INT_TO_JSVAL(xtrn->cost)
                    174:                ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    175:                return(FALSE);
                    176: 
                    177: #ifdef BUILD_JSDOCS
                    178:        js_CreateArrayOfStrings(cx, obj, "_property_desc_list", xtrn_prog_prop_desc, JSPROP_READONLY);
                    179: #endif
                    180: 
                    181:        return(TRUE);
                    182: }
                    183: 
                    184: 
                    185: JSObject* DLLCALL js_CreateXtrnAreaObject(JSContext* cx, JSObject* parent, scfg_t* cfg
1.1.1.2 ! root      186:                                                                                  ,user_t* user, client_t* client)
1.1       root      187: {
                    188:        JSObject*       areaobj;
                    189:        JSObject*       allsec;
                    190:        JSObject*       allprog;
                    191:        JSObject*       secobj;
                    192:        JSObject*       progobj;
                    193:        JSObject*       eventobj;
                    194:        JSObject*       event_array;
                    195:        JSObject*       xeditobj;
                    196:        JSObject*       xedit_array;
                    197:        JSObject*       sec_list;
                    198:        JSObject*       prog_list;
                    199:        JSString*       js_str;
                    200:        jsval           val;
                    201:        jsuint          sec_index;
                    202:        jsuint          prog_index;
                    203:        uint            l,d;
                    204: 
                    205:        /* Return existing object if it's already been created */
                    206:        if(JS_GetProperty(cx,parent,"xtrn_area",&val) && val!=JSVAL_VOID)
                    207:                areaobj = JSVAL_TO_OBJECT(val);
                    208:        else
                    209:                areaobj = JS_DefineObject(cx, parent, "xtrn_area", NULL
                    210:                                                                        , NULL, JSPROP_ENUMERATE|JSPROP_READONLY);
                    211: 
                    212:        if(areaobj==NULL)
                    213:                return(NULL);
                    214: 
                    215: #ifdef BUILD_JSDOCS
                    216:        js_DescribeSyncObject(cx,areaobj,"External Program Areas",310);
                    217: #endif
                    218: 
                    219:        /* xtrn_area.sec[] */
                    220:        if((allsec=JS_NewObject(cx,NULL,NULL,areaobj))==NULL)
                    221:                return(NULL);
                    222: 
                    223:        val=OBJECT_TO_JSVAL(allsec);
                    224:        if(!JS_SetProperty(cx, areaobj, "sec", &val))
                    225:                return(NULL);
                    226: 
                    227:        /* xtrn_area.prog[] */
                    228:        if((allprog=JS_NewObject(cx,NULL,NULL,areaobj))==NULL)
                    229:                return(NULL);
                    230: 
                    231:        val=OBJECT_TO_JSVAL(allprog);
                    232:        if(!JS_SetProperty(cx, areaobj, "prog", &val))
                    233:                return(NULL);
                    234: 
                    235:        /* xtrn_area.sec_list[] */
                    236:        if((sec_list=JS_NewArrayObject(cx, 0, NULL))==NULL) 
                    237:                return(NULL);
                    238: 
                    239:        val=OBJECT_TO_JSVAL(sec_list);
                    240:        if(!JS_SetProperty(cx, areaobj, "sec_list", &val)) 
                    241:                return(NULL);
                    242: 
                    243:        for(l=0;l<cfg->total_xtrnsecs;l++) {
                    244: 
                    245:                if((secobj=JS_NewObject(cx, NULL, NULL, NULL))==NULL)
                    246:                        return(NULL);
                    247: 
                    248:                sec_index=-1;
1.1.1.2 ! root      249:                if(user==NULL || chk_ar(cfg,cfg->xtrnsec[l]->ar,user,client)) {
1.1       root      250: 
                    251:                        if(!JS_GetArrayLength(cx, sec_list, &sec_index))
                    252:                                return(NULL);
                    253: 
                    254:                        val=OBJECT_TO_JSVAL(secobj);
                    255:                        if(!JS_SetElement(cx, sec_list, sec_index, &val))
                    256:                                return(NULL);
                    257:                }
                    258: 
                    259:                /* Add as property (associative array element) */
                    260:                if(!JS_DefineProperty(cx, allsec, cfg->xtrnsec[l]->code, val
                    261:                        ,NULL,NULL,JSPROP_READONLY|JSPROP_ENUMERATE))
                    262:                        return(NULL);
                    263: 
                    264:                val=INT_TO_JSVAL(sec_index);
                    265:                if(!JS_SetProperty(cx, secobj, "index", &val))
                    266:                        return(NULL);
                    267: 
                    268:                val=INT_TO_JSVAL(l);
                    269:                if(!JS_SetProperty(cx, secobj, "number", &val))
                    270:                        return(NULL);
                    271: 
                    272:                if((js_str=JS_NewStringCopyZ(cx, cfg->xtrnsec[l]->code))==NULL)
                    273:                        return(NULL);
                    274:                val=STRING_TO_JSVAL(js_str);
                    275:                if(!JS_SetProperty(cx, secobj, "code", &val))
                    276:                        return(NULL);
                    277: 
                    278:                if((js_str=JS_NewStringCopyZ(cx, cfg->xtrnsec[l]->name))==NULL)
                    279:                        return(NULL);
                    280:                val=STRING_TO_JSVAL(js_str);
                    281:                if(!JS_SetProperty(cx, secobj, "name", &val))
                    282:                        return(NULL);
                    283: 
                    284:                if((js_str=JS_NewStringCopyZ(cx, cfg->xtrnsec[l]->arstr))==NULL)
                    285:                        return(NULL);
                    286:                val=STRING_TO_JSVAL(js_str);
                    287:                if(!JS_SetProperty(cx, secobj, "ars", &val))
                    288:                        return(NULL);
                    289: 
1.1.1.2 ! root      290:                if(user==NULL || chk_ar(cfg,cfg->xtrnsec[l]->ar,user,client))
        !           291:                        val=JSVAL_TRUE;
        !           292:                else
        !           293:                        val=JSVAL_FALSE;
        !           294:                if(!JS_SetProperty(cx, secobj, "can_access", &val))
        !           295:                        return(NULL);
        !           296: 
1.1       root      297:                /* prog_list[] */
                    298:                if((prog_list=JS_NewArrayObject(cx, 0, NULL))==NULL) 
                    299:                        return(NULL);
                    300: 
                    301:                val=OBJECT_TO_JSVAL(prog_list);
                    302:                if(!JS_SetProperty(cx, secobj, "prog_list", &val)) 
                    303:                        return(NULL);
                    304: 
                    305: #ifdef BUILD_JSDOCS
                    306:                js_DescribeSyncObject(cx,secobj,"Online Program (door) Sections (current user has access to)",310);
                    307: #endif
                    308: 
                    309:                for(d=0;d<cfg->total_xtrns;d++) {
                    310:                        if(cfg->xtrn[d]->sec!=l)
                    311:                                continue;
                    312: 
                    313:                        if((progobj=JS_NewObject(cx, NULL, NULL, NULL))==NULL)
                    314:                                return(NULL);
                    315: 
                    316:                        prog_index=-1;
1.1.1.2 ! root      317:                        if((user==NULL || chk_ar(cfg,cfg->xtrn[d]->ar,user,client))
1.1       root      318:                                && !(cfg->xtrn[d]->event && cfg->xtrn[d]->misc&EVENTONLY)) {
                    319: 
                    320:                                if(!JS_GetArrayLength(cx, prog_list, &prog_index))
                    321:                                        return(NULL);                                                   
                    322: 
                    323:                                val=OBJECT_TO_JSVAL(progobj);
                    324:                                if(!JS_SetElement(cx, prog_list, prog_index, &val))
                    325:                                        return(NULL);
                    326:                        }
                    327: 
                    328:                        /* Add as property (associative array element) */
                    329:                        if(!JS_DefineProperty(cx, allprog, cfg->xtrn[d]->code, val
                    330:                                ,NULL,NULL,JSPROP_READONLY|JSPROP_ENUMERATE))
                    331:                                return(NULL);
                    332: 
                    333:                        val=INT_TO_JSVAL(prog_index);
                    334:                        if(!JS_SetProperty(cx, progobj, "index", &val))
                    335:                                return(NULL);
                    336: 
                    337:                        val=INT_TO_JSVAL(d);
                    338:                        if(!JS_SetProperty(cx, progobj, "number", &val))
                    339:                                return(NULL);
                    340: 
                    341:                        val=INT_TO_JSVAL(sec_index);
                    342:                        if(!JS_SetProperty(cx, progobj, "sec_index", &val))
                    343:                                return(NULL);
                    344: 
                    345:                        val=INT_TO_JSVAL(l);
                    346:                        if(!JS_SetProperty(cx, progobj, "sec_number", &val))
                    347:                                return(NULL);
                    348: 
                    349:                        val=STRING_TO_JSVAL(JS_NewStringCopyZ(cx,cfg->xtrnsec[l]->code));
                    350:                        if(!JS_SetProperty(cx, progobj, "sec_code", &val))
                    351:                                return(NULL);
                    352: 
                    353:                        if(!js_CreateXtrnProgProperties(cx, progobj, cfg->xtrn[d]))
                    354:                                return(NULL);
                    355: 
1.1.1.2 ! root      356:                        if(user==NULL || chk_ar(cfg,cfg->xtrn[d]->ar,user,client))
        !           357:                                val=JSVAL_TRUE;
        !           358:                        else
        !           359:                                val=JSVAL_FALSE;
        !           360:                        if(!JS_SetProperty(cx, progobj, "can_access", &val))
        !           361:                                return(NULL);
        !           362: 
        !           363:                        if(user==NULL || chk_ar(cfg,cfg->xtrn[d]->run_ar,user,client))
1.1       root      364:                                val=JSVAL_TRUE;
                    365:                        else
                    366:                                val=JSVAL_FALSE;
                    367:                        if(!JS_SetProperty(cx, progobj, "can_run", &val))
                    368:                                return(NULL);
                    369: 
                    370: #ifdef BUILD_JSDOCS
                    371:                        js_DescribeSyncObject(cx,progobj,"Online External Programs (doors) (current user has access to)",310);
                    372: #endif
                    373:                }
                    374: 
                    375: #ifdef BUILD_JSDOCS
                    376:                js_CreateArrayOfStrings(cx, secobj, "_property_desc_list", xtrn_sec_prop_desc, JSPROP_READONLY);
                    377: #endif
                    378: 
                    379:        }
                    380: 
                    381: #ifdef BUILD_JSDOCS
                    382: 
                    383:        js_DescribeSyncObject(cx,allsec,"Associative array of all external program sections (use internal code as index)",312);
                    384:        JS_DefineProperty(cx,allsec,"_dont_document",JSVAL_TRUE,NULL,NULL,JSPROP_READONLY);
                    385: 
                    386:        js_DescribeSyncObject(cx,allprog,"Associative array of all external programs (use internal code as index)",311);
                    387:        JS_DefineProperty(cx,allprog,"_dont_document",JSVAL_TRUE,NULL,NULL,JSPROP_READONLY);
                    388: #endif
                    389: 
                    390:        /* Create event property */
                    391:        if((event_array=JS_NewObject(cx,NULL,NULL,areaobj))==NULL)
                    392:                return(NULL);
                    393: 
                    394:        val=OBJECT_TO_JSVAL(event_array);
                    395:        if(!JS_SetProperty(cx, areaobj, "event", &val))
                    396:                return(NULL);
                    397: 
                    398:        for(l=0;l<cfg->total_events;l++) {
                    399: 
                    400:                if((eventobj=JS_NewObject(cx, NULL, NULL, NULL))==NULL)
                    401:                        return(NULL);
                    402: 
                    403:                if(!JS_DefineProperty(cx, event_array, cfg->event[l]->code, OBJECT_TO_JSVAL(eventobj)
                    404:                        ,NULL,NULL,JSPROP_READONLY|JSPROP_ENUMERATE))
                    405:                        return(NULL);
                    406: 
                    407:                if((js_str=JS_NewStringCopyZ(cx, cfg->event[l]->cmd))==NULL)
                    408:                        return(NULL);
                    409:                if(!JS_DefineProperty(cx, eventobj, "cmd", STRING_TO_JSVAL(js_str)
                    410:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    411:                        return(NULL);
                    412: 
                    413:                if((js_str=JS_NewStringCopyZ(cx, cfg->event[l]->dir))==NULL)
                    414:                        return(NULL);
                    415:                if(!JS_DefineProperty(cx, eventobj, "startup_dir", STRING_TO_JSVAL(js_str)
                    416:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    417:                        return(NULL);
                    418: 
                    419:                if(!JS_DefineProperty(cx, eventobj, "node_num", INT_TO_JSVAL(cfg->event[l]->node)
                    420:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    421:                        return(NULL);
                    422: 
                    423:                if(!JS_DefineProperty(cx, eventobj, "time", INT_TO_JSVAL(cfg->event[l]->time)
                    424:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    425:                        return(NULL);
                    426: 
                    427:                if(!JS_DefineProperty(cx, eventobj, "freq", INT_TO_JSVAL(cfg->event[l]->freq)
                    428:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    429:                        return(NULL);
                    430: 
                    431:                if(!JS_DefineProperty(cx, eventobj, "days", INT_TO_JSVAL(cfg->event[l]->days)
                    432:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    433:                        return(NULL);
                    434: 
                    435:                if(!JS_DefineProperty(cx, eventobj, "mdays", INT_TO_JSVAL(cfg->event[l]->mdays)
                    436:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    437:                        return(NULL);
                    438: 
1.1.1.2 ! root      439:                if(!JS_DefineProperty(cx, eventobj, "months", INT_TO_JSVAL(cfg->event[l]->months)
        !           440:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
        !           441:                        return(NULL);
        !           442: 
1.1       root      443:                if(!JS_DefineProperty(cx, eventobj, "last_run", INT_TO_JSVAL(cfg->event[l]->last)
                    444:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    445:                        return(NULL);
                    446: 
                    447:                if(!JS_DefineProperty(cx, eventobj, "settings", INT_TO_JSVAL(cfg->event[l]->misc)
                    448:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    449:                        return(NULL);
                    450: 
                    451: #ifdef BUILD_JSDOCS
                    452:                js_CreateArrayOfStrings(cx, eventobj, "_property_desc_list", event_prop_desc, JSPROP_READONLY);
                    453: #endif
                    454:        }
                    455: 
                    456: #ifdef BUILD_JSDOCS
                    457:        js_DescribeSyncObject(cx,event_array,"Associative array of all timed events (use internal code as index)",311);
                    458:        JS_DefineProperty(cx,event_array,"_assoc_array",JSVAL_TRUE,NULL,NULL,JSPROP_READONLY);
                    459: #endif
                    460: 
                    461:        /* Create editor property */
                    462:        if((xedit_array=JS_NewObject(cx,NULL,NULL,areaobj))==NULL)
                    463:                return(NULL);
                    464: 
                    465:        val=OBJECT_TO_JSVAL(xedit_array);
                    466:        if(!JS_SetProperty(cx, areaobj, "editor", &val))
                    467:                return(NULL);
                    468: 
                    469:        for(l=0;l<cfg->total_xedits;l++) {
                    470: 
1.1.1.2 ! root      471:                if(user!=NULL && !chk_ar(cfg,cfg->xedit[l]->ar,user,client))
1.1       root      472:                        continue;
                    473: 
                    474:                if((xeditobj=JS_NewObject(cx, NULL, NULL, NULL))==NULL)
                    475:                        return(NULL);
                    476: 
                    477:                if(!JS_DefineProperty(cx, xedit_array, cfg->xedit[l]->code, OBJECT_TO_JSVAL(xeditobj)
                    478:                        ,NULL,NULL,JSPROP_READONLY|JSPROP_ENUMERATE))
                    479:                        return(NULL);
                    480: 
                    481:                if((js_str=JS_NewStringCopyZ(cx, cfg->xedit[l]->name))==NULL)
                    482:                        return(NULL);
                    483:                if(!JS_DefineProperty(cx, xeditobj, "name", STRING_TO_JSVAL(js_str)
                    484:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    485:                        return(NULL);
                    486: 
                    487:                if((js_str=JS_NewStringCopyZ(cx, cfg->xedit[l]->rcmd))==NULL)
                    488:                        return(NULL);
                    489:                if(!JS_DefineProperty(cx, xeditobj, "cmd", STRING_TO_JSVAL(js_str)
                    490:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    491:                        return(NULL);
                    492: 
                    493:                if((js_str=JS_NewStringCopyZ(cx, cfg->xedit[l]->arstr))==NULL)
                    494:                        return(NULL);
                    495:                if(!JS_DefineProperty(cx, xeditobj, "ars", STRING_TO_JSVAL(js_str)
                    496:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    497:                        return(NULL);
                    498: 
                    499:                if(!JS_DefineProperty(cx, xeditobj, "settings", INT_TO_JSVAL(cfg->xedit[l]->misc)
                    500:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    501:                        return(NULL);
                    502: 
                    503:                if(!JS_DefineProperty(cx, xeditobj, "type", INT_TO_JSVAL(cfg->xedit[l]->type)
                    504:                        ,NULL,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))
                    505:                        return(NULL);
                    506: 
                    507: #ifdef BUILD_JSDOCS
                    508:                js_CreateArrayOfStrings(cx, xeditobj, "_property_desc_list", xedit_prop_desc, JSPROP_READONLY);
                    509: #endif
                    510:        }
                    511: 
                    512: #ifdef BUILD_JSDOCS
                    513:        js_DescribeSyncObject(cx,xedit_array,"Associative array of all external editors (use internal code as index)",311);
                    514:        JS_DefineProperty(cx,xedit_array,"_assoc_array",JSVAL_TRUE,NULL,NULL,JSPROP_READONLY);
                    515: #endif
                    516: 
                    517:        return(areaobj);
                    518: }
                    519: 
                    520: #endif /* JAVSCRIPT */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.