/******** HOOK ********/ int mesg_args(char *wbuf, int maxlen, argv_typ argv, char ulv, char sep, char dlv, char quot, int maxargs) { int r, lev, argc = 0; char buf[BUFFER_LEN]; char *ptr; int litflag = 0; /* for (ptr = wbuf; ptr && isspace(*ptr); ptr++); */ strcpyn(buf, sizeof(buf), wbuf); ptr = buf; for (lev = r = 0; (r < (BUFFER_LEN - 2)); r++) { if (buf[r] == '\0') { return (-1); } else if (buf[r] == '\\') { r++; continue; } else if (buf[r] == quot) { litflag = (!litflag); } else if (!litflag && buf[r] == ulv) { lev++; continue; } else if (!litflag && buf[r] == dlv) { lev--; if (lev < 0) { buf[r] = '\0'; if (argv[argc]) { free(argv[argc]); argv[argc] = NULL; } argv[argc] = (char*)malloc(((buf + r) - ptr) + 1); strcpyn(argv[argc++], ((buf + r) - ptr) + 1, ptr); ptr = buf + r + 1; break; } continue; } else if (!litflag && lev < 1 && buf[r] == sep) { if (argc < maxargs - 1) { buf[r] = '\0'; if (argv[argc]) { free(argv[argc]); argv[argc] = NULL; } argv[argc] = (char*)malloc(((buf + r) - ptr) + 1); strcpyn(argv[argc++], ((buf + r) - ptr) + 1, ptr); ptr = buf + r + 1; } } } buf[BUFFER_LEN - 1] = '\0'; strcpyn(wbuf, maxlen, ptr); return argc; }
void prim_interp(PRIM_PROTOTYPE) { struct inst *oper1 = NULL; /* prevents re-entrancy issues! */ struct inst *oper2 = NULL; /* prevents re-entrancy issues! */ struct inst *oper3 = NULL; /* prevents re-entrancy issues! */ struct inst *rv = NULL; char buf[BUFFER_LEN]; struct frame *tmpfr; CHECKOP(3); oper3 = POP(); /* string -- top stack argument */ oper2 = POP(); /* dbref -- trigger */ oper1 = POP(); /* dbref -- Program to run */ if (!valid_object(oper1) || Typeof(oper1->data.objref) != TYPE_PROGRAM) abort_interp("Bad program reference. (1)"); if (!valid_object(oper2)) abort_interp("Bad object. (2)"); if (oper3->type != PROG_STRING) abort_interp("Expected a string. (3)"); if ((mlev < 3) && !permissions(ProgUID, oper2->data.objref)) abort_interp("Permission denied."); if (fr->level > 8) abort_interp("Interp call loops not allowed."); CHECKREMOTE(oper2->data.objref); strcpyn(buf, sizeof(buf), match_args); strcpyn(match_args, sizeof(match_args), DoNullInd(oper3->data.string)); tmpfr = interp(fr->descr, player, LOCATION(player), oper1->data.objref, oper2->data.objref, PREEMPT, STD_HARDUID, 0); if (tmpfr) { rv = interp_loop(player, oper1->data.objref, tmpfr, 1); } strcpyn(match_args, sizeof(match_args), buf); CLEAR(oper3); CLEAR(oper2); CLEAR(oper1); if (rv) { if (rv->type < PROG_STRING) { push(arg, top, rv->type, MIPSCAST(&rv->data.number)); } else { push(arg, top, rv->type, MIPSCAST(rv->data.string)); } } else { PushNullStr; } }
/* Load() Carica l'immagine dal file nel controllo, creando l'oggetto immagine con la libreria specificata. */ BOOL CDibCtrl::Load(LPCSTR lpszFileName,LPCSTR lpcszLibraryName,BOOL bRebuildPalette/*=TRUE*/,BOOL bClearBeforeDraw/*=TRUE*/) { CWaitCursor cursor; m_bValidDib = FALSE; // controlla che sia un file if(!(::GetFileAttributes(lpszFileName) & FILE_ATTRIBUTE_DIRECTORY)) { // verifica se e' stata specificata una libreria differente if(m_szLibraryName[0]=='\0') strcpyn(m_szLibraryName,lpcszLibraryName,sizeof(m_szLibraryName)); if(stricmp(m_szLibraryName,lpcszLibraryName)!=0) { m_ImageFactory.Delete(); m_pImage = NULL; strcpyn(m_szLibraryName,lpcszLibraryName,sizeof(m_szLibraryName)); } // crea l'oggetto immagine if(!m_pImage) m_pImage = m_ImageFactory.Create(m_szLibraryName,sizeof(m_szLibraryName)); // carica l'immagine nel controllo if(m_pImage) { if(m_pImage->IsSupportedFormat(lpszFileName)) if(m_pImage->Load(lpszFileName)) { m_bValidDib = TRUE; // usa lo stesso oggetto per ogni immagine, per cui occhio con il parametro per ricalcolare la paletta m_ImageDraw.SetImage(m_pImage); if(bRebuildPalette) { m_ImageDraw.BuildLogPalette(); RealizePalette(FALSE); } Paint(bClearBeforeDraw); } } } if(!m_bValidDib) Clear(); return(m_bValidDib); }
int split_args(char *str, char data[MAX_SHELL_ARG][ARG_SIZE]) { int i = 0, cpt = 0; char *next; str = trim(str); while (*str != '\0') { next = strchr(str, ' '); if (next != NULL) { if (i < MAX_SHELL_ARG) { strcpyn(str, data[i], next - str); cpt++; } str = next; str++; } else { next = strchr(str, '\0'); if (i < MAX_SHELL_ARG) { strcpy(str, data[i]); cpt++; } str = next; } i++; } return (i <= MAX_SHELL_ARG) ? cpt - 1 : -1; }
void prim_propdirp(PRIM_PROTOTYPE) { /* dbref dir -- int */ CHECKOP(2); oper2 = POP(); /* prop name */ oper1 = POP(); /* dbref */ if (mlev < 2) abort_interp("Permission denied."); if (oper1->type != PROG_OBJECT) abort_interp("Argument must be a dbref (1)"); if (!valid_object(oper1)) abort_interp("Invalid dbref (1)"); if (oper2->type != PROG_STRING) abort_interp("Argument not a string. (2)"); if (!oper2->data.string) abort_interp("Null string not allowed. (2)"); ref = oper1->data.objref; (void) strcpyn(buf, sizeof(buf), oper2->data.string->data); CLEAR(oper1); CLEAR(oper2); result = is_propdir(ref, buf); #ifdef LOG_PROPS log2file("props.log", "#%d (%d) PROPDIR?: o=%d n=\"%s\" v=%d", program, pc->line, ref, buf, result); #endif PushInt(result); }
const char * gui_dlog_alloc(int descr, Gui_CB callback, GuiErr_CB error_cb, void *context) { char tmpid[32]; DlogData *ptr; int tlen; while (1) { snprintf(tmpid, sizeof(tmpid), "%08lX", (unsigned long)RANDOM()); if (!gui_dlog_find(tmpid)) { break; } } ptr = (DlogData *) malloc(sizeof(DlogData)); tlen = strlen(tmpid)+1; ptr->id = (char *) malloc(tlen); strcpyn(ptr->id, tlen, tmpid); ptr->descr = descr; ptr->dismissed = 0; ptr->callback = callback; ptr->error_cb = error_cb; ptr->context = context; ptr->values = NULL; ptr->prev = &dialog_list; ptr->next = dialog_list; if (dialog_list) dialog_list->prev = &ptr->next; dialog_list = ptr; dialog_last_accessed = ptr; return ptr->id; }
/* CreateEx() */ BOOL CWallPaperDrawSettingsModeDlg::CreateEx(CWnd* pParent,UINT nID,CWallPaperConfig* pConfig) { // configurazione corrente m_pConfig = pConfig; // crea l'oggetto immagine per l'elenco dei formati supportati strcpyn(m_szLibraryName,m_pConfig->GetString(WALLPAPER_OPTIONS_KEY,WALLPAPER_CURRENTLIBRARY_KEY),sizeof(m_szLibraryName)); m_pImage = m_ImageFactory.Create(m_szLibraryName,sizeof(m_szLibraryName)); m_ImageParams.Reset(); m_pImage->SetImageParamsDefaultValues(&m_ImageParams); m_pImage->SetImageParamsMinMax(&m_ImageParams); // imposta con i valori della configurazione m_nOwnerMode = m_nWindowsMode = 0; m_nDrawMode = m_pConfig->GetNumber(WALLPAPER_OPTIONS_KEY,WALLPAPER_DRAWMODE_KEY); m_nAreaRatio = m_pConfig->GetNumber(WALLPAPER_OPTIONS_KEY,WALLPAPER_DRAWAREARATIO_KEY); m_nWidth = m_pConfig->GetNumber(WALLPAPER_OPTIONS_KEY,WALLPAPER_DRAWRECTX_KEY); m_nHeight = m_pConfig->GetNumber(WALLPAPER_OPTIONS_KEY,WALLPAPER_DRAWRECTY_KEY); m_nMinWidth = DEFAULT_DRAWRECTX_MIN; m_nMinHeight = DEFAULT_DRAWRECTY_MIN; m_nScreenWidth = ::GetSystemMetrics(SM_CXSCREEN); m_nScreenHeight = ::GetSystemMetrics(SM_CYSCREEN); m_nAreaRatio = m_nAreaRatio < 1 || m_nAreaRatio > 100 ? 50 : m_nAreaRatio; m_nWidth = m_nWidth < m_nMinWidth || m_nWidth > m_nScreenWidth ? m_nMinWidth : m_nWidth; m_nHeight = m_nHeight < m_nMinHeight || m_nHeight > m_nScreenHeight ? m_nMinHeight : m_nHeight; m_nDrawEffect = m_pConfig->GetNumber(WALLPAPER_OPTIONS_KEY,WALLPAPER_DRAWEFFECT_KEY); m_nDrawEffectValue = m_pConfig->GetNumber(WALLPAPER_OPTIONS_KEY,WALLPAPER_DRAWEFFECTVALUE_KEY); // crea il dialogo return(Create(nID,pParent)); }
const char * mfn_left(MFUNARGS) { /* {left:string,fieldwidth,padstr} */ /* Left justify string to a fieldwidth, filling with padstr */ char *ptr; char *fptr; int i, len; char *fillstr; len = (argc > 1) ? atoi(argv[1]) : 78; if (len > BUFFER_LEN - 1) ABORT_MPI("LEFT", "Fieldwidth too big."); fillstr = (argc > 2) ? argv[2] : " "; if (!*fillstr) ABORT_MPI("LEFT", "Null pad string."); strcpyn(buf, buflen, argv[0]); for (i = strlen(argv[0]), ptr = &buf[i], fptr = fillstr; i < len; i++) { *ptr++ = *fptr++; if (!*fptr) fptr = fillstr; } *ptr = '\0'; return buf; }
const char * mfn_right(MFUNARGS) { /* {right:string,fieldwidth,padstr} */ /* Right justify string to a fieldwidth, filling with padstr */ char *ptr; char *fptr; int i, len; char *fillstr; len = (argc > 1) ? atoi(argv[1]) : 78; if (len > BUFFER_LEN - 1) ABORT_MPI("RIGHT", "Fieldwidth too big."); fillstr = (argc > 2) ? argv[2] : " "; if (!*fillstr) ABORT_MPI("RIGHT", "Null pad string."); for (ptr = buf, fptr = fillstr, i = strlen(argv[0]); i < len; i++) { *ptr++ = *fptr++; if (!*fptr) fptr = fillstr; } strcpyn(ptr, buflen - (ptr - buf), argv[0]); return buf; }
int fetch_propvals(dbref obj, const char *dir) { PropPtr p, pptr; int cnt = 0; char buf[BUFFER_LEN]; char name[BUFFER_LEN]; p = first_prop_nofetch(obj, dir, &pptr, name, sizeof(name)); while (p) { cnt = (cnt || propfetch(obj, p)); if (PropDir(p) || (PropFlags(p) & PROP_DIRUNLOADED)) { strcpyn(buf, sizeof(buf), dir); strcatn(buf, sizeof(buf), name); strcatn(buf, sizeof(buf), "/"); if (PropFlags(p) & PROP_DIRUNLOADED) { SetPFlags(p, (PropFlags(p) & ~PROP_DIRUNLOADED)); getproperties(input_file, obj, buf); } fetch_propvals(obj, buf); } p = next_prop(pptr, p, name, sizeof(name)); } return cnt; }
const char * mfn_center(MFUNARGS) { /* {center:string,fieldwidth,padstr} */ /* Center justify string to a fieldwidth, filling with padstr */ char *ptr; char *fptr; int i, len, halflen; char *fillstr; len = (argc > 1) ? atoi(argv[1]) : 78; if (len > BUFFER_LEN - 1) ABORT_MPI("CENTER", "Fieldwidth too big."); halflen = len / 2; fillstr = (argc > 2) ? argv[2] : " "; if (!*fillstr) ABORT_MPI("CENTER", "Null pad string."); for (ptr = buf, fptr = fillstr, i = strlen(argv[0]) / 2; i < halflen; i++) { *ptr++ = *fptr++; if (!*fptr) fptr = fillstr; } strcpyn(ptr, buflen - (ptr - buf), argv[0]); for (i = strlen(buf), ptr = &buf[i], fptr = fillstr; i < len; i++) { *ptr++ = *fptr++; if (!*fptr) fptr = fillstr; } *ptr = '\0'; return buf; }
void log_program_text(struct line *first, dbref player, dbref i) { FILE *f; char fname[BUFFER_LEN]; time_t lt = time(NULL); strcpyn(fname, sizeof(fname), PROGRAM_LOG); f = fopen(fname, "ab"); if (!f) { log_status("Couldn't open file %s!", fname); return; } fputs("#######################################", f); fputs("#######################################\n", f); fprintf(f, "PROGRAM %s, SAVED AT %s BY %s(%d)\n", unparse_object(player, i), ctime(<), NAME(player), player); fputs("#######################################", f); fputs("#######################################\n\n", f); while (first) { if (!first->this_line) continue; fputs(first->this_line, f); fputc('\n', f); first = first->next; } fputs("\n\n\n", f); fclose(f); }
char * do_parse_mesg(int descr, dbref player, dbref what, const char *inbuf, const char *abuf, char *outbuf, int outbuflen, int mesgtyp) { if (tp_do_mpi_parsing) { char *tmp = NULL; struct timeval st, et; /* Quickie additions to do rough per-object MPI profiling */ gettimeofday(&st,NULL); tmp = do_parse_mesg_2(descr, player, what, what, inbuf, abuf, outbuf, outbuflen, mesgtyp); gettimeofday(&et,NULL); if (strcmp(tmp,inbuf)) { if (st.tv_usec > et.tv_usec) { et.tv_usec += 1000000; et.tv_sec -= 1; } et.tv_usec -= st.tv_usec; et.tv_sec -= st.tv_sec; DBFETCH(what)->mpi_proftime.tv_sec += et.tv_sec; DBFETCH(what)->mpi_proftime.tv_usec += et.tv_usec; if (DBFETCH(what)->mpi_proftime.tv_usec >= 1000000) { DBFETCH(what)->mpi_proftime.tv_usec -= 1000000; DBFETCH(what)->mpi_proftime.tv_sec += 1; } DBFETCH(what)->mpi_prof_use++; } return(tmp); } else { strcpyn(outbuf, outbuflen, inbuf); } return outbuf; }
/* Link() */ BOOL CId3v1Tag::Link(const char* lpcszFileName) { BOOL bRet = FALSE; Unlink(); strcpyn(m_szFileName,lpcszFileName,sizeof(m_szFileName)); { CBinFileEx file; if(file.OpenExistingReadOnly(m_szFileName)) { if(file.SeekEx((LONGLONG)sizeof(m_ID3v1) * -1,FILE_END)!=FILE_EEOF) if(file.Read(m_ID3v1,sizeof(m_ID3v1))!=FILE_EOF) { SetTagsFromTag(); bRet = TRUE; } file.Close(); } } return(bRet); }
char * string_substitute(const char *str, const char *oldstr, const char *newstr, char *buf, int maxlen) { const char *ptr = str; char *ptr2 = buf; const char *ptr3; int len = strlen(oldstr); int clen = 0; if (len == 0) { strcpyn(buf, maxlen, str); return buf; } while (*ptr && clen < (maxlen+2)) { if (!strncmp(ptr, oldstr, len)) { for (ptr3 = newstr; ((ptr2 - buf) < (maxlen - 2)) && *ptr3;) *(ptr2++) = *(ptr3++); ptr += len; clen += len; } else { *(ptr2++) = *(ptr++); clen++; } } *ptr2 = '\0'; return buf; }
/* Insert() */ BOOL CUrlService::Insert(UINT& nID, LPCSTR lpcszParentUrl, LPCSTR lpcszUrl, CUrlStatus::URL_STATUS nStat/* = CUrlStatus::URL_STATUS_UNKNOWN*/, LPCSTR lpcszFile/* = NULL*/, double dlSize/* = (double)-1.0f*/, double dlTotalTime/* = 0.0f*/ ) { BOOL bInserted = FALSE; if(m_bIsValid) { // sincronizza l'accesso alla tabella if(m_mutexTable.Lock()) { // decodifica le url strcpyn(m_szUrl,lpcszUrl,sizeof(m_szUrl)); m_Url.DecodeUrl(m_szUrl); strcpyn(m_szParentUrl,lpcszParentUrl,sizeof(m_szParentUrl)); m_Url.DecodeUrl(m_szParentUrl); // inserisce solo se gia' non esiste if(!m_pUrlTable->Seek(m_szUrl,URL_IDX_URL)) { m_pUrlTable->ResetMemvars(); m_pUrlTable->PutField_Id ( ++nID ); m_pUrlTable->PutField_ParentUrl ( m_szParentUrl ); m_pUrlTable->PutField_Url ( m_szUrl ); m_pUrlTable->PutField_Stat ( (short int)nStat ); m_pUrlTable->PutField_File ( lpcszFile ? lpcszFile : "" ); m_pUrlTable->PutField_Size ( dlSize!=(double)-1.0f ? dlSize : 0 ); m_pUrlTable->PutField_Seconds ( dlTotalTime ); m_pUrlTable->GatherMemvars(); bInserted = m_pUrlTable->Insert(); } m_mutexTable.Unlock(); } } return(bInserted); }
const char * mfn_otell(MFUNARGS) { char buf2[BUFFER_LEN]; char *ptr, *ptr2; dbref obj = getloc(player); dbref eobj = player; dbref thing; if (argc > 1) obj = mesg_dbref_local(descr, player, what, perms, argv[1], mesgtyp); if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME) ABORT_MPI("OTELL", "Match failed."); if (obj == PERMDENIED) ABORT_MPI("OTELL", "Permission denied."); if ((mesgtyp & MPI_ISLISTENER) && (Typeof(what) != TYPE_ROOM)) ABORT_MPI("OTELL", "Permission denied."); if (argc > 2) eobj = mesg_dbref_raw(descr, player, what, perms, argv[2]); strcpyn(buf2, sizeof(buf2), argv[0]); for (ptr = buf2; *ptr; ptr = ptr2) { ptr2 = index(ptr, '\r'); if (ptr2) { *ptr2 = '\0'; } else { ptr2 = ptr + strlen(ptr); } if (((OWNER(what) == OWNER(obj) || isancestor(what, obj)) && (Typeof(what) == TYPE_ROOM || (Typeof(what) == TYPE_EXIT && Typeof(getloc(what)) == TYPE_ROOM))) || string_prefix(argv[0], NAME(player))) { strcpyn(buf, buflen, ptr); } else { snprintf(buf, BUFFER_LEN, "%.16s%s%.4078s", NAME(player), ((*argv[0] == '\'' || isspace(*argv[0])) ? "" : " "), ptr); } thing = DBFETCH(obj)->contents; while (thing != NOTHING) { if (thing != eobj) { notify_from_echo(player, thing, buf, 0); } thing = DBFETCH(thing)->next; } } return argv[0]; }
/* Exist() */ BOOL CUrlDatabaseService::Exist(LPCSTR lpcszUrl,LPSTR lpszDate,UINT nDateSize,CUrlStatus::URL_STATUS& nStat,UINT& nID) { BOOL bExist = FALSE; nStat = CUrlStatus::URL_STATUS_UNKNOWN; nID = 0; if(m_bIsValid) { // sincronizza gli accessi if(m_pUrlDatabaseTable->Lock(SYNC_5_SECS_TIMEOUT)) { strcpyn(m_szUrl,lpcszUrl,sizeof(m_szUrl)); m_Url.DecodeUrl(m_szUrl); // controlla se il valore specificato esiste if(m_pUrlDatabaseTable->Seek(m_szUrl,URLDATABASE_IDX_URL)) { m_pUrlDatabaseTable->ScatterMemvars(); CDateTime* pDate = m_pUrlDatabaseTable->GetField_Date(); CDateTime* pTime = m_pUrlDatabaseTable->GetField_StartTime(); m_DateTime.SetYear(pDate->GetYear()); m_DateTime.SetMonth(pDate->GetMonth()); m_DateTime.SetDay(pDate->GetDay()); m_DateTime.SetHour(pTime->GetHour()); m_DateTime.SetMin(pTime->GetMin()); m_DateTime.SetSec(pTime->GetSec()); m_DateTime.SetDateFormat(GMT); strcpyn(lpszDate,m_DateTime.GetFormattedDate(FALSE),nDateSize); nStat = (CUrlStatus::URL_STATUS)m_pUrlDatabaseTable->GetField_Status(); nID = m_pUrlDatabaseTable->GetField_Id(); bExist = TRUE; } else { memset(lpszDate,'\0',nDateSize); } m_pUrlDatabaseTable->Unlock(); } } return(bExist); }
/* SetValue() */ void CConfig::CONFIG::SetValue(LPCSTR lpcszKeyValue) { if(lpcszKeyValue) { memset(m_Value.szValue,'\0',REGKEY_MAX_KEY_VALUE+1); strcpyn(m_Value.szValue,lpcszKeyValue,REGKEY_MAX_KEY_VALUE+1); m_Type = LPSTR_TYPE; } }
void muf_dlog_add(struct frame *fr, const char *dlogid) { struct dlogidlist *item = (struct dlogidlist *) malloc(sizeof(struct dlogidlist)); strcpyn(item->dlogid, sizeof(item->dlogid), dlogid); item->next = fr->dlogids; fr->dlogids = item; }
int blessprops_wildcard(dbref player, dbref thing, const char *dir, const char *wild, int blessp) { char propname[BUFFER_LEN]; char wld[BUFFER_LEN]; char buf[BUFFER_LEN]; char buf2[BUFFER_LEN]; char *ptr, *wldcrd = wld; PropPtr propadr, pptr; int i, cnt = 0; int recurse = 0; #ifdef GOD_PRIV if(tp_strict_god_priv && !God(player) && God(OWNER(thing))) { notify(player,"Only God may touch what is God's."); return 0; } #endif strcpyn(wld, sizeof(wld), wild); i = strlen(wld); if (i && wld[i - 1] == PROPDIR_DELIMITER) strcatn(wld, sizeof(wld), "*"); for (wldcrd = wld; *wldcrd == PROPDIR_DELIMITER; wldcrd++) ; if (!strcmp(wldcrd, "**")) recurse = 1; for (ptr = wldcrd; *ptr && *ptr != PROPDIR_DELIMITER; ptr++) ; if (*ptr) *ptr++ = '\0'; propadr = first_prop(thing, (char *) dir, &pptr, propname, sizeof(propname)); while (propadr) { if (equalstr(wldcrd, propname)) { snprintf(buf, sizeof(buf), "%s%c%s", dir, PROPDIR_DELIMITER, propname); if (!Prop_System(buf) && ((!Prop_Hidden(buf) && !(PropFlags(propadr) & PROP_SYSPERMS)) || Wizard(OWNER(player)))) { if (!*ptr || recurse) { cnt++; if (blessp) { set_property_flags(thing, buf, PROP_BLESSED); snprintf(buf2, sizeof(buf2), "Blessed %s", buf); } else { clear_property_flags(thing, buf, PROP_BLESSED); snprintf(buf2, sizeof(buf2), "Unblessed %s", buf); } notify(player, buf2); } if (recurse) ptr = "**"; cnt += blessprops_wildcard(player, thing, buf, ptr, blessp); } } propadr = next_prop(pptr, propadr, propname, sizeof(propname)); } return cnt; }
/* InitializeNode() Inizializza il nodo. Non inizializza il puntatore al nodo successivo dato che i nodi inutilizzati vengono riciclati (il ptr al nodo successivo viene inizializzato solo quando si inserisce un nuovo nodo nella lista con InsertNode()). */ void CNodeList::InitializeNode(CNode* pNode,int status,void* ptr) { #ifdef _DEBUG memset(pNode->signature,'\0',SIGNATURE_LEN+1); strcpyn(pNode->signature,Signature(),SIGNATURE_LEN+1); #endif pNode->index = 0; pNode->status = status; pNode->data = ptr; }
/* CIcy() */ CIcy::CIcy(LPCSTR pUrl /*= NULL*/,int nPort /*= HTTP_DEFAULT_PORT*/) { Reset(); m_nPort = nPort; if(pUrl) { URL url; SplitUrl(pUrl,&url); strcpyn(m_szHost,StripUrlType(url.host),sizeof(m_szHost)); if(!strnull(url.dir)) strcpyn(m_szDir,url.dir,sizeof(m_szDir)); if(!strnull(url.file)) strcpyn(m_szFile,url.file,sizeof(m_szFile)); m_nPort = url.port; } if(m_nPort <= 0) m_nPort = HTTP_DEFAULT_PORT; }
void prim_abort(PRIM_PROTOTYPE) { CHECKOP(1); oper1 = POP(); if (oper1->type != PROG_STRING) abort_interp("Invalid argument"); strcpyn(buf, sizeof(buf), DoNullInd(oper1->data.string)); abort_interp(buf); }
int new_mvar(const char *varname, char *buf) { if (strlen(varname) > MAX_MFUN_NAME_LEN) return 1; if (varc >= MPI_MAX_VARIABLES) return 2; strcpyn(varv[varc].name, sizeof(varv[varc].name), varname); varv[varc++].buf = buf; return 0; }
int new_mfunc(const char *funcname, const char *buf) { if (strlen(funcname) > MAX_MFUN_NAME_LEN) return 1; if (funcc > MPI_MAX_FUNCTIONS) return 2; strcpyn(funcv[funcc].name, sizeof(funcv[funcc].name), funcname); funcv[funcc++].buf = (char *) string_dup(buf); return 0; }
char * stripspaces(char *buf, int buflen, char *in) { char *ptr; for (ptr = in; *ptr == ' '; ptr++) ; strcpyn(buf, buflen, ptr); ptr = strlen(buf) + buf - 1; while (*ptr == ' ' && ptr > buf) *(ptr--) = '\0'; return buf; }
/* AddItem() */ BOOL CWallBrowserFileView::AddItem(int nIndex,WIN32_FIND_DATA* pfd) { BOOL bAdded = FALSE; ITEMINFO* pItem = new ITEMINFO; if(pItem) { int nImageIndex = 0; char* p = (char*)strrchr(pItem->strFileName,'.'); if(p) { char szExt[_MAX_EXT+1]; strcpyn(szExt,p,sizeof(szExt)); ITERATOR iter; ICONINDEX* iconindex; if((iter = m_IconList.First())!=(ITERATOR)NULL) { while(iter!=(ITERATOR)NULL) { iconindex = (ICONINDEX*)iter->data; if(iconindex) { if(stricmp(iconindex->ext,szExt)==0) { nImageIndex = iconindex->index; break; } } iter = m_IconList.Next(iter); } } } pItem->strFileName = pfd->cFileName; pItem->nFileSizeLow = pfd->nFileSizeLow; pItem->ftLastWriteTime = pfd->ftLastWriteTime; LV_ITEM lvi; lvi.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM; lvi.iItem = nIndex; lvi.iSubItem = 0; lvi.iImage = nImageIndex; lvi.pszText = LPSTR_TEXTCALLBACK; lvi.lParam = (LPARAM)pItem; bAdded = GetListCtrl().InsertItem(&lvi)!=-1; } return(bAdded); }
/* OnGetDispInfo() */ void CWallBrowserFileView::OnGetDispInfo(NMHDR* pnmh,LRESULT* /*pResult*/) { LV_DISPINFO* plvdi = (LV_DISPINFO*)pnmh; if(plvdi->item.mask & LVIF_TEXT) { ITEMINFO* pItem = (ITEMINFO*)plvdi->item.lParam; switch(plvdi->item.iSubItem) { // Name case 0: strcpyn(plvdi->item.pszText,(LPCTSTR)pItem->strFileName,plvdi->item.cchTextMax-1); break; // Size case 1: _snprintf(plvdi->item.pszText, plvdi->item.cchTextMax-1, "%u", pItem->nFileSizeLow ); break; // Modified case 2: BOOL pm = FALSE; CTime time(pItem->ftLastWriteTime); int nHour = time.GetHour(); if(nHour==0) nHour = 12; else if(nHour==12) pm = TRUE; else if(nHour > 12) { nHour -= 12; pm = TRUE; } _snprintf(plvdi->item.pszText, plvdi->item.cchTextMax-1, "%0.2d/%0.2d/%0.2d %0.2d:%0.2d %s", time.GetDay(), time.GetMonth(), time.GetYear() % 100, nHour, time.GetMinute(), pm ? "pm" : "am" ); break; } } }
void gui_value_set_local(const char *dlogid, const char *id, int lines, const char **value) { DlogValue *ptr; DlogData *ddata = gui_dlog_find(dlogid); int i; int limit = 256; if (!ddata) { return; } ptr = ddata->values; while (ptr && strcmp(ptr->name, id)) { ptr = ptr->next; if (!limit--) { return; } } if (ptr) { for (i = 0; i < ptr->lines; i++) { free(ptr->value[i]); } free(ptr->value); } else { int ilen = strlen(id)+1; ptr = (DlogValue *) malloc(sizeof(DlogValue)); ptr->name = (char *) malloc(ilen); strcpyn(ptr->name, ilen, id); ptr->next = ddata->values; ddata->values = ptr; } ptr->lines = lines; ptr->value = (char **) malloc(sizeof(char *) * lines); for (i = 0; i < lines; i++) { int vlen = strlen(value[i])+1; ptr->value[i] = (char *) malloc(vlen); strcpyn(ptr->value[i], vlen, value[i]); } }