~ubuntu-branches/debian/sid/flickcurl/sid

« back to all changes in this revision

Viewing changes to src/photo.c

  • Committer: Package Import Robot
  • Author(s): Kumar Appaiah
  • Date: 2013-05-20 21:15:09 UTC
  • mfrom: (1.4.1) (15.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130520211509-e701o5dlwa04aqiw
Tags: 1.24-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 * photo.c - Flickcurl photo functions
4
4
 *
5
 
 * Copyright (C) 2007-2010, David Beckett http://www.dajobe.org/
 
5
 * Copyright (C) 2007-2012, David Beckett http://www.dajobe.org/
6
6
 * 
7
7
 * This file is licensed under the following three licenses as alternatives:
8
8
 *   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
203
203
            photo->fields[PHOTO_FIELD_secret].string);
204
204
  }
205
205
  len = strlen(buf);
206
 
  result = (char*)malloc(len+1);
207
 
  strcpy(result, buf);
 
206
  result = (char*)malloc(len + 1);
 
207
  memcpy(result, buf, len + 1);
208
208
  return result;
209
209
}
210
210
 
229
229
          photo->fields[PHOTO_FIELD_owner_nsid].string, photo->id);
230
230
 
231
231
  len = strlen(buf);
232
 
  result = (char*)malloc(len+1);
233
 
  strncpy(result, buf, len+1);
 
232
  result = (char*)malloc(len + 1);
 
233
  memcpy(result, buf, len + 1);
234
234
  return result;
235
235
}
236
236
 
286
286
    return NULL;
287
287
  
288
288
  r = result;
289
 
  strncpy(result, short_uri_prefix, SHORT_URI_PREFIX_LEN);
 
289
  memcpy(result, short_uri_prefix, SHORT_URI_PREFIX_LEN);
290
290
  r += SHORT_URI_PREFIX_LEN;
291
291
  /* now copy it backwards into new result string */
292
292
  while(p != buf)
405
405
{
406
406
  char buf[1024];
407
407
  char *result;
408
 
  size_t len;
409
408
  
410
 
  if(server && farm && nsid)
411
 
  /* http://farm{icon-farm}.static.flickr.com/{icon-server}/buddyicons/{nsid}.jpg */
 
409
  if(server && farm && nsid) {
 
410
    size_t len;
 
411
    /* http://farm{icon-farm}.static.flickr.com/{icon-server}/buddyicons/{nsid}.jpg */
412
412
    sprintf(buf, "http://farm%d.static.flickr.com/%d/buddicons/%s.jpg", 
413
 
            farm, server, nsid);
414
 
  else
415
 
    strcpy(buf, "http://www.flickr.com/images/buddyicon.jpg");
 
413
            farm, server, nsid); 
 
414
    len = strlen(buf);
 
415
    result = (char*)malloc(len + 1);
 
416
    memcpy(result, buf, len + 1);
 
417
  } else {
 
418
    #define MAGIC_LEN 42
 
419
    result = (char*)malloc(MAGIC_LEN + 1);
 
420
    memcpy(result, "http://www.flickr.com/images/buddyicon.jpg", MAGIC_LEN + 1);
 
421
  }
416
422
 
417
 
  len = strlen(buf);
418
 
  result = (char*)malloc(len+1);
419
 
  strncpy(result, buf, len+1);
420
423
  return result;
421
424
}
422
425
 
968
971
  int i;
969
972
  
970
973
  xpathExpr_len = strlen((const char*)xpathExpr);
971
 
  strncpy((char*)full_xpath, (const char*)xpathExpr, xpathExpr_len+1);
 
974
  memcpy(full_xpath, xpathExpr, xpathExpr_len + 1);
972
975
  
973
976
  xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
974
977
  if(!xpathObj) {
1060
1063
                    string_value, (long)unix_time, new_value);
1061
1064
#endif
1062
1065
            free(string_value);
1063
 
            string_value= new_value;
1064
 
            int_value= (int)unix_time;
 
1066
            string_value = new_value;
 
1067
            int_value = (int)unix_time;
1065
1068
            datatype = VALUE_TYPE_DATETIME;
1066
1069
          } else
1067
1070
            /* failed to convert, make it a string */
1072
1075
        case VALUE_TYPE_BOOLEAN:
1073
1076
          if(!*string_value && datatype == VALUE_TYPE_BOOLEAN) {
1074
1077
            /* skip setting field with a boolean value '' */
 
1078
            free(string_value);
1075
1079
            special = 1;
1076
1080
            break;
1077
1081
          }
1084
1088
          photo->tags = flickcurl_build_tags_from_string(fc, photo,
1085
1089
                                                         (const char*)string_value,
1086
1090
                                                         &photo->tags_count);
 
1091
          free(string_value);
1087
1092
          special = 1;
1088
1093
          break;
1089
1094
 
1100
1105
          abort();
1101
1106
      }
1102
1107
 
 
1108
      /* If special, do not store here */
1103
1109
      if(special)
1104
1110
        continue;
1105
1111
 
1134
1140
                                         &photo->notes_count);
1135
1141
 
1136
1142
    if(!photo->media_type) {
1137
 
      photo->media_type = (char*)malloc(6);
1138
 
      strncpy(photo->media_type, "photo", 6);
 
1143
#define PHOTO_STR_LEN 5
 
1144
      photo->media_type = (char*)malloc(PHOTO_STR_LEN + 1);
 
1145
      memcpy(photo->media_type, "photo", PHOTO_STR_LEN + 1);
1139
1146
    }
1140
1147
 
1141
1148
    if(xpathNodeCtx)
1150
1157
  tidy:
1151
1158
  if(xpathObj)
1152
1159
    xmlXPathFreeObject(xpathObj);
1153
 
  if(fc->failed)
 
1160
  if(fc->failed) {
 
1161
    if(photos)
 
1162
      flickcurl_free_photos(photos);
1154
1163
    photos = NULL;
 
1164
  }
1155
1165
 
1156
1166
  return photos;
1157
1167
}
1215
1225
  size_t format_len;
1216
1226
 
1217
1227
  photos_list = flickcurl_new_photos_list(fc);
 
1228
  if(!photos_list)
 
1229
    return NULL;
 
1230
 
1218
1231
  if(format) {
1219
1232
    nformat = format;
1220
1233
    format_len = strlen(format);
1327
1340
    fc->failed = 1;
1328
1341
    goto tidy;
1329
1342
  }
1330
 
  memcpy(photos_list->format, nformat, format_len+1);
 
1343
  memcpy(photos_list->format, nformat, format_len + 1);
1331
1344
 
1332
1345
  tidy:
1333
1346
  if(xpathNodeCtx)