/* * get the address of Dos32Debug, and get the flat selectors, too. */ int GetDos32Debug( char __far *err ) { char buff[256]; RESULTCODES resc; USHORT dummy; PSZ start; PSZ p; HFILE inh; HFILE outh; USHORT rc; struct { ULONG dos_debug; USHORT cs; USHORT ds; USHORT ss; } data; rc = DosGetModName( ThisDLLModHandle, sizeof( buff ), buff ); if( rc ) { StrCopy( TRP_OS2_no_dll, err ); return( FALSE ); } start = buff; for( p = buff; *p != '\0'; ++p ) { switch( *p ) { case ':': case '\\': case '/': start = p + 1; break; } } p = StrCopy( LOCATOR, start ); if( DosMakePipe( &inh, &outh, sizeof( data ) ) ) { StrCopy( TRP_OS2_no_pipe, err ); return( FALSE ); } *++p = outh + '0'; *++p = '\0'; *++p = '\0'; rc = DosExecPgm( NULL, 0, EXEC_ASYNC, buff, NULL, &resc, buff ); DosClose( outh ); if( rc ) { DosClose( inh ); StrCopy( TRP_OS2_no_help, err ); return( FALSE ); } rc = DosRead( inh, &data, sizeof( data ), &dummy ); DosClose( inh ); if( rc ) { StrCopy( TRP_OS2_no_help, err ); return( FALSE ); } DebugFunc = (void __far *)data.dos_debug; FlatCS = (USHORT) data.cs; FlatDS = (USHORT) data.ds; _retaddr = MakeLocalPtrFlat( (void __far *)DoReturn ); return( TRUE ); }
static void NewGameGetPlayerName( UInt16 field, Int16 player) { FormPtr frm = FrmGetActiveForm(); Char *buff; if( tmppref[player].type == PlayerNone ) { return; } buff = FldGetTextPtr( FrmGetObjectPtr( frm, FrmGetObjectIndex( frm, fldNGname0+player ) ) ); if( tmppref[player].type == PlayerHuman ) { StrCopy( tmppref[player].hname, buff ); } if( tmppref[player].type == PlayerAI ) { StrCopy( tmppref[player].aname, buff ); } }
void FString::Insert (size_t index, const char *instr, size_t instrlen) { if (instrlen > 0) { size_t mylen = Len(); if (index >= mylen) { AppendCStrPart(instr, instrlen); } else if (Data()->RefCount <= 1) { ReallocBuffer(mylen + instrlen); memmove(Chars + index + instrlen, Chars + index, (mylen - index + 1) * sizeof(char)); memcpy(Chars + index, instr, instrlen * sizeof(char)); } else { FStringData *old = Data(); AllocBuffer(mylen + instrlen); StrCopy(Chars, old->Chars(), index); StrCopy(Chars + index, instr, instrlen); StrCopy(Chars + index + instrlen, old->Chars() + index, mylen - index); old->Release(); } } }
void FString::Remove(size_t index, size_t remlen) { if (index < Len()) { if (index + remlen >= Len()) { Truncate((long)index); } else { remlen = Len() - remlen < remlen ? Len() - remlen : remlen; if (Data()->RefCount == 1) { // Can do this in place memmove(Chars + index, Chars + index + remlen, Len() - index - remlen); memset(Chars + Len() - remlen, 0, remlen); Data()->Len -= (unsigned)remlen; } else { // Must do it in a copy FStringData *old = Data(); AllocBuffer(old->Len - remlen); StrCopy(Chars, old->Chars(), index); StrCopy(Chars + index, old->Chars() + index + remlen, old->Len - index - remlen); old->Release(); } } } }
extern bool WndEvalInspectExpr( char *item, bool pop ) /********************************************************/ { char *old; char buff[12],*p; bool rc; if( ispunct(item[0]) && ( item[1] == '\0' || ( ispunct( item[1] ) && item[2] == '\0' ) ) ) { // nyi - pui - use SSL p = StrCopy( item, StrCopy( "operator", buff ) ); if( item[0] == '[' && item[1] == '\0' ) { StrCopy( "]", p ); } else if( item[0] == '(' && item[1] == '\0' ) { StrCopy( ")", p ); } old = ReScan( buff ); } else { old = ReScan( item ); } _SwitchOn( SW_CALL_FATAL ); _SwitchOn( SW_ERR_IN_TXTBUFF ); _SwitchOn( SW_NO_DISAMBIGUATOR ); rc = ( Spawn( DoLValExpr ) == 0 ); _SwitchOff( SW_CALL_FATAL ); _SwitchOff( SW_NO_DISAMBIGUATOR ); _SwitchOff( SW_ERR_IN_TXTBUFF ); ReScan( old ); if( pop && rc ) PopEntry(); return( rc ); }
Status Replace(SString& S, SString T, SString V){ //入口断言:S,T,V存在 //操作结果:将S中出现的所有不重复的T都替换为V int k = Index(S, T, 1); if(k){ SString suffix; StrAssign(suffix,""); int n = T[0], m = S[0]; while(k){ printf("%d\n",k); SString temp; SubString(temp, S, 1, k-1); //当前第一个T的前缀 StrPrint(temp); if(Concat(suffix, temp)){ StrPrint(suffix); Concat(suffix, V); //追加上V StrPrint(suffix); m -= (k-1)+n; //处理掉上一组后剩余的后缀长度 SubString(temp, S, k+n, m); StrCopy(S, temp); //S被截断为尚未处理的后缀 k = Index(S, T, 1); }else return OVERFLOW; //S空间不足 } if(Concat(suffix, S)){ StrCopy(S, suffix); return OK; }else return OVERFLOW; } else return OK; //T未出现过 }
bool ReportTrap( unsigned conditions, bool stack_cmds ) { bool cmds_pushed; char *p; if( conditions & COND_EXCEPTION ) { RecordMsgText( &conditions ); // get the 'access violation, etc' message p = StrCopy( LIT_ENG( Task_Exception ), TxtBuff ); if( MsgText != NULL ) StrCopy( MsgText, p ); MsgText = DbgRealloc( MsgText, strlen( TxtBuff ) + 1 ); StrCopy( TxtBuff, MsgText ); DUIMsgBox( MsgText ); } if( conditions & (COND_EXCEPTION|COND_TERMINATE) ) { RingBell(); } DisplayMsgText(); if( conditions & COND_USER ) { DUIInfoBox( LIT_ENG( User_Interupt ) ); PurgeInpStack(); RecordAsynchEvent(); } else if( conditions & COND_TERMINATE ) { DUIInfoBox( LIT_ENG( Task_Completed ) ); _SwitchOff( SW_HAVE_TASK ); } else if( conditions & COND_LIBRARIES ) { Format( TxtBuff, "%s '%s'", LIT_ENG( Break_on_DLL_Load ), GetLastImageName() ); DUIInfoBox( TxtBuff ); } else { DUIStatusText( LIT_ENG( Empty ) ); } cmds_pushed = DispBPMsg( stack_cmds ); DbgUpdate( UP_MEM_CHANGE | UP_CSIP_CHANGE | UP_REG_CHANGE | UP_CODE_EXECUTED | UP_THREAD_STATE ); return( cmds_pushed ); }
// В отладочном режиме предоставляем возможность установить отладочный хост void SetDebugHost(PCHAR Host) { MDBG_Config("Config","SetDebugHost"); if (!StrCopy(DebugHost, Host)) StrCopy(DebugHost, "localhost"); }
char* RemoveExtraSpaces(char* line) { int i, len = strlen(line); for (i=0; i<len; i++) { if (line[i] == ' ') { if (i+1 == len) line[i] = '\0'; else if (i+1 != len && line[i+1] == ' ') { StrCopy(&line[i], &line[i+1]); i--; len--; } } } if (len > 0 && line[0] == ' ') StrCopy(&line[0], &line[1]); if (len > 0 && line[len -1] == ' ') line[len -1] = '\0'; return line; }
/*********************************************************************** * * FUNCTION: SetTimeTriggers * * DESCRIPTION: This routine sets the text label of the start time and * end time triggers. * * PARAMETERS: startTime - pointer to TimeType * endTime - pointer to TimeType * startTimeText - buffer that holds start time string * emdTimeText - buffer that holds end time string * timeFormat - time format * untimed - true if there isn't a time. * * RETURNED: nothing * * REVISION HISTORY: * Name Date Description * ---- ---- ----------- * art 4/4/96 Initial Revision * ***********************************************************************/ static void SetTimeTriggers (TimeType startTime, TimeType endTime, Char * startTimeText, Char * endTimeText, TimeFormatType timeFormat, Boolean untimed) { FormType * frm; ControlPtr startTimeCtl, endTimeCtl; frm = FrmGetActiveForm (); startTimeCtl = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorStartTimeButton)); endTimeCtl = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, TimeSelectorEndTimeButton)); if (! untimed) { TimeToAscii (startTime.hours, startTime.minutes, timeFormat, startTimeText); TimeToAscii (endTime.hours, endTime.minutes, timeFormat, endTimeText); } else { // copy two spaces into these fields instead of just a null // because controls with empty strings (or one space) cause old-style // graphic control behavior, which uses the wrong colors! StrCopy(startTimeText, " "); StrCopy(endTimeText, " "); } CtlSetLabel (startTimeCtl, startTimeText); CtlSetLabel(endTimeCtl, endTimeText); }
static void UserCredentialsFormValidate(FormType* form, FlickrPrefs& prefs) { const char* email = FldGetTextPtr((FieldType*)FrmGetObjectPtr(form, FrmGetObjectIndex(form, emailField))); const char* password = FldGetTextPtr((FieldType*)FrmGetObjectPtr(form, FrmGetObjectIndex(form, passwordField))); StrCopy(prefs.email, email); StrCopy(prefs.password, password); }
static bool CallGetLine( a_window *wnd, int row, int piece, wnd_line_piece *line ) { call_chain *chain; call_window *call = WndCall( wnd ); chain = GetCallChain( &call->tb, row ); if( chain == NULL ) return( false ); line->extent = WND_MAX_EXTEND; switch( piece ) { case PIECE_SYMBOL: StrCopy( ":", StrCopy( chain->symbol, TxtBuff ) ); line->text = TxtBuff; return( true ); case PIECE_SOURCE: line->indent = call->max_sym_len + 3 * WndAvgCharX( wnd ); line->tabstop = FALSE; line->use_prev_attr = TRUE; if( chain->source_line == NULL ) { line->text = TxtBuff; UnAsm( chain->lc.execution, TxtBuff, TXT_LEN ); } else { line->text = chain->source_line; } return( true ); default: return( false ); } }
void CallConf( void ) { char *ptr; unsigned i; bool first; if( _IsOn( SW_HAVE_SET_CALL ) ) { ptr = TxtBuff; if( DefCallType != MAD_MSTR_NIL ) { *ptr++ = '/'; ptr += MADCli( String )( DefCallType, ptr, TXT_LEN ); } *ptr++ = '('; first = true; for( i = 0; i < MAX_PARMS; ++i ) { if( DefParms[i] != NULL ) { if( !first ) { *ptr++ = ','; } ptr = StrCopy( DefParms[i], ptr ); first = false; } } *ptr++ = ')'; if( DefReturn == NULL ) { *ptr++ = '/'; *ptr = NULLCHAR; } else { StrCopy( DefReturn, ptr ); } ConfigLine( TxtBuff ); } }
/* bo5-52.c 广义表的书写形式串为HString类型 */ #include"c4-2.h" /* 定义HString类型 */ #include"bo4-2.c" /* HString类型的基本操作 */ Status sever(HString *str,HString *hstr) { /* 将非空串str分割成两部分:hstr为第一个','之前的子串,str为之后的子串 */ int n,i=1,k=0; /* k记尚未配对的左括号个数 */ HString ch,c1,c2,c3; InitString(&ch); /* 初始化HString类型的变量 */ InitString(&c1); InitString(&c2); InitString(&c3); StrAssign(&c1,","); StrAssign(&c2,"("); StrAssign(&c3,")"); n=StrLength(*str); do { SubString(&ch,*str,i,1); if(!StrCompare(ch,c2)) ++k; else if(!StrCompare(ch,c3)) --k; ++i; }while(i<=n&&StrCompare(ch,c1)||k!=0); if(i<=n) { StrCopy(&ch,*str); SubString(hstr,ch,1,i-2); SubString(str,ch,i,n-i+1); } else { StrCopy(hstr,*str); ClearString(str); } return OK; }
FString::FString (const char *head, const char *tail) { size_t len1 = strlen (head); size_t len2 = strlen (tail); AllocBuffer (len1 + len2); StrCopy (Chars, head, len1); StrCopy (Chars + len1, tail, len2); }
FString::FString (const FString &head, const FString &tail) { size_t len1 = head.Len(); size_t len2 = tail.Len(); AllocBuffer (len1 + len2); StrCopy (Chars, head); StrCopy (Chars + len1, tail); }
extern void DlgAbout( void ) { int i; char *p; p = StrCopy( LIT_ENG( Empty ), TxtBuff ); for( i = 0; i < AboutSize; ++i ) { p = StrCopy( "\r", StrCopy( AboutMessage[i], p ) ); } Say2( LIT_DUI( About_The_WATCOM_Debugger ), TxtBuff ); }
En_Decode::En_Decode(const char *fin_name, const char *fout_name) { BitContainer = 0; BitCounter = 0; NumOfRootNode = 0; for (int i = 0; i < 511; i++) OurTree[i].freq = 0; StrCopy(fout_name, outfile_buf); StrCopy(fin_name, infile_buf); }
char* GetVdatString(char* dest, int size, VdatStringField field) { VbSharedDataHeader* sh = VbSharedDataRead(); char* value = dest; if (!sh) return NULL; switch (field) { case VDAT_STRING_TIMERS: snprintf(dest, size, "LFS=%" PRIu64 ",%" PRIu64 " LF=%" PRIu64 ",%" PRIu64 " LK=%" PRIu64 ",%" PRIu64, sh->timer_vb_init_enter, sh->timer_vb_init_exit, sh->timer_vb_select_firmware_enter, sh->timer_vb_select_firmware_exit, sh->timer_vb_select_and_load_kernel_enter, sh->timer_vb_select_and_load_kernel_exit); break; case VDAT_STRING_LOAD_FIRMWARE_DEBUG: value = GetVdatLoadFirmwareDebug(dest, size, sh); break; case VDAT_STRING_LOAD_KERNEL_DEBUG: value = GetVdatLoadKernelDebug(dest, size, sh); break; case VDAT_STRING_MAINFW_ACT: switch(sh->firmware_index) { case 0: StrCopy(dest, "A", size); break; case 1: StrCopy(dest, "B", size); break; case 0xFF: StrCopy(dest, "recovery", size); break; default: value = NULL; } break; default: value = NULL; break; } free(sh); return value; }
/* Initialize format of percentage indicator */ void InitializeResultFormat ( const Char* lang ) { /* in some languages they say %10 instead of 10%, so we make the format configurable */ if ( STREQ( lang, "tr" ) ) StrCopy( resultFormat, "%%%ld" ); else StrCopy( resultFormat, "%3ld%%" ); }
static Boolean CourseListHandleSelection(void) { MemHandle m, mWebsite, mEmail, old; CourseDBRecord c; FieldType *fldWebsite, *fldEmail; Char *buffer; m = DmQueryRecord(DatabaseGetRefN(DB_MAIN), gCourseInd[LstGetSelection(GetObjectPtr(LIST_courses))]); if (! m) return true; UnpackCourse(&c, MemHandleLock(m)); fldWebsite = GetObjectPtr(FIELD_cl_website); fldEmail = GetObjectPtr(FIELD_cl_email); if (StrLen(c.website) == 0) { mWebsite = MemHandleNew(4); buffer=MemHandleLock(mWebsite); MemSet(buffer, 4, 0); StrCopy(buffer, "-?-"); } else { mWebsite = MemHandleNew(StrLen(c.website)+1); buffer = MemHandleLock(mWebsite); MemSet(buffer, StrLen(c.website)+1, 0); StrCopy(buffer, c.website); } MemHandleUnlock(mWebsite); old = FldGetTextHandle(fldWebsite); FldSetTextHandle(fldWebsite, mWebsite); if (old != NULL) MemHandleFree(old); FldDrawField(fldWebsite); if (StrLen(c.teacherEmail) == 0) { mEmail = MemHandleNew(4); buffer = MemHandleLock(mEmail); MemSet(buffer, 4, 0); StrCopy(buffer, "-?-"); } else { mEmail = MemHandleNew(StrLen(c.teacherEmail)+1); buffer = MemHandleLock(mEmail); MemSet(buffer, StrLen(c.teacherEmail)+1, 0); StrCopy(buffer, c.teacherEmail); } MemHandleUnlock(mEmail); old = FldGetTextHandle(fldEmail); FldSetTextHandle(fldEmail, mEmail); if (old != NULL) MemHandleFree(old); FldDrawField(fldEmail); MemHandleUnlock(m); return false; }
static Status Concat(LString &T,LString S1,LString S2) { // 用T返回由S1和S2联接而成的新串 LString a1,a2; InitString(a1); InitString(a2); StrCopy(a1,S1); StrCopy(a2,S2); T.curlen=S1.curlen+S2.curlen; T.head=a1.head; a1.tail->next=a2.head; T.tail=a2.tail; return OK; }
Status Concat(LString *T,LString S1,LString S2) { /* 用T返回由S1和S2联接而成的新串 */ LString a1,a2; InitString(&a1); InitString(&a2); StrCopy(&a1,S1); StrCopy(&a2,S2); (*T).curlen=S1.curlen+S2.curlen; (*T).head=a1.head; a1.tail->next=a2.head; (*T).tail=a2.tail; return OK; }
static char *GetBPAddrText( brkp *bp, char *p ) { if( bp->th != MAD_NIL_TYPE_HANDLE ) { p = StrCopy( LIT( Break_on_write ), p ); if( bp->source_line != NULL ) { p = StrCopy( bp->source_line, p ); } else { p = Format( p, "%a", bp->loc.addr ); } } else { p = Format( p, LIT( Break_on_execute ) ); p = Format( p, BrkFmt(), bp->loc.addr ); } return( p ); }
void SetBPPatch( brkp *bp, char *patch ) { char *end; end = StrCopy( patch, StrCopy( " ", StrCopy( GetCmdName( CMD_DO ), TxtBuff ) ) ); if( bp->cmds != NULL ) { FreeCmdList( bp->cmds ); } if( patch == NULL || patch[0] == '\0' ) { bp->cmds = NULL; } else { bp->cmds = AllocCmdList( TxtBuff, end - TxtBuff ); } bp->status.b.use_cmds = ( bp->cmds != NULL ); }
static char *GetBPAddrText( brkp *bp, char *p ) { if( IS_BP_EXECUTE( bp->th ) ) { p = Format( p, LIT_ENG( Break_on_execute ) ); p = Format( p, BrkFmt(), bp->loc.addr ); } else { p = StrCopy( LIT_ENG( Break_on_write ), p ); if( bp->source_line != NULL ) { p = StrCopy( bp->source_line, p ); } else { p = Format( p, "%a", bp->loc.addr ); } } return( p ); }
bool Label::Create(LPCTSTR name, HINSTANCE hInstance) { // Set this instance's name StrCopy(mName, MAX_NAME, name); // Read configuration first since we need it to create the window ReadConfig(); // Create the window mWindow = CreateWindowEx(WS_EX_TOOLWINDOW, WINDOW_CLASS, NULL, WS_POPUP, mX, mY, mWidth, mHeight, NULL, NULL, hInstance, this); if (!mWindow) { TRACE2("%s: CreateWindowEx failed, GetLastError returns %d", MODULE_NAME, GetLastError()); return false; } // Adjust the window's z-order, make it sticky, and show it SetAlwaysOnTop(mAlwaysOnTop); SetSticky(true); SetVisible(mVisible); return true; }
/* bo5-51.c 广义表的书写形式串为SString类型 */ #include "../ch4/c4-1.h" /* 定义SString类型 */ #include "../ch4/bo4-1.c" /* SString类型的基本操作 */ void sever(SString str,SString hstr) /* 算法5.8 SString是数组,不需引用类型 */ { /* 将非空串str分割成两部分:hsub为第一个','之前的子串,str为之后的子串 */ int n,k,i; /* k记尚未配对的左括号个数 */ SString ch,c1,c2,c3; n=StrLength(str); StrAssign(c1,","); StrAssign(c2,"("); StrAssign(c3,")"); SubString(ch,str,1,1); for(i=1,k=0;i<=n&&StrCompare(ch,c1)||k!=0;++i) { /* 搜索最外层的第一个逗号 */ SubString(ch,str,i,1); if(!StrCompare(ch,c2)) ++k; else if(!StrCompare(ch,c3)) --k; } if(i<=n) { SubString(hstr,str,1,i-2); SubString(str,str,i,n-i+1); } else { StrCopy(hstr,str); ClearString(str); } }
static bool CheckLoadDebugInfo( image_entry *image, file_handle fh, unsigned start, unsigned end ) { char buff[TXT_LEN]; char *symfile; unsigned prio; char *endstr; prio = start; for( ;; ) { prio = DIPPriority( prio ); if( prio == 0 || prio > end ) return( false ); DIPStatus = DS_OK; image->dip_handle = DIPLoadInfo( fh, sizeof( image_entry * ), prio ); if( image->dip_handle != NO_MOD ) break; if( DIPStatus & DS_ERR ) { symfile = image->symfile_name; if( symfile == NULL ) symfile = image->image_name; endstr = Format( buff, LIT_ENG( Sym_Info_Load_Failed ), symfile ); *endstr++ = ' '; StrCopy( DIPMsgText( DIPStatus ), endstr ); Warn( buff ); return( false ); } } *(image_entry **)ImageExtra( image->dip_handle ) = image; return( true ); }
void __fastcall TfrmLayer::TrackBar1Change(TObject *Sender) { TTrackBar* p = dynamic_cast<TTrackBar *>(Sender); TCHAR code[7]; StrCopy(code,p->Name.c_str()); int layerID; int columnID; for(int i =0 ; i < p->Name.Length() ; i++) { code[i] = code[i+1]; } layerID = StrToInt(code)/10; columnID = StrToInt(code)%10; int colorsID = layerID * 2 + columnID - 1; TColor color = _Colors[colorsID]->Selected; int alphaValue = p->Position; if(columnID == 1) { _layers->at(layerID)->setLineColor(tcolor2rgb(color,alphaValue)); } if(columnID == 2) { _layers->at(layerID)->setFillColor(tcolor2rgb(color,alphaValue)); } _fview->FormPaint(this); }