add debugging for main()
so far, that's mostly mailbox listing
This commit is contained in:
		
							parent
							
								
									0e1f8f9a3f
								
							
						
					
					
						commit
						03a124051f
					
				
					 3 changed files with 31 additions and 4 deletions
				
			
		| 
						 | 
					@ -64,6 +64,7 @@ typedef unsigned int uint;
 | 
				
			||||||
#define DEBUG_NET       0x04
 | 
					#define DEBUG_NET       0x04
 | 
				
			||||||
#define DEBUG_NET_ALL   0x08
 | 
					#define DEBUG_NET_ALL   0x08
 | 
				
			||||||
#define DEBUG_SYNC      0x10
 | 
					#define DEBUG_SYNC      0x10
 | 
				
			||||||
 | 
					#define DEBUG_MAIN      0x20
 | 
				
			||||||
#define DEBUG_ALL       (0xFF & ~DEBUG_NET_ALL)
 | 
					#define DEBUG_ALL       (0xFF & ~DEBUG_NET_ALL)
 | 
				
			||||||
#define QUIET           0x100
 | 
					#define QUIET           0x100
 | 
				
			||||||
#define VERYQUIET       0x200
 | 
					#define VERYQUIET       0x200
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										28
									
								
								src/main.c
									
										
									
									
									
								
							
							
						
						
									
										28
									
								
								src/main.c
									
										
									
									
									
								
							| 
						 | 
					@ -99,6 +99,16 @@ PACKAGE " " VERSION " - mailbox synchronizer\n"
 | 
				
			||||||
	exit( code );
 | 
						exit( code );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void ATTR_PRINTFLIKE(1, 2)
 | 
				
			||||||
 | 
					debug( const char *msg, ... )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						va_list va;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						va_start( va, msg );
 | 
				
			||||||
 | 
						vdebug( DEBUG_MAIN, msg, va );
 | 
				
			||||||
 | 
						va_end( va );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __linux__
 | 
					#ifdef __linux__
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
crashHandler( int n )
 | 
					crashHandler( int n )
 | 
				
			||||||
| 
						 | 
					@ -433,6 +443,8 @@ main( int argc, char **argv )
 | 
				
			||||||
						op = DEBUG_CRASH;
 | 
											op = DEBUG_CRASH;
 | 
				
			||||||
					else if (!strcmp( opt, "-maildir" ))
 | 
										else if (!strcmp( opt, "-maildir" ))
 | 
				
			||||||
						op = VERBOSE | DEBUG_MAILDIR;
 | 
											op = VERBOSE | DEBUG_MAILDIR;
 | 
				
			||||||
 | 
										else if (!strcmp( opt, "-main" ))
 | 
				
			||||||
 | 
											op = VERBOSE | DEBUG_MAIN;
 | 
				
			||||||
					else if (!strcmp( opt, "-net" ))
 | 
										else if (!strcmp( opt, "-net" ))
 | 
				
			||||||
						op = VERBOSE | DEBUG_NET;
 | 
											op = VERBOSE | DEBUG_NET;
 | 
				
			||||||
					else if (!strcmp( opt, "-net-all" ))
 | 
										else if (!strcmp( opt, "-net-all" ))
 | 
				
			||||||
| 
						 | 
					@ -618,6 +630,9 @@ main( int argc, char **argv )
 | 
				
			||||||
				case 'm':
 | 
									case 'm':
 | 
				
			||||||
					op |= DEBUG_MAILDIR | VERBOSE;
 | 
										op |= DEBUG_MAILDIR | VERBOSE;
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
 | 
									case 'M':
 | 
				
			||||||
 | 
										op |= DEBUG_MAIN | VERBOSE;
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
				case 'n':
 | 
									case 'n':
 | 
				
			||||||
					op |= DEBUG_NET | VERBOSE;
 | 
										op |= DEBUG_NET | VERBOSE;
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
| 
						 | 
					@ -918,6 +933,8 @@ store_opened( store_t *ctx, void *aux )
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					flags |= LIST_PATH;
 | 
										flags |= LIST_PATH;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									debug( "pattern '%s' (effective '%s'): %sPath, %sINBOX\n",
 | 
				
			||||||
 | 
									       pat, buf, (flags & LIST_PATH) ? "" : "no ",  (flags & LIST_INBOX) ? "" : "no ");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		set_bad_callback( ctx, store_bad, AUX );
 | 
							set_bad_callback( ctx, store_bad, AUX );
 | 
				
			||||||
| 
						 | 
					@ -932,13 +949,18 @@ static void
 | 
				
			||||||
