// And this is the routine that sets up the array. static void setup_init_properties () { int ix = 0; BSTR scriptname = get_scriptname(); BSTR hostname = get_hostname(); // Init array so that all entrys are unused and init propset_info. memset(gbl_init_props, not_in_use, MAX_INIT_PROPERTIES * sizeof(init_property)); // DBPROPSET_DBINIT, main OLE DB init and auth properties. init_propset_info[oleinit_props].start = ix; init_propset_info[oleinit_props].no_of_props = 0; add_init_property("IntegratedSecurity", oleinit_props, DBPROP_AUTH_INTEGRATED, TRUE, VT_BSTR, FALSE, L"SSPI", NULL, ix); add_init_property("Password", oleinit_props, DBPROP_AUTH_PASSWORD, TRUE, VT_BSTR, TRUE, NULL, NULL, ix); add_init_property("Username", oleinit_props, DBPROP_AUTH_USERID, TRUE, VT_BSTR, TRUE, NULL, NULL, ix); add_init_property("Database", oleinit_props, DBPROP_INIT_CATALOG, TRUE, VT_BSTR, FALSE, L"tempdb", NULL, ix); add_init_property("Server", oleinit_props, DBPROP_INIT_DATASOURCE, TRUE, VT_BSTR, FALSE, L"(local)", NULL, ix); add_init_property("GeneralTimeout", oleinit_props, DBPROP_INIT_GENERALTIMEOUT, TRUE, VT_I4, FALSE, NULL, 0, ix); add_init_property("LCID", oleinit_props, DBPROP_INIT_LCID, TRUE, VT_I4, FALSE, NULL, GetUserDefaultLCID(), ix); add_init_property("Pooling", oleinit_props, DBPROP_INIT_OLEDBSERVICES, TRUE, VT_I4, FALSE, NULL, DBPROPVAL_OS_RESOURCEPOOLING, ix); add_init_property("Prompt", oleinit_props, DBPROP_INIT_PROMPT, TRUE, VT_I2, FALSE, NULL, DBPROMPT_NOPROMPT, ix); add_init_property("ConnectionString", oleinit_props, DBPROP_INIT_PROVIDERSTRING, TRUE, VT_BSTR, TRUE, NULL, NULL, ix); add_init_property("ConnectTimeout", oleinit_props, DBPROP_INIT_TIMEOUT, TRUE, VT_I4, FALSE, NULL, 15, ix); // DBPROPSET_SQLSERVERDBINIT, SQLOLEDB specific proprties. init_propset_info[ssinit_props].start = ix; init_propset_info[ssinit_props].no_of_props = 0; add_init_property("Appname", ssinit_props, SSPROP_INIT_APPNAME, TRUE, VT_BSTR, FALSE, scriptname, NULL, ix); add_init_property("Autotranslate", ssinit_props, SSPROP_INIT_AUTOTRANSLATE, TRUE, VT_BOOL, TRUE, NULL, NULL, ix); add_init_property("Language", ssinit_props, SSPROP_INIT_CURRENTLANGUAGE, TRUE, VT_BSTR, TRUE, NULL, NULL, ix); add_init_property("AttachFilename", ssinit_props, SSPROP_INIT_FILENAME, TRUE, VT_BSTR, TRUE, NULL, NULL, ix); add_init_property("NetworkAddress", ssinit_props, SSPROP_INIT_NETWORKADDRESS, TRUE, VT_BSTR, TRUE, NULL, NULL, ix); add_init_property("Netlib", ssinit_props, SSPROP_INIT_NETWORKLIBRARY, TRUE, VT_BSTR, TRUE, NULL, NULL, ix); add_init_property("PacketSize", ssinit_props, SSPROP_INIT_PACKETSIZE, TRUE, VT_I4, TRUE, NULL, NULL, ix); add_init_property("UseProcForPrep", ssinit_props, SSPROP_INIT_USEPROCFORPREP, TRUE, VT_I4, FALSE, NULL, SSPROPVAL_USEPROCFORPREP_OFF, ix); add_init_property("Hostname", ssinit_props, SSPROP_INIT_WSID, TRUE, VT_BSTR, FALSE, hostname, NULL, ix); // Available first in 2.6. add_init_property("Encrypt", ssinit_props, SSPROP_INIT_ENCRYPT, TRUE, VT_BOOL, TRUE, NULL, NULL, ix); // The above properties are those that are in SQLOLEDB. no_of_ssprops_sqloledb = init_propset_info[ssinit_props].no_of_props; // These properties were added in SQL 2005. add_init_property("FailoverPartner", ssinit_props, SSPROP_INIT_FAILOVERPARTNER, FALSE, VT_BSTR, TRUE, NULL, NULL, ix); add_init_property("TrustServerCert", ssinit_props, SSPROP_INIT_TRUST_SERVER_CERTIFICATE, FALSE, VT_BOOL, TRUE, NULL, NULL, ix); add_init_property("OldPassword", ssinit_props, SSPROP_AUTH_OLD_PASSWORD, FALSE, VT_BSTR, TRUE, NULL, NULL, ix); no_of_ssprops_sqlncli = init_propset_info[ssinit_props].no_of_props; // These two were added with SQL 2008. add_init_property("ServerSPN", ssinit_props, SSPROP_INIT_SERVERSPN, FALSE, VT_BSTR, TRUE, NULL, NULL, ix); add_init_property("FailoverPartnerSPN", ssinit_props, SSPROP_INIT_FAILOVERPARTNERSPN, FALSE, VT_BSTR, TRUE, NULL, NULL, ix); no_of_ssprops_sqlncli10 = init_propset_info[ssinit_props].no_of_props; // And here is a single one that made into SQL 2012. add_init_property("ApplicationIntent", ssinit_props, SSPROP_INIT_APPLICATIONINTENT, FALSE, VT_BSTR, FALSE, L"ReadWrite", NULL, ix); no_of_ssprops_sqlncli11 = init_propset_info[ssinit_props].no_of_props; // DBPROPSET_DATASOURCE, data-source properties. init_propset_info[datasrc_props].start = ix; init_propset_info[datasrc_props].no_of_props = 0; add_init_property("MultiConnections", datasrc_props, DBPROP_MULTIPLECONNECTIONS, TRUE, VT_BOOL, FALSE, NULL, FALSE, ix); SysFreeString(scriptname); SysFreeString(hostname); }
static PT_THREAD(handle_script(struct httpd_state *s)) { /* Note script includes will attach a leading : to the filename and a trailing zero */ static char scriptname[MAX_SCRIPT_NAME_LENGTH+1],*pptr; static uint16_t filelength; PT_BEGIN(&s->scriptpt); filelength=s->file.len; while(s->file.len > 0) { /* Sanity check */ if (s->file.len > filelength) break; /* Check if we should start executing a script, flagged by %! */ if(httpd_fs_getchar(s->file.data) == ISO_percent && httpd_fs_getchar(s->file.data + 1) == ISO_bang) { /* Extract name, if starts with colon include file else call cgi */ s->scriptptr=get_scriptname(scriptname,s->file.data+2); s->scriptlen=s->file.len-(s->scriptptr-s->file.data); PRINTF("httpd: Handle script named %s\n",scriptname); if(scriptname[0] == ISO_colon) { if (httpd_fs_open(&scriptname[1], &s->file)) { PT_WAIT_THREAD(&s->scriptpt, send_file(s)); } } else { PT_WAIT_THREAD(&s->scriptpt,httpd_cgi(scriptname)(s, s->scriptptr)); } next_scriptstate(s); /* Reset the pointers and continue sending the current file. */ s->file.data = s->scriptptr; s->file.len = s->scriptlen; } else { /* Send file up to the next potential script */ if(s->file.len > uip_mss()) { s->len = uip_mss(); } else { s->len = s->file.len; } if(httpd_fs_getchar(s->file.data) == ISO_percent) { pptr = (char *) httpd_fs_strchr(s->file.data + 1, ISO_percent); } else { pptr = (char *) httpd_fs_strchr(s->file.data, ISO_percent); } if(pptr != NULL && pptr != s->file.data) { s->len = (int)(pptr - s->file.data); if(s->len >= uip_mss()) { s->len = uip_mss(); } } PRINTF("httpd: Sending %u bytes from 0x%04x\n",s->file.len,(unsigned int)s->file.data); PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s)); s->file.data += s->len; s->file.len -= s->len; } } PT_END(&s->scriptpt); }
/** * Parses shtml document for possible script includes. * Accepts includes of the form '%! scriptname'. * * If scriptname starts with ':' it is assumed to be an SSI, * otherwise it will be handled as CGI call. */ static PT_THREAD(handle_scripts(struct httpd_state *s)) { /* Note script includes will attach a leading : to the filename and a trailing zero */ static char scriptname[MAX_SCRIPT_NAME_LENGTH + 1], *pptr; // static uint16_t filelength; static int done, eof, eoc; PT_BEGIN(&s->scriptpt); eoc = eof = done = 0; /* Init cache (null-terminated)*/ load_cache(s); while (!done) { /* Assure we can read at least a '%!' sequence. */ // if (cache_size() < 2) { // reload_cache(s); // } /* Check if we should start executing a script, flagged by %! */ if (file_cache_ptr[0] == ISO_percent && file_cache_ptr[1] == ISO_bang) { /* Test if a whole line is in cache, otherwise reload cache. */ if (strchr(&file_cache_ptr[2], ISO_nl) == NULL) { reload_cache(s); } /* Extract name, if starts with colon include file else call cgi */ s->scriptptr = get_scriptname(scriptname, &file_cache_ptr[2]); // s->scriptlen = files[s->fd].len - (s->scriptptr - file_cache_ptr[0]); PRINTD("httpd: Handle script named %s\n", scriptname); /* Include scripts prefixed with ':' are SSI else CGI scripts */ if (scriptname[0] == ISO_colon) { #if WEBSERVER_CONF_INCLUDE PRINTD("IS SSI\n"); s->scriptfd = httpd_fs_open(&scriptname[1], HTTPD_FS_READ); /* Send script if open succeeded. */ if (s->scriptfd != -1) { s->sendfd = s->scriptfd; PT_WAIT_THREAD(&s->scriptpt, send_file(s)); } else { PRINTD("failed opening %s\n", scriptname); } httpd_fs_close(s->scriptfd); /*TODO dont print anything if file not found */ #endif /* Execute unprefixed scripts. */ } else { PRINTD("IS CGI\n"); #if WEBSERVER_CONF_CGI PT_WAIT_THREAD(&s->scriptpt, httpd_cgi(scriptname)(s, s->scriptptr)); #endif } skip_scriptline(s); file_cache_ptr = s->scriptptr; if (cache_size() < 2) { reload_cache(s); } if (cache_size() == 0) { done = 1; } } else { // no script /* get position of next percent character */ if (file_cache_ptr[0] == ISO_percent) { pptr = (char *) strchr(&file_cache_ptr[1], ISO_percent); } else { pptr = (char *) strchr(&file_cache_ptr[0], ISO_percent); } /* calc new length to send */ if (pptr == NULL) { /* no further percent sign found in cache. */ /* Send to end of cache */ s->sendlen = cache_len - (&file_cache_ptr[0] - &file_cache_array[0]); eoc = 1;// inidcates thate we need new cache } else { s->sendlen = (int) ((int) pptr - (int) &file_cache_ptr[0]); } if (s->sendlen > 0) { PRINTD("httpd: Sending %u bytes from 0x%04x\n", s->sendlen, (unsigned int) pptr); s->sendfd = s->fd; PT_WAIT_THREAD(&s->scriptpt, send_part_of_cache(s)); } /* Reload cache if it was marked as empty. */ if (eoc) { reload_cache(s); } /* If (reloaded) cache empty, stop sending */ if (cache_size() == 0) { done = 1; } } } PT_END(&s->scriptpt); }