Annotation of sbbs/sbbs2/uti/utihigh.c, revision 1.1

1.1     ! root        1: /* UTIHIGH.C */
        !             2: 
        !             3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
        !             4: 
        !             5: #include "sbbs.h"
        !             6: #include "uti.h"
        !             7: 
        !             8: smb_t smb;
        !             9: 
        !            10: /****************************************************************************/
        !            11: /* Returns the total number of msgs in the sub-board and sets 'ptr' to the  */
        !            12: /* number of the last message in the sub (0) if no messages.                */
        !            13: /****************************************************************************/
        !            14: ulong getlastmsg(uint subnum, ulong *ptr, time_t *t)
        !            15: {
        !            16:     char        str[256];
        !            17:     int         i;
        !            18:     ulong       total;
        !            19:     idxrec_t    idx;
        !            20: 
        !            21: if(ptr)
        !            22:     (*ptr)=0;
        !            23: if(t)
        !            24:     (*t)=0;
        !            25: 
        !            26: sprintf(smb.file,"%s%s",sub[subnum]->data_dir,sub[subnum]->code);
        !            27: smb.retry_time=30;
        !            28: if((i=smb_open(&smb))!=0) {
        !            29:        errormsg(WHERE,ERR_OPEN,smb.file,i);
        !            30:     return(0); }
        !            31: 
        !            32: if(!filelength(fileno(smb.sid_fp))) {                  /* Empty base */
        !            33:        smb_close(&smb);
        !            34:     return(0); }
        !            35: if((i=smb_locksmbhdr(&smb))!=0) {
        !            36:        smb_close(&smb);
        !            37:        errormsg(WHERE,ERR_LOCK,smb.file,i);
        !            38:     return(0); }
        !            39: if((i=smb_getlastidx(&smb,&idx))!=0) {
        !            40:        smb_close(&smb);
        !            41:        errormsg(WHERE,ERR_READ,smb.file,i);
        !            42:     return(0); }
        !            43: total=filelength(fileno(smb.sid_fp))/sizeof(idxrec_t);
        !            44: smb_unlocksmbhdr(&smb);
        !            45: smb_close(&smb);
        !            46: if(ptr)
        !            47:     (*ptr)=idx.number;
        !            48: if(t)
        !            49:     (*t)=idx.time;
        !            50: return(total);
        !            51: }
        !            52: 
        !            53: 
        !            54: int main(int argc, char **argv)
        !            55: {
        !            56:        char str[256];
        !            57:        int file,subnum,i;
        !            58:        ulong ptr;
        !            59: 
        !            60: PREPSCREEN;
        !            61: 
        !            62: printf("Synchronet UTIHIGH v%s\n",VER);
        !            63: 
        !            64: 
        !            65: if(argc<3)
        !            66:        exit(1);
        !            67: 
        !            68: uti_init("UTIHIGH",argc,argv);
        !            69: 
        !            70: subnum=getsubnum(argv[1]);
        !            71: if((int)subnum==-1)
        !            72:        bail(7);
        !            73: getlastmsg(subnum,&ptr,0);
        !            74: 
        !            75: if((file=nopen(argv[2],O_CREAT|O_TRUNC|O_WRONLY))==-1)
        !            76:        bail(2);
        !            77: 
        !            78: sprintf(str,"%lu",ptr);
        !            79: write(file,str,strlen(str));
        !            80: close(file);
        !            81: sprintf(str,"%20s Last message #%lu\r\n","",ptr);
        !            82: write(logfile,str,strlen(str));
        !            83: printf("\nDone.\n");
        !            84: bail(0);
        !            85: return(0);
        !            86: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.