File: main.cc

package info (click to toggle)
bbmail 0.8.3-7
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 784 kB
  • sloc: cpp: 7,307; sh: 3,506; makefile: 83; perl: 26
file content (114 lines) | stat: -rw-r--r-- 3,723 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//  Basewindow.cc for bbtools.
//
//  Copyright (c) 1998-2000 by John Kennis, jkennis@chello.nl
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// (See the included file COPYING / GPL-2.0)
//

#include "bbmail.hh"
#include "main.hh"

void Usage()
{
	fprintf(stdout,"\n%s version %s \n",BBTOOL,BBTOOL_VERSION);
	fprintf(stdout,"Usage: %s [options]\n",BBTOOL);
	fprintf(stdout,"Options:\n");
	fprintf(stdout,"-display <display name>     X server to connect to\n");
	fprintf(stdout,"-c[onfig] <filename>        Alternate config file\n");
	fprintf(stdout,"-n[obb]                     Fall back on default configuration\n");
	fprintf(stdout,"-v[ersion]                  Display version number\n");
	fprintf(stdout,"-h[elp]                     Display this help\n");
	fprintf(stdout,"-geom[etry] <geometry>      Set geometry of window\n");
	fprintf(stdout,"-d[ecorated]                Show 'normal' decorated window\n");
	fprintf(stdout,"-w[ithdrawn]                Place bbtool in the Slit\n");
	fprintf(stdout,"-s[hape]                    Don't display groundplate\n");

	fprintf(stdout,"-sp[ooldir]                 Define alternate spooldir\n");
	fprintf(stdout,"-m[ailbox] <number>         Show only mailbox <number>\n\n");
}


int main(int argc,char **argv)
{
	int i;
	struct CMDOPTIONS options;
	options.display_name=NULL;
	options.geometry=NULL;
	options.withdrawn=False;
	options.shape=False;
	options.config_file=NULL;
	options.nobb_config=False;
	options.decorated=False;
	options.spooldir=NULL;
	options.mailbox=0;
	options.app_name=argv[0];


	for(i=1;i<argc;i++) {
		if ((!strcmp(argv[i],"-display"))) {
			if(++i==argc)  {
				Usage();
				exit(2);
			};
			options.display_name=argv[i];
		} else if ((!strcmp(argv[i],"-config"))|(!strcmp(argv[i],"-c"))) {
			if(++i==argc)  {
				Usage();
				exit(2);
			};
			options.config_file=argv[i];
		} else if ((!strcmp(argv[i],"-nobb"))|(!strcmp(argv[i],"-n"))) {
			options.nobb_config=True;
		} else if ( (!strcmp(argv[i],"-v")) || (!strcmp(argv[i],"-version"))) {
			fprintf(stderr," %s version %s\n",BBTOOL,BBTOOL_VERSION);
			exit(2);
		} else if ( (!strcmp(argv[i],"-h")) || (!strcmp(argv[i],"-help"))) {
			Usage();
			exit(2);
		} else if ((!strcmp(argv[i],"-geometry")) || (!strcmp(argv[i],"-geom"))) {
			if(++i==argc)  {
				Usage();
				exit(2);
			};
			options.geometry=argv[i];
		}
		else if ((!strcmp(argv[i],"-withdrawn")) || (!strcmp(argv[i],"-w"))) {
			options.withdrawn=True;
		} else if ((!strcmp(argv[i],"-shape")) || (!strcmp(argv[i],"-s"))) {
			options.shape=True;
		} else if ((!strcmp(argv[i],"-decorated")) || (!strcmp(argv[i],"-d"))) {
			options.decorated=True;
		} else if ((!strcmp(argv[i],"-spooldir")) || (!strcmp(argv[i],"-sp"))) {
			if(++i==argc)  {
				Usage();
				exit(2);
			};
			options.spooldir=argv[i];
		}
		if ((!strcmp(argv[i],"-m"))||(!strcmp(argv[i],"-mailbox"))) {
			if(++i==argc)  {
				Usage();
				exit(2);
			};
			if (sscanf(argv[i], "%d", &options.mailbox) != 1) {
				Usage();
				exit(2);
			};
		}
	}
	ToolWindow bbmail(argc,argv,&options);
}