/* * NextUnread - return the inote of the next unread message * * arguments: * inote - start looking after this, -1 means start at beginning * * return value: * ERROR (-1) all messages read * any + num message number of next unread message */ IDOC PASCAL INTERNAL NextUnread ( INOTE inote ) { INT i; for ( i = ++inote; i <= inoteLast; i++) { GenerateFlags ( mpInoteIdoc [ i ] ); if ( TESTFLAG ( rgDoc [ mpInoteIdoc [ i ] ].flag, F_UNREAD ) ) break; } return ( i > inoteLast ) ? ERROR : mpInoteIdoc [ i ]; }
/* Look4Message - look for a message * * arguments: * inote starting with inote * i +1 or -1 * fLook4Undel search * * * * return value: * ERROR (-1) at the end of the header list * any + num message number of next message */ INOTE PASCAL INTERNAL Look4Inote ( INOTE inote, INT i, FLAG fLook4Undel ) { if ( inote != -1 ) { while ( ( inote = inote + i ) >= 0 && inote <= inoteLast ) { GenerateFlags ( inote ); if ( !fLook4Undel || !TESTFLAG (rgDoc[mpInoteIdoc[inote]].flag, F_DELETED ) ) return ( inote ); } } return ERROR; }
int main(int argc, char **argv) { unsigned num_of_args = atoi(argv[1]); std::vector<unsigned long> flags = GenerateFlags(num_of_args); unsigned cnt(0); for(auto ele : flags){ std::cout << ele << " "; if(++cnt == /*pow(2, */num_of_args)/*)*/{ std::cout << std::endl; cnt = 0; } } return 0; }
/* AppendMsgs - append the passed message list to the passed file stream. * * arguments: * hWnd window for error messages. * pMsgList pointer to a message list. * pDestName pointer to destination file name. * options F_TABMSG set => adds tab (4 spaces) to beginning of line * F_INDENTMSG set => use RFAIndent at beginning of line * F_FIXFROM set => replace "From" with ">From" * F_BRKLN set => print seperating line after each file * F_HEADERS set => print only headers * * return value: * FALSE (0) append worked fine. * TRUE (-1) error during append. */ FLAG PASCAL INTERNAL AppendMsgs ( HW hWnd, PSTR pMsgList, PSTR pDestName, UINT options ) { struct vectorType *pVec = NULL; INT i = -1; IDOC idoc; FLAG fTemp; FILE *fp = NULL; PSTR pTmpFN = NULL; PSTR p = NULL; if ( !( MsgList ( &pVec, &pMsgList, TRUE ) ) ) SendMessage ( hWnd, DISPLAY, "There is an error in the message list." ); else if ( ( pVec == NULL ) || ( pVec->count == 0 ) ) SendMessage ( hWnd, DISPLAY, "No matching message set found" ); else { if (TESTFLAG (options, F_HEADERS | F_SENDER | F_NUMFROM)) fp = fopen ( pDestName, "a" ); for ( i = 0; i < pVec->count; i++) { idoc = (INT) pVec->elem[i]; if ( TESTFLAG (options, F_HEADERS)) { p = hdrLine ( NULL, idoc ); fprintf ( fp, "%s\n", p ); ZMfree ( p ); } else if ( TESTFLAG (options, F_SENDER | F_NUMFROM)) { GenerateFlags ( idoc ); p = GetSender (rgDoc[idoc].hdr, strEMPTY); fprintf ( fp, "%-15s", p ); ZMfree ( p ); if ( TESTFLAG (options, F_NUMFROM)) fprintf ( fp, " %4ld", (LONG)idoc+1 ); fprintf ( fp, "\n" ); } else { pTmpFN = mktmpnam ( ); if ( IdocToFile ( idoc, pTmpFN, 0 ) != ERROR ) { fTemp = FileFixTab ( hWnd, pTmpFN, pDestName, options, idoc + 1 ); _unlink ( pTmpFN ); ZMfree ( pTmpFN ); if ( fTemp ) { SendMessage ( hWnd, DISPLAY, "I couldn't 'fix' a message." ); pVec->count = i; break; } } else { ZMfree ( pTmpFN ); pVec->count = i; break; } } } PrintMsgList (hWnd, pVec); WndPrintf (hWnd, "\r\n"); } if ( pVec != PARSEERROR ) ZMfree ( ( PSTR ) pVec ); if (fp != NULL) fclose ( fp ); return i == -1 || i < pVec->count; }