Changeset 1122 for trunk/src/kmk/function.c
- Timestamp:
- Sep 25, 2007, 8:16:26 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/function.c
r1121 r1122 43 43 #include <assert.h> /* bird */ 44 44 45 #if defined (CONFIG_WITH_MATH) || defined (CONFIG_WITH_NANOTS) /* bird */45 #if defined (CONFIG_WITH_MATH) || defined (CONFIG_WITH_NANOTS) || defined (CONFIG_WITH_FILE_SIZE) /* bird */ 46 46 # include <ctype.h> 47 47 # ifdef _MSC_VER … … 51 51 typedef int64_t math_int; 52 52 # endif 53 static char *math_int_to_variable_buffer (char *, math_int); 53 54 #endif 54 55 … … 2674 2675 2675 2676 #ifdef CONFIG_WITH_DATE 2677 /* The first argument is the strftime format string, a iso 2678 timestamp is the default if nothing is given. 2679 2680 The second argument is a time value if given. The format 2681 is either the format from the first argument or given as 2682 an additional third argument. */ 2676 2683 static char * 2677 2684 func_date (char *o, char **argv, const char *funcname) … … 2689 2696 buf++; 2690 2697 if (*buf) 2691 format = buf;2698 format = argv[0]; 2692 2699 } 2693 2700 … … 2709 2716 free (buf); 2710 2717 return o; 2718 } 2719 #endif 2720 2721 #ifdef CONFIG_WITH_FILE_SIZE 2722 /* Prints the size of the specified file. Only one file is 2723 permitted, notthing is stripped. -1 is returned if stat 2724 fails. */ 2725 static char * 2726 func_file_size (char *o, char **argv, const char *funcname) 2727 { 2728 struct stat st; 2729 if (stat (argv[0], &st)) 2730 return variable_buffer_output (o, "-1", 2); 2731 return math_int_to_variable_buffer (o, st.st_size); 2711 2732 } 2712 2733 #endif … … 2762 2783 #endif /* CONFIG_WITH_STACK */ 2763 2784 2764 #if defined (CONFIG_WITH_MATH) || defined (CONFIG_WITH_NANOTS) 2785 #if defined (CONFIG_WITH_MATH) || defined (CONFIG_WITH_NANOTS) || defined (CONFIG_WITH_FILE_SIZE) 2765 2786 /* outputs the number (as a string) into the variable buffer. */ 2766 2787 static char * … … 3196 3217 { STRING_SIZE_TUPLE("date-utc"), 0, 1, 1, func_date}, 3197 3218 #endif 3219 #ifdef CONFIG_WITH_FILE_SIZE 3220 { STRING_SIZE_TUPLE("file-size"), 1, 1, 1, func_file_size}, 3221 #endif 3198 3222 #ifdef CONFIG_WITH_STACK 3199 3223 { STRING_SIZE_TUPLE("stack-push"), 2, 2, 1, func_stack_push},
Note:
See TracChangeset
for help on using the changeset viewer.