Subversion Repositories public

Rev

Rev 93 | Rev 218 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 93 Rev 136
Line 1094... Line 1094...
1094
    rpath[j++] = path[n++];
1094
    rpath[j++] = path[n++];
1095
    if ( path[n] == '/' ) {
1095
    if ( path[n] == '/' ) {
1096
      rpath[j] = 0;
1096
      rpath[j] = 0;
1097
      if ( stat(rpath,&sb) != -1 ) {  /* this part already exists */
1097
      if ( stat(rpath,&sb) != -1 ) {  /* this part already exists */
1098
	if ( !S_ISDIR(sb.st_mode) ) { /* but is not a directory!  */
1098
	if ( !S_ISDIR(sb.st_mode) ) { /* but is not a directory!  */
-
 
1099
	  char hv0[1024];
1099
	  fprintf(stderr,"mkpath: %s exists but is not a directory",rpath);
1100
	  sprintf(&hv0[0], "mkpath: %s exists but is not a directory",rpath);
-
 
1101
	  garmin_queue_error(hv0, err_error);
1100
	  ok = 0;
1102
	  ok = 0;
1101
	  break;
1103
	  break;
1102
	} else {
1104
	} else {
1103
	  
1105
	  
1104
	  /* figure out who owns the directory, what permissions they have */
1106
	  /* figure out who owns the directory, what permissions they have */
Line 1112... Line 1114...
1112
	if ( mkdir(rpath,mode) != -1 ) {   /* have to make this part */
1114
	if ( mkdir(rpath,mode) != -1 ) {   /* have to make this part */
1113
	  if ( already ) {
1115
	  if ( already ) {
1114
	    chown(rpath,owner,group);
1116
	    chown(rpath,owner,group);
1115
	  }
1117
	  }
1116
	} else {
1118
	} else {
-
 
1119
	  char hv0[1024];
1117
	  fprintf(stderr,"mkpath: mkdir(%s,%o): %s",path,mode,strerror(errno));
1120
	  sprintf(hv0, "mkpath: mkdir(%s,%o): %s",path,mode,strerror(errno));
-
 
1121
	  garmin_queue_error(hv0, err_error);
1118
	  ok = 0;
1122
	  ok = 0;
1119
	  break;
1123
	  break;
1120
	}
1124
	}
1121
      }
1125
      }
1122
    }
1126
    }
Line 1127... Line 1131...
1127
  if ( mkdir(path,mode) != -1 ) {
1131
  if ( mkdir(path,mode) != -1 ) {
1128
    if ( already ) {
1132
    if ( already ) {
1129
      chown(rpath,owner,group);
1133
      chown(rpath,owner,group);
1130
    }
1134
    }
1131
  } else {
1135
  } else {
-
 
1136
    char hv0[1024];
1132
    fprintf(stderr,"mkpath: mkdir(%s,%o): %s",path,mode,strerror(errno));
1137
    sprintf(hv0, "mkpath: mkdir(%s,%o): %s",path,mode,strerror(errno));
-
 
1138
    garmin_queue_error(hv0, err_error);
1133
    ok = 0;
1139
    ok = 0;
1134
  }
1140
  }
1135
 
1141
 
1136
  return ok;
1142
  return ok;
1137
}
1143
}
Line 1180... Line 1186...
1180
 
1186
 
1181
	/* write GARMIN_MAGIC, GARMIN_VERSION, and bytes. */
1187
	/* write GARMIN_MAGIC, GARMIN_VERSION, and bytes. */
1182
 
1188
 
1183
	pos = buf;
1189
	pos = buf;
1184
	memset(pos,0,GARMIN_HEADER);
1190
	memset(pos,0,GARMIN_HEADER);
1185
	strncpy(pos,GARMIN_MAGIC,11);
1191
	strncpy((char *)pos,GARMIN_MAGIC,11);
1186
	put_uint32(pos+12,GARMIN_VERSION);
1192
	put_uint32(pos+12,GARMIN_VERSION);
1187
	marker = pos+16;
1193
	marker = pos+16;
1188
	pos += GARMIN_HEADER;
1194
	pos += GARMIN_HEADER;
