~ubuntu-branches/debian/jessie/tickr/jessie

« back to all changes in this revision

Viewing changes to src/libetm-0.4.3/str_mem.c

  • Committer: Package Import Robot
  • Author(s): Emmanuel Thomas-Maurin
  • Date: 2012-06-04 14:23:24 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120604142324-j6ycu0cw6vvoahhy
Tags: 0.6.1-1
* Add: 'quick setup' thing (in tickr_quicksetup.c) which is launched
  at program startup if config file doesn't exist.

* Little improvements in layout of 'feed picker win' and 'preferences
  win'.

* Fix a segfault that happens when trying to export params and no
  config file exists yet.

* Make several windows that should not be resized by user, unresizable.

* Fix Launchpad bug #1007346: When 'window always-on-top' is disabled,
  'visible on all user desktops' stops working.

* If mouse wheel scrolling applies to speed (or feed), then Ctrl +
  mouse wheel scrolling applies to feed (or speed.)

* No real code changes in libetm, only in comments, so no need for a
  new version number.

* Update tickr_helptext.c and tickr.1 (man page.)

* Add new cli option 'no-ui' (similar to 'instance-id') used by new
  IF_UI_ALLOWED macro and remove all #if USE_GUI occurences.

* In tickr_list.c, free listfname before using it. Fixed by swapping 2
  lines:
    warning(FALSE, 4, "Can't save URL list ", listfname, ...);
    l_str_free(listfname);

* Use/add #define
    FONT_MAXLEN         68
    ARBITRARY_TASKBAR_HEIGHT    25
  to replace a few 'magic' numeric values.

* Rename: rss_title/description(_delimiter) ->
    item_title/description(_delimiter)
  then add new param: feed_title(_delimiter). Now we have:
  feed title / item title / item description.

* Use table in resource properties window.

* Fix a bug in f_list_load_from_file() in tickr_list.c which
  uncorrectly retrieves any feed title string containing TITLE_TAG_CHAR
  when TITLE_TAG_CHAR has not been removed from string first, for
  instance: 'NYT > World' -> ' World'.

* New param: disable left-click.

* Add 'check for updates' feature.

* Launch 'import OPML file' if feed list doesn't exist.

* Remove code changing get_params()->disable_popups value in
    START/END_PAUSE_TICKER_WHILE_OPENING
  macros which prevents this setting to be saved and add
    START/END_PAUSE_TICKER_ENABLE_POPUPS_WHILE_OPENING
  new macros. Which ones to use depends on context.

* Move:
    #ifdef G_OS_WIN32
    extern FILE *stdout_fp, *stderr_fp;
    #endif
  from *.c into tickr.h.

