static int detect_tp(void) { unsigned long tmo; /* Turn on the chip auto detection of 10BT/ AUI */ clrline(); printf("attempting %s:","TP"); /* If connected to another full duplex capable 10-Base-T card the link pulses seem to be lost when the auto detect bit in the LineCTL is set. To overcome this the auto detect bit will be cleared whilst testing the 10-Base-T interface. This would not be necessary for the sparrow chip but is simpler to do it anyway. */ writereg(PP_LineCTL, eth_linectl &~ AUI_ONLY); control_dc_dc(0); /* Delay for the hardware to work out if the TP cable is present - 150ms */ for (tmo = currticks() + 4; currticks() < tmo; ); if ((readreg(PP_LineST) & LINK_OK) == 0) return 0; if (eth_cs_type != CS8900) { writereg(PP_AutoNegCTL, eth_auto_neg_cnf & AUTO_NEG_MASK); if ((eth_auto_neg_cnf & AUTO_NEG_BITS) == AUTO_NEG_ENABLE) { printf(" negotiating duplex... "); while (readreg(PP_AutoNegST) & AUTO_NEG_BUSY) { if (currticks() - tmo > 40*TICKS_PER_SEC) { printf("time out "); break; } } } if (readreg(PP_AutoNegST) & FDX_ACTIVE) printf("using full duplex"); else printf("using half duplex"); } return A_CNF_MEDIA_10B_T; }
int main(int argc, char* argv[]) { if (argc < 2) { usage(); } SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ); char* path = argv[1]; std::ifstream inf(path); if (!inf.is_open()) std::cout << "open file failed!" << std::endl; std::string buffer; long n = 0; char c = 0; printf("%d", n); while (std::getline(inf, buffer)) { if (buffer.empty()) continue; do { clrline(); for (int i = 0; i < ONCE_LINE_COUNT; i++) { std::cout << buffer.substr(0,80) << std::endl; buffer.erase(0, 80); } ::Sleep(500); while (!g_hasEvent) { ::Sleep(1); } g_hasEvent = false; if (c == 'n' || c == 0x72) { clrscr(); usage(); return 0; } } while (buffer.length() > 80); } clrscr(); usage(); return 0; }
int get_file_over_ftp (net_t *netpolicy) { char buffer [HUGE0], *ptr; struct hostent *phostent; struct sockaddr_in client, pasvclient; int rval; unsigned long filesz, received; slassert (netpolicy != NULL); fprintf (stdout, netpolicy->msg); fflush (stdout); if (!netpolicy->savepart) slassert (!netpolicy->checkstamp); if (!netpolicy->overwrite && file_exist (netpolicy->destpath, NULL, true)) /* regular file exist */ { return shutdown_net_t (netpolicy, FILE_DOWNLOADED, "Already downloaded"); } __act (phostent = gethostbyname (netpolicy->hostname), -1, "Cannot resolve host"); client.sin_family = phostent->h_addrtype; client.sin_port = htons ((unsigned short) netpolicy->port); memcpy (&client.sin_addr.s_addr, phostent->h_addr_list[0], phostent->h_length); __act ((netpolicy->sd = socket (client.sin_family, SOCK_STREAM, 0)) >= 0, -1, NULL); __act ((rval = t_connect (netpolicy->sd, (struct sockaddr *)&client, sizeof client, netpolicy->timeout)) >= 0, -1, NULL); /* starting FTP transaction */ fprintf (stdout, "\r%s [Starting ftp transaction]", netpolicy->msg); fflush (stdout); netpolicy->ftpquit = true; /* read server ready */ __act (t_recv (netpolicy->sd, buffer, HUGE) >= 0, FILE_NOT_DOWNLOADED, "Server not ready"); __act (strncmp (buffer, "220", 3) == 0, FILE_NOT_DOWNLOADED, "Server not ready"); /* anonymous login */ clrline (stdout, strlen (netpolicy->msg) + 30); fprintf (stdout, "\r%s [FTP anonymous login]", netpolicy->msg); fflush (stdout); /* sending username */ __act (!ftp_act (netpolicy, "USER anonymous\r\n", "331"), FILE_NOT_DOWNLOADED, "User failed"); /* sending pass */ __act (!ftp_act (netpolicy, "PASS [email protected]\r\n", "230"), FILE_NOT_DOWNLOADED, "Pass failed"); clrline (stdout, strlen (netpolicy->msg) + 25); fprintf (stdout, "\r%s [Retrieving file]", netpolicy->msg); fflush (stdout); __act (!ftp_act (netpolicy, "SYST\r\n", "215"), FILE_NOT_DOWNLOADED, "Syst error"); __act (!ftp_act (netpolicy, "TYPE I\r\n", "200"), FILE_NOT_DOWNLOADED, "Type I error"); __act (!ftp_act (netpolicy, "PASV\r\n", "227"), FILE_NOT_DOWNLOADED, "Pasv error"); /* obtain ip and port on passive mode */ __act (ptr = strchr (netpolicy->ftpreply, '('), FILE_NOT_DOWNLOADED, "Error on pasv mode"); sscanf (ptr, "(%hu,%hu,%hu,%hu,%hu,%hu)", &netpolicy->pasv[0], &netpolicy->pasv[1], /* IP */ &netpolicy->pasv[2], &netpolicy->pasv[3], /* IP */ &netpolicy->pasv[4], &netpolicy->pasv[5]); /* port: pasv[4] * 256 + pasv[5] */ snprintf (netpolicy->pasvip, sizeof netpolicy->pasvip, "%hu.%hu.%hu.%hu", netpolicy->pasv[0], netpolicy->pasv[1], netpolicy->pasv[2], netpolicy->pasv[3]); netpolicy->pasvport = netpolicy->pasv[4] * 256 + netpolicy->pasv[5]; netpolicy->pasvsd = socket (AF_INET, SOCK_STREAM, 0); pasvclient.sin_family = AF_INET; pasvclient.sin_port = htons((unsigned short) netpolicy->pasvport); __act (inet_pton (AF_INET, netpolicy->pasvip, &pasvclient.sin_addr) == 1 && !t_connect (netpolicy->pasvsd, (struct sockaddr *) &pasvclient, sizeof pasvclient, netpolicy->timeout), -1, "ftp pasv error"); snprintf (buffer, HUGE, "SIZE %s\r\n", netpolicy->srcpath); __act (!ftp_act (netpolicy, buffer, "213"), FILE_NOT_DOWNLOADED, (atoi (netpolicy->ftpreply) == 550) ? "File not found" : "Size error"); filesz = atoi (netpolicy->ftpreply + 4); /* 4 = strlen ("213 ") */ /* require file */ snprintf (buffer, HUGE, "RETR %s\r\n", netpolicy->srcpath); __act (!ftp_act (netpolicy, buffer, "150"), FILE_NOT_DOWNLOADED, "Retr error"); checkstamp (netpolicy, netpolicy->pasvsd); __act (netpolicy->oldstamp != 0, FILE_ALREADY_UPDATE, "Already update"); if (netpolicy->savepart) { slassert ((strlen (netpolicy->destpath) + strlen (".part")) < sizeof (netpolicy->destpath)); strcat (netpolicy->destpath, ".part"); } __act (netpolicy->fddest = fopen (netpolicy->destpath, "wb"), -1, netpolicy->destpath); if (netpolicy->oldstamp == 1) { fwrite (netpolicy->stamprecv, 1, STAMPSZ, netpolicy->fddest); } received = (netpolicy->checkstamp) ? STAMPSZ : 0; clrline (stdout, strlen (netpolicy->msg) + 25); netstat (NETSTAT_INIT, 0, 0, 0); /* init */ while ((rval = recv (netpolicy->pasvsd, buffer, HUGE, 0)) > 0) { received += (unsigned long) rval; fprintf (stdout, "\r%s [%s]", netpolicy->msg, netstat (0, 1, received, filesz)); fflush (stdout); fwrite (buffer, 1, rval, netpolicy->fddest); } fprintf (stdout, "\r%s [%s]\n", netpolicy->msg, netstat (NETSTAT_END, 1, received, filesz)); /* finish, flush 100% */ fflush (stdout); return shutdown_net_t (netpolicy, 0, NULL); }
void buftscr( union both_scr *posptr, int nfield, int rowcol[] [5], char inptext[] [25] [80], register struct bufline *curr, int maxlrecl, int coloffset, int wherest[25], int wherend[25], register struct lineptrs *place, int clrmsg) /**********************************************************************/ /* */ /* Move the data from the input buffer linear format to the inptext */ /* triplex format and display to the screen one line at a time */ /* using buftsln. */ /* */ /**********************************************************************/ /* */ /* This is ZEDIT source material. */ /* */ /* ZEDIT Source Materials are intellectual property */ /* (c) Copyright 1987,2001 by Clyde Thomas Zuber. */ /* */ /**********************************************************************/ { extern unsigned int graphic; register int line_no; int col_no; int rc[1] [5]; int amode; int num; int eol; int toright = YES; char *scratch; char cwrk[8]; rc[0] [0] = 0; rc[0] [1] = 0; rc[0] [2] = maxlrecl; rc[0] [3] = 0; rc[0] [4] = RC_ENTRY; topline(posptr, nfield, rowcol, inptext, curr, maxlrecl, coloffset, clrmsg); if (rowcol[nfield - 1] [TOP_MAR] == rowcol[nfield] [TOP_MAR] && rowcol[nfield - 1] [BOTTOM_MAR] == rowcol[nfield] [BOTTOM_MAR]) num = YES; else num = NO; line_no = rowcol[nfield] [TOP_MAR]; /**********************************************************************/ /* Since the starting offset for each high level index are 2000 bytes */ /* apart the minimum and maximum needed is 4000 + maxlrecl. */ /**********************************************************************/ if (coloffset) { scratch = (char *) malloc(4000 + maxlrecl); if (!scratch) zfinish(posptr, no_storage); } /* end then */ while (curr && line_no <= rowcol[nfield] [BOTTOM_MAR]) { if (curr -> status & ST_EXCL) { curr = curr -> next; continue; } /* end then */ if (num) if (curr == place -> slst) { dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#(( ", 0, inptext); itoa(place -> count, cwrk, 10); dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR] + 3, cwrk, 0, inptext); } /* end then */ else if (curr == place -> srst) { dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#)) ", 0, inptext); itoa(place -> count, cwrk, 10); dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR] + 3, cwrk, 0, inptext); } /* end then, else */ else if (curr == place -> after) dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#A ", 0, inptext); else if (curr == place -> copyst) if (place -> copyst == place -> copyfn) dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#C ", 0, inptext); else dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#CC ", 0, inptext); else if (curr == place -> copyfn) dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#CC ", 0, inptext); else if (curr == place -> delst) dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#DD ", 0, inptext); else if (curr == place -> movest) if (place -> movest == place -> movefn) dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#M ", 0, inptext); else dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#MM ", 0, inptext); else if (curr == place -> movefn) dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#MM ", 0, inptext); else if (curr == place -> onst) dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#OO ", 0, inptext); else if (curr == place -> onfn) dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#OO ", 0, inptext); else if (curr == place -> repst) { dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#RR ", 0, inptext); itoa(place -> count, cwrk, 10); dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR] + 3, cwrk, 0, inptext); } /* end then, else */ else if (curr == place -> excst) dispnum(posptr, nfield, rowcol, NO, line_no, rowcol[nfield - 1] [LEFT_MAR], "#XX ", 0, inptext); else dispnum(posptr, nfield, rowcol, curr -> status, line_no, rowcol[nfield - 1] [LEFT_MAR], curr -> lineno, 0, inptext); /* zedpimg and zedpbuf have parallel logic */ amode = curr -> script; if (curr -> script == BUF_HEBREW) toright = NO; else toright = YES; wherest[line_no] = 0; eol = NO; if (coloffset && (curr -> status & ST_SCRL)) getstrt(coloffset, curr -> bline, rc, scratch, &wherest[line_no], &amode, &eol, &toright); wherend[line_no] = wherest[line_no]; if (toright) col_no = rowcol[nfield] [LEFT_MAR]; else col_no = rowcol[nfield] [RIGHT_MAR]; buftsln(posptr, nfield, rowcol, curr, line_no, maxlrecl, inptext, &wherend[line_no], &amode, &eol, &toright, &col_no); curr = curr -> next; ++line_no; } /* end lineloop */ /* clear out bottom of window */ while (line_no <= rowcol[nfield] [BOTTOM_MAR]) { clrline(posptr, line_no); memset(&inptext[ATR] [line_no] [0], ATR_PROTECT, 80); memset(&inptext[TXT] [line_no] [0], 0x00, 80); memset(&inptext[SRP] [line_no] [0], 0x00, 80); memset(&inptext[OVR] [line_no] [0], 0x00, 80); ++line_no; } /* end while */ if (coloffset) free(scratch); if (graphic & XGA) xga8514(posptr, FULLSCR, NO); } /* end buftscr */
char interpEditObjMiscMenu(usint ch, dikuObject *obj) { char strn[256] = "\0"; struct rccoord coords; // edit object type if (ch == 'A') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); while (TRUE) { if (checkForObjHeresWithLoadedContainer(obj->objNumber)) { displayColorString( "&+MCannot change type - objects exist of this type with items inside - press a key&n"); getkey(); displayEditObjMiscMenu(obj); return FALSE; } displayColorString("&+CNew object type (? for list): &n"); itoa(obj->objType, strn, 10); getStrn(strn, 3, 1, 7, '°', strn, FALSE, FALSE); if (!strcmp(strn, "?")) displayObjTypeList(); else break; } obj->objType = atoi(strn); displayEditObjMiscMenu(obj); } else // edit object value 0 if (ch == 'B') { editObjValueField(obj, 0); displayEditObjMiscMenu(obj); } else // edit object value 1 if (ch == 'C') { editObjValueField(obj, 1); displayEditObjMiscMenu(obj); } else // edit object value 2 if (ch == 'D') { editObjValueField(obj, 2); displayEditObjMiscMenu(obj); } else // edit object value 3 if (ch == 'E') { editObjValueField(obj, 3); displayEditObjMiscMenu(obj); } else // edit object value 4 if (ch == 'F') { editObjValueField(obj, 4); displayEditObjMiscMenu(obj); } else // edit object value 5 if (ch == 'G') { editObjValueField(obj, 5); displayEditObjMiscMenu(obj); } else // edit object value 6 if (ch == 'H') { editObjValueField(obj, 6); displayEditObjMiscMenu(obj); } else // edit object value 7 if (ch == 'I') { editObjValueField(obj, 7); displayEditObjMiscMenu(obj); } else // edit apply "type" 0 if (ch == 'J') { editObjApplyType(obj, 0); displayEditObjMiscMenu(obj); } else // edit apply modifier 0 if (ch == 'K') { editObjApplyValue(obj, 0); displayEditObjMiscMenu(obj); } else // edit apply "type" 1 if (ch == 'L') { editObjApplyType(obj, 1); displayEditObjMiscMenu(obj); } else // edit apply modifier 1 if (ch == 'M') { editObjApplyValue(obj, 1); displayEditObjMiscMenu(obj); } else if (checkMenuKey(ch, FALSE) == MENUKEY_SAVE) return TRUE; return FALSE; }
void editObjValueField(dikuObject *obj, uchar valueField) { struct rccoord coords; char strn[256], helpAvail = checkForValueList(obj->objType, valueField), verboseAvail = checkForVerboseAvail(obj->objType, valueField), searchAvail = (checkForSearchAvail(obj->objType, valueField) ? TRUE : FALSE); coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); if (!specialObjValEdit(obj, valueField, FALSE)) { while (TRUE) { if (!(verboseAvail && searchAvail)) sprintf(strn, "&+CNew value for object field #%u", valueField + 1); else sprintf(strn, "&+CNew val for obj field #%u", valueField + 1); // assume verbose/search are only available if help is available if (helpAvail) { strcat(strn, " (? for list"); // if (verboseAvail) strcat(strn, ", ?? for full list"); if (searchAvail) strcat(strn, ", $ to search"); strcat(strn, "): &n"); } else strcat(strn, ": &n"); displayColorString(strn); itoa(obj->objValues[valueField], strn, 10); getStrn(strn, 8, 1, 7, '°', strn, FALSE, FALSE); if (!strcmp(strn, "?") && helpAvail) { displayObjValueHelp(obj->objType, valueField, FALSE); } else // below assumes that verbose is only available when help is available if (!strcmp(strn, "??") && verboseAvail) { displayObjValueHelp(obj->objType, valueField, TRUE); } else // ditto for search if (!strcmp(strn, "$") && searchAvail) { searchObjValue(obj->objType, valueField); } else break; // later add some sorta range checking or sump'n } obj->objValues[valueField] = atoi(strn); } else specialObjValEdit(obj, valueField, TRUE); }
char jumpObj(const dikuObject *obj, ulong *numb) { struct rccoord coords; char strn[128], numbStrn[64]; ulong numb2; coords = _gettextposition(); // coords.row -= 2; _settextposition(coords.row, 1); clrline(coords.row); while (TRUE) { sprintf(strn, "&+CJump to which object (%u-%u, ? for list, $ to search): &n", getLowestObjNumber(), getHighestObjNumber()); displayColorString(strn); itoa(obj->objNumber, numbStrn, 10); getStrn(strn, 6, 1, 7, '°', numbStrn, FALSE, FALSE); // check user input if (!strcmp(strn, "?")) { displayObjectTypeList(); } else if (!strcmp(strn, "$")) { strn[0] = 0; _setbkcolor(0); displayColorString("\n&+CEnter substring to search object list for: &n"); getStrn(strn, 25, 1, 7, '°', strn, FALSE, FALSE); upstrn(strn); displayObjectTypeList(strn, FALSE); } else { numb2 = strtoul(strn, NULL, 10); if ((!strnumer(strn)) || (numb2 >= numbLookupEntries) || (!findObj(numb2))) { clrline(coords.row, 7, 0); _settextposition(coords.row, 1); _setbkcolor(0); displayColorString(getMenuPromptName()); return MENU_JUMP_ERROR; } else { *numb = numb2; return MENU_JUMP_VALID; } } } }
char interpEditObjTypeMenu(usint ch, dikuObject *obj, dikuObject *origObj, char *addedIdentKeyword) { struct rccoord coords; char strn[256], numbStrn[32], newName[256]; stringNode *strnN; ulong i; // edit obj short name if (ch == 'A') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString("&+CNew object short name: &n"); // length - 1 - 1 because we gotta allow space for the tilde at the end getStrn(obj->objShortName, MAX_OBJSNAME_LEN - 1 - 1 - 1, 1, 7, '°', obj->objShortName, FALSE, FALSE); remTrailingSpaces(obj->objShortName); remLeadingSpaces(obj->objShortName); displayEditObjTypeMenu(obj); } else // edit obj long name if (ch == 'B') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString("&+CNew object long name: &n"); // length - 1 - 1 because we gotta allow space for the tilde at the end getStrn(obj->objLongName, MAX_OBJLNAME_LEN - 1 - 1 - 1, 1, 7, '°', obj->objLongName, FALSE, FALSE); remTrailingSpaces(obj->objLongName); remLeadingSpaces(obj->objLongName); displayEditObjTypeMenu(obj); } else // edit obj keywords if (ch == 'C') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString("&+CNew object keywords: &n"); createKeywordString(obj->keywordListHead, strn); strn[strlen(strn) - 1] = '\0'; // get rid of tilde getStrn(strn, MAX_OBJKEY_LEN - 1, 1, 7, '°', strn, FALSE, FALSE); remTrailingSpaces(strn); remLeadingSpaces(strn); strcat(strn, "~"); deleteStringNodes(obj->keywordListHead); obj->keywordListHead = createKeywordList(strn); displayEditObjTypeMenu(obj); } else // edit obj extra flags if (ch == 'D') { editObjExtraFlags(obj, origObj); displayEditObjTypeMenu(obj); } else // edit obj extra2 flags if (ch == 'E') { editObjExtra2Flags(obj, origObj); displayEditObjTypeMenu(obj); } else // edit obj wear flags if (ch == 'F') { editObjWearFlags(obj, origObj); displayEditObjTypeMenu(obj); } else // edit obj anti flags if (ch == 'G') { editObjAntiFlags(obj, origObj); displayEditObjTypeMenu(obj); } else // edit obj anti2 flags if (ch == 'H') { editObjAnti2Flags(obj, origObj); displayEditObjTypeMenu(obj); } else // edit obj type, applies, values if (ch == 'I') { editObjMisc(obj); displayEditObjTypeMenu(obj); } else // edit obj weight, dam bonus, etc if (ch == 'J') { editObjMisc2(obj); displayEditObjTypeMenu(obj); } else // edit obj extra descs if (ch == 'K') { if (editObjExtraDesc(obj, addedIdentKeyword)) { // user aborted, check for _id_ keyword and remove it if (*addedIdentKeyword) { strnN = obj->keywordListHead; while (strnN) { if (!strcmp(strnN->string, "_ID_")) { if (!strnN->Last) // head of list { obj->keywordListHead = obj->keywordListHead->Next; obj->keywordListHead->Last = NULL; delete strnN; } else { strnN->Last->Next = strnN->Next; strnN->Next->Last = strnN->Last; delete strnN; } } strnN = strnN->Next; } } } displayEditObjTypeMenu(obj); } else // edit obj trap info if (ch == 'M') { editObjTrapInfo(obj); displayEditObjTypeMenu(obj); } else // if allowed, edit aff1 flag if (getObjAffectVal() && (ch == 'N')) { editObjAffect1Flags(obj); displayEditObjTypeMenu(obj); } else // ditto for aff2 flag if (getObjAffectVal() && (ch == 'O')) { editObjAffect2Flags(obj); displayEditObjTypeMenu(obj); } else // ditto for aff3 flag if (getObjAffectVal() && (ch == 'P')) { editObjAffect3Flags(obj); displayEditObjTypeMenu(obj); } else // ditto for aff4 flag if (getObjAffectVal() && (ch == 'Q')) { editObjAffect4Flags(obj); displayEditObjTypeMenu(obj); } else // change limit if (ch == 'L') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString( "&+CNew limit on loads for this object type (0 = no limit): &n"); itoa(getNumbEntities(ENTITY_OBJECT, obj->objNumber, TRUE), numbStrn, 10); // strn[0] = '\0'; getStrn(strn, 6, 1, 7, '°', numbStrn, FALSE, FALSE); // check user input if (!strnumer(strn)) { clrline(coords.row, 7, 0); _settextposition(coords.row, 1); _setbkcolor(0); displayColorString(getMenuPromptName()); return FALSE; } i = atoi(strn); if ((i <= getNumbEntities(ENTITY_OBJECT, obj->objNumber, FALSE)) && (i != 0)) { _settextposition(coords.row, 1); clrline(coords.row, 7, 0); _setbkcolor(0); displayColorString( "&+CError: Limit being set lower than or equal to the number loaded - press any key&n"); getkey(); clrline(coords.row, 7, 0); _settextposition(coords.row, 1); _setbkcolor(0); displayColorString(getMenuPromptName()); return FALSE; } setEntityOverride(ENTITY_OBJECT, obj->objNumber, i, obj->globalmaxload); obj->maxload = i; madeChanges = TRUE; displayEditObjTypeMenu(obj); } else if (ch == 'R') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString( "&+CNew MUD-wide limit on loads for this object type (0 = no limit): &n"); itoa(getNumbEntities(ENTITY_OBJECT, obj->objNumber, TRUE), numbStrn, 10); // strn[0] = '\0'; getStrn(strn, 6, 1, 7, '°', numbStrn, FALSE, FALSE); // check user input if (!strnumer(strn)) { clrline(coords.row, 7, 0); _settextposition(coords.row, 1); _setbkcolor(0); displayColorString(getMenuPromptName()); return FALSE; } i = atoi(strn); if ((i <= getNumbEntities(ENTITY_OBJECT, obj->objNumber, FALSE)) && (i != 0)) { _settextposition(coords.row, 1); clrline(coords.row, 7, 0); _setbkcolor(0); displayColorString( "&+CError: Limit being set lower than or equal to the number loaded - press any key&n"); getkey(); clrline(coords.row, 7, 0); _settextposition(coords.row, 1); _setbkcolor(0); displayColorString(getMenuPromptName()); return FALSE; } setEntityOverride(ENTITY_OBJECT, obj->objNumber, obj->maxload, i); obj->globalmaxload = i; madeChanges = TRUE; displayEditObjTypeMenu(obj); } else // change vnum if ((ch == 'V') && !obj->defaultObj) { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); sprintf(strn, "&+YNew object vnum (highest allowed %u): &n", numbLookupEntries - 1); displayColorString(strn); itoa(obj->objNumber, numbStrn, 10); getStrn(strn, 6, 1, 7, '°', numbStrn, FALSE, FALSE); // check user input if ((!strnumer(strn)) || (atoi(strn) >= numbLookupEntries) || (findObj(atoi(strn)))) { clrline(coords.row, 7, 0); _settextposition(coords.row, 1); _setbkcolor(0); displayColorString(getMenuPromptName()); return FALSE; } i = atoi(strn); resetAllObjHere(obj->objNumber, i, roomHead); resetNumbLoaded(ENTITY_OBJECT, obj->objNumber, i); checkAndFixRefstoObj(obj->objNumber, i); objLookup[i] = origObj; objLookup[obj->objNumber] = NULL; obj->objNumber = i; resetEntityPointersByNumb(TRUE, FALSE); _settextposition(1, 1); clrline(1, 0, 0); fixObjName(obj->objShortName, newName); _setbkcolor(0); sprintf(strn, "&n&+gEditing object type #&+c%u&+w, &+L\"&n%s&+L\"&n\n\n", obj->objNumber, newName); displayColorString(strn); clrline(coords.row, 7, 0); _settextposition(coords.row, 1); displayColorString(getMenuPromptName()); } else // quit if (checkMenuKey(ch, FALSE) == MENUKEY_SAVE) return TRUE; return FALSE; }
monitor() { register char chr; int timevec[2]; register int controlno; while (chr = getch()) { if (chr == '\\') { /* process control sequence */ if ((controlno = getescape(1)) == 0) continue; switch (controlno) { case C_EDIT: edit(); continue; case C_PRINT: print(); continue; case C_LIST: eval(1); continue; case C_EVAL: eval(0); Autoclear = TRUE; continue; case C_INCLUDE: include(0); cgprompt(); continue; case C_WRITE: writeout(); cgprompt(); continue; case C_CHDIR: newdirec(); cgprompt(); continue; case C_RESET: clear(1); continue; case C_GO: go(); continue; case C_QUIT: clrline(1); quit(); case C_SHELL: shell(); continue; case C_TIME: time(timevec); printf("%s", ctime(timevec)); clrline(0); continue; case C_APPEND: Autoclear = 0; clrline(0); continue; case C_MARK: getfilename(); prompt(0); continue; case C_BRANCH: branch(); prompt(0); continue; default: syserr("monitor: bad code %d", controlno); } } putch(chr); } if (Input == stdin) { if (Nodayfile >= 0) printf("\n"); } else fclose(Input); }
//*************************************************************************** // Message Menu used to create ASCII strings from the keypad //*************************************************************************** void enter_chars(char *p) { int i, column, len, disp_col, disp_row; int wKey; char *orig_ptr; // Initialize function parameters orig_ptr = p; i = 0; column = 0; len = 0; // Display the initial charater set for the user to choose from glBlankScreen(); TextGotoXY(&textWindow1, 0, 1); TextPrintf(&textWindow1, "-"); TextGotoXY(&textWindow1, 0, 0); TextPrintf(&textWindow1, "%s", s[i]); // Display user instructions display_help(); // Setup for FAST key repeat after holding down key for 12 ticks keyConfig ( 6,'E',0, 12, 1, 1, 1 ); keyConfig ( 2,'D',0, 12, 1, 1, 1 ); keyConfig ( 5,'+',0, 12, 1, 1, 1 ); keyConfig ( 1,'U',0, 12, 1, 1, 1 ); keyConfig ( 4,'-',0, 12, 1, 1, 1 ); keyConfig ( 0,'L',0, 12, 1, 1, 1 ); keyConfig ( 3,'R',0, 12, 1, 1, 1 ); // Clear only the bottom half of the display glSetBrushType(PIXWHITE); glBlock(0,16,122,16); glSetBrushType(PIXBLACK); // Set window2 to start at column 0 TextGotoXY(&textWindow2, 0, 0); TextPrintf(&textWindow2, "_"); TextGotoXY(&textWindow2, 0, 0); do { // Wait for a key to be pressed do { keyProcess(); msDelay(50); wKey = keyGet(); } while(wKey == 0); switch(wKey) { // Scroll-Down to select new character group case 'D': i = i < (sizeof(s)/2)-1 ? ++i : 0; clrline(1, len); TextGotoXY(&textWindow1, 0, 1); TextPrintf(&textWindow1, "-"); column = 0; clrline(0, strlen(*s)); TextGotoXY(&textWindow1, 0, 0); TextPrintf(&textWindow1, "%s", s[i]); break; // Scroll-Up to select new character group case 'U': i = i > 0 ? --i : 0; clrline(1, len); TextGotoXY(&textWindow1, 0, 1); TextPrintf(&textWindow1, "-"); column = 0; clrline(0, strlen(*s)); TextGotoXY(&textWindow1, 0, 0); TextPrintf(&textWindow1, "%s", s[i]); break; // Scroll-Right for character set case 'R': column = column < strlen(*(&s[i]))-1 ? ++column : 0; clrline(1, len = strlen(*(&s[i]))); TextGotoXY(&textWindow1, column, 1); TextPrintf(&textWindow1, "-"); break; // Scroll-Left for character set case 'L': column = column > 0 ? --column : 0; clrline(1, len = strlen(*(&s[i]))); TextGotoXY(&textWindow1, column, 1); TextPrintf(&textWindow1, "-"); break; // Add the selected character to the message case '+': // select char *p = s[i][column]; if(*p == '_' && column == strlen(*(&s[i]))-1 ) { // Change to a space *p = ' '; } TextCursorLocation(&textWindow2, &disp_col, &disp_row); TextPrintf(&textWindow2, "%c", *p++); TextPrintf(&textWindow2, "_"); TextGotoXY(&textWindow2, disp_col+1, 0); break; // Do a Backspace in the message case '-': TextGotoXY(&textWindow2, disp_col, disp_row); TextPrintf(&textWindow2, " "); TextGotoXY(&textWindow2, disp_col, disp_row); TextPrintf(&textWindow2, "_ "); if(disp_col > 0) { p--; } TextGotoXY(&textWindow2, disp_col--, disp_row); if(disp_col < 0) { disp_col = 0; p = orig_ptr; } break; } }while(wKey != 'E'); // NULL the terminate the user message *p = '\0'; // Set the keypad back to the default driver configuration keypadDef(); }
char interpEditObjTrapInfoMenu(usint ch, dikuObject *obj) { char strn[256] = "\0", newName[256]; struct rccoord coords; // edit trap affect flag if (ch == 'A') { fixObjName(obj->objShortName, newName); sprintf(strn, "&+gEditing trap effect flags for obj #&+c%u&+w, &+L\"&n%s&+L\"&n\n\n", obj->objNumber, newName); editFlags(trapEffFlagDef, &(obj->trapAff), strn, "object trap effect flags", NULL, 1); displayEditObjTrapInfoMenu(obj); } else // edit trap damage type if (ch == 'B') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); while (TRUE) { displayColorString("&+CNew trap damage type (? for list):&n "); itoa(obj->trapDam, strn, 10); getStrn(strn, 10, 1, 7, '°', strn, FALSE, FALSE); if (!strcmp(strn, "?")) displayObjTrapDamList(); else break; // later add some sorta range checking or sump'n } obj->trapDam = atoi(strn); displayEditObjTrapInfoMenu(obj); } else // edit number of trap uses if (ch == 'C') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); while (TRUE) { displayColorString("&+CNew number of trap uses:&n "); itoa(obj->trapCharge, strn, 10); getStrn(strn, 10, 1, 7, '°', strn, FALSE, FALSE); break; } obj->trapCharge = atoi(strn); displayEditObjTrapInfoMenu(obj); } else // edit trap level if (ch == 'D') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); while (TRUE) { displayColorString("&+CNew trap level (1-100):&n "); itoa(obj->trapLevel, strn, 10); getStrn(strn, 10, 1, 7, '°', strn, FALSE, FALSE); break; } obj->trapLevel = atoi(strn); displayEditObjTrapInfoMenu(obj); } else if (ch == 'E') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); while (TRUE) { displayColorString("&+CNew trap percent (1-100):&n "); itoa(obj->trapPercent, strn, 10); getStrn(strn, 10, 1, 7, '°', strn, FALSE, FALSE); break; } obj->trapPercent = atoi(strn); displayEditObjTrapInfoMenu(obj); } else if (checkMenuKey(ch, FALSE) == MENUKEY_SAVE) return TRUE; return FALSE; }
void displine(struct line_node *line,unsigned y,unsigned linenum) { register unsigned x = 0; int count = firstcol; font_attr tempfont, curfont = 0; char *st; st = line->text; y += wind.row; while ((count > 0) && (*st != '\0')) { if (whatlevel(*st) == MIDDLE) { if (*st < 32) { togglefont(&curfont,*st); } else { if ((curfont & ENLARGEATTR) == ENLARGEATTR) { count--; } count--; } } st++; } if ((count < 0) && ((curfont & ENLARGEATTR) == ENLARGEATTR)) { x++; } while ((*st != '\0') && (x < (wind.length - 2))){ if (*st < 32) { togglefont(&curfont,*st); } else { tempfont = curfont; if (haveblock() && inblock(linenum,x + firstcol) && dispblock) { curfont = curfont | REVERSEATTR; } if (whatlevel(*st) != MIDDLE) { if (x > 0) { if ((curfont & ENLARGEATTR) == ENLARGEATTR) { if (x >= 2) { prchar(*st,curfont,wind.col+x-2,y); } } else { prchar(*st,curfont,wind.col+x-1,y); } } } else { if ((*st != ' ') || (curfont != 0)) { if ((curfont & ENLARGEATTR) != ENLARGEATTR) { prchar(*st,curfont,wind.col+x,y); x++; } else { prchar(*st,curfont,wind.col+x,y); x += 2; } } else { /* if it's blank and normal attribute,use prblank to speed up */ prblank(wind.col+x,y); x++; } } curfont = tempfont; } st++; } clrline(wind.col+x,y,wind.col+wind.length-1); if (line->wrap == NO) { prchar('<',0,wind.col + wind.length - 1,y); } if (*st != '\0') { prchar('+',0,wind.col + wind.length - 1,y); } y -= wind.row; /* if (graphbuff[y] != NULL) paintlinegraph(graphbuff[y],y); */ }
char interpEditConfigMenu(const usint ch) { struct rccoord coords; char tempStrn[256], strn[256]; // toggle vnum checking if (ch == 'A') { setVarBoolVal(&varHead, VAR_VNUMCHECK_NAME, !getVnumCheckVal(), FALSE); displayEditConfigMenu(); } else // toggle zone flag checking if (ch == 'B') { setVarBoolVal(&varHead, VAR_CHECKZONEFLAGS_NAME, !getCheckZoneFlagsVal(), FALSE); displayEditConfigMenu(); } else // toggle stopping at zone 'S' line setting /* if (ch == 'C') { setVarBoolVal(&varHead, VAR_IGNOREZONES_NAME, !getIgnoreZoneSVal(), FALSE); displayEditConfigMenu(); } else */ // toggle the showing of info on menus if (ch == 'C') { setVarBoolVal(&varHead, VAR_SHOWMENUINFO_NAME, !getShowMenuInfoVal(), FALSE); displayEditConfigMenu(); } else // toggle walk creation mode if (ch == 'D') { setVarBoolVal(&varHead, VAR_WALKCREATE_NAME, !getWalkCreateVal(), FALSE); displayEditConfigMenu(); } else // toggle saving of currentRoom vnum if (ch == 'E') { setVarBoolVal(&varHead, VAR_SROOMACTIVE_NAME, !getStartRoomActiveVal(), FALSE); displayEditConfigMenu(); } else // toggle object edesc thingy /* if (ch == 'F') { setVarBoolVal(&varHead, VAR_FIRSTOBJEDESCKEY_NAME, !getFirstObjEdescKeyVal(), FALSE); displayEditConfigMenu(); } else */ // toggle 'consider exit dest of -1 as out-of-zone' var if (ch == 'F') { setVarBoolVal(&varHead, VAR_NEGDESTOUTOFZONE_NAME, !getNegDestOutofZoneVal(), FALSE); displayEditConfigMenu(); } else // toggle 'show shop prices adjusted' var if (ch == 'G') { setVarBoolVal(&varHead, VAR_SHOWPRICESADJUSTED_NAME, !getShowPricesAdjustedVal(), FALSE); displayEditConfigMenu(); } else // toggle 'autosave every X commands' var if (ch == 'H') { setVarBoolVal(&varHead, VAR_SAVEEVERYXCOMMANDS_NAME, !getSaveEveryXCommandsVal(), FALSE); displayEditConfigMenu(); } else // edit 'when to autosave' variable if (ch == 'I') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString("&+CNew number of commands between autosaving: &n"); itoa(getSaveHowOftenVal(), strn, 10); getStrn(tempStrn, 4, 1, 7, '°', strn, FALSE, FALSE); if (strnumer(tempStrn)) { addVar(&varHead, VAR_SAVEHOWOFTEN_NAME, tempStrn); } displayEditConfigMenu(); } else // edit screen height if (ch == 'J') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString("&+CNew screen height: &n"); itoa(getScreenHeight(), strn, 10); getStrn(tempStrn, 4, 1, 7, '°', strn, FALSE, FALSE); // allowing a height of 0 would be bad if (strnumer(tempStrn) && atoi(tempStrn)) { addVar(&varHead, VAR_SCREENHEIGHT_NAME, tempStrn); } displayEditConfigMenu(); } else // edit screen width if (ch == 'K') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString("&+CNew screen width: &n"); itoa(getScreenWidth(), strn, 10); getStrn(tempStrn, 4, 1, 7, '°', strn, FALSE, FALSE); // allowing a width of 0 would be very bad if (strnumer(tempStrn) && atoi(tempStrn)) { addVar(&varHead, VAR_SCREENWIDTH_NAME, tempStrn); } displayEditConfigMenu(); } else // edit name of external editor if (ch == 'L') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString("&+CNew external editor (full path, if necessary): &n"); getStrn(tempStrn, MAX_VARVAL_LEN - 1, 1, 7, '°', getEditorName(), FALSE, FALSE); addVar(&varHead, VAR_TEXTEDIT_NAME, tempStrn); displayEditConfigMenu(); } else // edit name of menu edit prompt if (ch == 'M') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString("&+CNew prompt for menus: &n"); getStrn(tempStrn, MAX_VARVAL_LEN - 1, 1, 7, '°', getMenuPromptName(), FALSE, FALSE); if ((strlen(tempStrn) < (MAX_VARVAL_LEN - 1 - 2)) && !strright(tempStrn, "&n") && !strright(tempStrn, "&N")) strcat(tempStrn, "&n"); addVar(&varHead, VAR_MENUPROMPT_NAME, tempStrn); displayEditConfigMenu(); } else // edit name of main prompt if (ch == 'N') { coords = _gettextposition(); _settextposition(coords.row, 1); clrline(coords.row); displayColorString("&+CNew main prompt: &n"); getStrn(tempStrn, MAX_VARVAL_LEN - 1, 1, 7, '°', getMainPromptStrn(), FALSE, FALSE); if ((strlen(tempStrn) < (MAX_VARVAL_LEN - 1 - 2)) && !strright(tempStrn, "&n") && !strright(tempStrn, "&N") && strcmp(tempStrn, "default")) strcat(tempStrn, "&n"); addVar(&varHead, VAR_MAINPROMPT_NAME, tempStrn); createPrompt(); displayEditConfigMenu(); } else // quit if (checkMenuKey(ch, FALSE) == MENUKEY_SAVE) return TRUE; return FALSE; }
void cmddone( union both_scr *posptr, int toright, unsigned int panel, int nfield, int rowcol[] [5], int *line_no, int *col_no, char inptext[] [25] [80], unsigned int cmd[], char dsn[56], int *maxlrecl, int *amount, char cmdln[], char prm1[], char prm2[]) /**********************************************************************/ /* */ /* Processing which is done between command interpretation and */ /* implementation. One of the main functions is to clean up */ /* (redisplay) the command line. */ /* */ /**********************************************************************/ /* */ /* This is ZEDIT source material. */ /* */ /* ZEDIT Source Materials are intellectual property */ /* (c) Copyright 1987,2001 by Clyde Thomas Zuber. */ /* */ /**********************************************************************/ { int newlrecl; if ((cmd[0] >= EXITSYS && cmd[0] <= CANCEL) || (cmd[0] >= CURSOR && cmd[0] <= HELP) || cmd[0] == ERASEEOF) return; switch(panel) { case CFGKPAN: if (cmd[1] == ENTER) if (cfgkget(posptr, rowcol, inptext)) cmd[1] = NOP; else clrline(posptr, 24); else cmdrest(posptr, toright, rowcol, line_no, col_no, inptext); break; case CFGFPAN: if (cmd[1] == ENTER) { cfgfget(posptr, rowcol, inptext); cmd[0] = RETURN; } /* end then */ else cmdrest(posptr, toright, rowcol, line_no, col_no, inptext); break; case PRIMARY: cmdrest(posptr, toright, rowcol, line_no, col_no, inptext); clrline(posptr, 24); break; case DSENTRY: if (cmd[1] == ENTER) { formdsn(&inptext[TXT] [rowcol[1] [TOP_MAR]] [rowcol[1] [LEFT_MAR]], &inptext[TXT] [rowcol[2] [TOP_MAR]] [rowcol[2] [LEFT_MAR]], &inptext[TXT] [rowcol[3] [TOP_MAR]] [rowcol[3] [LEFT_MAR]], &inptext[TXT] [rowcol[4] [TOP_MAR]] [rowcol[4] [LEFT_MAR]], &inptext[TXT] [rowcol[5] [TOP_MAR]] [rowcol[5] [LEFT_MAR]], &inptext[TXT] [rowcol[6] [TOP_MAR]] [rowcol[6] [LEFT_MAR]], &inptext[TXT] [rowcol[7] [TOP_MAR]] [rowcol[7] [LEFT_MAR]], &inptext[TXT] [rowcol[8] [TOP_MAR]] [rowcol[8] [LEFT_MAR]], dsn); upper(dsn); newlrecl = atoi(rightjst(&inptext[TXT] [rowcol[9] [TOP_MAR]] [rowcol[9] [LEFT_MAR]], 5)); if (newlrecl > 2 && newlrecl != MAXLREC) *maxlrecl = newlrecl; } /* end then */ else cmdrest(posptr, toright, rowcol, line_no, col_no, inptext); break; default: *amount = cmdparm(cmd[0], toright, *line_no, *col_no, &inptext[TXT] [rowcol[1] [TOP_MAR]] [rowcol[1] [LEFT_MAR]], nfield, rowcol, cmdln, prm1, prm2); if (*amount || cmd[1] == ENTER) cmdrest(posptr, toright, rowcol, line_no, col_no, inptext); break; } /* end switch */ } /* end cmddone */