bbsferrari 0 Posted 2005-04-14 12:54:59 Share Posted 2005-04-14 12:54:59 Хочу написать внешний интерфейс, позволяющий изменять баланс на счету пользователя. На ум приходит способ напрямую изменять параметр Cash в файле stat внутри пользовательского каталога. Вопрос лишь в том, как система поймет, что файл изменился? Видимо нужно запустить какой-то скрипт? А может есть другой способ? Заранее, спасибо. Сергей Дзюба, ТЦ Планар. Link to post Share on other sites
Keen 10 Posted 2005-04-14 20:46:01 Share Posted 2005-04-14 20:46:01 Да, есть такой способ - єто использовать консольный конфигуратор, о котором говорится в предыдущем разделе Link to post Share on other sites
lamo 0 Posted 2005-04-17 08:17:43 Share Posted 2005-04-17 08:17:43 У меня уже давно работает такая схема: останавливается stg меняется параметр cash запускается stg Програмка,меняющая cash элементарная #include <string.h> #include <stdlib.h> #include <ctype.h> #include <time.h> int main(int argc, char *arg[]){ time_t t=time(NULL); struct tm *ti = localtime(&t); char *tii; tii=asctime(ti); FILE * f; FILE * f1; FILE *lg; char *statname="stat"; char *logname="changes.log"; char st[256]; char log[256]; char str[256]; char *sub; char *ca; int line=0; double cash; double addcash; strcpy(st,arg[1]); strcat(st,statname); strcpy(log,arg[1]); strcat(log,logname); f=fopen(st,"r+"); lg=fopen(log,"a"); f1=fopen("temp","w"); addcash=strtod(arg[2],NULL); while (fgets(str,1000,f)) {line++; if (line==21) {sub=strstr(str,"=");sub++; cash=strtod(sub,NULL); cash+=addcash; fprintf(f1,"Cash=%f\n",cash); } else fputs(str,f1); //if (&str[0]=="C") {sprintf(str);} } printf("%d",line); fclose(f); fclose(f1); f=fopen(st,"w"); f1=fopen("temp","r"); while (fgets(str,1000,f1)) {fputs(str,f);} fclose(f); fclose(f1); fprintf(lg,"Cash added from card %s( %f added) at %i.%i.%i %i:%i:%i \n",arg[3],addcash,ti->tm_year+1900,ti->tm_mon+1,ti->tm_mday,ti->tm_hour,ti->tm_min,ti->tm_sec); return 0; } Теперь, с появлением консольного конфигуратора, все станет намного проще (надеюсь) Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now