Gestione utenti

git-svn-id: svn://10.65.10.50/trunk@556 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1994-11-07 16:32:57 +00:00
parent f404830196
commit aa91be2d8e
12 changed files with 146 additions and 38 deletions

View File

@ -57,7 +57,9 @@ bool TEdit_form::menu(MENU_TAG tag)
int cg1300(int argc, char* argv[])
{
if (argc < 3)
int arg = argc;
if (strncmp(argv[arg - 1], "-u", 2) == 0) arg--;
if (arg < 3)
{
error_box("Specificare il nome del profilo di stampa");
return 1;
@ -65,7 +67,7 @@ int cg1300(int argc, char* argv[])
TFilename form(argv[2]); form.ext("frm");
const char mode = argc > 3 ? toupper(argv[3][1]) : ' ';
const char mode = arg > 3 ? toupper(argv[3][1]) : ' ';
const bool crea = (mode == 'C') || !fexist(form);
if (crea)

View File

@ -1,10 +1,15 @@
#include <xvt.h>
#include <stdlib.h>
#include <applicat.h>
#include "cg2.h"
int main(int argc,char** argv)
{
const int n = (argc > 1) ? (argv[1][1]-'0') : 0;
check_parameters(argc, argv);
const int n = (argc > 1) ? atoi(&argv[1][1]) : 0;
switch(n)
{
case 1:

View File

@ -141,9 +141,7 @@ $(O)/cg4304.o: cg4304.cpp cg4300.h $(I6) $(I10) $(I24) $(I27) $(I33)
$(O)/cg4305.o: cg4305.cpp cg4300.h $(I6) $(I10) $(I24) $(I27) $(I33)
$(O)/cg4401.o: cg4401.cpp cg4400.h
$(O)/cg4400.o: cg4400.cpp cg4401.cpp cg4400.h
$(O)/cg4400.o: cg4400.cpp cg4400.h
$(O)/cg4500.o: cg4500.cpp $(I24) $(I31) $(I33) $(I40) $(I42) $(I51) cg4500a.h cg4500b.h
@ -153,8 +151,8 @@ $(O)/cglib01.o: cglib01.cpp $(I24) $(I31) $(I33) $(I40) $(I42) $(I51) cglib.h
$(O)/conto.o: conto.cpp conto.h
$(EP)cg4: $(O)/cg4.o $(LIBD1) $(O)/cg4300.o $(O)/cg4301.o $(O)/cg4302.o $(O)/cg4303.o $(O)/cg4304.o $(O)/cg4305.o $(O)/cg4400.o $(O)/cg4401.o $(O)/conto.o $(O)/cglib01.o $(O)/cglib02.o $(O)/cg4500.o $(O)/cg2101.o $(O)/cg2103.o $(O)/cg4100.o $(O)/cg4600.o $(EP)cg4.frl $(O)/cglib03.o
$(LINK) $(LFLAGSD1) $@ $(O)/cg4.o $(O)/cg4300.o $(O)/cg4301.o $(O)/cg4302.o $(O)/cg4303.o $(O)/cg4304.o $(O)/cg4305.o $(O)/cg4400.o $(O)/cg4401.o $(O)/conto.o $(O)/cglib01.o $(O)/cglib02.o $(O)/cg4500.o $(O)/cglib03.o $(O)/cg2101.o $(O)/cg2103.o $(O)/cg4100.o $(O)/cg4600.o
$(EP)cg4: $(O)/cg4.o $(LIBD1) $(O)/cg4300.o $(O)/cg4301.o $(O)/cg4302.o $(O)/cg4303.o $(O)/cg4304.o $(O)/cg4305.o $(O)/cg4400.o $(O)/conto.o $(O)/cglib01.o $(O)/cglib02.o $(O)/cg4500.o $(O)/cg2101.o $(O)/cg2103.o $(O)/cg4100.o $(O)/cg4600.o $(EP)cg4.frl $(O)/cglib03.o
$(LINK) $(LFLAGSD1) $@ $(O)/cg4.o $(O)/cg4300.o $(O)/cg4301.o $(O)/cg4302.o $(O)/cg4303.o $(O)/cg4304.o $(O)/cg4305.o $(O)/cg4400.o $(O)/conto.o $(O)/cglib01.o $(O)/cglib02.o $(O)/cg4500.o $(O)/cglib03.o $(O)/cg2101.o $(O)/cg2103.o $(O)/cg4100.o $(O)/cg4600.o
$(EP)cg4400.frl: cg4400.url $(U1)
$(RCOMP) cg4400 -l $(EP)cg4400

View File

@ -5,6 +5,7 @@
#include <applicat.h>
#include <config.h>
#include <extcdecl.h>
#include <lffiles.h>
#include <modaut.h>
#include <mask.h>
#include <prefix.h>
@ -15,6 +16,7 @@
#include <bagn002.h>
#define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
///////////////////////////////////////////////////////////
// Metodi di accesso globali all'applicazione corrente
@ -22,6 +24,7 @@
HIDDEN TApplication* _application = NULL;
HIDDEN long savefirm = 0;
HIDDEN TString80 __user;
TApplication* MainApp()
{
@ -304,7 +307,7 @@ void TApplication::stop_run()
}
TApplication::TApplication() : _printer(NULL)
TApplication::TApplication() : _printer(NULL), _user("PRASSI")
{
init_global_vars();
_bar = TASK_MENUBAR;
@ -384,11 +387,64 @@ const char* TApplication::get_module_name() const
return module;
}
void TApplication::set_perms()
{
CGetAut(1);
_dongle_aut.set(0);
for (int i = 1 ; i < ENDAUT; i++)
{
const int af = i - 1;
const bool val = BITTEST(_int_tab0[af / 16], af % 16);
_dongle_aut.set(i, val);
}
_user_aut.set(0);
if (_user.not_empty())
{
if (_user == "PRASSI")
{
for (int i = 1 ; i < ENDAUT; i++)
_user_aut.set(i);
}
else
{
TLocalisamfile users(LF_USER);
users.zero();
users.put("USERNAME", _user);
if (users.read() == NOERR)
{
const TString80 aut(users.get("AUTSTR"));
const int max = aut.len();
for (int i = 1 ; i < max; i++)
_user_aut.set(i, aut[i] == 'X');
}
}
}
}
void check_parameters(int & argc, char* argv[])
{
if (strncmp(argv[argc - 1], "-u", 2) == 0)
{
__user = &argv[argc - 1][2];
argc--;
}
}
void TApplication::run(int argc, char* argv[], const char* title)
{
TFilename base(argv[0]);
base.ext(""); base.lower();
_title = title;
if (__user.empty())
check_parameters(argc, argv);
if(__user.not_empty()) _user = __user;
__argc = argc;
__argv = (const char**)argv;
@ -404,6 +460,7 @@ void TApplication::run(int argc, char* argv[], const char* title)
addbar = 0;
_name = cmd2name(argv[0]);
}
set_perms();
TString80 caption;
caption << "PRASSI S.p.A. - " << get_module_name();
@ -473,9 +530,14 @@ void TApplication::dispatch_e_menu(MENU_TAG item)
}
bool TApplication::has_module(int module) const
bool TApplication::has_module(int module, int checktype) const
{
return (bool)CGetAut(module);
bool ok = TRUE;
if (checktype == CHK_ALL || checktype == CHK_DONGLE)
ok = _dongle_aut[module];
if (ok && checktype == CHK_ALL || checktype == CHK_USER)
ok = _user_aut[module];
return ok;
}

View File

@ -16,6 +16,9 @@
#define MSG_AI "AI" // message auto_insert (relapp)
#define MSG_FS "FS" // message filtered start (relapp)
#define MSG_LN "LN" // message (printapp -> relapp)
#define CHK_ALL -1 // all authorization checks
#define CHK_DONGLE 0 // dongle authorization checks
#define CHK_USER 1 // user authorization checks
class TApplication
{
@ -23,8 +26,11 @@ class TApplication
int _bar;
int __argc;
const char** __argv;
TBit_array _dongle_aut;
TBit_array _user_aut;
TString80 _name, _title;
TString16 _user;
TPrinter* _printer;
protected:
@ -32,7 +38,7 @@ protected:
static long task_eh(WINDOW win, EVENT* ep);
virtual long handler(WINDOW win, EVENT* ep);
virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box?
virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box
void terminate();
bool config();
@ -75,7 +81,10 @@ public:
virtual bool change_config(const char* var, const char* oldv, const char* newv);
bool has_module(int module) const;
void set_perms();
void set_user(const char * user) { _user = user; }
const char * user() const { return _user; }
bool has_module(int module, int checktype = CHK_ALL) const;
bool set_firm(long cod = -1);
long get_firm() const;
const char* get_firm_dir() const;
@ -87,5 +96,6 @@ public:
bool xvt_running(); // xvt is running?
TApplication* MainApp(); // main application (old fashioned: will be removed soon
TApplication& main_app();
void check_parameters(int & argc, char *argv[]);
#endif // __APPLICATION_H

View File

@ -9,9 +9,14 @@
#include <sys/wait.h>
#endif
#include <applicat.h>
#if XVT_OS == XVT_OS_WIN
#include <windows.h>
#include <applicat.h>
#endif
#if XVT_OS == XVT_OS_DOS
#include <holdev.h>
#endif
#include <execp.h>
@ -27,7 +32,10 @@
int TExternal_app::run(bool async)
{
TApplication & app = main_app();
TString256 path(_path);
path << " -u" << app.user();
_error = 0;
_exitcode = 0;
@ -70,7 +78,7 @@ int TExternal_app::run(bool async)
_exitcode = -1;
break;
case 0:
const char* s = strdup(_path);
const char* s = strdup( path);
char* p = strchr(s, ' ');
if (p) *p = '\0';
const char* pathn = strdup(s);
@ -86,12 +94,15 @@ int TExternal_app::run(bool async)
}
args[i] = NULL;
for (i = 3; i < _NFILE; i++) fcntl(i,F_SETFD,1);
// execvp(_path, NULL);
// execvp( path, NULL);
execvp ( pathn , args );
exit ( -1 );
default:
if(wait(&_exitcode) == -1)
{
error_box("Impossibile eseguire '%s':\nErrore %d", (const char*)_path, _exitcode);
_exitcode = -1;
}
else _exitcode = _exitcode >> 8;
break;
}

View File

@ -4,6 +4,30 @@
#ifndef __EXTCTYPE_H
#include <extctype.h>
#endif
#if XVT_OS == XVT_OS_SCOUNIX
#include "keye.h"
#else
#include "hlapi_c.h"
#endif
/* @(:) 2.3.01.178 */
#define MAXCKEY 5
#define MAXCLEN 10
#define MAXENTRYNAME 16
#define MAXTENTRY 48
/* @(!) 2.3.01.temp */
#define MAXENTRYSIZE 4096
/* @(:) 2.3.01.temp */
#define MAXDISPCOLS 4
#define CONFFILE "conf.gen"
#if XVT_OS == XVT_OS_SCOUNIX
#include "keye.h"
#define HLBLOCK 2
#else
#include "hlapi_c.h"
#define HLBLOCK 1
#define REFKEY "CAMPOKEY"
#define VERKEY "ìpÙˆ¬cê<"
#endif
/* @DES Funzioni C esterne. Sorgenti in /disk1/p.uno */
@ -16,6 +40,7 @@ extern "C" {
extern short formflag;
extern int SerNo;
extern word ModAd;
extern word _int_tab0[4];
extern char __ptprf[80];
// Guy moved these outside extern
@ -36,6 +61,9 @@ extern "C" {
/* @END */
/* @FPUB */
#if XVT_OS == XVT_OS_SCOUNIX
Word Hl_Port(Word);
#endif
short cverdata(char *);
TrDate cpackdata(char *);
void ceditdata(TrDate ,char *);

View File

@ -1,5 +1,6 @@
S1=$(LOCAL)/xvtch/include/xvt.h
S2=$(DEVHOME)/mathlib/gmsys1.h $(DEVHOME)/mathlib/gfd.h $(DEVHOME)/mathlib/gmfequs.h $(DEVHOME)/mathlib/gmfuncts.h
S2=$(DEVHOME)/mathlib/gm.h
I1=$(IP)stdtypes.h
I2=$(IP)classes.h
I3=$(IP)conf.h
@ -53,9 +54,9 @@ I52=$(IP)colors.h
I53=$(I24) $(I33) $(I39) $(IP)relapp.h
I34=$(IP)brwapp.h $(I53)
I54=$(I33) $(IP)msksheet.h
I55=$(IP)assoc.h
I56=$(IP)config.h
I57=$(IP)confapp.h
I55=$(IP)assoc.h $(I10) $(I13)
I56=$(IP)config.h $(I55) $(I13)
I57=$(IP)confapp.h $(I56) $(I24)
I58=$(IP)text.h $(I13)
I59=$(IP)viswin.h $(I13) $(I32) $(I10) $(I58)
I60=$(IP)printwin.h $(I32)

View File

@ -3,7 +3,7 @@
#define __LFFILES_H
#define LF_DIR 1
#define LF_DITTE 2
#define LF_USER 2
#define LF_TABGEN 3
#define LF_TABCOM 4
#define LF_TAB 5

View File

@ -3,24 +3,13 @@
@(C#) PUBBLICHE
CGAUT : modulo contabilita'
MUAUT : autorizzazione per Multiutenza (RETE+UNIX)
FTAUT : modulo fatturazione
SCAUT : modulo saldaconto
EFAUT : modulo effetti
VEAUT : modulo vendite
MGAUT : modulo magazzino
DBAUT : modulo distinta base
PRAUT : modulo agenti
RTAUT : modulo RITMO
ORAUT : modulo ordini
SPAUT : modulo scadenzario
CMAUT : modulo commesse
CPAUT : modulo cooperative
CBAUT : modulo conto corrente
CEAUT : modulo cespiti
STAUT : modulo statistiche vendite
POAUT : modulo penna ottica
TPAUT : modulo PRASSI
LSAUT : modulo LIFO Stratificato
RCAUT : modulo Registratore di cassa
M77AUT : modulo 770
ABAUT : modulo analisi di bilancio
NIAUT : modulo nota integrativa
NIAUT : modulo nota integrativa
-------------------------------------------------------------------------------
*/
@ -36,4 +25,5 @@
#define M77AUT 7
#define ABAUT 20
#define NIAUT 21
#define ENDAUT 22
#endif // __MODAUT_H

View File

@ -5,4 +5,4 @@ sc Saldaconto
ef Gestione effetti
ve Vendite
mg magazzino
77 Modello 770
m7 Modello 770

View File

@ -59,7 +59,8 @@ void init_global_vars()
}
#if XVT_OS == XVT_OS_SCOUNIX
if ((SerNo) && (!CGetAut(MUAUT)))
const bool muflag = CGetAut(MUAUT);
if (SerNo /* && fexist("net.ini") */ && !muflag)
fatal_box("Abnormal termination: check protection or serial number\n");
#endif
}