* Default always-on-top setting changed to 'n' (so that tickr is not
  intrusive by default.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *      libetm-0.4 / str_mem.c - Copyright (C) Emmanuel Thomas-Maurin 2008-2012
3
3
 *      <manutm007@gmail.com>
4
4
 *
5
 
 *      - some strings and memory management functions -
 
5
 *      - A few strings and memory management functions -
6
6
 *
7
7
 *      This program is free software: you can redistribute it and/or modify
8
8
 *      it under the terms of the GNU General Public License as published by
26
26
#include "libetm.h"
27
27
 
28
28
/*
29
 
 * copy n bytes max from src to dest then add '\0' at the end of dest
 
29
 * Copy n bytes max from src to dest then add '\0' at end of dest.
30
30
 */
31
31
char *str_n_cpy(char *dest, const char *src, size_t length)
32
32
{
44
44
}
45
45
 
46
46
/*
47
 
 * concanate n bytes max of src to dest then add '\0' at the end of dest
48
 
 * strings may not be identical and should not overlap
 
47
 * Concanate n bytes max of src to dest then add '\0' at end of dest.
 
48
 * Strings may not be identical and should not overlap.
49
49
 */
50
50
char *str_n_cat(char *dest, const char *src, size_t length)
51
51
{
64
64
}
65
65
 
66
66
/*
67
 
 * create new_l_str (allocate memory) and copy str (can be NULL) to new_l_str
 
67
 * Create new_l_str (allocate memory) and copy str (can be NULL) to new_l_str.
68
68
 */
69
69
char *l_str_new(const char *str)
70
70
{
82
82
}
83
83
 
84
84
/*
85
 
 * append l_str_src (can be NULL) to l_str_dest (re-allocate memory as necessary)
86
 
 * l_str_dest must have been created by l_str_new - strings may overlap
 
85
 * Append l_str_src (can be NULL) to l_str_dest (re-allocate memory as necessary).
 
86
 * l_str_dest must have been created by l_str_new - strings may overlap.
87
87
 */
88
88
char *l_str_cat(char *l_str_dest, const char *l_str_src)
89
89
{
109
109
}
110
110
 
111
111
/*
112
 
 * free string created by l_str_new() or l_str_cat()
 
112
 * Free string created by l_str_new() or l_str_cat().
113
113
 */
114
114
void l_str_free(char *l_str)
115
115
{
122
122
}
123
123
 
124
124
/*
125
 
 * wrappers for malloc(), realloc(), calloc() and free() which check returned value
 
125
 * Wrappers for malloc(), realloc(), calloc() and free() which check returned value.
126
126
 */
127
127
void *malloc2(size_t size)
128
128
{
181
181
}
182
182
 
183
183
/*
184
 
 * return size in readable format (KiB, MiB, GiB, TiB)
185
 
 * *** allow up to 16 simultaneous calls ***
186
 
 * convention: we assume 2.5 MiB = 2 MiB + [0.5 x 1024 = 512] KiB, not 500 KiB
187
 
 * otherwise, there is no way to express a value in the range 1000 - 1023
 
184
 * Return size in readable format (KiB, MiB, GiB, TiB).
 
185
 * *** Allow up to 16 simultaneous calls ***
 
186
 * Convention: we assume 2.5 MiB = 2 MiB + [0.5 x 1024 = 512] KiB, not 500 KiB.
 
187
 * Otherwise, there is no way to express a value in the range 1000 - 1023,
188
188
 * so x.y MiB = x MiB + 0.y MiB, that is: not y x 100 KiB but y x 102.4 KiB
189
189
 * (isn't this a bit confusing?)
190
190
 */
191
191
const char *readable_size(double size_bytes)
192
192
{
193
 
        /* we use an array of 16 strings to store the returned string in order
 
193
        /* We use an array of 16 strings to store the returned string in order
194
194
         * to allow 16 simultaneous calls (should be enough in most cases?)
195
 
         * otherwise, sth like:
 
195
         * Otherwise, sth like:
196
196
         * printf("size1 = %s / size2 = %s\n", readable_size(size1), readable_size(size2))
197
197
         * would produce unpredictable / false results (like readable sizes are
198
 
         * equal whereas sizes are different
 
198
         * equal whereas sizes are different).
199
199
         */
200
200
        static char     lib_static_str[16][128];
201
201
        unsigned long   size_KiB, size_MiB, size_GiB, size_TiB;
228
228
}
229
229
 
230
230
/*
231
 
 * itoa() is not ansi c so this one could be useful
232
 
 * *** allow up to 16 simultaneous calls ***
 
231
 * itoa() is not ansi c so this one could be useful.
 
232
 * *** Allow up to 16 simultaneous calls ***
233
233
 */
234
234
const char *itoa2(long int n)
235
235
{
236
 
        /* array of 16 strings (like for readable_size() - see above) */
 
236
        /* Array of 16 strings (like for readable_size() - see above) */
237
237
        static char     lib_static_str[16][128];
238
238
        static int      count = -1;
239
239
 
244
244
}
245
245
 
246
246
/*
247
 
 * modify string in place
 
247
 * Modify string in place
248
248
 */
249
249
char *remove_char_from_str(char *str, char c)
250
250
{
260
260
}
261
261
 
262
262
/*
263
 
 * modify string in place
 
263
 * Modify string in place
264
264
 */
265
265
char *remove_trailing_whitespaces_from_str(char *str)
266
266
{
273
273
}
274
274
 
275
275
/*
276
 
 * very basic xor sym encryption for small strings (up to 511 chars)
277
 
 * *** key must be ascii / if 2 chars match (in str and key) the string is cut ***
278
 
 * *** allow up to 16 simultaneous calls ***
279
 
 * works with ascii strings, probably not otherwise so don't try with
 
276
 * Very basic xor sym encryption for small strings (up to 511 chars).
 
277
 * *** Key must be ascii / if 2 chars match (in str and key) the string is cut ***
 
278
 * *** Allow up to 16 simultaneous calls ***
 
279
 * Works with ascii strings, probably not otherwise so don't try with
280
280
 * exotic things...
281
281
 */
282
282
const char *str_crypt(const char *str, const char *key)
283
283
{
284
 
        /* array of 16 strings (like for readable_size() - see above) */
 
284
        /* Array of 16 strings (like for readable_size() - see above) */
285
285
        static char     str2[16][512];
286
286
        static int      count = -1;
287
287
        int             i, j;
298
298
}
299
299
 
300
300
/*
301
 
 * very basic crypto hash
 
301
 * Very basic crypto hash
302
302
 */
303
303
unsigned long str_crypto_hash(const char *str, const char* salt)
304
304
{
315
315
}
316
316
 
317
317
/*
318
 
 * generate a random string up to 1023 chars long
 
318
 * Generate a random string up to 1023 chars long.
319
319
 * mode = a -> alpha / d -> digits / b ->  both
320
320
 */
321
321
const char *rnd_str(char mode, int length)