/* * Show filelist from current area, called from the menu. */ void Copy_Home() { char *File, *temp1, *temp2; int err, Found = FALSE; struct _fdbarea *fdb_area = NULL; File = calloc(81, sizeof(char)); temp1 = calloc(PATH_MAX, sizeof(char)); temp2 = calloc(PATH_MAX, sizeof(char)); Enter(1); /* Please enter filename: */ pout(YELLOW, BLACK, (char *) Language(245)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(File, 80); Enter(2); if ((strcmp(File, "")) == 0) { /* No filename entered, Aborting. */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(246)); Enter(2); Pause(); free(File); free(temp1); free(temp2); return; } if (*(File) == '/' || *(File) == ' ') { /* Illegal Filename! */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247)); Enter(2); Pause(); free(File); free(temp1); free(temp2); return; } if (Access(exitinfo.Security, area.DLSec) == FALSE) { pout(YELLOW, BLACK, (char *) Language(236)); Enter(2); Pause(); free(File); free(temp1); free(temp2); return; } if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) { free(File); free(temp1); free(temp2); return; } while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { if ((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) { Found = TRUE; if (((fdb.Size + Quota()) > (CFG.iQuota * 1048576))) { /* You have not enough diskspace free to copy this file */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(279)); Enter(1); Syslog('+', "Copy homedir, not enough quota"); } else { snprintf(temp1, PATH_MAX, "%s/%s", area.Path, fdb.LName); /* Use real longname here */ snprintf(temp2, PATH_MAX, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, File); colour(CFG.TextColourF, CFG.TextColourB); /* Start copy: */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(289)); PUTSTR(File); PUTCHAR(' '); Syslog('b', "Copy from : %s", temp1); Syslog('b', "Copy to : %s", temp2); if ((err = file_cp(temp1, temp2))) { /* Failed! */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(353)); WriteError("Copy %s to homedir failed, code %d", File, err); } else { /* Ok */ PUTSTR((char *) Language(200)); Syslog('+', "Copied %s from area %d to homedir", File, iAreaNumber); } Enter(1); } } } mbsedb_CloseFDB(fdb_area); if (!Found) { /* File does not exist, please try again ... */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(296)); Enter(1); } Pause(); free(File); free(temp1); free(temp2); }
void SectionSpecification::writeXMLToStream(XMLSerializer& xml_stream) const { xml_stream.openTag("Section"); if (!d_owner.empty()) xml_stream.attribute("look", d_owner); xml_stream.attribute("section", d_sectionName); // render controlling property name if needed if (!d_renderControlProperty.empty()) xml_stream.attribute("controlProperty", d_renderControlProperty); if (d_usingColourOverride) { // output modulative colours for this section if (!d_colourPropertyName.empty()) { if (d_colourProperyIsRect) xml_stream.openTag("ColourRectProperty"); else xml_stream.openTag("ColourProperty"); xml_stream.attribute("name", d_colourPropertyName) .closeTag(); } else if (!d_coloursOverride.isMonochromatic() || d_coloursOverride.d_top_left != colour(1,1,1,1)) { xml_stream.openTag("Colours") .attribute("topLeft", PropertyHelper::colourToString(d_coloursOverride.d_top_left)) .attribute("topRight", PropertyHelper::colourToString(d_coloursOverride.d_top_right)) .attribute("bottomLeft", PropertyHelper::colourToString(d_coloursOverride.d_bottom_left)) .attribute("bottomRight", PropertyHelper::colourToString(d_coloursOverride.d_bottom_right)) .closeTag(); } } // close section element xml_stream.closeTag(); }
int Read_a_Email(unsigned int Num) { char *p = NULL, *fn, *charset = NULL, *charsin = NULL; lastread LR; unsigned int mycrc; LastNum = Num; iLineCount = 7; WhosDoingWhat(READ_POST, NULL); /* * The area data is already set, so we can do the next things */ if (EmailBase.Total == 0) { Enter(1); /* There are no messages in this area */ pout(WHITE, BLACK, (char *) Language(205)); Enter(2); sleep(3); return FALSE; } if (!Msg_Open(sMailpath)) { WriteError("Error open JAM base %s", sMailpath); return FALSE; } if (!Msg_ReadHeader(Num)) { Enter(1); pout(WHITE, BLACK, (char *)Language(77)); Enter(2); Msg_Close(); sleep(3); return FALSE; } /* * Fill Quote file in case the user wants to reply. Note that line * wrapping is set lower then normal message read, to create room * for the Quote> strings at the start of each line. */ fn = calloc(PATH_MAX, sizeof(char)); snprintf(fn, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name); if ((qf = fopen(fn, "w")) != NULL) { if (Msg_Read(Num, 75)) { if ((p = (char *)MsgText_First()) != NULL) do { if (p[0] == '\001') { /* * Check CHRS kludge */ if (strncmp(p, "\001CHRS: ", 7) == 0) { charset = xstrcpy(p + 7); } /* * While doing this, store the original Message-id in case * a reply will be made. */ if (strncasecmp(p, "\001Message-id: ", 13) == 0) { snprintf(Msg.Msgid, sizeof(Msg.Msgid), "%s", p+13); Syslog('m', "Stored Msgid \"%s\"", Msg.Msgid); } if (Kludges) { p[0] = 'a'; fprintf(qf, "^%s\n", p); } } else fprintf(qf, "%s\n", p); } while ((p = (char *)MsgText_Next()) != NULL); } fclose(qf); } else { WriteError("$Can't open %s", p); } free(fn); if (charset == NULL) { charsin = xstrcpy((char *)"CP437"); } else { charsin = xstrcpy(get_ic_ftn(find_ftn_charset(charset))); } /* * Setup character translation */ chartran_init(charsin, get_ic_ftn(exitinfo.Charset), 'b'); ShowEmailHdr(); /* * Show message text */ colour(CFG.TextColourF, CFG.TextColourB); if (Msg_Read(Num, 79)) { if ((p = (char *)MsgText_First()) != NULL) { do { if (p[0] == '\001') { if (Kludges) { colour(LIGHTGRAY, BLACK); if (p[0] == '\001') p[0] = 'a'; PUTSTR(chartran(p)); Enter(1); if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE)) break; } } else { colour(CFG.TextColourF, CFG.TextColourB); if (strchr(p, '>') != NULL) if ((strlen(p) - strlen(strchr(p, '>'))) < 10) colour(CFG.HiliteF, CFG.HiliteB); PUTSTR(chartran(p)); Enter(1); if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE)) break; } } while ((p = (char *)MsgText_Next()) != NULL); } } if (charset) free(charset); if (charsin) free(charsin); chartran_close(); /* * Set the Received status on this message. */ if (!Msg.Received) { Syslog('m', "Marking message received"); Msg.Received = TRUE; Msg.Read = time(NULL) - (gmt_offset((time_t)0) * 60); if (Msg_Lock(30L)) { Msg_WriteHeader(Num); Msg_UnLock(); } } /* * Update lastread pointer. */ p = xstrcpy(exitinfo.sUserName); mycrc = StringCRC32(tl(p)); free(p); if (Msg_Lock(30L)) { LR.UserID = grecno; LR.UserCRC = mycrc; if (Msg_GetLastRead(&LR) == TRUE) { LR.LastReadMsg = Num; if (Num > LR.HighReadMsg) LR.HighReadMsg = Num; if (LR.HighReadMsg > EmailBase.Highest) LR.HighReadMsg = EmailBase.Highest; LR.UserCRC = mycrc; if (!Msg_SetLastRead(LR)) WriteError("Error update lastread"); } else { /* * Append new lastread pointer */ LR.UserCRC = mycrc; LR.UserID = grecno; LR.LastReadMsg = Num; LR.HighReadMsg = Num; if (!Msg_NewLastRead(LR)) WriteError("Can't append lastread"); } Msg_UnLock(); } Msg_Close(); return TRUE; }
/* * Change default archiver. */ void Chg_Archiver() { FILE *fp; int Found = FALSE; char *temp; temp = calloc(PATH_MAX, sizeof(char)); ReadExitinfo(); Syslog('+', "Old archiver %s", exitinfo.Archiver); while(TRUE) { snprintf(temp, PATH_MAX, "%s/etc/archiver.data", getenv("FTND_ROOT")); if ((fp = fopen(temp, "r")) == NULL) { WriteError("$Can't open %s", temp); /* Can't open archiver file. */ Enter(1); PUTSTR((char *) Language(86)); Enter(2); Pause(); free(temp); return; } fread(&archiverhdr, sizeof(archiverhdr), 1, fp); Enter(1); /* Select your preferred archiver */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(87)); Enter(2); while (fread(&archiver, archiverhdr.recsize, 1, fp) == 1) { if (archiver.available && strlen(archiver.marc) && strlen(archiver.farc)) { colour(LIGHTBLUE, BLACK); snprintf(temp, 81, "%-6s", archiver.name); PUTSTR(temp); colour(WHITE, BLACK); snprintf(temp, 81, "%s\r\n", archiver.comment); PUTSTR(temp); } } Enter(1); /* Select Archiver (Enter to Quit): */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(88)); alarm_on(); memset(temp, 0, PATH_MAX); GetstrC(temp, 5); if (strlen(temp) == 0) { free(temp); return; } Found = FALSE; fseek(fp, archiverhdr.hdrsize, SEEK_SET); while (fread(&archiver, archiverhdr.recsize, 1, fp) == 1) { if (archiver.available && strlen(archiver.marc) && strlen(archiver.farc)) { if (strcasecmp(archiver.name, temp) == 0) { /* Valid input, set new archiver */ Found = TRUE; break; } } } fclose(fp); if (Found) break; Enter(2); /* Invalid selection, please try again! */ pout(LIGHTGREEN, BLACK, (char *) Language(265)); Enter(2); /* Loop for new attempt */ } strncpy(exitinfo.Archiver, archiver.name, 6); /* Archiver now set to: */ snprintf(temp, 81, "%s %s", Language(89), exitinfo.Archiver); colour(WHITE, BLACK); PUTSTR(temp); Syslog('+', "New archiver %s", exitinfo.Archiver); WriteExitinfo(); free(temp); Enter(2); Pause(); }
void Chg_Password() { char *temp1, *temp2, *args[16]; temp1 = calloc(PATH_MAX, sizeof(char)); temp2 = calloc(PATH_MAX, sizeof(char)); ReadExitinfo(); DisplayFile((char *)"password"); Enter(1); /* Old password: */ language(WHITE, BLACK, 120); colour(CFG.InputColourF, CFG.InputColourB); Getpass(temp1); if (!strcmp(exitinfo.Password, temp1)) { while (TRUE) { Enter(1); /* New password: */ language(LIGHTBLUE, BLACK, 121); colour(CFG.InputColourF, CFG.InputColourB); Getpass(temp1); if((strlen(temp1)) >= CFG.password_length) { Enter(1); /* Confirm new password: */ language(LIGHTBLUE, BLACK, 122); colour(CFG.InputColourF, CFG.InputColourB); Getpass(temp2); if(( strcmp(temp1,temp2)) != 0) { /* Passwords do not match! */ Enter(2); language(LIGHTRED, BLACK, 123); Enter(1); } else { break; } } else { colour(LIGHTRED, BLACK); /* Your password must contain at least %d characters! Try again.*/ snprintf(temp2, PATH_MAX, "\r\n%s%d %s\r\n\r\n", (char *) Language(42), CFG.password_length, (char *) Language(43)); PUTSTR(temp2); } } Syslog('+', "%s/bin/ftnpasswd %s ******", getenv("FTND_ROOT"), exitinfo.Name); snprintf(temp1, PATH_MAX, "%s/bin/ftnpasswd", getenv("FTND_ROOT")); memset(args, 0, sizeof(args)); args[0] = temp1; args[1] = exitinfo.Name; args[2] = temp2; args[3] = NULL; if (execute(args, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") != 0) { WriteError("Failed to set new Unix password"); } else { memset(&exitinfo.Password, 0, sizeof(exitinfo.Password)); strcpy(exitinfo.Password, temp2); exitinfo.tLastPwdChange = time(NULL); Enter(1); /* Password Change Successful */ language(LIGHTGREEN, BLACK, 124); Syslog('+', "User changed his password"); WriteExitinfo(); } } else { Enter(1); /* Old password incorrect! */ language(LIGHTRED, BLACK, 125); } free(temp1); free(temp2); Enter(2); Pause(); }
//----------------------------------------------------------------------------- void ManualObject::colour(const ColourValue& col) { colour(col.r, col.g, col.b, col.a); }
void user(void) { FILE *pUsrConfig, *pLimits; int i, x, FoundName = FALSE, iFoundLimit = FALSE, IsNew = FALSE, logins = 0, Start; int l1, l2; char *token, temp[PATH_MAX], temp1[84], UserName[37], buf[128], *fullname; time_t LastLogin; struct stat st; grecno = 0; Syslog('+', "Unixmode login: %s", sUnixName); snprintf(temp, PATH_MAX, "%s/etc/users.data", getenv("FTND_ROOT")); if ((pUsrConfig = fopen(temp,"r+")) == NULL) { /* * This should not happen. */ WriteError("$Can't open %s", temp); PUTSTR((char *)"Can't open userfile, run \"newuser\" first"); Enter(1); ExitClient(FTNERR_OK); } fread(&usrconfighdr, sizeof(usrconfighdr), 1, pUsrConfig); while (fread(&usrconfig, usrconfighdr.recsize, 1, pUsrConfig) == 1) { if (strcmp(usrconfig.Name, sUnixName) == 0) { FoundName = TRUE; break; } else grecno++; } if (!FoundName) { fclose(pUsrConfig); snprintf(temp, PATH_MAX, "Unknown username: %s\r\n", sUnixName); PUTSTR(temp); /* FATAL ERROR: You are not in the BBS users file.*/ snprintf(temp, PATH_MAX, "%s\r\n", (char *) Language(389)); PUTSTR(temp); /* Please run 'newuser' to create an account */ snprintf(temp, PATH_MAX, "%s\r\n", (char *) Language(390)); PUTSTR(temp); Syslog('?', "FATAL: Could not find user in BBS users file."); Syslog('?', " and system is using unix accounts\n"); Free_Language(); ExitClient(FTNERR_OK); } /* * Copy username, split first and lastname. */ strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1); if ((strchr(UserName,' ') == NULL) && !CFG.iOneName) { token = strtok(UserName, " "); strncpy(FirstName, token, sizeof(FirstName)-1); token = strtok(NULL, "\0"); i = strlen(token); for (x = 2; x < i; x++) { if (token[x] == ' ') token[x] = '\0'; } strncpy(LastName, token, sizeof(LastName)-1); } else strncpy(FirstName, UserName, sizeof(FirstName)-1); strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1); Syslog('+', "%s On-Line from \"%s\", node %d", UserName, ttyinfo.comment, iNode); IsDoing("Just Logged In"); /* * Check some essential files, create them if they don't exist. */ ChkFiles(); /* * Setup users favourite language. */ utf8 = (usrconfig.Charset == FTNC_UTF8); Set_Language(usrconfig.iLanguage); Free_Language(); InitLanguage(); /* * User logged in, tell it to the server. Check if a location is * set, if Ask User location for new users is off, this field is * empty but we have to send something to the server. */ if (strlen(usrconfig.sLocation)) UserCity(mypid, usrconfig.Name, usrconfig.sLocation); else UserCity(mypid, usrconfig.Name, (char *)"N/A"); /* * Count simultaneous logins */ Start = TRUE; while (TRUE) { if (Start) snprintf(buf, 128, "GMON:1,1;"); else snprintf(buf, 128, "GMON:1,0;"); Start = FALSE; if (socket_send(buf) == 0) { strcpy(buf, socket_receive()); if (strncmp(buf, "100:0;", 6) == 0) break; /* No more data */ if (strstr(buf, "ftnbbs")) { /* * Only ftnbbs is wanted */ strtok(buf, ","); /* response */ strtok(NULL, ","); /* pid */ strtok(NULL, ","); /* tty */ fullname = xstrcpy(cldecode(strtok(NULL, ","))); /* username */ if (strcmp(fullname, usrconfig.Name) == 0) { logins++; } free(fullname); } } } if (CFG.max_logins && (logins > CFG.max_logins)) { Syslog('+', "User logins %d, allowed %d, disconnecting", logins, CFG.max_logins); colour(LIGHTRED, BLACK); snprintf(temp, PATH_MAX, "%s %d %s\r\n", (char *) Language(18), CFG.max_logins, (char *) Language(19)); PUTSTR(temp); Quick_Bye(FTNERR_INIT_ERROR); } /* * Set last file and message area so these numbers are saved when * the user hangs up or is logged off before het gets to the main * menu. Later in this function the areas are set permanent. */ iAreaNumber = usrconfig.iLastFileArea; iMsgAreaNumber = usrconfig.iLastMsgArea; /* * See if this user is the Sysop. */ strcpy(temp, UserName); strcpy(temp1, CFG.sysop_name); if ((strcasecmp(CFG.sysop_name, UserName)) == 0) { /* * If login name is sysop, set SYSOP true */ SYSOP = TRUE; Syslog('+', "Sysop is online"); } /* * Is this a new user? */ if (usrconfig.iTotalCalls == 0) IsNew = TRUE; /* * Pause after logo screen. */ alarm_on(); Pause(); if (usrconfig.Archiver[0] == '\0') { usrconfig.Archiver[0] = 'Z'; usrconfig.Archiver[1] = 'I'; usrconfig.Archiver[2] = 'P'; Syslog('+', "Setup default archiver ZIP"); } /* * Check users date format. We do it strict as we * need this to be good for several other purposes. * If it is correct, the users age is set in UserAge */ if (!Test_DOB(usrconfig.sDateOfBirth)) { Syslog('!', "Error in Date of Birth"); Chg_DOB(); strcpy(usrconfig.sDateOfBirth, exitinfo.sDateOfBirth); } /* * Check to see if user must expire */ snprintf(temp,PATH_MAX, "%s", (char *) GetDateDMY()); SwapDate(temp, usrconfig.sExpiryDate); /* Convert Date1 & Date2 to longs for compare */ l1 = atol(Date1); l2 = atol(Date2); if (l1 >= l2 && l2 != 0) { /* * If Expiry Date is the same as today expire to * Expire Sec level */ usrconfig.Security = usrconfig.ExpirySec; Syslog('!', "User is expired, resetting level"); /* * Show texfile to user telling him about this. */ DisplayFile((char *)"expired"); } free(Date1); free(Date2); /* * Copy limits.data into memory */ snprintf(temp, PATH_MAX, "%s/etc/limits.data", getenv("FTND_ROOT")); if ((pLimits = fopen(temp,"rb")) == NULL) { WriteError("$Can't open %s", temp); } else { fread(&LIMIThdr, sizeof(LIMIThdr), 1, pLimits); while (fread(&LIMIT, sizeof(LIMIT), 1, pLimits) == 1) { if (LIMIT.Security == usrconfig.Security.level) { iFoundLimit = TRUE; break; } } fclose(pLimits); } if (!iFoundLimit) { WriteError("Unknown Security Level in limits.data"); usrconfig.iTimeLeft = 0; /* Could not find limit, so set to Zero */ usrconfig.iTimeUsed = 0; /* Set to Zero as well */ } else { /* * Give user new time limit everyday, also new users get a new limit. */ snprintf(temp,PATH_MAX, "%s", (char *) GetDateDMY()); if (((strcmp(StrDateDMY(usrconfig.tLastLoginDate), temp)) != 0) || IsNew) { /* * If no timelimit set give user 24 hours. */ if (LIMIT.Time) usrconfig.iTimeLeft = LIMIT.Time; else usrconfig.iTimeLeft = 86400; usrconfig.iTimeUsed = 0; /* Set time used today to Zero */ usrconfig.iConnectTime = 0; /* Set connect time to Zero */ /* * Give user new bytes and files every day if needed. */ if (LIMIT.DownK) { usrconfig.DownloadKToday = LIMIT.DownK; } if (LIMIT.DownF) { usrconfig.DownloadsToday = LIMIT.DownF; } } } /* End of else */ usrconfig.iConnectTime = 0; /* Copy Users Protocol into Memory */ Set_Protocol(usrconfig.sProtocol); tlf(usrconfig.sProtocol); /* * Set last login Date and Time, copy previous session * values in memory. */ snprintf(LastLoginDate, 12, "%s", StrDateDMY(usrconfig.tLastLoginDate)); snprintf(LastLoginTime, 9, "%s", StrTimeHMS(usrconfig.tLastLoginDate)); LastLogin = usrconfig.tLastLoginDate; usrconfig.tLastLoginDate = ltime; /* Set current login to current date */ usrconfig.iTotalCalls++; /* * Update user record. */ if (fseek(pUsrConfig, usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize), 0) != 0) { WriteError("Can't seek in %s/etc/users.data", getenv("FTND_ROOT")); } else { fwrite(&usrconfig, sizeof(usrconfig), 1, pUsrConfig); } fclose(pUsrConfig); /* * Write users structure to tmp file in ~/home/unixname/exitinfo * A copy of the userrecord is also in the variable exitinfo. */ if (! InitExitinfo()) Good_Bye(FTNERR_INIT_ERROR); /* * If user has not set a preferred character set, force this */ if (exitinfo.Charset == FTNC_NONE) { Chg_Charset(); } setlocale(LC_CTYPE, getlocale(exitinfo.Charset)); Syslog('b', "setlocale(LC_CTYPE, NULL) returns \"%s\"", printable(setlocale(LC_CTYPE, NULL), 0)); GetLastUser(); StartTime = xstrcpy(GetLocalHM()); ChangeHomeDir(exitinfo.Name, exitinfo.Email); Syslog('+', "User successfully logged into BBS"); Syslog('+', "Level %d (%s), %d mins. left, port %s", exitinfo.Security.level, LIMIT.Description, exitinfo.iTimeLeft, pTTY); Time2Go = time(NULL); Time2Go += exitinfo.iTimeLeft * 60; iUserTimeLeft = exitinfo.iTimeLeft; IsDoing("Welcome screens"); DisplayFile((char *)"mainlogo"); DisplayFile((char *)"welcome"); /* * The following files are only displayed if the user has * turned the Bulletins on. */ if (exitinfo.ieNEWS) { DisplayFile((char *)"welcome1"); DisplayFile((char *)"welcome2"); DisplayFile((char *)"welcome3"); DisplayFile((char *)"welcome4"); DisplayFile((char *)"welcome5"); DisplayFile((char *)"welcome6"); DisplayFile((char *)"welcome7"); DisplayFile((char *)"welcome8"); DisplayFile((char *)"welcome9"); snprintf(temp, PATH_MAX, "%s", (char *) GetDateDMY() ); if ((strcmp(exitinfo.sDateOfBirth, temp)) == 0) DisplayFile((char *)"birthday"); /* * Displays file if it exists DD-MM.A?? */ snprintf(temp, PATH_MAX, "%s", (char *) GetDateDMY()); strcpy(temp1, ""); strncat(temp1, temp, 5); snprintf(temp, PATH_MAX, "%s", temp1); DisplayFile(temp); /* * Displays users security file if it exists */ snprintf(temp, PATH_MAX, "sec%d", exitinfo.Security.level); DisplayFile(temp); /* * Display News file */ DisplayFile((char *)"news"); } /* * Display Onceonly file, first get the date of that * file, search order is the same as in DisplayFile() */ st.st_mtime = 0; snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.ans", getenv("FTND_ROOT"), lang.lc); stat(temp, &st); if (st.st_mtime == 0) { snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.ans", getenv("FTND_ROOT"), CFG.deflang); stat(temp, &st); } if (st.st_mtime == 0) { snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.asc", getenv("FTND_ROOT"), lang.lc); stat(temp, &st); if (st.st_mtime == 0) { snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/onceonly.asc", getenv("FTND_ROOT"), CFG.deflang); stat(temp, &st); } } if ((st.st_mtime != 0) && (LastLogin < st.st_mtime)) DisplayFile((char *)"onceonly"); OLR_SyncTags(); if (exitinfo.MailScan) { IsDoing("New mail check"); CheckMail(); } /* * We don't show new files to new users. */ if (exitinfo.ieFILE && (!IsNew)) { IsDoing("New files check"); NewfileScan(FALSE); } /* * Copy last file Area in to current Area */ SetFileArea(exitinfo.iLastFileArea); /* * Copy Last Message Area in to Current Msg Area */ SetMsgArea(usrconfig.iLastMsgArea); SetEmailArea((char *)"mailbox"); /* * Set or Reset the DoNotDisturb flag, now is the time * we may be interrupted. */ UserSilent(usrconfig.DoNotDisturb); /* * Start the menu. */ menu(); }
void RecordSample(const std::string uri, const std::string vid_file, const std::string ui_file) { // Setup Video Source pangolin::VideoRecordRepeat video(uri, vid_file, 1024*1024*200); const pangolin::VideoPixelFormat vid_fmt = video.PixFormat(); const unsigned w = video.Width(); const unsigned h = video.Height(); pangolin::InputRecordRepeat input("ui."); input.LoadBuffer(ui_file); // Create OpenGL window const int panel_width = 200; pangolin::CreateWindowAndBind("Main",w + panel_width,h); // Create viewport for video with fixed aspect pangolin::CreatePanel("ui.") .SetBounds(0.0, 1.0, 0.0, pangolin::Attach::Pix(panel_width)); pangolin::View& vVideo = pangolin::Display("Video") .SetBounds(0.0, 1.0, pangolin::Attach::Pix(panel_width), 1.0) .SetAspect((float)w/h); // OpenGl Texture for video frame pangolin::GlTexture texVideo(w,h,GL_RGBA); unsigned char* img = new unsigned char[video.SizeBytes()]; pangolin::Var<bool> record("ui.Record",false,false); pangolin::Var<bool> play("ui.Play",false,false); pangolin::Var<bool> source("ui.Source",false,false); pangolin::Var<bool> realtime("ui.realtime",true,true); pangolin::Var<float> hue("ui.Hue",0,0,360); pangolin::Var<bool> colour("ui.Colour Video",false,true); while( !pangolin::ShouldQuit() ) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Load next video frame if( video.GrabNext(img,true) ) { texVideo.Upload(img, vid_fmt.channels==1 ? GL_LUMINANCE:GL_RGB, GL_UNSIGNED_BYTE); // Associate input with this video frame input.SetIndex(video.FrameId()); } // Activate video viewport and render texture vVideo.Activate(); if( colour ) { glColorHSV(hue,0.5,1.0); }else{ glColor3f(1,1,1); } texVideo.RenderToViewportFlipY(); if(pangolin::Pushed(record)) { video.Record(); input.Record(); } if(pangolin::Pushed(play)) { video.Play(realtime); input.PlayBuffer(0,input.Size()-1); input.SaveBuffer(ui_file); } if(pangolin::Pushed(source)) { video.Source(); input.Stop(); input.SaveBuffer(ui_file); } pangolin::FinishFrame(); } delete[] img; }
/* * Delete files from home directory */ void Delete_Home() { char *temp, *temp1, msg[81]; int i; temp = calloc(PATH_MAX, sizeof(char)); temp1 = calloc(PATH_MAX, sizeof(char)); snprintf(temp, PATH_MAX, "%s/%s/wrk/", CFG.bbs_usersdir, exitinfo.Name); Enter(1); /* Please enter filename to delete: */ pout(LIGHTBLUE, BLACK, (char *) Language(292)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp1, 80); if (strcmp(temp1, "") == 0) { free(temp); free(temp1); return; } if (temp1[0] == '.') { Enter(1); /* Sorry you may not delete hidden files ...*/ pout(LIGHTRED, BLACK, (char *) Language(293)); } else { strcat(temp, temp1); if ((access(temp, R_OK)) == 0) { Enter(1); /* Delete file: */ /* Are you Sure? [Y/n]: */ snprintf(msg, 81, "%s %s, %s", (char *) Language(368), temp1, (char *) Language(369)); pout(LIGHTGREEN, BLACK, msg); i = toupper(Readkey()); if (i == Keystroke(369, 0) || i == 13) { i = unlink(temp); if (i == -1) { Enter(1); /* Unable to delete file ... */ pout(LIGHTRED, BLACK, (char *) Language(294)); } else { Syslog('+', "Delete %s from homedir", temp1); } } else { Enter(2); /* Aborting ... */ pout(DARKGRAY, BLACK, (char *) Language(116)); } } else { Enter(1); /* Invalid filename, please try again ... */ pout(LIGHTRED, BLACK, (char *) Language(295)); } } Enter(2); free(temp); free(temp1); Pause(); }
void shutdown() { // Reset to white text on black background colour(FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); }
// Do your clean up of memory here // This is called once just before the game exits void shutdown() { // Reset to white text on black background colour(FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); console.clearBuffer(); }
int p_key() const { return colour() + rank/(p_grp_size*group_size)*group_size; }
static bool left_colour_match(s8 p) { if (p == 0 || (p % side) == 0) return true; return colour(p - 1, 1) == colour(p, 3); }
void game::loadShip(std::string filename) { // RGB channels contain separate information: // R: Strength (higher = more) // G: Empty or not (white background has high G so is ignored, all materials have low G) // B: Hull or not (blue has high G, is not hull; black has high G, is hull) // black: weak hull; blue: weak internal; red: strong hull; magenta: strong internal // Can vary shades of red for varying strengths and colours lastFilename = filename; int nodecount = 0, springcount = 0; std::map<vec3f, material*> colourdict; for (unsigned int i = 0; i < materials.size(); i++) colourdict[materials[i]->colour] = materials[i]; wxImage shipimage(filename, wxBITMAP_TYPE_PNG); phys::ship *shp = new phys::ship(wld); std::map<int, std::map <int, phys::point*> > points; for (int x = 0; x < shipimage.GetWidth(); x++) { for (int y = 0; y < shipimage.GetHeight(); y++) { vec3f colour(shipimage.GetRed (x, shipimage.GetHeight() - y - 1) / 255.f, shipimage.GetGreen(x, shipimage.GetHeight() - y - 1) / 255.f, shipimage.GetBlue (x, shipimage.GetHeight() - y - 1) / 255.f); if (colourdict.find(colour) != colourdict.end()) { material *mtl = colourdict[colour]; points[x][y] = new phys::point(wld, vec2(x - shipimage.GetWidth()/2, y), mtl, mtl->isHull? 0 : 1); // no buoyancy if it's a hull section shp->points.insert(points[x][y]); nodecount++; } else { points[x][y] = 0; } } } // Points have been generated, so fill in all the beams between them. // If beam joins two hull nodes, it is a hull beam. // If a non-hull node has empty space on one of its four sides, it is automatically leaking. for (int x = 0; x < shipimage.GetWidth(); x++) { for (int y = 0; y < shipimage.GetHeight(); y++) { phys::point *a = points[x][y]; if (!a) continue; // First four directions out of 8: from 0 deg (+x) through to 135 deg (-x +y) - this covers each pair of points in each direction for (int i = 0; i < 4; i++) { phys::point *b = points[x + directions[i][0]][y + directions[i][1]]; // adjacent point in direction (i) phys::point *c = points[x + directions[(i + 1) % 8][0]][y + directions[(i + 1) % 8][1]]; // adjacent point in next CW direction (for constructing triangles) if (b) { bool pointIsHull = a->mtl->isHull; bool isHull = pointIsHull && b->mtl->isHull; material *mtl = b->mtl->isHull? a->mtl : b->mtl; // the spring is hull iff both nodes are hull; if so we use the hull material. shp->springs.insert(new phys::spring(wld, a, b, mtl, -1)); if (!isHull) { shp->adjacentnodes[a].insert(b); shp->adjacentnodes[b].insert(a); } if (!(pointIsHull || (points[x+1][y] && points[x][y+1] && points[x-1][y] && points[x][y-1]))) // check for gaps next to non-hull areas: { a->isLeaking = true; } if (c) shp->triangles.insert(new phys::ship::triangle(shp, a, b, c)); springcount++; } } } } std::cout << "Loaded ship \"" << filename << "\": " << nodecount << " points, " << springcount << " springs.\n"; }
void CreateComposed::CreatePanel() { VComposedNames.push_back("View All"); ComposedIntegratedNames.push_back("Main"); wxBoxSizer* Screen=new wxBoxSizer(wxVERTICAL); wxBoxSizer* total=new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* Select=new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* controls=new wxBoxSizer(wxVERTICAL); wxBoxSizer* SelectView=new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* SelectComposed=new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* CoLFin=new wxBoxSizer(wxHORIZONTAL); wxColour colour(193,221,224); this->SetBackgroundColour(colour); canvas3d=new Canvas(this,wxID_ANY,wxDefaultPosition,wxSize(600,600)); canvas3d->DrawGrid(); wxStaticText* SelectCompToViewText=new wxStaticText(this,wxID_ANY,wxT("View Composed"),wxDefaultPosition,wxSize(115,25)); selectComposedtoView=new wxComboBox(); selectComposedtoView->Create(this,ID_SELECTCOMPOSEDTOVIEW,wxEmptyString,wxDefaultPosition,wxSize(130,20),VComposedNames,wxCB_DROPDOWN); SelectView->Add(SelectCompToViewText,0,wxSHAPED); SelectView->Add(selectComposedtoView,0,wxSHAPED); selectComposedtoView->SetStringSelection(VComposedNames[0]); wxStaticText* CurrentComposedText=new wxStaticText(this,wxID_ANY,wxT("Current Composed"),wxDefaultPosition,wxSize(115,25)); CurrentComposed=new wxComboBox(); CurrentComposed->Create(this,ID_SELECTCURRENTCOMPOSED,wxEmptyString,wxDefaultPosition,wxSize(130,20),ComposedIntegratedNames,wxCB_DROPDOWN); SelectComposed->Add(CurrentComposedText,0,wxSHAPED); SelectComposed->Add(CurrentComposed,0,wxSHAPED); CurrentComposed->SetStringSelection(ComposedIntegratedNames[0]); wxBitmap bitmaps[9]; bitmaps[0] = wxBitmap (cylinder_xpm); bitmaps[1]=wxBitmap (sphereCom_xpm); bitmaps[2]=wxBitmap (prismCom_xpm); bitmaps[3]=wxBitmap(coloursComp_xpm); bitmaps[4]=wxBitmap(AddComposedIcon_xpm); bitmaps[5]=wxBitmap(AddAnotherItem_xpm); bitmaps[6]=wxBitmap(IrrPrismCom_xpm); MainToolbar=new wxToolBar(); MainToolbar->Create(this,wxID_ANY,wxDefaultPosition,wxSize(650,40),wxBORDER_NONE|wxTB_HORIZONTAL); MainToolbar->AddTool( ID_ADDCOMPPART, wxString("Add new Composed"), bitmaps[4]); MainToolbar->AddSeparator(); MainToolbar->AddTool(ID_ADDANOTHERITEM,wxString("Add New Item"), bitmaps[5]); MainToolbar->SetBackgroundColour(wxColour(255,255,131)); MainToolbar->Realize(); Toolbar=new wxToolBar(); Toolbar->Create(this,wxID_ANY,wxDefaultPosition,wxSize(300,30),wxBORDER_NONE|wxTB_HORIZONTAL); Toolbar->AddTool(ID_CYLINDCOMPOSED,"Create Cylinder",bitmaps[0]); Toolbar->AddTool(ID_SPHERECOMPOSED,"Create Sphere",bitmaps[1]); Toolbar->AddTool(ID_REGPRISMCOMPOSED,"Create Regular Prism",bitmaps[2]); Toolbar->AddTool(ID_IRRPRISMCOMPOSED,"Create Irregular Prism",bitmaps[6]); Toolbar->SetBackgroundColour(*wxWHITE); Toolbar->Realize(); Screen->Add(MainToolbar,5,wxEXPAND); Select->Add(SelectView,5,wxEXPAND); Select->AddSpacer(10); Select->Add(SelectComposed,5,wxEXPAND); Screen->Add(Select,0,wxEXPAND); Screen->Add(Toolbar,5,wxEXPAND); Screen->Add(canvas3d,0,wxEXPAND); PositionX=new GenericSlider(this,wxT("PositionX"),wxDefaultPosition,wxDefaultSize,false); PositionY=new GenericSlider(this,wxT("PositionY"),wxDefaultPosition,wxDefaultSize,false); PositionZ=new GenericSlider(this,wxT("PositionZ"),wxDefaultPosition,wxDefaultSize,false); Roll=new GenericSlider(this,wxT("Roll Orientation"),wxDefaultPosition,wxDefaultSize,false); Pitch=new GenericSlider(this,wxT("Pitch Orientation"),wxDefaultPosition,wxDefaultSize,false); Yaw=new GenericSlider(this,wxT("Yaw orientation"),wxDefaultPosition,wxDefaultSize,false); Radio=new GenericSlider(this,wxT("Radio"),wxDefaultPosition,wxDefaultSize,false); Height=new GenericSlider(this,wxT("Height"),wxDefaultPosition,wxDefaultSize,false); BaseVertex=new GenericSlider(this,wxT("Base Vertex"),wxDefaultPosition,wxDefaultSize,false); PositionX->setProperties(-20,20); PositionY->setProperties(-20,20); PositionZ->setProperties(-20,20); Roll->setProperties(-180,180); Pitch->setProperties(-180,180); Yaw->setProperties(-180,180); Radio->setProperties(0,20); Height->setProperties(0,20); BaseVertex->setProperties(3,10); wxStaticText* ColourText=new wxStaticText(this,wxID_ANY,wxT("Colour"),wxDefaultPosition,wxSize(35,15)); wxBitmapButton* colo = new wxBitmapButton(this,ID_COLOR,wxIcon(coloursComp_xpm),wxDefaultPosition,wxDefaultSize); wxBitmapButton* FinishComp = new wxBitmapButton(this,ID_FINISHCOMPOSED,wxIcon(FinishComp_xpm),wxDefaultPosition,wxDefaultSize); wxBoxSizer *FinishEdition=new wxBoxSizer(wxHORIZONTAL); FinishEdition->Add(FinishComp,0,wxSHAPED); ResetValues(); controls->Add(PositionX,0,wxEXPAND); controls->Add(PositionY,0,wxEXPAND); controls->Add(PositionZ,0,wxEXPAND); controls->Add(Roll,0,wxEXPAND); controls->Add(Pitch,0,wxEXPAND); controls->Add(Yaw,0,wxEXPAND); controls->Add(Radio,0,wxEXPAND); controls->Add(Height,0,wxEXPAND); controls->Add(BaseVertex,0,wxEXPAND); controls->Add(ColourText,0,wxEXPAND); CoLFin->Add(colo,0,wxSHAPED); CoLFin->Add(FinishEdition,0,wxSHAPED|wxALIGN_RIGHT); controls->Add(CoLFin,0,wxEXPAND); total->Add(Screen,5,wxEXPAND); total->AddSpacer(5); total->Add(controls,0,wxEXPAND|wxALIGN_RIGHT); SetSizer(total); total->SetSizeHints(this); ResetValues(); }
/* * Search for a file, called from the menu. */ int FilenameScan() { FILE *pAreas; int Found, Count = 0; char mask[256]; char *Name; _Tag T; unsigned int OldArea; struct _fdbarea *fdb_area = NULL; Name = calloc(81, sizeof(char)); OldArea = iAreaNumber; iLineCount = 2; /* Reset Line Counter to Zero */ arecno = 1; /* Reset Area Number to One */ Enter(2); /* Accepts wildcards such as : *.zip, *.gz, *.* */ pout(WHITE, BLACK, (char *) Language(269)); Enter(2); /* Enter filename to search for : */ pout(LIGHTCYAN, BLACK, (char *) Language(271)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(Name, 80); if ((strcmp(Name, "")) == 0) { free(Name); return 0; } strcpy(mask, re_mask(Name, TRUE)); Syslog('+', "FilenameScan(): \"%s\" -> \"%s\"", Name, mask); free(Name); re_comp(mask); clear(); /* File Search by Filename */ pout(WHITE, BLACK, (char *) Language(272)); Enter(1); InitTag(); if ((pAreas = OpenFareas(FALSE)) == NULL) return 0; while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) { if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) { Found = FALSE; Sheader(); Nopper(); while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { if (re_exec(fdb.Name) || re_exec(fdb.LName)) { if (!Found) { Enter(2); if (iLC(2) == 1) { SetFileArea(OldArea); return 1; } Found = TRUE; } memset(&T, 0, sizeof(T)); T.Area = arecno; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, fdb.LName, 81); SetTag(T); Count++; if (ShowOneFile() == 1) { SetFileArea(OldArea); return 1; } } } /* End of while */ mbsedb_CloseFDB(fdb_area); if (Found) { Enter(2); if (iLC(2) == 1) { SetFileArea(OldArea); return 1; } } } /* End Check for LTSec */ } /* if access */ arecno++; /* Go to next file area */ } /* End of Main */ Syslog('+', "Found %d files", Count); fclose(pAreas); Enter(1); if (Count) Mark(); else Pause(); SetFileArea(OldArea); return 1; }
/* * Scan for new files, called from menu. */ int NewfileScan(int AskStart) { FILE *pAreas; int ifDate, itDate; char *temp, *Date; int Found, Count = 0; _Tag T; struct _fdbarea *fdb_area = NULL; Date = calloc(81, sizeof(char)); temp = calloc(81, sizeof(char)); iLineCount = 2; arecno = 1; /* Reset Area Number to One */ if (AskStart) { Enter(2); /* Search for new since your last call [Y/n]: */ pout(LIGHTCYAN, BLACK, (char *) Language(273)); colour(CFG.InputColourF, CFG.InputColourB); if (toupper(Readkey()) == Keystroke(273, 1)) { Enter(1); /* Enter new date to search for [DD-MM-YYYY]: */ pout(GREEN, BLACK, (char *) Language(274)); colour(CFG.InputColourF, CFG.InputColourB); GetDate(temp, 10); } else { strcpy(temp, LastLoginDate); } } else { strcpy(temp, LastLoginDate); } Syslog('+', "NewfileScan() since %s", temp); clear(); /* File Search by Date */ pout(WHITE, BLACK, (char *) Language(275)); Enter(2); Date[0] = temp[6]; /* Swap the date around */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[2] = temp[8]; /* Let it equal YYYYMMDD */ Date[3] = temp[9]; /* Swap the date around */ Date[4] = temp[3]; /* Swap the date around */ Date[5] = temp[4]; /* because when you convert */ Date[6] = temp[0]; /* a string to an int you */ Date[7] = temp[1]; /* loose the front Zero */ Date[8] = '\0'; /* making the number smaller */ itDate = atol(Date); InitTag(); if ((pAreas = OpenFareas(FALSE)) == NULL) return 0; while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0) && (area.New)) { if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) { Sheader(); Found = FALSE; Nopper(); while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */ Date[0] = temp[6]; /* Swap the date around */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[2] = temp[8]; /* Let it equal YYYYMMDD */ Date[3] = temp[9]; /* Swap the date around */ Date[4] = temp[3]; /* Swap the date around */ Date[5] = temp[4]; /* because when you convert */ Date[6] = temp[0]; /* a string to an int you */ Date[7] = temp[1]; /* loose the front Zero */ Date[8] = '\0'; /* making the number smaller */ /* and invalid to this cause */ ifDate = atol(Date); if (ifDate >= itDate) { if (!Found) { Enter(2); if (iLC(2) == 1) { free(Date); free(temp); mbsedb_CloseFDB(fdb_area); fclose(pAreas); return 1; } Found = TRUE; } memset(&T, 0, sizeof(T)); T.Area = arecno; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, fdb.LName, 80); SetTag(T); Count++; if (ShowOneFile() == 1) { free(Date); free(temp); mbsedb_CloseFDB(fdb_area); fclose(pAreas); return 1; } } /* End of if */ } /* End of while */ mbsedb_CloseFDB(fdb_area); /* * Add 2 blank lines after found files. */ if (Found) { Enter(2); if (iLC(2) == 1) { free(Date); free(temp); fclose(pAreas); return 1; } } } /* End of open filebase */ } /* End of check new files scan */ arecno++; /* Go to next file area */ } /* End of Main */ if (Count) Syslog('+', "Found %d new files", Count); fclose(pAreas); Enter(1); if (Count) Mark(); else Pause(); free(temp); free(Date); return 1; }
/* * Function allows user to download from his/her home directory * but still does all the necessary checks */ int Download_Home() { char *temp, *File; struct stat statfile; int rc; File = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char)); WhosDoingWhat(DOWNLOAD, NULL); Enter(1); /* Please enter filename: */ pout(YELLOW, BLACK, (char *) Language(245)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(File, 80); if (( strcmp(File, "")) == 0) { Enter(2); /* No filename entered, Aborting. */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(246)); Enter(2); Pause(); free(File); free(temp); return FALSE; } if (*(File) == '/' || *(File) == ' ') { Enter(2); /* Illegal Filename! */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247)); Enter(2); Pause(); free(File); free(temp); return FALSE; } /* * Get path for users home directory */ snprintf(temp, PATH_MAX, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, File); if (stat(temp, &statfile) != 0) { Enter(2); /* File does not exist, please try again ...*/ pout(LIGHTRED, BLACK, (char *) Language(296)); Enter(2); Pause(); free(File); free(temp); return FALSE; } rc = DownloadDirect(temp, TRUE); free(File); free(temp); return rc; }
/************************************************************************* Set the mouse cursor's alpha *************************************************************************/ void MouseCursor::setAlpha(float alpha) { d_colourRect.setColours(colour(1.0f, 1.0f, 1.0f, alpha)); }
/* * Select filearea, called from menu. */ void FileArea_List(char *Option) { FILE *pAreas; int iAreaCount = 6, Recno = 1, iOldArea, iAreaNum = 0; int iGotArea = FALSE; /* Flag to check if user typed in area */ int offset; char *temp; /* * Save old area, incase he picks a invalid area */ iOldArea = iAreaNumber; if ((pAreas = OpenFareas(FALSE)) == NULL) return; /* * Count howmany records there are */ fseek(pAreas, 0, SEEK_END); iAreaNum = (ftell(pAreas) - areahdr.hdrsize) / areahdr.recsize; /* * If there are menu options, select area direct. */ if (strlen(Option) != 0) { if (strcmp(Option, "F+") == 0) { while (TRUE) { iAreaNumber++; if (iAreaNumber > iAreaNum) iAreaNumber = 1; offset = areahdr.hdrsize + ((iAreaNumber - 1) * areahdr.recsize); if (fseek(pAreas, offset, 0) != 0) { printf("Can't move pointer here"); } fread(&area, areahdr.recsize, 1, pAreas); if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) break; } } if (strcmp(Option, "F-") == 0) { while (TRUE) { iAreaNumber--; if (iAreaNumber < 1) iAreaNumber = iAreaNum; offset = areahdr.hdrsize + ((iAreaNumber - 1) * areahdr.recsize); if (fseek(pAreas, offset, 0) != 0) { printf("Can't move pointer here"); } fread(&area, areahdr.recsize, 1, pAreas); if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) break; } } SetFileArea(iAreaNumber); Syslog('+', "File area %lu %s", iAreaNumber, sAreaDesc); fclose(pAreas); return; } /* * Interactive mode */ clear(); Enter(1); /* File Areas */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(298)); Enter(2); temp = calloc(81, sizeof(char)); fseek(pAreas, areahdr.hdrsize, 0); while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available)) { area.Name[31] = '\0'; snprintf(temp, 81, "%5d", Recno); pout(WHITE, BLACK, temp); snprintf(temp, 81, " %c ", 46); pout(LIGHTBLUE, BLACK, temp); snprintf(temp, 81, "%-31s", area.Name); pout(CYAN, BLACK, temp); iAreaCount++; if ((iAreaCount % 2) == 0) { Enter(1); } else { PUTCHAR(' '); } } Recno++; if ((iAreaCount / 2) == rows) { /* More (Y/n/=/Area #): */ pout(CFG.MoreF, CFG.MoreB, (char *) Language(207)); /* * Ask user for Area or enter to continue */ colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp, 7); if (toupper(*(temp)) == Keystroke(207, 1)) break; if ((strcmp(temp, "")) != 0) { iGotArea = TRUE; break; } iAreaCount = 2; } } /* * If user type in area above during area listing * don't ask for it again */ if (!iGotArea) { Enter(1); /* Select Area: */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(232)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp, 80); } /* * Check if user pressed ENTER */ if ((strcmp(temp, "")) == 0) { fclose(pAreas); return; } iAreaNumber = atoi(temp); /* * Do a check in case user enters a negative value */ if (iAreaNumber < 1) iAreaNumber = 1; offset = areahdr.hdrsize + ((iAreaNumber - 1) * areahdr.recsize); if (fseek(pAreas, offset, 0) != 0) printf("Can't move pointer there."); else fread(&area, areahdr.recsize, 1, pAreas); /* * Do a check if area is greater or less number than allowed, * security access level, is oke, and the area is active. */ if (iAreaNumber > iAreaNum || iAreaNumber < 1 || (Access(exitinfo.Security, area.LTSec) == FALSE) || (strlen(area.Name) == 0)) { Enter(1); /* Invalid area specified - Please try again ...*/ pout(LIGHTRED, BLACK, (char *) Language(233)); Enter(2); Pause(); fclose(pAreas); iAreaNumber = iOldArea; SetFileArea(iAreaNumber); free(temp); return; } SetFileArea(iAreaNumber); Syslog('+', "File area %lu %s", iAreaNumber, sAreaDesc); /* * Check if file area has a password, if it does ask user for it */ if ((strlen(area.Password)) > 2) { Enter(2); /* Please enter Area Password: */ pout(WHITE, BLACK, (char *) Language(299)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp, 20); Enter(1); if ((strcmp(temp, area.Password)) != 0) { /* Password is incorrect */ pout(LIGHTRED, BLACK, (char *) Language(234)); Syslog('!', "Incorrect File Area # %d password given: %s", iAreaNumber, temp); SetFileArea(iOldArea); } else { /* Password is correct */ pout(WHITE, BLACK, (char *) Language(235)); } Enter(2); Pause(); } free(temp); fclose(pAreas); }
// Attempts to instance a font effect from an instancer registered with the factory. FontEffect* Factory::InstanceFontEffect(const String& name, const PropertyDictionary& properties) { bool set_colour = false; Colourb colour(255, 255, 255); bool set_z_index = false; float z_index = 0; int specificity = -1; FontEffectInstancerMap::iterator iterator = font_effect_instancers.find(name); if (iterator == font_effect_instancers.end()) return NULL; FontEffectInstancer* instancer = iterator->second; // Turn the generic, un-parsed properties we've got into a properly parsed dictionary. const PropertySpecification& property_specification = (*iterator).second->GetPropertySpecification(); PropertyDictionary parsed_properties; for (PropertyMap::const_iterator i = properties.GetProperties().begin(); i != properties.GetProperties().end(); ++i) { specificity = Math::Max(specificity, i->second.specificity); // Check for the 'z-index' property; we don't want to send this through. if (i->first == Z_INDEX) { set_z_index = true; z_index = i->second.value.Get< float >(); } else if (i->first == COLOR) { static PropertyParserColour colour_parser; Property colour_property; if (colour_parser.ParseValue(colour_property, i->second.value.Get< String >(), ParameterMap())) { colour = colour_property.value.Get< Colourb >(); set_colour = true; } } else { property_specification.ParsePropertyDeclaration(parsed_properties, (*i).first, (*i).second.value.Get< String >(), (*i).second.source, (*i).second.source_line_number); } } // Set the property defaults for all unset properties. property_specification.SetPropertyDefaults(parsed_properties); // Compile an ordered list of the values of the properties used to generate the effect's // textures and geometry. typedef std::list< std::pair< String, String > > GenerationPropertyList; GenerationPropertyList generation_properties; for (PropertyMap::const_iterator i = parsed_properties.GetProperties().begin(); i != parsed_properties.GetProperties().end(); ++i) { if (instancer->volatile_properties.find(i->first) != instancer->volatile_properties.end()) { GenerationPropertyList::iterator j = generation_properties.begin(); while (j != generation_properties.end() && j->first < i->first) ++j; generation_properties.insert(j, GenerationPropertyList::value_type(i->first, i->second.value.Get< String >())); } } String generation_key; for (GenerationPropertyList::iterator i = generation_properties.begin(); i != generation_properties.end(); ++i) { generation_key += i->second; generation_key += ";"; } // Now we can actually instance the effect! FontEffect* font_effect = (*iterator).second->InstanceFontEffect(name, parsed_properties); if (font_effect == NULL) return NULL; font_effect->name = name; font_effect->generation_key = generation_key; if (set_z_index) font_effect->SetZIndex(z_index); if (set_colour) font_effect->SetColour(colour); font_effect->SetSpecificity(specificity); font_effect->instancer = (*iterator).second; return font_effect; }
/* * Edit the list of tagged files. */ void EditTaglist() { FILE *tf; int i, x, Fg, Count; char *temp; if ((tf = fopen("taglist", "r+")) == NULL) { Enter(1); /* No files tagged. */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(361)); Enter(2); Pause(); return; } temp = calloc(81, sizeof(char)); if (utf8) chartran_init((char *)"CP437", (char *)"UTF-8", 'B'); while (TRUE) { clear(); fseek(tf, 0, SEEK_SET); Count = 0; /* # Area Active Size Cost File */ /* 123 12345 123456 12345678 12345 */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(355)); Enter(1); colour(LIGHTGREEN, BLACK); PUTSTR(chartran(fLine_str(79))); while ((fread(&Tag, sizeof(Tag), 1, tf) == 1)) { Count++; if (Tag.Active) Fg = WHITE; else Fg = LIGHTGRAY; snprintf(temp, 81, "%3d ", Count); pout(Fg, BLACK, temp); Fg--; snprintf(temp, 81, "%5d ", Tag.Area); pout(Fg, BLACK, temp); Fg--; if (Tag.Active) /* Yes */ snprintf(temp, 81, "%-6s ", (char *) Language(356)); else /* No */ snprintf(temp, 81, "%-6s ", (char *) Language(357)); pout(Fg, BLACK, temp); Fg--; snprintf(temp, 81, "%8d ", (int)(Tag.Size)); pout(Fg, BLACK, temp); Fg--; snprintf(temp, 81, "%5d ", Tag.Cost); pout(Fg, BLACK, temp); Fg--; snprintf(temp, 81, "%s", Tag.LFile); pout(Fg, BLACK, temp); Enter(1); } colour(LIGHTGREEN, BLACK); PUTSTR(chartran(fLine_str(79))); /* (T)oggle active, (E)rase all, (ENTER) to continue: */ pout(WHITE, RED, (char *) Language(358)); i = toupper(Readkey()); colour(CFG.CRColourF, CFG.CRColourB); if (i == Keystroke(358, 0)) { Enter(2); /* Enter file number, 1.. */ snprintf(temp, 81, "%s%d ", (char *) Language(359), Count); PUTSTR(temp); GetstrC(temp, 5); x = atoi(temp); if ((x > 0) && (x <= Count)) { if (fseek(tf, (x - 1) * sizeof(Tag), SEEK_SET) == 0) { if (fread(&Tag, sizeof(Tag), 1, tf) == 1) { if (Tag.Active) Tag.Active = FALSE; else Tag.Active = TRUE; fseek(tf,(x - 1) * sizeof(Tag), SEEK_SET); fwrite(&Tag, sizeof(Tag), 1, tf); } } } } chartran_close(); if (i == Keystroke(358, 1)) { fclose(tf); unlink("taglist"); free(temp); return; } if ((i == '\r') || (i == '\n')) { fclose(tf); free(temp); return; } } }
/* * Change character set. */ void Chg_Charset() { int i; char *temp; temp = calloc(81, sizeof(char)); ReadExitinfo(); Syslog('+', "Old character set %s", getftnchrs(exitinfo.Charset)); while(TRUE) { Enter(1); /* Select your preferred character set */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(23)); Enter(2); colour(LIGHTBLUE, BLACK); for (i = (FTNC_NONE + 1); i <= FTNC_MAXCHARS; i++) { colour(LIGHTBLUE, BLACK); snprintf(temp, 81, "%2d ", i); PUTSTR(temp); colour(LIGHTCYAN, BLACK); snprintf(temp, 81, "%-9s ", getftnchrs(i)); PUTSTR(temp); colour(LIGHTMAGENTA, BLACK); snprintf(temp, 81, "%s\r\n", getchrsdesc(i)); PUTSTR(temp); } Enter(1); /* Select character set (Enter to Quit): */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(24)); Getnum(temp, 2); if (((strcmp(temp, "")) == 0) && (exitinfo.Charset != FTNC_NONE)) { free(temp); return; } i = atoi(temp); if ((i > FTNC_NONE) && (i <= FTNC_MAXCHARS)) { exitinfo.Charset = i; Syslog('+', "New character set %s", getftnchrs(exitinfo.Charset)); WriteExitinfo(); setlocale(LC_CTYPE, getlocale(exitinfo.Charset)); utf8 = (exitinfo.Charset == FTNC_UTF8); Syslog('b', "setlocale(LC_CTYPE, NULL) returns \"%s\"", printable(setlocale(LC_CTYPE, NULL), 0)); Enter(2); colour(LIGHTGREEN, BLACK); /* Character set now set to: */ snprintf(temp, 81, "%s%s", (char *) Language(25), getftnchrs(i)); PUTSTR(temp); free(temp); Enter(2); Pause(); return; } Enter(2); /* Invalid selection, please try again! */ pout(LIGHTRED, BLACK, (char *) Language(265)); Enter(2); } }
/* * View a file in the current area, menu 103. * If a file name is given, display direct, * else ask for filename to view. */ void ViewFile(char *name) { char *File, *temp, *arc; int count, total, rc, found = FALSE; FILE *fp; struct _fdbarea *fdb_area = NULL; Syslog('+', "ViewFile(%s)", printable(name, 0)); if (Access(exitinfo.Security, area.LTSec) == FALSE) { Enter(1); /* You don't have enough security to list this area */ pout(YELLOW, BLACK, (char *) Language(236)); Enter(2); Pause(); return; } File = calloc(PATH_MAX, sizeof(char)); if ((name != NULL) && strlen(name)) { strcpy(File, name); } else { Enter(2); /* Please enter filename: */ pout(YELLOW, BLACK, (char *) Language(245)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(File, 80); if ((strcmp(File, "")) == 0) { free(File); return; } if (*(File) == '.' || *(File) == '*' || *(File) == ' ' || *(File) == '/') { Enter(1); /* Illegal Filename! */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247)); Enter(2); Pause(); free(File); return; } Strlen = strlen(File); Strlen--; if (*(File + Strlen) == '.' || *(File + Strlen) == '/' || *(File + Strlen) == ' ') { Enter(1); /* Illegal Filename! */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247)); Enter(2); Pause(); free(File); return; } if ((!strcmp(File, "files.bbs")) || (!strcmp(File, "00index")) || (strstr(File, (char *)".html"))) { Enter(1); /* Illegal Filename! */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247)); Enter(2); Pause(); free(File); return; } } /* * Now check if this file is present */ if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) { free(File); return; } while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { if (((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) && (!fdb.Deleted)) { found = TRUE; break; } } mbsedb_CloseFDB(fdb_area); if (!found) { Enter(1); /* File does not exist, please try again ... */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(296)); Enter(2); free(File); Pause(); return; } snprintf(File, PATH_MAX, "%s/%s", sAreaPath, fdb.LName); arc = GetFileType(File); Syslog('+', "File to view: %s, type %s", fdb.LName, printable(arc, 0)); if (arc != NULL) { found = FALSE; temp = calloc(PATH_MAX, sizeof(char)); snprintf(temp, PATH_MAX, "%s/etc/archiver.data", getenv("MBSE_ROOT")); if ((fp = fopen(temp, "r")) != NULL) { fread(&archiverhdr, sizeof(archiverhdr), 1, fp); while (fread(&archiver, archiverhdr.recsize, 1, fp) == 1) { if ((strcmp(arc, archiver.name) == 0) && (archiver.available)) { found = TRUE; break; } } fclose(fp); } if (!found || (strlen(archiver.varc) == 0)) { Syslog('+', "No archiver view for %s available", File); Enter(1); /* Archiver not available */ pout(CFG.HiliteF, CFG.HiliteB, Language(442)); Enter(2); free(File); free(temp); Pause(); return; } /* * Archiver viewer is available. Make a temp file which we will * display to the user. */ snprintf(temp, PATH_MAX, "%s/%s/temptxt", CFG.bbs_usersdir, exitinfo.Name); rc = execute_str(archiver.varc, File, NULL, (char *)"/dev/null", temp, (char *)"/dev/null"); Syslog('+', "Display temp file %s", temp); DisplayTextFile(temp); unlink(temp); free(temp); } else { /* * Most likely a textfile, first check. */ total = count = 0; if ((fp = fopen(File, "r"))) { while (TRUE) { rc = fgetc(fp); if (rc == EOF) break; total++; if (isascii(rc)) count++; } fclose(fp); } if (((count * 10) / total) < 8) { Syslog('+', "This is not a ASCII textfile"); Enter(1); pout(CFG.HiliteF, CFG.HiliteB, Language(17)); Enter(2); Pause(); free(File); return; } Syslog('+', "Display text file %s", File); DisplayTextFile(File); } free(File); }
int Chg_Language(int NewMode) { FILE *pLang; int iLang, iFoundLang = FALSE; char *temp; temp = calloc(PATH_MAX, sizeof(char)); if (!NewMode) ReadExitinfo(); while(TRUE) { snprintf(temp, PATH_MAX, "%s/etc/language.data", getenv("FTND_ROOT")); if(( pLang = fopen(temp, "r")) == NULL) { WriteError("$Can't open %s", temp); snprintf(temp, 81, "\nFATAL: Can't open language file\n\n"); PUTSTR(temp); Pause(); free(temp); return 0; } fread(&langhdr, sizeof(langhdr), 1, pLang); colour(CFG.HiliteF, CFG.HiliteB); /* Select your preferred language */ snprintf(temp, 81, "\r\n%s\r\n\r\n", (char *) Language(378)); PUTSTR(temp); iLang = 6; colour(LIGHTBLUE, BLACK); while (fread(&lang, langhdr.recsize, 1, pLang) == 1) if (lang.Available) { colour(LIGHTMAGENTA, BLACK); snprintf(temp, 81, "(%s)", lang.LangKey); PUTSTR(temp); colour(DARKGRAY, BLACK); snprintf(temp, 81, " %c ", 46); PUTSTR(temp); colour(CYAN, BLACK); snprintf(temp, 81, "%-29s ", lang.Name); PUTSTR(temp); iLang++; if ((iLang % 2) == 0) { PUTCHAR('\r'); PUTCHAR('\n'); } } Enter(1); colour(CFG.HiliteF, CFG.HiliteB); /* Select language: */ snprintf(temp, 81, "\n%s", (char *) Language(379)); PUTSTR(temp); alarm_on(); iLang = toupper(Readkey()); PUTCHAR(iLang); fseek(pLang, langhdr.hdrsize, 0); while (fread(&lang, langhdr.recsize, 1, pLang) == 1) { strcpy(lang.LangKey,tu(lang.LangKey)); if ((lang.LangKey[0] == iLang) && (lang.Available)) { strcpy(current_language, lang.lc); iFoundLang = TRUE; break; } } fclose(pLang); if(!iFoundLang) { Enter(2); /* Invalid selection, please try again! */ pout(LIGHTGREEN, BLACK, (char *) Language(265)); Enter(2); } else { exitinfo.iLanguage = iLang; strcpy(current_language, lang.lc); Free_Language(); InitLanguage(); colour(LIGHTGREEN, BLACK); /* Language now set to" */ snprintf(temp, 81, "\r\n\r\n%s%s\r\n\r\n", (char *) Language(380), lang.Name); PUTSTR(temp); if (!NewMode) { Syslog('+', "Changed language to %s", lang.Name); WriteExitinfo(); Pause(); } break; } } free(temp); Enter(1); return iLang; }
/* * Show Raw directory */ void File_RawDir(char *OpData) { DIR *dirp; char *FileName, *temp, temp2[81]; int iFileCount = 0, LineCount = 2, iBytes = 0; struct dirent *dp; struct stat statfile; FileName = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char)); if ((strcmp(OpData, "/F")) == 0) strcpy(temp, sAreaPath); else strcpy(temp, OpData); if ((dirp = opendir(temp)) == NULL) { clear(); WriteError("$RawDir: Can't open dir: %s", temp); Enter(1); pout(LIGHTRED, BLACK, (char *)"Can't open directory for raw listing!"); Enter(2); Pause(); } else { if (utf8) chartran_init((char *)"CP437", (char *)"UTF-8", 'b'); clear(); /* Filename Size Date */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(261)); Enter(1); PUTSTR(chartran(fLine_str(78))); while ((dp = readdir( dirp )) != NULL ) { snprintf(FileName, PATH_MAX, "%s/%s", temp, dp->d_name); if (*(dp->d_name) != '.') { iFileCount++; if (stat(FileName, &statfile) != 0) { pout(LIGHTRED, BLACK, (char *)"Can't stat file "); PUTSTR(FileName); } else { iBytes += statfile.st_size; snprintf(temp2, 81, "%-54s " , dp->d_name); pout(YELLOW, BLACK, temp2); snprintf(temp2, 81, "%-12d", (int)(statfile.st_size)); pout(LIGHTMAGENTA, BLACK, temp2); snprintf(temp2, 81, "%-10s", StrDateDMY(statfile.st_mtime)); pout(LIGHTGREEN, BLACK, temp2); } Enter(1); LineCount++; if (LineCount == rows) { Pause(); LineCount = 0; } } } colour(CFG.HiliteF, CFG.HiliteB); PUTSTR(chartran(fLine_str(78))); /* Total Files: */ /* Bytes */ snprintf(temp2, 81, "%s %d, %d %s", (char *) Language(242), iFileCount, iBytes, (char *) Language(354)); pout(LIGHTGREEN, BLACK, temp2); Enter(2); Pause(); closedir(dirp); chartran_close(); } free(temp); free(FileName); }
/* * Change default protocol. */ void Chg_Protocol() { FILE *pProtConfig; int iProt, iFoundProt = FALSE, precno = 0; char *temp, Prot[2]; temp = calloc(PATH_MAX, sizeof(char)); ReadExitinfo(); Set_Protocol(exitinfo.sProtocol); Syslog('+', "Old protocol %s", sProtName); while(TRUE) { snprintf(temp, PATH_MAX, "%s/etc/protocol.data", getenv("FTND_ROOT")); if ((pProtConfig = fopen(temp, "r")) == NULL) { WriteError("$Can't open %s", temp); /* Protocol: Can't open protocol file. */ Enter(1); PUTSTR((char *) Language(262)); Enter(2); Pause(); free(temp); fclose(pProtConfig); return; } fread(&PROThdr, sizeof(PROThdr), 1, pProtConfig); Enter(1); /* Select your preferred protocol */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(263)); Enter(2); while (fread(&PROT, PROThdr.recsize, 1, pProtConfig) == 1) { if (PROT.Available && Access(exitinfo.Security, PROT.Level)) { colour(LIGHTBLUE, BLACK); PUTCHAR('('); colour(WHITE, BLACK); PUTSTR(PROT.ProtKey); colour(LIGHTBLUE, BLACK); snprintf(temp, 81, ") %-20s Efficiency %3d %%\r\n", PROT.ProtName, PROT.Efficiency); PUTSTR(temp); } } Enter(1); pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(264)); alarm_on(); iProt = toupper(Readkey()); PUTCHAR(iProt); snprintf(Prot, 2, "%c", iProt); fseek(pProtConfig, PROThdr.hdrsize, 0); while (fread(&PROT, PROThdr.recsize, 1, pProtConfig) == 1) { if ((strncmp(PROT.ProtKey, Prot, 1) == 0) && PROT.Available && Access(exitinfo.Security, PROT.Level)) { strcpy(sProtName, PROT.ProtName); strcpy(sProtUp, PROT.ProtUp); strcpy(sProtDn, PROT.ProtDn); strcpy(sProtAdvice, PROT.Advice); uProtInternal = PROT.Internal; iProtEfficiency = PROT.Efficiency; iFoundProt = TRUE; } else precno++; } fclose(pProtConfig); if (iProt == 13) { free(temp); return; } else { if (!iFoundProt) { Enter(2); pout(LIGHTGREEN, BLACK, (char *) Language(265)); Enter(2); /* Loop for new attempt */ } else { Setup(exitinfo.sProtocol, sProtName); Enter(1); /* Protocol now set to: */ pout(LIGHTGREEN, BLACK, (char *) Language(266)); PUTSTR(sProtName); Enter(2); Pause(); break; } } } Syslog('+', "New protocol %s", sProtName); WriteExitinfo(); free(temp); }
/* * Search for keyword, called from menu. */ int KeywordScan() { FILE *pAreas; int i, z, y, Found, Count = 0; char *Name, *tmpname, *BigDesc, temp[81]; _Tag T; unsigned int OldArea; struct _fdbarea *fdb_area = NULL; Name = calloc(81, sizeof(char)); tmpname = calloc(81, sizeof(char)); BigDesc = calloc(1230, sizeof(char)); OldArea = iAreaNumber; iLineCount = 2; /* Reset Line Counter to Zero */ arecno = 1; /* Reset Area Number to One */ Enter(2); /* Enter keyword to use for Search: */ pout(LIGHTCYAN, BLACK, (char *) Language(267)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(Name, 80); if ((strcmp(Name, "")) == 0) return 0; strcpy(tmpname, tl(Name)); strcpy(Name, ""); y = strlen(tmpname); for (z = 0; z < y; z++) { if (tmpname[z] != '*') { snprintf(temp, 81, "%c", tmpname[z]); strcat(Name, temp); } } Syslog('+', "KeywordScan(): \"%s\"", Name); clear(); /* File search by keyword */ pout(WHITE, BLACK, (char *) Language(268)); Enter(1); InitTag(); if ((pAreas = OpenFareas(FALSE)) == NULL) return 0; while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) { if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) { Nopper(); Found = FALSE; Sheader(); while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { for (i = 0; i < 25; i++) snprintf(BigDesc, 1230, "%s%s", BigDesc, *(fdb.Desc + i)); if ((strstr(fdb.Name,Name) != NULL) || (strstr(tl(BigDesc), Name) != NULL)) { if (!Found) { Enter(2); if (iLC(2) == 1) { free(BigDesc); free(Name); free(tmpname); SetFileArea(OldArea); return 1; } Found = TRUE; } memset(&T, 0, sizeof(T)); T.Area = arecno; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, fdb.LName, 80); SetTag(T); Count++; if (ShowOneFile() == 1) { free(BigDesc); free(Name); free(tmpname); SetFileArea(OldArea); return 1; } } strcpy(BigDesc, ""); /* Clear BigDesc */ } /* while */ mbsedb_CloseFDB(fdb_area); if (Found) { Enter(2); if (iLC(2) == 1) { free(BigDesc); free(Name); free(tmpname); SetFileArea(OldArea); return 1; } } } /* End check for LTSec */ } /* if access */ arecno++; /* Go to next file area */ } /* End of Main */ Syslog('+', "Found %d files", Count); free(BigDesc); free(Name); free(tmpname); fclose(pAreas); Enter(1); if (Count) Mark(); else Pause(); SetFileArea(OldArea); return 1; }
/* * Read e-mail, called from the menus */ void Read_Email(void) { char *temp, *p; unsigned int Start, mycrc; lastread LR; if (HasNoEmail()) return; Enter(1); temp = calloc(128, sizeof(char)); /* Message area \"%s\" contains %lu messages. */ snprintf(temp, 128, "\n%s\"%s\" %s%u %s", (char *) Language(221), sMailbox, (char *) Language(222), EmailBase.Total, (char *) Language(223)); pout(CFG.TextColourF, CFG.TextColourB, temp); /* * Check for lastread pointer, suggest lastread number for start. */ Start = EmailBase.Lowest; p = xstrcpy(exitinfo.sUserName); mycrc = StringCRC32(tl(p)); free(p); if (Msg_Open(sMailpath)) { LR.UserID = grecno; LR.UserCRC = mycrc; if (Msg_GetLastRead(&LR)) Start = LR.HighReadMsg + 1; else Start = 1; Msg_Close(); /* * If we already have read the last message, the pointer is * higher then HighMsgNum, we set it at HighMsgNum to prevent * errors and read that message again. */ if (Start > EmailBase.Highest) Start = EmailBase.Highest; } Enter(1); /* Please enter a message between */ snprintf(temp, 81, "%s(%u - %u)", (char *) Language(224), EmailBase.Lowest, EmailBase.Highest); pout(WHITE, BLACK, temp); Enter(1); /* Message number [ */ snprintf(temp, 81, "%s%u]: ", (char *) Language(225), Start); PUTSTR(temp); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp, 80); if ((strcmp(temp, "")) != 0) Start = atoi(temp); free(temp); if (!Read_a_Email(Start)) return; if (EmailBase.Total == 0) return; while(EmailPanel()) {} }
void image_widget::paint(graphics_context& aGraphicsContext) const { if (iTexture.is_empty()) return; scoped_units su(*this, UnitsPixels); rect placementRect(point{}, iTexture.extents()); if (iAspectRatio == aspect_ratio::Stretch) { placementRect.cx = client_rect().width(); placementRect.cy = client_rect().height(); } else if (placementRect.width() >= placementRect.height()) { switch (iAspectRatio) { case aspect_ratio::Ignore: if (placementRect.width() > client_rect().width()) placementRect.cx = client_rect().width(); if (placementRect.height() > client_rect().height()) placementRect.cy = client_rect().height(); break; case aspect_ratio::Keep: if (placementRect.width() > client_rect().width()) { placementRect.cx = client_rect().width(); placementRect.cy = placementRect.cx * iTexture.extents().cy / iTexture.extents().cx; } if (placementRect.height() > client_rect().height()) { placementRect.cy = client_rect().height(); placementRect.cx = placementRect.cy * iTexture.extents().cx / iTexture.extents().cy; } break; case aspect_ratio::KeepExpanding: if (placementRect.height() > client_rect().height()) { placementRect.cy = client_rect().height(); placementRect.cx = placementRect.cy * iTexture.extents().cx / iTexture.extents().cy; } break; } } else { switch (iAspectRatio) { case aspect_ratio::Ignore: if (placementRect.width() > client_rect().width()) placementRect.cx = client_rect().width(); if (placementRect.height() > client_rect().height()) placementRect.cy = client_rect().height(); break; case aspect_ratio::Keep: if (placementRect.height() > client_rect().height()) { placementRect.cy = client_rect().height(); placementRect.cx = placementRect.cy * iTexture.extents().cx / iTexture.extents().cy; } if (placementRect.width() > client_rect().width()) { placementRect.cx = client_rect().width(); placementRect.cy = placementRect.cx * iTexture.extents().cy / iTexture.extents().cx; } break; case aspect_ratio::KeepExpanding: if (placementRect.width() > client_rect().width()) { placementRect.cx = client_rect().width(); placementRect.cy = placementRect.cx * iTexture.extents().cy / iTexture.extents().cx; } break; } } switch (iPlacement) { case cardinal_placement::NorthWest: placementRect.position() = point{}; break; case cardinal_placement::North: placementRect.position() = point{ std::floor((client_rect().width() - placementRect.cx) / 2.0), 0.0 }; break; case cardinal_placement::NorthEast: placementRect.position() = point{ client_rect().width() - placementRect.width(), 0.0 }; break; case cardinal_placement::West: placementRect.position() = point{ 0.0, std::floor((client_rect().height() - placementRect.cy) / 2.0) }; break; case cardinal_placement::Centre: placementRect.position() = point{ std::floor((client_rect().width() - placementRect.cx) / 2.0), std::floor((client_rect().height() - placementRect.cy) / 2.0) }; break; case cardinal_placement::East: placementRect.position() = point{ client_rect().width() - placementRect.width(), std::floor((client_rect().height() - placementRect.cy) / 2.0) }; break; case cardinal_placement::SouthWest: placementRect.position() = point{ 0.0, client_rect().height() - placementRect.height() }; break; case cardinal_placement::South: placementRect.position() = point{ std::floor((client_rect().width() - placementRect.cx) / 2.0), client_rect().height() - placementRect.height() }; break; case cardinal_placement::SouthEast: placementRect.position() = point{ client_rect().width() - placementRect.width(), client_rect().height() - placementRect.height() }; break; } if (effectively_disabled()) aGraphicsContext.set_monochrome(true); aGraphicsContext.draw_texture(placementRect, iTexture, effectively_disabled() ? colour(0xFF, 0xFF, 0xFF, 0x80) : optional_colour()); aGraphicsContext.set_monochrome(false); }