File: mbl_lc.c

package info (click to toggle)
fbb 7.07-3
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 5,244 kB
  • ctags: 8,123
  • sloc: ansic: 87,810; sh: 2,324; makefile: 297
file content (179 lines) | stat: -rw-r--r-- 3,423 bytes parent folder | download | duplicates (8)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
   /****************************************************************
    Copyright (C) 1986-2000 by

    F6FBB - Jean-Paul ROUBELAT
    6, rue George Sand
    31120 - Roquettes - France
	jpr@f6fbb.org

    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    Parts of code have been taken from many other softwares.
    Thanks for the help.
    ****************************************************************/

#include <serv.h>

/*
 * Module commande LC
 */

#define NB_THEMES	1000

static void list_themes (void);

typedef struct theme
{
	char nom[6];
	int nb;
	struct theme *suiv;
}
Theme;


int list_lc (void)
{
	int error = 0;

	sup_ln (indd);
/************** Tester l'espace ******************/
	incindd ();

	if ((*indd == ';') || (*indd == '?'))
		list_themes ();

	else
	{
		if (*indd)
		{
			strn_cpy (6, pvoie->finf.filtre, indd);
			if (strcmp (pvoie->finf.filtre, "*") == 0)
			{
				*pvoie->finf.filtre = '\0';
			}
		}
		outln ("=> $l", 5);
	}

	retour_mbl ();
	return (error);
}

static void list_themes (void)
{
	char s[30];
	char temp[30];
	Theme *tptr = NULL;
	Theme *cptr;
	Theme *sptr;
	Theme *prec;
	int nb;
	int comp;
	unsigned offset;
	bloc_mess *bptr = tete_dir;
	bullist ligne;

	ouvre_dir ();

	offset = 0;
	while (bptr)
	{
		if (bptr->st_mess[offset].noenr)
		{
			read_dir (bptr->st_mess[offset].noenr, &ligne);

			if ((ligne.type == 'B') && (droit_ok (&ligne, 1)))
			{
				if (tptr == NULL)
				{
					tptr = (Theme *) m_alloue (sizeof (Theme));
					tptr->suiv = NULL;
					strncpy (tptr->nom, ligne.desti, 6);
					tptr->nb = 1;
				}
				else
				{
					prec = NULL;
					sptr = tptr;
					for (;;)
					{
						if (sptr == NULL)
						{
							cptr = (Theme *) m_alloue (sizeof (Theme));
							cptr->suiv = NULL;
							strncpy (cptr->nom, ligne.desti, 6);
							cptr->nb = 1;
							if (prec)
								prec->suiv = cptr;
							else
								tptr = cptr;
							break;
						}
						comp = strncmp (sptr->nom, ligne.desti, 6);
						if (comp == 0)
						{
							++sptr->nb;
							break;
						}
						if (comp > 0)
						{
							cptr = (Theme *) m_alloue (sizeof (Theme));
							strncpy (cptr->nom, ligne.desti, 6);
							cptr->nb = 1;
							if (prec)
								prec->suiv = cptr;
							else
								tptr = cptr;
							cptr->suiv = sptr;
							break;
						}
						prec = sptr;
						sptr = sptr->suiv;
					}
				}
			}
		}

		if (++offset == T_BLOC_MESS)
		{
			bptr = bptr->suiv;
			offset = 0;
		}

	}

	ferme_dir ();

	nb = 0;
	cptr = tptr;
	while (cptr)
	{
		strn_cpy (6, temp, cptr->nom);
		sprintf (s, "%-6s %d          ", temp, cptr->nb);
		out (s, 13);
		if (++nb == 6)
		{
			cr ();
			nb = 0;
		}
		prec = cptr;
		cptr = cptr->suiv;
		m_libere (prec, sizeof (Theme));
	}

	if (nb != 0)
		cr ();

}