1189
	packed = GARMIN_HEADER;
1195
	packed = GARMIN_HEADER;
1190
 
1196
 
Line 1195... Line 1201...
1195
 
1201
 
1196
	/* Now write the data to the file and close the file. */
1202
	/* Now write the data to the file and close the file. */
1197
 
1203
 
1198
	if ( (wrote = write(fd,buf,packed)) != packed ) {
1204
	if ( (wrote = write(fd,buf,packed)) != packed ) {
1199
	  /* write error! */
1205
	  /* write error! */
-
 
1206
	  char hv0[256];
1200
	  printf("write of %d bytes returned %d: %s\n",
1207
	  sprintf(hv0, "write of %d bytes returned %d: %s",
1201
		 packed,wrote,strerror(errno));
1208
		 packed,wrote,strerror(errno));
-
 
1209
	  garmin_queue_error(hv0, err_error);
1202
	}
1210
	}
1203
	close(fd);
1211
	close(fd);
1204
 
1212
 
1205
	/* Free the buffer. */
1213
	/* Free the buffer. */
1206
	
1214
	
1207
	free(buf);
1215
	free(buf);
1208
 
1216
 
1209
      } else {
1217
      } else {
1210
	/* malloc error */
1218
	/* malloc error */
-
 
1219
	char hv0[256];
1211
	printf("malloc(%d): %s\n",bytes + GARMIN_HEADER, strerror(errno));
1220
	sprintf(hv0, "malloc(%d): %s",bytes + GARMIN_HEADER, strerror(errno));
-
 
1221
	garmin_queue_error(hv0, err_error);
1212
      }
1222
      }
1213
    } else {
1223
    } else {
1214
      /* problem creating file. */
1224
      /* problem creating file. */
-
 
1225
      char hv0[1024];
1215
      printf("creat: %s: %s\n",path,strerror(errno));
1226
      sprintf(hv0, "creat: %s: %s",path,strerror(errno));
-
 
1227
      garmin_queue_error(hv0, err_error);
1216
    }
1228
    }
1217
  } else {
1229
  } else {
1218
    /* don't write empty data */
1230
    /* don't write empty data */
-
 
1231
    char hv0[1024];
1219
    printf("%s: garmin_data_size was 0\n",path);
1232
    printf("%s: garmin_data_size was 0",path);
-
 
1233
    garmin_queue_error(hv0, err_error);
1220
  }
1234
  }
1221
 
1235
 
1222
  return bytes;
1236
  return bytes;
1223
}
1237
}
1224
 
1238
 
Line 1237... Line 1251...
1237
{
1251
{
1238
  uint8 * start;
1252
  uint8 * start;
1239
  uint8 * finish;
1253
  uint8 * finish;
1240
  uint8 * marker;
1254
  uint8 * marker;
1241
  uint32  bytes = 0;
1255
  uint32  bytes = 0;
-
 
1256
  char    hv0[256];
1242
 
1257
 
1243
  if ( garmin_data_size(data) == 0 ) return 0;
1258
  if ( garmin_data_size(data) == 0 ) return 0;
1244
 
1259
 
1245
  /* OK, we must know how to serialize this data.  Let's go for it. */
1260
  /* OK, we must know how to serialize this data.  Let's go for it. */
1246
 
1261
 
Line 1317... Line 1332...
1317
  CASE_DATA(1011);
1332
  CASE_DATA(1011);
1318
  CASE_DATA(1012);
1333
  CASE_DATA(1012);
1319
  CASE_DATA(1013);
1334
  CASE_DATA(1013);
1320
  CASE_DATA(1015);
1335
  CASE_DATA(1015);
1321
  default:
1336
  default:
1322
    printf("garmin_pack: data type %d not supported\n",data->type);
1337
    sprintf(hv0, "garmin_pack: data type %d not supported",data->type);
-
 
1338
    garmin_queue_error(hv0, err_warning);
1323
    break;
1339
    break;
1324
  }
1340
  }
1325
#undef CASE_DATA
1341
#undef CASE_DATA
1326
 
1342
 
1327
  return bytes;
1343
  return bytes;