/* ** Name: WTSOpenUpLoad() - ** ** Description: ** ** Inputs: ** contentType ** session ** ** Outputs: ** ** Returns: ** GSTATUS : GSTAT_OK ** ** Exceptions: ** None ** ** Side Effects: ** None ** ** History: */ GSTATUS WTSOpenUpLoad( char *contentType, WTS_SESSION *session) { GSTATUS err; i4 length = STlength(MULTIPART); PWTS_UPLOAD load = NULL; char* bound; i4 blen; if (contentType != NULL && STscompare(contentType, length, MULTIPART, length) == 0) { session->status = UPLOAD; if ((err = GAlloc ((char**)&load, sizeof(WTS_UPLOAD), FALSE)) == GSTAT_OK) { session->load = load; bound = STindex (contentType, BOUNDARY, 0) + STlength(BOUNDARY); blen = STlength (bound); /* ** Allocate space for a start boundary and and en boundary ** each having the delimiters and null terminator. */ if (((err = GAlloc (&load->start, blen + 3, FALSE)) == GSTAT_OK) && ((err = GAlloc (&load->end, blen + 5, FALSE)) == GSTAT_OK)) { STcopy ("--",load->start); STlcopy (bound, load->start + 2, blen); STcopy (load->start, load->end); STcat (load->end, "--"); } load->state = US_BEGIN; } } else { session->status = NO_UPLOAD; session->load = NULL; } session->list = NULL; session->variable = NULL; session->vlen = 0; return(GSTAT_OK); }
/* ** Name: ParserOpenHex() - ** ** Description: ** ** Inputs: ** PPARSER_IN in ** PPARSER_OUT out ** ** Outputs: ** ** Returns: ** GSTATUS : GSTAT_OK ** ** Exceptions: ** None ** ** Side Effects: ** None ** ** History: */ GSTATUS ParserOpenHex ( PPARSER_IN in, PPARSER_OUT out) { GSTATUS err = GSTAT_OK; PVAR_PARSER_OUT pout; u_i4 length; u_i4 size; pout = (PVAR_PARSER_OUT) out; length = in->current - in->position; size = ((((pout->valuePos + length) / 32) + 1) * 32); err = GAlloc(&pout->value, size, TRUE); if (err == GSTAT_OK) { MECOPY_VAR_MACRO( in->buffer + in->position, length, pout->value + pout->valuePos); pout->valuePos += length; pout->HexProcessing = pout->valuePos++; pout->value[pout->HexProcessing] = EOS; } in->position = in->current + 1; return(err); }
/* ** Name: ParserGetName() - ** ** Description: ** ** Inputs: ** PPARSER_IN in ** PPARSER_OUT out ** ** Outputs: ** ** Returns: ** GSTATUS : GSTAT_OK ** ** Exceptions: ** None ** ** Side Effects: ** None ** ** History: */ GSTATUS ParserGetName ( PPARSER_IN in, PPARSER_OUT out) { GSTATUS err = GSTAT_OK; PVAR_PARSER_OUT pout; u_i4 length; u_i4 size; pout = (PVAR_PARSER_OUT) out; length = in->current - in->position; size = ((((pout->valuePos + length) / 32) + 1) * 32); err = GAlloc(&pout->name, size, FALSE); if (err == GSTAT_OK && pout->valuePos > 0) { MECOPY_VAR_MACRO(pout->value, pout->valuePos, pout->name); pout->namePos = pout->valuePos; pout->valuePos = 0; } MECOPY_VAR_MACRO(in->buffer + in->position, length, pout->name + pout->namePos); pout->namePos += length; in->position = in->current+1; return(err); }
int TXT_GetTextCountEnter( char *str ) { char *buf = (char*)GAlloc( strlen(str)+1 ), *ptr; int i=0,j=0; int count,ret=0,space=0; while( str[i]!='\0' ){ j=0; space=0; ptr = buf+i; while( str[i]!='\0' && str[i]!='\n' && !(str[i]=='\\'&&str[i+1]=='n') ){ if( ('!'<=str[i] && str[i]<='~') || ('�'<=str[i] && str[i]<='�') ){ i++; }else if( ' '==str[i] ){ i++; space++; }else{ ptr[j++] = str[i++]; ptr[j++] = str[i++]; } } if(str[i]=='\\'&&str[i+1]=='n') i++; if(str[i]!='\0') i++; ptr[j] = '\0'; count = TXT_DrawTextEx( NULL, 0, 0, 0, 256, 256, 0, 0, NULL, NULL, NULL, 20, ptr, 0, -1, -1, 128, 128, 128, 256, 0, 1 )*2+space; if(count>ret) ret=count; } GFree(buf); return ret; }
/* ** Name: FWrite_Fenc ** ** Decription: ** An encoding description for the following file. Stored for use in ** the furture. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS FParm_Fenc (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; i4 remain = linelen - *pos; char* p = line + *pos; char* enc = NULL; i4 i=0; if ((err = GAlloc (&enc, remain + 1, FALSE)) == GSTAT_OK) { load->encode = enc; while (CMwhite(p)) { CMbyteinc(i,p); CMnext(p); } while (i < remain) { CMbyteinc(i,p); CMcpyinc (p, enc); } load->state = US_FPARM; } *pos += i; return (err); }
/* ** Name: File_Mime ** ** Decription: ** The mime type of the following file. Extracted an saved for use in ** in the future. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS File_Mime (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; i4 remain = linelen - *pos; char* p = line + *pos; char* mime = NULL; i4 i=0; if ((err = GAlloc (&mime, remain + 1, FALSE)) == GSTAT_OK) { load->type = mime; while ((remain > 0) && CMwhite(p)) { CMbyteinc(i,p); CMnext(p); } while (i < remain) { CMbyteinc(i,p); CMcpyinc (p, mime); } load->state = US_FPARM; } *pos += i; return (err); }
/* ** Name: Val_Value ** ** Decription: ** A value should be extracted from the buffer and appended to the ** variables list. ** Format of the variable list is variable=value&variable=value. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS Val_Value (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; i4 nlen = STlength (load->varname); err = GAlloc((PTR*)&sess->variable, sess->vlen + nlen + linelen + 2, TRUE); if (err == GSTAT_OK && sess->variable != NULL) { if (sess->vlen > 0) { sess->variable[sess->vlen++] = '&'; } MECOPY_VAR_MACRO(load->varname, nlen, sess->variable + sess->vlen); sess->vlen += STlength (load->varname); if (linelen) { MECOPY_VAR_MACRO(line, linelen, sess->variable + sess->vlen); sess->vlen += linelen; load->varcmplt = 1; } sess->variable[sess->vlen] = EOS; } load->state = US_VAL; *pos = linelen; return (err); }
/* ** Name: Disp_Form ** ** Decription: ** Disposition: form-data; recevied with no filename. Implies a page ** variable name. ** Extract the variable and store it in the upload structure for use ** later. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS Disp_Form (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; char* p = line + *pos; char* varname; i4 remain = linelen - *pos; i4 i = 0; i4 j = 0; if (STbcompare ("name", 4, p, 0, TRUE) == 0) { /* ** Find the first quote after name */ while ((*p != '\"') && (i < remain)) { CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); /* skip the quote */ CMnext(p); varname= p; while ((*p != '\"') && (i < remain)) { j+=CMbytecnt(p); CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); /* skip the quote */ CMnext(p); /* ** Allocate space for the variable name a '=' character and an EOS */ if ((err = GAlloc (&load->varname, j+2, FALSE)) == GSTAT_OK) { MEfill (j+2, 0, load->varname); MECOPY_VAR_MACRO (varname, j, load->varname); STcat (load->varname, "="); } *pos += i; load->state = US_VAL; } else { HandlerException (sess, line, linelen, pos); } return (err); }
void EnumAdapters( int nAdapter ) { int i,n; char buf[128]; n = pD3D->GetAdapterModeCount(nAdapter); D3DCapsStruct.m_DisplayModeNum = n; if( D3DCapsStruct.m_DisplayMode==NULL ) D3DCapsStruct.m_DisplayMode = (D3DDISPLAYMODE*)GAlloc( sizeof(D3DDISPLAYMODE)*n ); for( i=0 ; i<n ; i++ ){ if( pD3D->EnumAdapterModes(nAdapter,i,&D3DCapsStruct.m_DisplayMode[i]) == D3D_OK){ wsprintf( buf, "%d x %d (%d Hz) - %s\n", D3DCapsStruct.m_DisplayMode[i].Width, D3DCapsStruct.m_DisplayMode[i].Height, D3DCapsStruct.m_DisplayMode[i].RefreshRate, TxFmtMode[ LIM(D3DCapsStruct.m_DisplayMode[i].Format,0,D3DFMT_D3DD_MAX-1) ] ); DebugPrintf( buf ); } } }
// --------------------------------------------------------------------------- // iniファイルから文字を読み取る // --------------------------------------------------------------------------- int ReadIniFileStr( char *vname, char *str, char *def, int size, char *sec_name, char *ini_fname ) { char *buf = (char*)GAlloc( size+1 ); // char *buf = (char*)GAlloc( size ); if( ini_fname==NULL){ if(IniFileName[0]==0){ ini_fname = "default.ini"; }else{ ini_fname = IniFileName; } } GetPrivateProfileString( sec_name, vname, def, buf, size, ini_fname ); if( _mbscmp( (BYTE*)def, (BYTE*)buf ) ){ _mbscpy( (BYTE*)str, (BYTE*)buf+1 ); }else{ _mbscpy( (BYTE*)str, (BYTE*)buf ); } // _mbscpy( (BYTE*)str, (BYTE*)buf ); GFree(buf); return 0; }
int PAC_PackFileMovie_Open( char *PackFname ) { int i; int size; for(i=0;i<32;i++){ if(!MoveInfo[i].fh) break; } if(i==32) return -1; PAC_PackFileMovie_Close( i ); MoveInfo[i].fh = CREATE_READ_FILE2( PackFname, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN ); if( MoveInfo[i].fh==INVALID_HANDLE_VALUE ){ MoveInfo[i].fh=NULL; return -2; } ReadFile( MoveInfo[i].fh, &MoveInfo[i].bmi, sizeof(BMP_MOVE_INFO), (unsigned long *)&size, NULL); ReadFile( MoveInfo[i].fh, MoveInfo[i].next_size, sizeof(DWORD)*2, (unsigned long *)&size, NULL); GFree( MoveInfo[i].buf ); MoveInfo[i].buf = (char *)GAlloc( MoveInfo[i].bmi.sx*MoveInfo[i].bmi.sy + 1024 + 8 ); MoveInfo[i].db_buf = 0; MoveInfo[i].count = 0; MoveInfo[i].start_time = 0; MoveInfo[i].cond = MOVE_COND_STOP; MoveInfo[i].loop = 1; MoveInfo[i].r = 128; MoveInfo[i].g = 128; MoveInfo[i].b = 128; return i; }
/* ** Name: WMODocument() - insert, update, delete, select and retrieve documents ** ** Description: ** ** Inputs: ** ACT_PSESSION : active session ** char*[] : list of parameters ** ** Outputs: ** bool* : TRUE is there is something to print ** PTR* : cursor pointer (if NULL means no more information) ** ** Returns: ** GSTATUS : GSTAT_OK ** ** Exceptions: ** None ** ** Side Effects: ** None ** ** History: ** 28-Apr-2000 (fanra01) ** Add additional scheme parameter to WPSrequest. ** 30-Oct-2001 (fanra01) ** Replace ambiguous profile error message with authorization ** and permission messages. */ GSTATUS WMODocument ( ACT_PSESSION act_session, char* params[], bool* print, PTR* user_info) { GSTATUS err = GSTAT_OK; u_i4 action; u_i4 unit_id = 0; u_i4 ext_loc = 0; i4 flag = 0; u_i4 owner = 0; u_i4 *pid = NULL; u_i4 *punit_id = NULL; i4 *pflag = NULL; u_i4 *powner = NULL; u_i4 *pext_loc = NULL; char *ext_file; char *ext_suffix; bool accessible = TRUE; WPS_FILE *cache = NULL; bool status; *print = TRUE; if (*user_info == NULL) { G_ASSERT (params[0] == NULL || params[0][0] == EOS, E_WS0059_WSF_BAD_PARAM); if (act_session->user_session == NULL) { *print = FALSE; err = DDFStatusAlloc( E_WS0101_WSS_UNAUTHORIZED_USE ); return(err); } if (err == GSTAT_OK) err = WMOTypeAction(params[0], &action); } else action = WSS_ACTION_TYPE_SEL; if (err == GSTAT_OK) if (action == WSS_ACTION_TYPE_SEL) { if (*user_info == NULL) { err = WCSOpenDocument(user_info); if (err == GSTAT_OK) err = GAlloc((PTR*)¶ms[1], NUM_MAX_INT_STR, FALSE); } if (err == GSTAT_OK) { err = WCSGetDocument( user_info, &pid, &punit_id, ¶ms[4], ¶ms[5], (u_i4**)&pflag, &powner, &pext_loc, ¶ms[12], ¶ms[13]); if (err != GSTAT_OK || *user_info == NULL) { CLEAR_STATUS (WCSCloseDocument(user_info)); *print = FALSE; } else { err = WSSDocAccessibility(act_session->user_session, *pid, WSF_READ_RIGHT, &accessible); if (err == GSTAT_OK && accessible == TRUE) { WSF_CVNA(err, *pid, params[1]); unit_id = *punit_id; flag = *pflag; ext_loc= *pext_loc; } else *print = FALSE; } } } else { u_i4 id; switch(action) { case WSS_ACTION_TYPE_DEL: case WSS_ACTION_TYPE_RET: G_ASSERT (params[1] == NULL || CVan(params[1], (i4*)&id) != OK, E_WS0059_WSF_BAD_PARAM); if (action == WSS_ACTION_TYPE_DEL) { err = WSSDocAccessibility(act_session->user_session, id, WSF_DEL_RIGHT, &accessible); if (err == GSTAT_OK) if (accessible == TRUE) err = WCSDeleteDocument (id); else err = DDFStatusAlloc( E_WS0065_WSF_UNAUTH_ACCESS ); } else { err = WSSDocAccessibility(act_session->user_session, id, WSF_READ_RIGHT, &accessible); if (err == GSTAT_OK && accessible == TRUE) { err = WCSRetrieveDocument ( id, &punit_id, ¶ms[4], ¶ms[5], (u_i4**)&pflag, &powner, &pext_loc, ¶ms[12], ¶ms[13]); if (err == GSTAT_OK && punit_id != NULL) { unit_id = *punit_id; flag = *pflag; ext_loc= *pext_loc; owner = *powner; if (err == GSTAT_OK) { err = WPSRequest( act_session->user_session->name, act_session->scheme, act_session->host, act_session->port, NULL, unit_id, params[4], params[5], &cache, &status); if (err == GSTAT_OK) { if (status == WCS_ACT_LOAD) { if ((flag & WCS_EXTERNAL) == FALSE) err = WCSExtractDocument (cache->file); if (err == GSTAT_OK) CLEAR_STATUS(WCSLoaded(cache->file, TRUE)) else CLEAR_STATUS(WCSLoaded(cache->file, FALSE)) } if (err == GSTAT_OK) { char *tmp = (cache->url == NULL) ? WSF_UNDEFINED : cache->url; u_i4 length = STlength(tmp) + 1; err = GAlloc((PTR*)¶ms[10], length, FALSE); if (err == GSTAT_OK) MECOPY_VAR_MACRO(tmp, length, params[10]); } CLEAR_STATUS(WPSRelease(&cache)); } } } } else
static BOOL SaerchNextFile2( char *src_dir, WIN32_FIND_DATA_LIST **list, SEARCH_DIR_DATA *sdd ) { char src_buf[1024]; if(*list==NULL){ *list = (WIN32_FIND_DATA_LIST *)GAlloc( sizeof(WIN32_FIND_DATA_LIST) ); if(sdd->subdir_chk){ (*list)->step = SEARCH_FILE_INIT; }else{ (*list)->step = SEARCH_FILE_INIT; } } while( *list ){ switch( (*list)->step ){ case SEARCH_DIR_INIT: wsprintf( src_buf, "%s%s", src_dir, "*" ); (*list)->handle = FindFirstFile( src_buf, &(*list)->data ); if( (*list)->handle == INVALID_HANDLE_VALUE ){ GFree( *list ); return FALSE; } FindNextFile( (*list)->handle, &(*list)->data ); (*list)->step = SEARCH_DIR; case SEARCH_DIR: if( (*list)->next==NULL ){ (*list)->fnf_ret = FindNextFile( (*list)->handle, &(*list)->data ); } if( (*list)->fnf_ret ){ if( (*list)->data.dwFileAttributes==FILE_ATTRIBUTE_DIRECTORY ){ wsprintf( src_buf, "%s%s\\", src_dir, (*list)->data.cFileName ); if( SaerchNextFile2( src_buf, (WIN32_FIND_DATA_LIST**)&(*list)->next, sdd ) ){ return TRUE; } } }else{ // FindClose( (*list)->handle ); // (*list)->step = SEARCH_FILE_INIT; GFree( *list ); return FALSE; } break; case SEARCH_FILE_INIT://直下ファイルを検索 wsprintf( src_buf, "%s%s", src_dir, sdd->file );//ファイルを検出 (*list)->handle = FindFirstFile( src_buf, &(*list)->data ); if( (*list)->handle == INVALID_HANDLE_VALUE ){ if(sdd->subdir_chk){ (*list)->step = SEARCH_DIR_INIT; }else{ GFree( *list ); } }else{ (*list)->step = SEARCH_FILE; if( (*list)->data.dwFileAttributes!=FILE_ATTRIBUTE_DIRECTORY ){//ファイル検出 strcpy( sdd->find_dir, src_dir + strlen(sdd->dir) ); sdd->find_data = (*list)->data; return TRUE; } } break; case SEARCH_FILE: (*list)->fnf_ret = FindNextFile( (*list)->handle, &(*list)->data ); if( (*list)->fnf_ret ){ if( (*list)->data.dwFileAttributes!=FILE_ATTRIBUTE_DIRECTORY ){//ファイル検出 strcpy( sdd->find_dir, src_dir + strlen(sdd->dir) ); sdd->find_data = (*list)->data; return TRUE; } }else{//ディレクトリ検索終了 FindClose( (*list)->handle ); if(sdd->subdir_chk){ (*list)->step = SEARCH_DIR_INIT; }else{ GFree( *list ); } } break; } } return FALSE; }
/* ** Name: ParserGetVariable() - ** ** Description: ** ** Inputs: ** PPARSER_IN in ** PPARSER_OUT out ** ** Outputs: ** ** Returns: ** GSTATUS : GSTAT_OK ** ** Exceptions: ** None ** ** Side Effects: ** None ** ** History: */ GSTATUS ParserGetVariable ( PPARSER_IN in, PPARSER_OUT out) { GSTATUS err = GSTAT_OK; PVAR_PARSER_OUT pout; u_i4 length; char* name = NULL; u_i4 nlen = 0; char* value = NULL; u_i4 vlen = 0; char nullval[] = ""; pout = (PVAR_PARSER_OUT) out; if (pout->namePos == 0) { err = DDFStatusAlloc(E_WS0012_WSS_VAR_BAD_NAME); } else { length = in->current - in->position; if (length > 0) { u_i4 size = ((((pout->valuePos + length) / 32) + 1) * 32); err = GAlloc(&pout->value, size, TRUE); if (err == GSTAT_OK) { MECOPY_VAR_MACRO(in->buffer + in->position, length, pout->value + pout->valuePos); pout->valuePos += length; } } in->position = in->current+1; if (pout->namePos > 0 && pout->name[0] == VARIABLE_MARK) err = WSMGetVariable ( pout->act_session, pout->name + 1, pout->namePos - 1, &name, WSM_SYSTEM | WSM_ACTIVE | WSM_USER); if (err == GSTAT_OK && name == NULL) { name = pout->name; nlen = pout->namePos; } else nlen = STlength(name); if (pout->valuePos <= 0) { vlen = 1; value = nullval; } else { if (pout->value[0] == VARIABLE_MARK) err = WSMGetVariable ( pout->act_session, pout->value+ 1, pout->valuePos - 1, &value, WSM_SYSTEM | WSM_ACTIVE | WSM_USER); if (err == GSTAT_OK && value == NULL) { value = pout->value; vlen = pout->valuePos; } else vlen = STlength(value); } err = WSMAddVariable ( pout->act_session, name, nlen, value, vlen, pout->type); } MEfree((PTR)pout->name); pout->name = NULL; MEfree((PTR)pout->value); pout->value = NULL; pout->namePos = 0; pout->valuePos = 0; return(err); }
/* ** Name: Disp_Fname ** ** Decription: ** Takes the string ** content-disposition: form-data; name="xxxx" filename="yyyy" ** opens an ice temporary file and sets items in the variable string ** as xxxx=icetempfile. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS Disp_Fname (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; char* p = line + *pos; char* name; i4 remain = linelen - *pos; i4 i = 0; i4 j = 0; UPLOADED_FILE* upload; if (STbcompare ("name", 4, p, 0, TRUE) == 0) { /* ** Find the first quote after name */ while ((*p != '\"') && (i < remain)) { CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); /* skip the quote */ CMnext(p); name= p; while ((*p != '\"') && (i < remain)) { j+=CMbytecnt(p); CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); CMnext(p); /* skip the quote */ while ((*p != ';') && (i < remain)) { CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); CMnext(p); /* skip the semi colon */ /* ** Allocate space for the variable name a '=' character and an EOS */ if ((err = GAlloc (&load->varname, j+2, FALSE)) == GSTAT_OK) { MEfill (j+2, 0, load->varname); MECOPY_VAR_MACRO (name, j, load->varname); STcat (load->varname, "="); } while (CMwhite(p) && (i < remain)) { CMbyteinc(i, p); CMnext(p); } if (STbcompare ("filename", 8, p, 0, TRUE) == 0) { /* ** Find the first quote after filename */ while ((*p != '\"') && (i < remain)) { CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); CMnext(p); /* skip the quote */ name= p; while ((*p != '\"') && (i < remain)) { j+=CMbytecnt(p); CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); CMnext(p); /* skip the quote */ /* ** Allocate space for the filename and an EOS */ if ((err = GAlloc (&load->filename, j+1, FALSE)) == GSTAT_OK) { MEfill (j+1, 0, load->filename); MECOPY_VAR_MACRO (name, j, load->filename); asct_trace( ASCT_LOG )( ASCT_TRACE_PARAMS, "Upload session=%s file=%s", ((sess->act_session != NULL) ? ((sess->act_session->user_session) ? sess->act_session->user_session->name : "None") : "None"), load->filename ); } *pos += i; err = G_ME_REQ_MEM(0, upload, UPLOADED_FILE, 1); if (err == GSTAT_OK) { bool status; err = WCSRequest( 0, NULL, SYSTEM_ID, NULL, WSF_ICE_SUFFIX, &upload->file, &status); if (err == GSTAT_OK) { CLEAR_STATUS(WCSLoaded(upload->file, TRUE)); err = WCSOpen (upload->file, "w", SI_BIN, 0); if (err == GSTAT_OK) { i4 nlen = STlength (load->varname); i4 flen = STlength(upload->file->info->path); err = GAlloc(&load->icefname, flen + 1, FALSE); if (err == GSTAT_OK) { MECOPY_VAR_MACRO( upload->file->info->path, flen, load->icefname); err = GAlloc((PTR*)&sess->variable, sess->vlen + nlen + flen + 2, TRUE); if (err == GSTAT_OK && sess->variable != NULL) { if (sess->vlen > 0) { sess->variable[sess->vlen++] = '&'; } MECOPY_VAR_MACRO(load->varname, nlen, sess->variable + sess->vlen); sess->vlen += nlen; if (flen) { MECOPY_VAR_MACRO(load->icefname, flen, sess->variable + sess->vlen); sess->vlen += flen; upload->next = sess->list; sess->list = upload; } sess->variable[sess->vlen] = EOS; } } } else { CLEAR_STATUS(WCSRelease(&upload->file)); } } } load->state = US_FILE; } else { HandlerException (sess, line, linelen, pos); } } else { HandlerException (sess, line, linelen, pos); } return (err); }
/* ** Name: WTSUpLoad() - ** ** Description: ** read the following format. ** 1) -- ** 2) boundary if there is a new parameter. ** 3) "Content-Disposition: form-data" ** 4) name and filename (if it is a file) of the parameter + '\r\n' ** 5) if it is a file, the mime type (Content-Type) '\r\n' ** 6) '\r\n' ** 7) the value + '\r\n' ** ** Inputs: ** ** Outputs: ** ** Returns: ** GSTATUS : GSTAT_OK ** ** Exceptions: ** None ** ** Side Effects: ** None ** ** History: ** 8-Sep-98 (marol01) ** fix issue with the upload feature. The format expected by the ** function is incorrect when the system try to read a file with ** a supported mime type. */ GSTATUS WTSUpLoad( char* data, i4 *datalength, WTS_SESSION *session) { GSTATUS err = GSTAT_OK; i4 linelen; i4 count = 0; i4 eventnum; char* p = data; char* work; PWTS_UPLOAD load = session->load; load->fragment &= ~FRAGMENT_INCOMPLETE; /* ** Terminate processing loop if incomplete message is encountered. ** This will be recalled once more data has been read. */ while ((err == GSTAT_OK) && (*datalength > 0) && ((load->fragment & FRAGMENT_INCOMPLETE) == 0)) { count = 0; linelen = endofline (load, p, *datalength); if ((load->fragment != 0) && (load->state != US_FWRITE)) { if ((load->fragment & FRAGMENT_MASK) == FRAGMENT_HEAD) { load->fraglen = linelen; err = GAlloc(&load->buf, load->fraglen, FALSE); MECOPY_VAR_MACRO(p, linelen, load->buf); work = NULL; p+=linelen; *datalength-=linelen; } else if ((load->fragment & FRAGMENT_MASK) == FRAGMENT_TAIL) { err = GAlloc(&load->buf, load->fraglen + linelen, TRUE); MECOPY_VAR_MACRO(p, linelen, load->buf + load->fraglen); work = load->buf; p+=linelen; *datalength-=linelen; linelen = load->fraglen + linelen; } } else { work = p; } if (work != NULL) { if (linelen != 0) { eventnum = getstrevent(load, work, linelen, *datalength, &count); err = handler[load->state][eventnum](session, work, linelen, &count); if (err == GSTAT_OK) { if ((load->fragment & FRAGMENT_MASK) != FRAGMENT_TAIL) { /* ** Processed whole line skip '\r\n' */ count += ((count==linelen) && (*datalength>linelen+2)) ? 2 : 0; *datalength -= count; p+=count; } else { load->fragment = 0; } } else { break; } } else { if (load->state == US_FPARM) { load->state = US_FWRITE; } count+=2; *datalength -= count; p+=count; } } } return(err); }