-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGS_USER.CPP
4801 lines (3965 loc) · 171 KB
/
GS_USER.CPP
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**********************************************************
Name: GS_USER.CPP
Module description: File funzioni per la gestione
degli utenti.
Author: Roberto Poltini
(c) Copyright 1995-2015 by IREN ACQUA GAS S.p.A.
**********************************************************/
#include "stdafx.h" // MFC core and standard components
#define INITGUID
#import "msado15.dll" no_namespace rename ("EOF", "EndOfFile") rename ("EOS", "ADOEOS")
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h> /* per _open() */
#include <sys\stat.h> /* per _open() */
#include <share.h> /* per apertura files in condivisione */
#include <math.h> /* per pow() */
#include <string.h> /* per strcat() strcmp() */
#include "adslib.h"
#include "adsdlg.h"
#include <adeads.h>
#include "..\gs_def.h" // definizioni globali
#include "gs_error.h"
#include "gs_opcod.h"
#include "gs_utily.h"
#include "gs_ade.h"
#include "gs_resbf.h"
#include "gs_list.h"
#include "gs_ase.h"
#include "gs_netw.h"
#include "gs_class.h"
#include "gs_prjct.h"
#include "gs_init.h"
#include "gs_area.h"
#include "gs_cmd.h"
#include "gs_graph.h"
#include "gs_user.h"
#include "d2hMap.h" // doc to help
/* Numero byte nell'HEADER di 'GEOpwd' per i campi di GS_LOG_HEAD */
#define LHL1 2 /* log_len */
#define LHL2 2 /* pwd_len */
#define LHL3 2 /* mode_len */
#define LHL4 2 /* flags_len */
#define LHL5 2 /* max_usr */
#define LHL6 2 /* num_usr */
#define LOG_HEAD_LEN LHL1+LHL2+LHL3+LHL4+LHL5+LHL6
//-----------------------------------------------------------------------//
// GLOBAL VARIABLES //
//-----------------------------------------------------------------------//
//-----------------------------------------------------------------------//
// FUNZIONI PRIVATE //
//-----------------------------------------------------------------------//
int print_users(int mode=ALL);
int gsc_setfamily(C_NODE *pPrj, int cod_class, int abilitaz, C_INT_INT_LIST *class_list);
static int gsc_setLastLogin(const TCHAR *login);
static int gsc_setCheckSessionOnLogin(int Value);
int gsc_createMapSuperUsr(const TCHAR *UserName, const TCHAR *Password);
int gsc_delMapUsr(const TCHAR *UserName);
int gsc_updMapUsrPwd(const TCHAR *UserName, const TCHAR *Password);
int permission_to_msg(GSDataPermissionTypeEnum Permission);
/*************************************************************************/
//-----------------------------------------------------------------------//
// FUNZIONI PER I COMANDI AUTOCAD SENZA INTERFACCIA DCL (DAL PROMPT) //
//-----------------------------------------------------------------------//
/*************************************************************************/
/*.doc gslogin() */
/*+
Gestisce il comando login senza interfaccia DCL.
-*/
/*************************************************************************/
void gslogin(void)
{
TCHAR user[MAX_LEN_LOGIN] = GS_EMPTYSTR, passwd[MAX_LEN_PWD] = GS_EMPTYSTR, buff[133];
size_t usrlen;
C_STRING msg;
GEOsimAppl::CMDLIST.StartCmd();
msg = GS_LFSTR;
msg += gsc_msg(128); // "Nome Utente: "
// leggo ultima login
if (gsc_getLastLogin(user) == GS_GOOD && wcslen(user) > 0)
{
msg += _T("<");
msg += user;
msg += _T("> ");
}
if (ads_getstring(TRUE, msg.get_name(), buff) != RTNORM)
return GEOsimAppl::CMDLIST.ErrorCmd();
usrlen = wcslen(buff);
// caso di stringa utente troppo lunga
if (usrlen > MAX_LEN_LOGIN)
{ GS_ERR_COD = eGSInvalidLogin; return GEOsimAppl::CMDLIST.ErrorCmd(); }
// se non è stata inserita una login
if (usrlen == 0)
{ // se non c'era una login di default
if (wcslen(user) == 0)
// "stringa utente deve essere almeno un carattere valido"
{ GS_ERR_COD = eGSInvalidLogin; return GEOsimAppl::CMDLIST.ErrorCmd(); }
}
else
gsc_strcpy(user, buff, MAX_LEN_LOGIN);
acutPrintf(GS_LFSTR);
if (gsc_getstringmask(TRUE, gsc_msg(129), buff, _T('*')) != GS_GOOD) // "Password: "
return GEOsimAppl::CMDLIST.ErrorCmd();
acutPrintf(GS_LFSTR);
gsc_strcpy(passwd, buff, MAX_LEN_PWD);
if (gsc_login(user, passwd) == GS_BAD)
return GEOsimAppl::CMDLIST.ErrorCmd();
return GEOsimAppl::CMDLIST.EndCmd();
}
/*************************************************************************/
/*.doc gscreausr() */
/*+
Comando che crea utente senza interfaccia DCL.
-*/
/*************************************************************************/
void gscreausr(void)
{
TCHAR user[MAX_LEN_LOGIN] = GS_EMPTYSTR, passwd[MAX_LEN_PWD] = GS_EMPTYSTR, confpwd[MAX_LEN_PWD] = GS_EMPTYSTR, buff[133];
size_t usrlen = 0;
int susr = 1, mval=0;
C_STRING Prompt;
GEOsimAppl::CMDLIST.StartCmd();
if (gsc_superuser() == GS_BAD)
{ GS_ERR_COD = eGSInvalidLogin; return GEOsimAppl::CMDLIST.ErrorCmd(); } // "Check se superuser"
if (acedInitGet(2, gsc_msg(143) ) != RTNORM)
return GEOsimAppl::CMDLIST.ErrorCmd(); // "Utente Superutente"
Prompt = gsc_msg(93); // "\nDigitare un'opzione "
Prompt += gsc_msg(142); // [<Utente>/Superutente]:
if (acedGetKword(Prompt.get_name(), buff) != RTNORM)
return GEOsimAppl::CMDLIST.ErrorCmd();
if (gsc_strcmp(buff, gsc_msg(155)) == 0 || wcslen(buff) ==0) susr = 0;
acutPrintf(GS_LFSTR);
if (ads_getstring(TRUE, gsc_msg(128), buff) != RTNORM) // "Nome Utente: "
return GEOsimAppl::CMDLIST.ErrorCmd();
usrlen = wcslen(buff);
if (usrlen > MAX_LEN_LOGIN || usrlen == 0 || buff[0] == _T('#'))
{ GS_ERR_COD = eGSInvalidLogin; return GEOsimAppl::CMDLIST.ErrorCmd(); } // "stringa utente troppo lunga"
// "stringa utente deve essere almeno un carattere valido"
gsc_strcpy(user, buff, MAX_LEN_LOGIN);
acutPrintf(GS_LFSTR);
if (gsc_getstringmask(TRUE, gsc_msg(129), buff, _T('*')) != GS_GOOD) // "Password: "
return GEOsimAppl::CMDLIST.ErrorCmd();
if (wcslen(buff) > MAX_LEN_PWD)
{GS_ERR_COD = eGSInvalidPwd; return GEOsimAppl::CMDLIST.ErrorCmd(); } // "stringa password troppo lunga"
acutPrintf(GS_LFSTR);
gsc_strcpy(passwd, buff, MAX_LEN_PWD);
if (gsc_getstringmask(TRUE, gsc_msg(137), buff, _T('*')) != GS_GOOD)
return GEOsimAppl::CMDLIST.ErrorCmd(); // "Conferma Password: "
acutPrintf(GS_LFSTR);
gsc_strcpy(confpwd, buff, MAX_LEN_PWD);
if (gsc_strcmp(passwd, confpwd) != 0)
{GS_ERR_COD = eGSInvalidPwd; return GEOsimAppl::CMDLIST.ErrorCmd(); } // "Conferma e passwd diverse"
if (gsc_creausr(user, passwd, susr) == 0) return GEOsimAppl::CMDLIST.ErrorCmd();
return GEOsimAppl::CMDLIST.EndCmd();
}
/*************************************************************************/
/*.doc gsmodpwd() */
/*+
Comando che modifica Password utente senza interfaccia DCL.
-*/
/*************************************************************************/
void gsmodpwd(void)
{
TCHAR oldpwd[MAX_LEN_PWD] = GS_EMPTYSTR, newpwd[MAX_LEN_PWD] = GS_EMPTYSTR, confpwd[MAX_LEN_PWD] = GS_EMPTYSTR, buff[133];
GEOsimAppl::CMDLIST.StartCmd();
if (gsc_getstringmask(TRUE, gsc_msg(144), buff, _T('*')) != GS_GOOD) return GEOsimAppl::CMDLIST.ErrorCmd(); // "Vecchia pwd: "
if (wcslen(buff) > MAX_LEN_PWD)
{GS_ERR_COD=eGSInvalidPwd; return GEOsimAppl::CMDLIST.ErrorCmd(); }; // "stringa password troppo lunga"
acutPrintf(GS_LFSTR);
gsc_strcpy(oldpwd,buff, MAX_LEN_PWD);
if (gsc_getstringmask(TRUE, gsc_msg(145), buff, _T('*')) != GS_GOOD) return GEOsimAppl::CMDLIST.ErrorCmd(); // "Nuova pwd "
if (wcslen(buff) > MAX_LEN_PWD)
{GS_ERR_COD=eGSInvalidPwd; return GEOsimAppl::CMDLIST.ErrorCmd(); }; // "stringa password troppo lunga"
acutPrintf(GS_LFSTR);
gsc_strcpy(newpwd, buff, MAX_LEN_PWD);
if (gsc_getstringmask(TRUE, gsc_msg(137), buff, _T('*')) != GS_GOOD) return GEOsimAppl::CMDLIST.ErrorCmd(); // "Conferma Password: "
acutPrintf(GS_LFSTR);
gsc_strcpy(confpwd, buff, MAX_LEN_PWD);
if (gsc_strcmp(newpwd, confpwd) != 0)
{GS_ERR_COD = eGSInvalidPwd; return GEOsimAppl::CMDLIST.ErrorCmd(); }; // "Conferma e passwd diverse"
if (gsc_modpwd(oldpwd, newpwd) == GS_BAD) return GEOsimAppl::CMDLIST.ErrorCmd();
return GEOsimAppl::CMDLIST.EndCmd();
}
/*************************************************************************/
/*.doc gsdelusr() */
/*+
Comando che cancella utente senza interfaccia DCL.
-*/
/*************************************************************************/
void gsdelusr(void)
{
TCHAR user[MAX_LEN_LOGIN] = GS_EMPTYSTR, passwd[MAX_LEN_PWD] = GS_EMPTYSTR, buff[133] = GS_EMPTYSTR;
C_INT_INT_STR userinfo;
size_t usrlen;
int ris;
GEOsimAppl::CMDLIST.StartCmd();
if (gsc_superuser() == GS_BAD)
{ GS_ERR_COD = eGSInvalidLogin; return GEOsimAppl::CMDLIST.ErrorCmd(); } // "Check se superuser"
if (ads_getstring(TRUE, gsc_msg(149), buff) != RTNORM) //"\nNome utente <?>: "
return GEOsimAppl::CMDLIST.ErrorCmd();
do
{
usrlen = wcslen(buff);
if ((TCHAR) buff[0] == _T('?') || usrlen == 0)
{
if (print_users() == GS_BAD)
{GS_ERR_COD=eGSListError; return GEOsimAppl::CMDLIST.ErrorCmd(); }
}
else break;
// "\nNome utente <?>: "
if (ads_getstring(TRUE, gsc_msg(149), buff) != RTNORM) return GEOsimAppl::CMDLIST.ErrorCmd();
}
while (TRUE);
if (usrlen > MAX_LEN_LOGIN || usrlen == 0)
{ GS_ERR_COD = eGSInvalidLogin; return GEOsimAppl::CMDLIST.ErrorCmd(); } // "Stringa utente troppo lunga"
gsc_strcpy(user, buff, MAX_LEN_LOGIN);
if (gsc_chkusr(user, &userinfo) == GS_BAD)
{ GS_ERR_COD = eGSInvalidUser; return GEOsimAppl::CMDLIST.ErrorCmd(); } // "stringa utente deve essere almeno un carattere valido"
acutPrintf(GS_LFSTR);
if (gsc_getstringmask(TRUE, gsc_msg(129), buff, _T('*')) != GS_GOOD) // "Password: "
return GEOsimAppl::CMDLIST.ErrorCmd();
gsc_strcpy(passwd, buff, MAX_LEN_PWD);
if (gsc_getconfirm(gsc_msg(163), &ris, GS_BAD) == GS_GOOD) // "\nConfermare."
{
if (ris==GS_GOOD)
if (gsc_delusr(userinfo.get_key(), passwd) == GS_BAD) return GEOsimAppl::CMDLIST.ErrorCmd();
}
return GEOsimAppl::CMDLIST.EndCmd();
}
/*********************************************************
/*.doc (new 2) printlistcommand <internal> */
/*+
Questa funzione stampa la lista dei comandi di GEOsim e
utente e il loro stato di abilitazione all'utente.
Parametri:
C_INT_LIST *commusr; lista dei codici alle operazioni abilitate
Restituisce GS_GOOD se tutto va bene.
-*/
/*********************************************************/
int printlistcommand(C_INT_LIST *commusr)
{
C_INT_STR_LIST punt;
C_INT_STR *p_comm;
if (gsc_getgscomm(&punt) == GS_BAD) return GS_BAD;
acutPrintf(_T("%s"), gsc_msg(177)); // \nLista comandi:
p_comm = (C_INT_STR *) punt.get_head();
while (p_comm)
{
acutPrintf(_T("\n%.*s"), 25, p_comm->get_name());
if (commusr->search_key(p_comm->get_key()) > 0)
acutPrintf(_T("%s"), gsc_msg(202)); // "\tAbilitato"
else
acutPrintf(_T("%s"), gsc_msg(203)); // "\tDisabilitato"
p_comm = (C_INT_STR *) punt.get_next();
}
return GS_GOOD;
}
/*********************************************************/
int printlistclasses(C_SINTH_CLASS_LIST *pclasses,C_INT_INT_LIST *classusr)
{
C_SINTH_CLASS *p_comm;
C_INT_INT *p;
acutPrintf(_T("%s"), gsc_msg(196)); // "\nLista classi"
p_comm = (C_SINTH_CLASS *)pclasses->get_head();
while (p_comm != NULL)
{
acutPrintf(_T("\n%.*s"), 25, p_comm->get_name());
if ((p = (C_INT_INT*) classusr->search_key(pclasses->get_cursor()->get_key())) != NULL)
{
switch (p->get_type())
{
case 1:
acutPrintf(_T("%s"),gsc_msg(205));
break;
case 2:
acutPrintf(_T("%s"),gsc_msg(206));
break;
}
}
else
acutPrintf(_T("%s"), gsc_msg(204));
p_comm = (C_SINTH_CLASS *) pclasses->get_next();
}
return GS_GOOD;
}
/*********************************************************
/*.doc codabl_to_msg(int codice) <internal> */
/*+
Questa funzione ritorna lo stato di abilitazione dei
comandi GEOsim asseganti all'utente.
Restituisce GS_GOOD se tutto va bene.
-*/
/*********************************************************/
int codabl_to_msg(int codice)
{
if (codice > 0)
acutPrintf(_T("%s"), gsc_msg(183)); // (stato attuale abilitato)
else
acutPrintf(_T("%s"), gsc_msg(184)); // (stato attuale disabilitato)
return GS_GOOD;
}
//-----------------------------------------------------------------------//
// FUNZIONI PER LE CHIAMATE LISP DEL MODULO ARX //
//-----------------------------------------------------------------------//
/*************************************************************************/
/*.doc gs_login */
/*+
Funzione lisp che riceve login e password di un utente ne controlla l'esattezza
nel file 'GEOpwd' in caso affermativo aggiorna tutte i campi della variabile
globale GEOsimAppl::GS_USER (allocando le stringhe) con le informazioni di 'GEOpwd'
Parametri:
(<nome> <parola segreta> [<controllo sessioni>])
La funzione ritorna T in caso di login corretta, nil altrimenti.
-*/
/*************************************************************************/
int gs_login(void)
{
TCHAR *login, *pwd;
resbuf *arg;
int SessionCheck = GS_GOOD;
acedRetNil();
arg = acedGetArgs();
// nome utente
if (arg == NULL || arg->restype != RTSTR) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
login = arg->resval.rstring;
// parola segreta
if ((arg = arg->rbnext) == NULL || arg->restype != RTSTR) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
pwd = arg->resval.rstring;
// controllo connessioni (opzionale)
if ((arg = arg->rbnext) != NULL && arg->restype == RTNIL) SessionCheck = GS_BAD;
if (gsc_login(login, pwd, SessionCheck)==GS_BAD) return RTERROR;
acedRetT();
return RTNORM;
}
//-----------------------------------------------------------------------//
// GS_SUPERUSER //
//-----------------------------------------------------------------------//
int gs_superuser(void)
{
// CHIAMATA FUNZIONE C++ RELATIVA
presbuf arg = acedGetArgs();
if (!arg)
{ // utente corrente
if (gsc_superuser() == GS_GOOD) acedRetT();
else acedRetNil();
}
else
{
if (arg->restype != RTSHORT) { GS_ERR_COD = eGSInvalidArg; return RTERROR; }
if (gsc_superuser(arg->resval.rint) == GS_GOOD) acedRetT();
else acedRetNil();
}
return RTNORM;
}
//-----------------------------------------------------------------------//
// GS_CHKUSR //
//-----------------------------------------------------------------------//
int gs_chkusr(void)
{
resbuf *arg;
C_RB_LIST ret;
int su = 1;
C_USER temp;
C_INT_INT_STR usr;
acedRetNil();
arg = acedGetArgs();
if (arg == NULL || arg->restype != RTSTR) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
// Chiamata a funzione C++ relativa.
if (gsc_chkusr(arg->resval.rstring, &usr) == GS_BAD) return RTERROR;
if ((ret << acutBuildList(RTSHORT, usr.get_key(),
RTSTR, usr.get_name(),
RTSHORT, usr.get_type(), 0)) == NULL)
{ GS_ERR_COD = eGSOutOfMem; return GS_BAD; }
ret.LspRetList();
return RTNORM;
}
/*********************************************************/
/*.doc gs_creausr <external> */
/*+
Funzione LISP per la creazione di un utente GEOsim.
Parametri:
Lista di resbuf (<login><password><flag>)
<flag> = 0 -> superutente, 1 -> utente normale
Ritorna il codice del nuovo utente creato o nil in caso di errore
-*/
/*********************************************************/
int gs_creausr(void)
{
TCHAR *log,*pwd;
resbuf *arg;
int su, UserID;
C_USER temp;
acedRetNil();
arg=acedGetArgs();
// alloca memoria usata solo per 'mode'
if(temp.alloc_from_geopwd()==GS_BAD) return RTERROR;
if (arg==NULL || arg->restype!=RTSTR) // Errore argomenti
{ GS_ERR_COD=eGSInvalidArg; return RTERROR; }
log=arg->resval.rstring;
if ((arg=arg->rbnext)==NULL || arg->restype!=RTSTR) // Errore argomenti
{ GS_ERR_COD=eGSInvalidArg; return RTERROR; }
pwd=arg->resval.rstring;
if ((arg=arg->rbnext)==NULL || arg->restype!=RTSHORT) //Errore argomenti
{ GS_ERR_COD=eGSInvalidArg; return RTERROR; }
su=arg->resval.rint;
// CHIAMATA FUNZIONE C++ RELATIVA
if ((UserID = gsc_creausr(log, pwd, su)) == 0) return RTERROR;
acedRetInt(UserID);
return RTNORM;
}
/*********************************************************/
/*.doc gs_delusr <external> */
/*+
Questa funzione LISP cancella un utente di GEOsim.
Parametri:
Lista RESBUF: <user_code><password>[<Destroy>]
<user_code> = codice utente da cancellare
<password> = password utente corrente
<Destroy> = Opzionale. Flag di modo, se = T distrugge l'utente senza fare controlli
Restituisce TRUE in caso di successo altrimenti restituisce NIL.
-*/
/*********************************************************/
int gs_delusr(void)
{
resbuf *arg = acedGetArgs();
int UsrCode;
bool DestroyUsr = false;
TCHAR *Pwd;
acedRetNil();
// Codice utente
if (gsc_rb2Int(arg, &UsrCode) == GS_BAD)
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
// password utente corrente
if (!(arg = arg->rbnext) || arg->restype != RTSTR)
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
Pwd = arg->resval.rstring;
// Flag di distruzione utente senza controlli (opzionale)
if ((arg = (arg->rbnext)) != NULL && arg->restype == RTT) DestroyUsr = true;
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_delusr(UsrCode, Pwd, DestroyUsr) == GS_BAD) return RTERROR;
acedRetT();
return RTNORM;
}
/*********************************************************/
/*.doc gs_getusr <external> */
/*+
Questa funzione LISP ritorna la lista degli utenti di GEOsim.
-*/
/*********************************************************/
int gs_getusr(void)
{
C_INT_INT_STR_LIST list;
acedRetNil();
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_getusrlist(&list) == GS_BAD) return RTERROR;
if (list.get_count() !=0 )
{
C_RB_LIST ret;
list.sort_name();
ret << list.to_rb();
ret.LspRetList();
}
return RTNORM;
}
//-----------------------------------------------------------------------//
// GS_WHOAMI //
//-----------------------------------------------------------------------//
int gs_whoami(void)
{
C_RB_LIST ret;
C_INT_INT_STR usr;
TCHAR *string, str[] = GS_EMPTYSTR;
acedRetNil();
if (gsc_whoami(&usr) == GS_BAD)
return (GS_ERR_COD == eGSInvalidLogin) ? RTNORM : RTERROR;
if ((string = usr.get_name()) == NULL) string = str;
if ((ret << acutBuildList(RTSHORT, usr.get_key() ,RTSTR, string, RTSHORT,
usr.get_type(), 0)) == NULL)
return RTERROR;
ret.LspRetList();
return RTNORM;
}
/*********************************************************/
/*.doc gs_getusrcomm <external> */
/*+
Questa funzione LISP ritorna la lista degli codici dei comandi
abilitati ad un utente di GEOsim.
-*/
/*********************************************************/
int gs_getusrcomm(void)
{
presbuf arg;
C_INT_LIST list;
acedRetNil();
arg = acedGetArgs();
if (arg == NULL || arg->restype != RTSHORT) // Errore argomenti //
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
// Chiamata funzione C++ relativa //
if (gsc_getusrcomm(arg->resval.rint, &list) == GS_BAD) return RTERROR;
if (list.get_count() > 0)
{
C_RB_LIST ret(list.to_rb());
ret.LspRetList();
}
return RTNORM;
}
//-----------------------------------------------------------------------//
// GS_SETUSRCOMM //
//-----------------------------------------------------------------------//
int gs_setusrcomm(void)
{
resbuf *arg;
int code;
C_INT_LIST list;
acedRetNil();
arg=acedGetArgs();
if (arg == NULL || arg->restype != RTSHORT) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
code = arg->resval.rint;
if (list.from_rb(arg->rbnext) == GS_BAD) return RTERROR;
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_setusrcomm(code,&list) == GS_BAD) return RTERROR;
acedRetT();
return RTNORM;
}
//-----------------------------------------------------------------------//
// GS_GETGSCOMM //
//-----------------------------------------------------------------------//
int gs_getgscomm(void)
{
C_INT_STR_LIST list;
acedRetNil();
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_getgscomm(&list)==GS_BAD) return RTERROR;
if (list.get_count() == 0) acedRetNil();
else
{
C_RB_LIST ret(list.to_rb());
ret.LspRetList();
}
return RTNORM;
}
/*********************************************************/
/*.doc gs_getusrprj <external> */
/*+
Questa funzione LISP ritorna la lista degli codici dei progetti
e relative abilitazioni personali (non ereditate) ad un utente di GEOsim.
-*/
/*********************************************************/
int gs_getusrprj(void)
{
presbuf arg = acedGetArgs();
C_INT_INT_LIST list;
acedRetNil();
if (!arg || arg->restype != RTSHORT) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_getPersonalPrjPermissions(arg->resval.rint, &list) == GS_BAD) return RTERROR;
if (list.get_count() > 0)
{
C_RB_LIST ret(list.to_rb());
ret.LspRetList();
}
return RTNORM;
}
//-----------------------------------------------------------------------//
// GS_SETUSRPRJ //
//-----------------------------------------------------------------------//
int gs_setusrprj(void)
{
resbuf *arg;
C_INT_INT_LIST list;
arg = acedGetArgs();
if (arg == NULL || arg->restype != RTSHORT) // Errore argomenti //
{ GS_ERR_COD = eGSInvalidArg; acedRetNil(); return RTERROR; }
if (list.from_rb(arg->rbnext) == GS_BAD)
{ acedRetNil(); return RTERROR; }
if (gsc_setPersonalPrjPermissions(arg->resval.rint, list) == GS_BAD)
{ acedRetNil(); return RTERROR; }
acedRetT();
return RTNORM;
}
/*********************************************************/
/*.doc gs_getPrjPermissions <external> */
/*+
Questa funzione LISP ritorna la lista degli codici dei progetti
e relative abilitazioni ad un utente di GEOsim.
-*/
/*********************************************************/
int gs_getPrjPermissions(void)
{
presbuf arg = acedGetArgs();
C_INT_INT_LIST list;
acedRetNil();
if (!arg || arg->restype != RTSHORT) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_getPrjPermissions(arg->resval.rint, list) == GS_BAD) return RTERROR;
if (list.get_count() > 0)
{
C_RB_LIST ret(list.to_rb());
ret.LspRetList();
}
return RTNORM;
}
/*********************************************************/
/*.doc gs_getusrclass <external> */
/*+
Funzione LISP per lettura abilitazione personale
(non ereditata) alla banca dati di un utente GEOsim.
Parametri:
Lista di resbuf (<user ID><prj>)
Ritorna una lista così composta:
((<cls><abilit>)...)
dove
<cls> codice classe
<abilit> 1 -> sola lettura, 2 -> modificabile
-*/
/*********************************************************/
int gs_getusrclass(void)
{
C_INT_INT_LIST list;
resbuf *arg;
int usr;
arg = acedGetArgs();
if (arg == NULL || arg->restype != RTSHORT) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; acedRetNil(); return RTERROR; }
usr = (int)arg->resval.rint;
if ((arg = arg->rbnext) == NULL || arg->restype != RTSHORT) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; acedRetNil(); return RTERROR; }
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_getPersonalClassPermissions(usr, arg->resval.rint, &list) == GS_BAD)
{ acedRetNil(); return RTERROR; }
if (list.get_count() == 0) acedRetNil();
else
{
C_RB_LIST ret(list.to_rb());
ret.LspRetList();
}
return RTNORM;
}
//-----------------------------------------------------------------------//
// GS_SETUSRCLASS //
//-----------------------------------------------------------------------//
int gs_setusrclass(void)
{
C_INT_INT_LIST list;
resbuf *arg = acedGetArgs();
int usr;
acedRetNil();
if (!arg || arg->restype != RTSHORT) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
usr = (int) arg->resval.rint;
if ((arg = arg->rbnext) == NULL || arg->restype != RTSHORT) //Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
if (list.from_rb(arg->rbnext) == GS_BAD) return RTERROR;
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_setPersonalClassPermissions(usr,arg->resval.rint, list) == GS_BAD) return RTERROR;
acedRetT();
return RTNORM;
}
/*********************************************************/
/*.doc gs_getClassPermissions <external> */
/*+
Funzione LISP per lettura abilitazione alla banca dati di un utente GEOsim.
Parametri:
Lista di resbuf (<user ID><prj>)
Ritorna una lista così composta:
((<cls><abilit>)...)
dove
<cls> codice classe
<abilit> 1 -> sola lettura, 2 -> modificabile
-*/
/*********************************************************/
int gs_getClassPermissions(void)
{
C_INT_INT_LIST list;
resbuf *arg;
int usr;
arg = acedGetArgs();
if (arg == NULL || arg->restype != RTSHORT) // Errore argomenti //
{ GS_ERR_COD = eGSInvalidArg; acedRetNil(); return RTERROR; }
usr = (int)arg->resval.rint;
if ((arg = arg->rbnext) == NULL || arg->restype != RTSHORT) //Errore argomenti//
{ GS_ERR_COD = eGSInvalidArg; acedRetNil(); return RTERROR; }
// CHIAMATA FUNZIONE C++ RELATIVA //
if (gsc_getClassPermissions(usr, arg->resval.rint, list) == GS_BAD)
{ acedRetNil(); return RTERROR; }
if (list.get_count() == 0) acedRetNil();
else
{
C_RB_LIST ret(list.to_rb());
ret.LspRetList();
}
return RTNORM;
}
//-----------------------------------------------------------------------//
// GS_CHKCLSVIS //
//-----------------------------------------------------------------------//
int gs_chkclsvis(void)
{
C_INT_INT_LIST list;
C_PROJECT *pPrj = NULL;
resbuf *arg;
arg = acedGetArgs();
if (arg == NULL || arg->restype != RTSHORT) // Errore argomenti //
{ GS_ERR_COD = eGSInvalidArg; acedRetNil(); return RTERROR; }
if (list.from_rb(arg->rbnext) == GS_BAD)
{ acedRetNil(); return RTERROR; }
if ((pPrj = (C_PROJECT *) GEOsimAppl::PROJECTS.search_key(arg->resval.rint)) == NULL)
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_chkClsPermissions(pPrj, list, 1) == GS_BAD)
{ acedRetNil(); return RTERROR; }
if (list.get_count() == 0) acedRetNil();
else
{
C_RB_LIST ret(list.to_rb());
ret.LspRetList();
}
return RTNORM;
}
//-----------------------------------------------------------------------//
// GS_GETFAMILY //
//-----------------------------------------------------------------------//
int gs_getfamily(void)
{
C_FAMILY_LIST list;
resbuf *arg;
int prj;
C_PROJECT *pPrj;
acedRetNil();
arg = acedGetArgs();
if (arg == NULL || arg->restype != RTSHORT) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
prj = (int) arg->resval.rint;
if ((pPrj = (C_PROJECT *) GEOsimAppl::PROJECTS.search_key(prj)) == NULL)
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
// CHIAMATA FUNZIONE C++ RELATIVA
if (gsc_getfamily(pPrj, &list) == GS_BAD) return RTERROR;
if (list.get_count() == 0) acedRetNil();
else
{
C_RB_LIST ret(list.to_rb());
ret.LspRetList();
}
return RTNORM;
}
/*********************************************************/
/*.doc gs_modpwd <external> */
/*+
Questa funzione modifica la propria password.
Lista : (<vecchia password> <nuova password>)
Restituisce RTNORM in caso di successo altrimenti restituisce RTERROR.
-*/
/*********************************************************/
int gs_modpwd(void)
{
presbuf arg;
TCHAR OldPassword[MAX_LEN_PWD], NewPassword[MAX_LEN_PWD];
acedRetNil();
arg = acedGetArgs();
if (arg == NULL || arg->restype != RTSTR) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
// vecchia password
if (wcslen(arg->resval.rstring) >= MAX_LEN_PWD)
{ GS_ERR_COD = eGSStringTooLong; return RTERROR; }
else wcscpy(OldPassword, arg->resval.rstring);
if ((arg = arg->rbnext) == NULL || arg->restype != RTSTR) // Errore argomenti
{ GS_ERR_COD = eGSInvalidArg; return RTERROR; }
// nuova password
if (wcslen(arg->resval.rstring) >= MAX_LEN_PWD)
{ GS_ERR_COD = eGSStringTooLong; return RTERROR; }
else wcscpy(NewPassword, arg->resval.rstring);
if (gsc_modpwd(OldPassword, NewPassword) == GS_BAD) return RTERROR;
acedRetT();
return RTNORM;
}
/*************************************************************************/
/*.doc gsc_login */
/*+
Riceve login e password di un utente ne controlla l'esattezza nel file
'GEOpwd' in caso affermativo aggiorna tutte i campi della variabile
globale GEOsimAppl::GS_USER (allocando le stringhe) con le informazioni di 'GEOpwd'
Parametri:
const TCHAR *log; Login utente
const TCHAR *pwd; Password utente
int CheckSessions; Flag; Se = GS_GOOD dopo la login effettuata con successo
controlla che l'utente loggato abbia sessioni attive appese
e in quel caso chiede conferma per la loro cancellazione
(default = GS_GOOD).
La funzione ritorna GS_GOOD in caso di login corretta, GS_BAD altrimenti.
-*/
/*************************************************************************/
int gsc_login(const TCHAR *log, const TCHAR *pwd, int CheckSessions)
{
C_USER temp;
C_LOG_HEAD log_head;