~ubuntu-branches/ubuntu/vivid/libmtp/vivid

« back to all changes in this revision

Viewing changes to .pc/1001-kfreebsd_hurd_ftbfs.patch/util/mtp-probe.c

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2012-06-21 10:44:53 UTC
  • mfrom: (16.2.12 experimental)
  • Revision ID: package-import@ubuntu.com-20120621104453-e9xhmt1aambphgfv
Tags: 1.1.3-24-g9aca343-3
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * \file mtp-probe.c
3
 
 * Program to probe newly connected device interfaces from
4
 
 * userspace to determine if they are MTP devices, used for
5
 
 * udev rules.
6
 
 *
7
 
 * Invoke the program from udev to check it for MTP signatures,
8
 
 * e.g.
9
 
 * ATTR{bDeviceClass}=="ff",
10
 
 * PROGRAM="<path>/mtp-probe /sys$env{DEVPATH} $attr{busnum} $attr{devnum}",
11
 
 * RESULT=="1", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1",
12
 
 * SYMLINK+="libmtp-%k", MODE="666"
13
 
 *
14
 
 * Is you issue this before testing your /var/log/messages
15
 
 * will be more verbose:
16
 
 *
17
 
 * udevadm control --log-priority=debug
18
 
 *
19
 
 * Exits with status code 1 if the device is an MTP device,
20
 
 * else exits with 0.
21
 
 *
22
 
 * Copyright (C) 2011 Linus Walleij <triad@df.lth.se>
23
 
 *
24
 
 * This library is free software; you can redistribute it and/or
25
 
 * modify it under the terms of the GNU Lesser General Public
26
 
 * License as published by the Free Software Foundation; either
27
 
 * version 2 of the License, or (at your option) any later version.
28
 
 *
29
 
 * This library is distributed in the hope that it will be useful,
30
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
32
 
 * Lesser General Public License for more details.
33
 
 *
34
 
 * You should have received a copy of the GNU Lesser General Public
35
 
 * License along with this library; if not, write to the
36
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
37
 
 * Boston, MA 02111-1307, USA.
38
 
 */
39
 
#ifndef __linux__
40
 
#error "This program should only be compiled for Linux!"
41
 
#endif
42
 
 
43
 
#include <unistd.h>
44
 
#include <stdlib.h>
45
 
#include <stdio.h>
46
 
#include <string.h>
47
 
#include <syslog.h>
48
 
#include <libmtp.h>
49
 
 
50
 
int main (int argc, char **argv)
51
 
{
52
 
  char *fname;
53
 
  int busno;
54
 
  int devno;
55
 
  int ret;
56
 
 
57
 
  if (argc < 4) {
58
 
    syslog(LOG_INFO, "need device path, busnumber, device number as argument\n");
59
 
    printf("0");
60
 
    exit(0);
61
 
  }
62
 
 
63
 
  fname = argv[1];
64
 
  busno = atoi(argv[2]);
65
 
  devno = atoi(argv[3]);
66
 
 
67
 
  syslog(LOG_INFO, "checking bus %d, device %d: \"%s\"\n", busno, devno, fname);
68
 
 
69
 
  ret = LIBMTP_Check_Specific_Device(busno, devno);
70
 
  if (ret) {
71
 
    syslog(LOG_INFO, "bus: %d, device: %d was an MTP device\n", busno, devno);
72
 
    printf("1");
73
 
  } else {
74
 
    syslog(LOG_INFO, "bus: %d, device: %d was not an MTP device\n", busno, devno);
75
 
    printf("0");
76
 
  }
77
 
 
78
 
  exit(0);
79
 
}