~ubuntu-branches/ubuntu/trusty/fotoxx/trusty

« back to all changes in this revision

Viewing changes to zfuncs.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Torres Batan
  • Date: 2009-10-10 13:06:31 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20091010130631-k3ovj0n0ungmrpy2
Tags: 8.5.2-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1970
1970
int convDS(double dnum, int digits, char *string, int *cc)
1971
1971
{
1972
1972
   char     *pstr;
1973
 
   int      ccc;
1974
1973
   
1975
1974
   sprintf(string,"%.*g",digits,dnum);
1976
1975
 
1977
 
   pstr = strstr(string,"e+");
1978
 
   if (pstr) strcpy(pstr+1,pstr+2);
1979
 
 
1980
 
   pstr = strstr(string,"e0");            
1981
 
   if (pstr) strcpy(pstr+1,pstr+2);
1982
 
 
1983
 
   pstr = strstr(string,"e0");            
1984
 
   if (pstr) strcpy(pstr+1,pstr+2);
1985
 
 
1986
 
   pstr = strstr(string,"e-0");
1987
 
   if (pstr) strcpy(pstr+2,pstr+3);
1988
 
 
1989
 
   pstr = strstr(string,"e-0");
1990
 
   if (pstr) strcpy(pstr+2,pstr+3);
1991
 
 
1992
 
   ccc = strlen(string);
1993
 
   if (cc) *cc = ccc;
 
1976
   pstr = strstr(string,"e+");                                             //  1.23e+12  >  1.23e12
 
1977
   if (pstr) strcpy(pstr+1,pstr+2);
 
1978
 
 
1979
   pstr = strstr(string,"e0");                                             //  1.23e02  >  1.23e2
 
1980
   if (pstr) strcpy(pstr+1,pstr+2);
 
1981
 
 
1982
   pstr = strstr(string,"e0");            
 
1983
   if (pstr) strcpy(pstr+1,pstr+2);
 
1984
 
 
1985
   pstr = strstr(string,"e-0");                                            //  1.23e-02  >  1.23e-2
 
1986
   if (pstr) strcpy(pstr+2,pstr+3);
 
1987
 
 
1988
   pstr = strstr(string,"e-0");
 
1989
   if (pstr) strcpy(pstr+2,pstr+3);
 
1990
 
 
1991
   if (cc) *cc = strlen(string);
1994
1992
 
1995
1993
   return 0;
1996
1994
}
1997
1995
 
1998
1996
 
 
1997
//  format a number as "123 B" or "12.3 KB" or "1.23 MB" etc.
 
1998
//  prec is the desired digits of precision to output
 
1999
 
 
2000
char * formatKBMB(double fnum, int prec)                                   //  v.2.25
 
2001
{
 
2002
   #define kilo 1000
 
2003
   #define mega (kilo*kilo)
 
2004
   #define giga (kilo*kilo*kilo)
 
2005
 
 
2006
   const char     *units;
 
2007
   static char    output[20];
 
2008
   double         gnum;
 
2009
   
 
2010
   gnum = fabs(fnum);
 
2011
   
 
2012
   if (gnum > giga) {
 
2013
      fnum = fnum / giga;
 
2014
      units = "GB";
 
2015
   }
 
2016
   else if (gnum > mega) {
 
2017
      fnum = fnum / mega;
 
2018
      units = "MB";
 
2019
   }
 
2020
   else if (gnum > kilo) {
 
2021
      fnum = fnum / kilo;
 
2022
      units = "KB";
 
2023
   }
 
2024
   else units = "B ";
 
2025
 
 
2026
   gnum = fabs(fnum);   
 
2027
   if (prec == 2 && gnum >= 99.5) prec++;                                  //  avoid e+nn formats
 
2028
   if (prec == 3 && gnum >= 999.5) prec++;
 
2029
   if (prec == 4 && gnum >= 9999.5) prec++;
 
2030
   if (prec == 5 && gnum >= 99999.5) prec++;
 
2031
   if (prec == 6 && gnum >= 999999.5) prec++;
 
2032
   
 
2033
   snprintf(output,20,"%.*g %s",prec,fnum,units);
 
2034
 
 
2035
   return output;
 
2036
}
 
2037
 
 
2038
 
1999
2039
/**************************************************************************
2000
2040
 
2001
2041
    Wildcard string match
2830
2870
   return y;
2831
2871
}
2832
2872
 
2833
 
using namespace std;
2834
 
 
2835
2873
 
2836
2874
/**************************************************************************
2837
2875
   Initialize application files according to following conventions:
2847
2885
   zuserdir    /home/user/.appname/       log file, user parameters
2848
2886
***************************************************************************/
2849
2887
 
2850
 
char     zappname[20];
2851
 
char     zdatadir[200], zdocdir[200], zicondir[200], zuserdir[200];
2852
 
char     zlanguage[8] = "en";                                              //  "lc" or "lc_RC"   v.2.14
 
2888
namespace zfuncs                                                           //  v.2.25
 
2889
{
 
2890
   char     zappname[20];
 
2891
   char     zdatadir[200], zdocdir[200], zicondir[200], zuserdir[200];
 
2892
   char     zlanguage[8] = "en";                                           //  "lc" or "lc_RC"   v.2.14
 
2893
}
 
2894
 
 
2895
using namespace zfuncs;
2853
2896
 
2854
2897
const char * get_zuserdir() { return  zuserdir; }                          //  /home/user/.appname
2855
2898
const char * get_zdatadir() { return  zdatadir; }                          //  parameters, icons
3243
3286
   return;
3244
3287
}
3245
3288
 
3246
 
using namespace std;
3247
 
 
3248
3289
 
3249
3290
//  Translate the input english string or return the input string.
3250
3291
//  Look for "context::string" and return "string" only if context found.
4924
4965
//
4925
4966
//  Memory for returned filespec should be freed via zfree()
4926
4967
 
4927
 
char     JPGquality[4] = "85";                                             //  JPG file save quality (extern)
 
4968
 
 
4969
namespace   zfuncs 
 
4970
{
 
4971
   char     JPGquality[4] = "85";                                          //  JPG file save quality
 
4972
}
 
4973
 
 
4974
using namespace zfuncs;
 
4975
 
4928
4976
 
4929
4977
char * zgetfile(cchar *title, cchar *initfile, cchar *action, cchar *buttx)
4930
4978
{
6118
6166
   return nn;
6119
6167
}
6120
6168
 
6121
 
using namespace std;
6122
 
 
6123
6169
 
6124
6170
/**************************************************************************
6125
6171
    parameter management functions