368 |
return Lstatus; |
return Lstatus; |
369 |
} |
} |
370 |
|
|
371 |
|
/* ne retourne que les numeriques d'une chaine */ |
372 |
|
gboolean get_only_numerics(gchar *Abuffer, gint Abufsize, gchar *Asource, gchar Aend) |
373 |
|
{ |
374 |
|
gchar *s = Asource; |
375 |
|
gchar *d = Abuffer; |
376 |
|
gint Lnum = 0; |
377 |
|
|
378 |
|
if (Abufsize<2) return FALSE; |
379 |
|
|
380 |
|
*d=0; |
381 |
|
while (*s && *s != Aend) { |
382 |
|
if (isdigit(*s)) { |
383 |
|
if (++Lnum == Abufsize-1) { |
384 |
|
*Abuffer = 0; |
385 |
|
return FALSE; |
386 |
|
} |
387 |
|
*(d++)=*s; |
388 |
|
} |
389 |
|
s++; |
390 |
|
} |
391 |
|
*d=0; |
392 |
|
|
393 |
|
return TRUE; |
394 |
|
} |
395 |
|
|
396 |
|
/* retourne une chaine MM:SS en secondes */ |
397 |
|
glong get_2time(gchar *Asource) |
398 |
|
{ |
399 |
|
gchar *s = Asource; |
400 |
|
gchar *e; |
401 |
|
glong Lret = 0; |
402 |
|
|
403 |
|
while (*s && !isdigit(*s)) s++; |
404 |
|
if (!*s) return -1; |
405 |
|
e=s; |
406 |
|
|
407 |
|
/* min */ |
408 |
|
while (isdigit(*s)) s++; |
409 |
|
*(s++)=0; |
410 |
|
Lret = atol(e) * 60; |
411 |
|
|
412 |
|
/* sec */ |
413 |
|
while (*s && !isdigit(*s)) s++; |
414 |
|
if (!*s) return -1; |
415 |
|
e=s; |
416 |
|
while (isdigit(*s)) s++; |
417 |
|
*(s++)=0; |
418 |
|
Lret += atol(e); |
419 |
|
|
420 |
|
return Lret; |
421 |
|
} |
422 |
|
|
423 |
|
gdouble get_pourcent(gchar *Atotal, gchar *Aactu) |
424 |
|
{ |
425 |
|
glong Lnumtotal = atol(Atotal); |
426 |
|
glong Lnumactu = atol(Aactu); |
427 |
|
|
428 |
|
if (Lnumtotal == 0) return -1; |
429 |
|
|
430 |
|
return (1.0/Lnumtotal) * Lnumactu; |
431 |
|
} |
432 |
|
|
433 |
|
gchar *next_no_numeric(gchar *Ade) |
434 |
|
{ |
435 |
|
gchar *Lret = Ade; |
436 |
|
|
437 |
|
while (*Lret && isdigit(*Lret)) Lret++; |
438 |
|
|
439 |
|
return *Lret ? Lret : NULL; |
440 |
|
} |
441 |
|
|
442 |
|
gchar *next_putzero(gchar *Asource, gchar Asrc) |
443 |
|
{ |
444 |
|
gchar *s; |
445 |
|
if ((s=strchr(Asource, Asrc))) { |
446 |
|
*(s++)=0; |
447 |
|
return s; |
448 |
|
} |
449 |
|
|
450 |
|
return NULL; |
451 |
|
} |
452 |
|
|
453 |
/* |
/* |
454 |
* vim:et:ts=8:sts=2:sw=2 |
* vim:et:ts=8:sts=2:sw=2 |
455 |
*/ |
*/ |