"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "zfuncs.cc" between
fotoxx-20.11.tar.gz and fotoxx-20.12.tar.gz

About: fotoxx is a program for photo editing and collection management.

zfuncs.cc  (fotoxx-20.11):zfuncs.cc  (fotoxx-20.12)
skipping to change at line 21 skipping to change at line 21
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. See https://www.gnu.org/licenses (at your option) any later version. See https://www.gnu.org/licenses
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. See the GNU General Public License for more details.
******************************************************************************** */ ******************************************************************************** */
#include "zfuncs.h" #include "zfuncs.h" // version for Fotoxx 20
/******************************************************************************* * /******************************************************************************* *
Table of Contents Table of Contents
================= =================
System Utility Functions System Utility Functions
------------------------ ------------------------
zmalloc zfree zstrdup replace malloc() etc. to add checks and statistics zmalloc zfree zstrdup replace malloc() etc. to add checks and statistics
printz printf() with immediate fflush() printz printf() with immediate fflush()
skipping to change at line 352 skipping to change at line 352
va_start(arglist,errmess); va_start(arglist,errmess);
vsnprintf(buff,200,errmess,arglist); vsnprintf(buff,200,errmess,arglist);
printz("zexit: %s\n",buff); printz("zexit: %s\n",buff);
} }
else printz("zexit\n"); else printz("zexit\n");
killpg(0,SIGKILL); // kill all processes in group killpg(0,SIGKILL); // kill all processes in group
sleep(10); // wait here to die sleep(10); // wait here to die
} }
/***
// Exit a process with an error message and kill all child processes.
// Use the command "ps -o pid,pgid" to find all child processes.
void zexit(cchar *errmess, ...)
// 7.4
{
va_list arglist;
FILE *fid;
pid_t pid, cpid, cpgid;
// process ID, progess group ID
char buff[200];
cchar *pp;
if (errmess) {
// output error message
va_start(arglist,errmess);
vsnprintf(buff,200,errmess,arglist);
printz("zexit: %s\n",buff);
}
else printz("zexit\n");
pid = getpid();
// calling process PID
fid = popen("ps -o pid,pgid","r");
// list my processes with pid, pgid
if (! fid) exit(0);
while (true) {
// read returned process list
pp = fgets(buff,100,fid);
if (! pp) break;
// EOF
pp = strField(buff,' ',1);
cpid = atoi(pp);
// process pid
if (cpid == pid) continue;
// skip calling process
pp = strField(buff,' ',2);
cpgid = atoi(pp);
// process goup ID
if (cpgid == pid) kill(cpid,SIGKILL);
// my child processes, kill
}
pclose(fid);
exit(0);
// exit calling process
}
***/
/******************************************************************************* */ /******************************************************************************* */
// produce a backtrace dump to stdout // produce a backtrace dump to stdout
void zbacktrace() void zbacktrace()
{ {
int nstack = 100; int nstack = 100;
void *stacklist[100]; void *stacklist[100];
nstack = backtrace(stacklist,nstack); // get backtrace data nstack = backtrace(stacklist,nstack); // get backtrace data
skipping to change at line 4777 skipping to change at line 4735
cchar * get_zhomedir() { return zfuncs::zhomedir; } // /home/<user>/.appname or /root/.appname cchar * get_zhomedir() { return zfuncs::zhomedir; } // /home/<user>/.appname or /root/.appname
cchar * get_zdatadir() { return zfuncs::zdatadir; } // data files cchar * get_zdatadir() { return zfuncs::zdatadir; } // data files
cchar * get_zdocdir() { return zfuncs::zdocdir; } // documentation files cchar * get_zdocdir() { return zfuncs::zdocdir; } // documentation files
cchar * get_zimagedir() { return zfuncs::zimagedir; } // image files 6.8 cchar * get_zimagedir() { return zfuncs::zimagedir; } // image files 6.8
cchar * get_zlocalesdir() { return zfuncs::zlocalesdir; } // translation files cchar * get_zlocalesdir() { return zfuncs::zlocalesdir; } // translation files
int zinitapp(cchar *appvers, cchar *homedir) // appname-N.N, opt. home dir 7.4 int zinitapp(cchar *appvers, cchar *homedir) // appname-N.N, opt. home dir 7.4
{ {
char logfile[200], oldlog[200]; char logfile[200], oldlog[200];
char buff[300], Phomedir[200]; char buff[300], Phomedir[200];
char *pp, *chTnow; char *pp, *ch_time; // 20.12
int cc, err; int cc, err;
time_t Tnow; time_t startime; // 20.12
STATB statb; STATB statb;
FILE *fid; FILE *fid;
ftime(&startime); startime = time(null);
// app startup time // app start time 20.12
Tnow = startime.time;
catch_signals(); // catch signals, do backtrace catch_signals(); // catch signals, do backtrace
progexe = 0; progexe = 0;
cc = readlink("/proc/self/exe",buff,300); // get own program path 7.1 cc = readlink("/proc/self/exe",buff,300); // get own program path 7.1
if (cc > 0) { if (cc > 0) {
buff[cc] = 0; // readlink() quirk buff[cc] = 0; // readlink() quirk
progexe = zstrdup(buff); progexe = zstrdup(buff);
} }
skipping to change at line 4831 skipping to change at line 4788
cc = strlen(zhomedir); // stop humongous username cc = strlen(zhomedir); // stop humongous username
if (cc > 160) zexit("home folder name too big"); if (cc > 160) zexit("home folder name too big");
err = stat(zhomedir,&statb); // does app home exist already? err = stat(zhomedir,&statb); // does app home exist already?
if (err) { if (err) {
err = mkdir(zhomedir,0750); // no, create and initialize err = mkdir(zhomedir,0750); // no, create and initialize
if (err) zexit("cannot create %s: %s",zhomedir,strerror(errno)); if (err) zexit("cannot create %s: %s",zhomedir,strerror(errno));
} }
chTnow = ctime(&Tnow);
chTnow[19] = 0;
// eliminate hundredths of seconds
if (! isatty(fileno(stdin))) { // not attached to a terminal if (! isatty(fileno(stdin))) { // not attached to a terminal
snprintf(logfile,199,"%s/logfile",zhomedir); // /home/<user>/logfile snprintf(logfile,199,"%s/logfile",zhomedir); // /home/<user>/logfile
snprintf(oldlog,199,"%s/logfile.old",zhomedir); snprintf(oldlog,199,"%s/logfile.old",zhomedir);
err = stat(logfile,&statb); err = stat(logfile,&statb);
if (! err) rename(logfile,oldlog); // rename old log file 6.6 if (! err) rename(logfile,oldlog); // rename old log file 6.6
fid = freopen(logfile,"a",stdout); // redirect output to log file fid = freopen(logfile,"a",stdout); // redirect output to log file
fid = freopen(logfile,"a",stderr); fid = freopen(logfile,"a",stderr);
if (! fid) printz("*** cannot redirect stdout and stderr \n"); if (! fid) printz("*** cannot redirect stdout and stderr \n");
} }
printz("start %s %s \n",zappname,chTnow); ch_time = ctime(&startime);
// start time: Ddd Mmm dd hh:mm:ss.nn 20.12
ch_time[19] = 0;
// eliminate hundredths of seconds
if (ch_time[8] == ' ') ch_time[8] = '0';
// replace ' d' with '0d'
printz("start %s %s \n",zappname,ch_time);
fflush(0); fflush(0);
cc = readlink("/proc/self/exe",zprefix,200); // get my executable path 6.4 cc = readlink("/proc/self/exe",zprefix,200); // get my executable path 6.4
if (cc <= 0) { if (cc <= 0) {
printz("readlink() /proc/self/exe) failed \n"); // if failed, assume /usr/bin/ printz("readlink() /proc/self/exe) failed \n"); // if failed, assume /usr/bin/
strcpy(zprefix,"/usr/bin/"); strcpy(zprefix,"/usr/bin/");
} }
else zprefix[cc] = 0; // readlink() quirk else zprefix[cc] = 0; // readlink() quirk
pp = strstr(zprefix,"/bin/"); // get install prefix (e.g. /usr) pp = strstr(zprefix,"/bin/"); // get install prefix (e.g. /usr)
if (pp) *pp = 0; if (pp) *pp = 0;
skipping to change at line 11056 skipping to change at line 11013
fclose(fid); fclose(fid);
return Nzd; return Nzd;
} }
printz("*** zdialog_inputs bad action: %s \n",action); printz("*** zdialog_inputs bad action: %s \n",action);
return 0; return 0;
} }
// Save dialog user input fields when a dialog is finished. // Save dialog user input fields when a dialog is finished.
// Called automatically by zdialog_free(). Private function. // Called automatically by zdialog_free(). Private function.
// Activated if zdialog_restore_inputs() is called before zdialog_run(). // 20.12
int zdialog_save_inputs(zdialog *zd) int zdialog_save_inputs(zdialog *zd)
{ {
using namespace zdinputs_names; using namespace zdinputs_names;
char zdtitle[ccmax1], wname[ccmax1], wdata[ccmax2], *type; char zdtitle[ccmax1], wname[ccmax1], wdata[ccmax2], *type;
int ii, jj, Nw, cc; int ii, jj, Nw, cc;
if (! zdialog_valid(zd)) return 0; if (! zdialog_valid(zd)) return 0;
if (! zd->saveinputs) return 0; // zdialog does not use this service if (! zd->saveinputs) return 0; // zdialog does not use this service
 End of changes. 8 change blocks. 
65 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)