store_listed( int sts, void *aux )
 | 
					store_listed( int sts, void *aux )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	MVARS(aux)
 | 
						MVARS(aux)
 | 
				
			||||||
	string_list_t **box;
 | 
						string_list_t **box, *bx;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (sts) {
 | 
						switch (sts) {
 | 
				
			||||||
	case DRV_CANCELED:
 | 
						case DRV_CANCELED:
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	case DRV_OK:
 | 
						case DRV_OK:
 | 
				
			||||||
		mvars->ctx[t]->listed = 1;
 | 
							mvars->ctx[t]->listed = 1;
 | 
				
			||||||
 | 
							if (DFlags & DEBUG_MAIN) {
 | 
				
			||||||
 | 
								debug( "got mailbox list from %s:\n", str_ms[t] );
 | 
				
			||||||
 | 
								for (bx = mvars->ctx[t]->boxes; bx; bx = bx->next)
 | 
				
			||||||
 | 
									debug( "  %s\n", bx->string );
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if (mvars->ctx[t]->conf->flat_delim) {
 | 
							if (mvars->ctx[t]->conf->flat_delim) {
 | 
				
			||||||
			for (box = &mvars->ctx[t]->boxes; *box; box = &(*box)->next) {
 | 
								for (box = &mvars->ctx[t]->boxes; *box; box = &(*box)->next) {
 | 
				
			||||||
				string_list_t *nbox;
 | 
									string_list_t *nbox;
 | 
				
			||||||
| 
						 | 
					@ -952,8 +974,10 @@ store_listed( int sts, void *aux )
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (mvars->ctx[t]->conf->map_inbox)
 | 
							if (mvars->ctx[t]->conf->map_inbox) {
 | 
				
			||||||
 | 
								debug( "adding mapped inbox to %s: %s\n", str_ms[t], mvars->ctx[t]->conf->map_inbox );
 | 
				
			||||||
			add_string_list( &mvars->ctx[t]->boxes, mvars->ctx[t]->conf->map_inbox );
 | 
								add_string_list( &mvars->ctx[t]->boxes, mvars->ctx[t]->conf->map_inbox );
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		mvars->ret = mvars->skip = 1;
 | 
							mvars->ret = mvars->skip = 1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,14 +80,16 @@ Display version information.
 | 
				
			||||||
\fB-V\fR, \fB--verbose\fR
 | 
					\fB-V\fR, \fB--verbose\fR
 | 
				
			||||||
Enable \fIverbose\fR mode, which displays what is currently happening.
 | 
					Enable \fIverbose\fR mode, which displays what is currently happening.
 | 
				
			||||||
.TP
 | 
					.TP
 | 
				
			||||||
\fB-D\fR[\fBC\fR][\fBm\fR][\fBn\fR|\fBN\fR][\fBs\fR]\fR]\fR,\
 | 
					\fB-D\fR[\fBC\fR][\fBm\fR][\fBM\fR][\fBn\fR|\fBN\fR][\fBs\fR]\fR]\fR,\
 | 
				
			||||||
 \fB--debug\fR[\fB-crash\fR|\fB-maildir\fR|\fB-net\fR|\fB-net-all\fR|\fB-sync\fR]
 | 
					 \fB--debug\fR[\fB-crash\fR|\fB-maildir\fR|\fB-main\fR|\fB-net\fR|\fB-net-all\fR|\fB-sync\fR]
 | 
				
			||||||
Enable debugging categories:
 | 
					Enable debugging categories:
 | 
				
			||||||
.in +4
 | 
					.in +4
 | 
				
			||||||
\fBC\fR, \fBcrash\fR - use built-in crash handler
 | 
					\fBC\fR, \fBcrash\fR - use built-in crash handler
 | 
				
			||||||
.br
 | 
					.br
 | 
				
			||||||
\fBm\fR, \fBmaildir\fR - print maildir debug info
 | 
					\fBm\fR, \fBmaildir\fR - print maildir debug info
 | 
				
			||||||
.br
 | 
					.br
 | 
				
			||||||
 | 
					\fBM\fR, \fBmain\fR - print main debug info
 | 
				
			||||||
 | 
					.br
 | 
				
			||||||
\fBn\fR, \fBnet\fR - print network traffic (protocol only)
 | 
					\fBn\fR, \fBnet\fR - print network traffic (protocol only)
 | 
				
			||||||
.br
 | 
					.br
 | 
				
			||||||
\fBN\fR, \fBnet-all\fR - print network traffic (including payloads)
 | 
					\fBN\fR, \fBnet-all\fR - print network traffic (including payloads)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue